diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/b_cd.c | 2 | ||||
-rw-r--r-- | src/d_define.h | 89 | ||||
-rw-r--r-- | src/f_com.c | 2 | ||||
-rw-r--r-- | src/f_fail.c | 4 | ||||
-rw-r--r-- | src/m_argv.c | 4 | ||||
-rw-r--r-- | src/m_init.c | 10 | ||||
-rw-r--r-- | src/m_mshrc.c | 2 | ||||
-rw-r--r-- | src/m_prompt.c | 4 | ||||
-rw-r--r-- | src/s_init.c | 50 | ||||
-rw-r--r-- | src/u_vars.c | 4 |
10 files changed, 85 insertions, 86 deletions
@@ -117,7 +117,7 @@ uint8_t b_cd(char *args[], t_msh *msh) if (u_get_var_value(path, "$HOME", PATH_MAX, msh) == 1) { ft_dprintf(STDERR_FILENO, "minishell: cd: %s\n", - FT_FAIL_HOME_NOT_SET); + F_HOME_NOT_SET); return (2); } } diff --git a/src/d_define.h b/src/d_define.h index 05332d9..23b3964 100644 --- a/src/d_define.h +++ b/src/d_define.h @@ -26,41 +26,38 @@ ** ====== PSX ====== */ -# define FT_DEFAULT_PS_ONE "minishell ~> " -# define FT_DEFAULT_PS_TWO "> " -# define FT_DEFAULT_PS_THR "> " -# define FT_DEFAULT_PS_FOU "> " +# define M_DEFAULT_PS_ONE "minishell ~> " +# define M_DEFAULT_PS_TWO "> " +# define M_DEFAULT_PS_THR "> " +# define M_DEFAULT_PS_FOU "> " /* ** ====== PSX RICE ====== */ -# define FT_PROGNAME "minishell" -# define FT_MSH_VERSION "0.1" +# define M_PROGNAME "minishell" +# define M_MSH_VERSION "0.1" /* ** ====== OPTIONS ====== */ -# define FT_OPT_COMMAND "-c" -# define FT_OPT_INTERACT "-i" +# define M_OPT_COMMAND "-c" +# define M_OPT_INTERACT "-i" /* ** ====== VARS ====== */ -# define FT_RET_VAR "$?" -# define FT_PID_VAR "$$" -# define FT_ARGC_VAR "$#" +# define M_RET_VAR "$?" +# define M_ARGC_VAR "$#" /* -** ====== FAIL MSG ====== +** ====== FILES ====== */ -# define FT_FAIL_COMMAND_NOT_FOUND "command not found" -# define FT_FAIL_NO_OPTIONS "no options required" -# define FT_FAIL_TOO_MANY_ARGS "too many arguments" -# define FT_FAIL_HOME_NOT_SET "HOME not set" +# define M_MINISHELLRC ".minishellrc" +# define M_DEFAULT_HISTFILE ".minishell_history" /* ** ====== UTILS ====== @@ -84,40 +81,42 @@ # define C_TILDE 0x7e /* -** ====== FILES ====== +** ====== SQB OPTIONS ====== */ -# define FT_MINISHELLRC ".minishellrc" -# define FT_DEFAULT_HISTFILE ".minishell_history" +# define B_SQB_B "-b" +# define B_SQB_C "-c" +# define B_SQB_D "-d" +# define B_SQB_E "-e" +# define B_SQB_F "-f" +# define B_SQB_H "-h" +# define B_SQB_N "-n" +# define B_SQB_P "-p" +# define B_SQB_R "-r" +# define B_SQB_S "-s" +# define B_SQB_W "-w" +# define B_SQB_X "-x" +# define B_SQB_Z "-z" +# define B_SQB_L_MAJ "-L" +# define B_SQB_S_MAJ "-S" +# define B_SQB_NT "-nt" +# define B_SQB_OT "-ot" +# define B_SQB_EQUA "=" +# define B_SQB_DIFF "!=" +# define B_SQB_EQ "-eq" +# define B_SQB_NE "-ne" +# define B_SQB_GT "-gt" +# define B_SQB_GE "-ge" +# define B_SQB_LT "-lt" +# define B_SQB_LE "-le" /* -** ====== SQB OPTIONS ====== +** ====== FAIL MSG ====== */ -# define FT_SQB_B "-b" -# define FT_SQB_C "-c" -# define FT_SQB_D "-d" -# define FT_SQB_E "-e" -# define FT_SQB_F "-f" -# define FT_SQB_H "-h" -# define FT_SQB_N "-n" -# define FT_SQB_P "-p" -# define FT_SQB_R "-r" -# define FT_SQB_S "-s" -# define FT_SQB_W "-w" -# define FT_SQB_X "-x" -# define FT_SQB_Z "-z" -# define FT_SQB_L_MAJ "-L" -# define FT_SQB_S_MAJ "-S" -# define FT_SQB_NT "-nt" -# define FT_SQB_OT "-ot" -# define FT_SQB_EQUA "=" -# define FT_SQB_DIFF "!=" -# define FT_SQB_EQ "-eq" -# define FT_SQB_NE "-ne" -# define FT_SQB_GT "-gt" -# define FT_SQB_GE "-ge" -# define FT_SQB_LT "-lt" -# define FT_SQB_LE "-le" +# define F_COMMAND_NOT_FOUND "command not found" +# define F_NO_OPTIONS "no options required" +# define F_TOO_MANY_ARGS "too many arguments" +# define F_HOME_NOT_SET "HOME not set" #endif diff --git a/src/f_com.c b/src/f_com.c index 7285205..4902977 100644 --- a/src/f_com.c +++ b/src/f_com.c @@ -20,6 +20,6 @@ void f_fail_command_not_found(const char command[], t_msh *msh) { ft_dprintf(STDERR_FILENO, "%s: %s: %s\n", "minishell", command, - FT_FAIL_COMMAND_NOT_FOUND); + F_COMMAND_NOT_FOUND); msh->ret = 127; } diff --git a/src/f_fail.c b/src/f_fail.c index c4868b2..28f744b 100644 --- a/src/f_fail.c +++ b/src/f_fail.c @@ -31,7 +31,7 @@ void f_fail_no_options(const char concern[], t_msh *msh) { - write_fail(concern, FT_FAIL_NO_OPTIONS, msh); + write_fail(concern, F_NO_OPTIONS, msh); } void @@ -46,5 +46,5 @@ void f_fail_too_many_args(const char concern[], t_msh *msh) { - write_fail(concern, FT_FAIL_TOO_MANY_ARGS, msh); + write_fail(concern, F_TOO_MANY_ARGS, msh); } diff --git a/src/m_argv.c b/src/m_argv.c index bd415ec..d29ac5d 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -72,12 +72,12 @@ uint8_t m_argv(int argc, char *const argv[], t_msh *msh) msh->fd = STDIN_FILENO; msh->ret = m_loop(STDIN_FILENO, msh); } - else if (argc > 1 && ft_strncmp(*(argv + 1), FT_OPT_COMMAND, 3) == 0) + else if (argc > 1 && ft_strncmp(*(argv + 1), M_OPT_COMMAND, 3) == 0) { if (*(argv + 2) == NULL) { ft_dprintf(STDERR_FILENO, "%s: %s: option requires an argument\n", - msh->argv[0], FT_OPT_COMMAND); + msh->argv[0], M_OPT_COMMAND); return (2); } msh->ret = m_comm(*(argv + 2), msh); diff --git a/src/m_init.c b/src/m_init.c index 91baf7c..fd42694 100644 --- a/src/m_init.c +++ b/src/m_init.c @@ -25,17 +25,17 @@ void char home[PATH_MAX]; char fmt[PATH_MAX]; - u_subst_var_value("$PS1", FT_DEFAULT_PS_ONE, msh); - u_subst_var_value("$PS2", FT_DEFAULT_PS_TWO, msh); - u_subst_var_value("$PS3", FT_DEFAULT_PS_THR, msh); - u_subst_var_value("$PS4", FT_DEFAULT_PS_FOU, msh); + u_subst_var_value("$PS1", M_DEFAULT_PS_ONE, msh); + u_subst_var_value("$PS2", M_DEFAULT_PS_TWO, msh); + u_subst_var_value("$PS3", M_DEFAULT_PS_THR, msh); + u_subst_var_value("$PS4", M_DEFAULT_PS_FOU, msh); u_get_var_value(home, "$HISTFILE", PATH_MAX, msh); if (home[0] == C_NUL) { u_get_var_value(home, "$HOME", PATH_MAX, msh); if (home[0] != C_NUL) { - ft_sprintf(fmt, "%s/%s", home, FT_DEFAULT_HISTFILE); + ft_sprintf(fmt, "%s/%s", home, M_DEFAULT_HISTFILE); u_subst_var_value("$HISTFILE", fmt, msh); } } diff --git a/src/m_mshrc.c b/src/m_mshrc.c index 5b1277e..40e14a1 100644 --- a/src/m_mshrc.c +++ b/src/m_mshrc.c @@ -30,7 +30,7 @@ uint8_t m_source_mshrc(t_msh *msh) uint8_t ret; u_get_var_value(home, "$HOME", PATH_MAX, msh); - ft_sprintf(file, "%s/%s", home, FT_MINISHELLRC); + ft_sprintf(file, "%s/%s", home, M_MINISHELLRC); if ((fd = open(file, O_RDONLY)) < 0) return (0); msh->fd = fd; diff --git a/src/m_prompt.c b/src/m_prompt.c index 94381c3..0dd525e 100644 --- a/src/m_prompt.c +++ b/src/m_prompt.c @@ -75,9 +75,9 @@ static void m_subst_prompt_rice(char var[], t_msh *msh) ft_strsubst_s(var, "\\w", "?"); } else if (var[i + 1] == 'v') - ft_strsubst_s(var, "\\v", FT_MSH_VERSION); + ft_strsubst_s(var, "\\v", M_MSH_VERSION); else if (var[i + 1] == 's') - ft_strsubst_s(var, "\\s", FT_PROGNAME); + ft_strsubst_s(var, "\\s", M_PROGNAME); else if (var[i + 1] == '?') { ft_uitoa_s(tmp, msh->ret); diff --git a/src/s_init.c b/src/s_init.c index c71ac9a..aff245f 100644 --- a/src/s_init.c +++ b/src/s_init.c @@ -29,40 +29,40 @@ static void s_init_sqb_ref_one(t_msh *msh) { - ft_memcpy(msh->sqb_ref[FT_ID_SQB_B], FT_SQB_B, ft_strlen(FT_SQB_B) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_C], FT_SQB_C, ft_strlen(FT_SQB_C) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_D], FT_SQB_D, ft_strlen(FT_SQB_D) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_E], FT_SQB_E, ft_strlen(FT_SQB_E) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_F], FT_SQB_F, ft_strlen(FT_SQB_F) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_H], FT_SQB_H, ft_strlen(FT_SQB_H) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_N], FT_SQB_N, ft_strlen(FT_SQB_N) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_P], FT_SQB_P, ft_strlen(FT_SQB_P) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_R], FT_SQB_R, ft_strlen(FT_SQB_R) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_S], FT_SQB_S, ft_strlen(FT_SQB_S) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_W], FT_SQB_W, ft_strlen(FT_SQB_W) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_X], FT_SQB_X, ft_strlen(FT_SQB_X) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_Z], FT_SQB_Z, ft_strlen(FT_SQB_Z) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_B], B_SQB_B, ft_strlen(B_SQB_B) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_C], B_SQB_C, ft_strlen(B_SQB_C) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_D], B_SQB_D, ft_strlen(B_SQB_D) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_E], B_SQB_E, ft_strlen(B_SQB_E) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_F], B_SQB_F, ft_strlen(B_SQB_F) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_H], B_SQB_H, ft_strlen(B_SQB_H) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_N], B_SQB_N, ft_strlen(B_SQB_N) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_P], B_SQB_P, ft_strlen(B_SQB_P) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_R], B_SQB_R, ft_strlen(B_SQB_R) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_S], B_SQB_S, ft_strlen(B_SQB_S) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_W], B_SQB_W, ft_strlen(B_SQB_W) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_X], B_SQB_X, ft_strlen(B_SQB_X) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_Z], B_SQB_Z, ft_strlen(B_SQB_Z) + 1); ft_memcpy(msh->sqb_ref[FT_ID_SQB_L_MAJ], - FT_SQB_L_MAJ, ft_strlen(FT_SQB_L_MAJ) + 1); + B_SQB_L_MAJ, ft_strlen(B_SQB_L_MAJ) + 1); ft_memcpy(msh->sqb_ref[FT_ID_SQB_S_MAJ], - FT_SQB_S_MAJ, ft_strlen(FT_SQB_S_MAJ) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_NT], FT_SQB_NT, ft_strlen(FT_SQB_NT) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_OT], FT_SQB_OT, ft_strlen(FT_SQB_OT) + 1); + B_SQB_S_MAJ, ft_strlen(B_SQB_S_MAJ) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_NT], B_SQB_NT, ft_strlen(B_SQB_NT) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_OT], B_SQB_OT, ft_strlen(B_SQB_OT) + 1); ft_memcpy(msh->sqb_ref[FT_ID_SQB_EQUA], - FT_SQB_EQUA, ft_strlen(FT_SQB_EQUA) + 1); + B_SQB_EQUA, ft_strlen(B_SQB_EQUA) + 1); ft_memcpy(msh->sqb_ref[FT_ID_SQB_DIFF], - FT_SQB_DIFF, ft_strlen(FT_SQB_DIFF) + 1); + B_SQB_DIFF, ft_strlen(B_SQB_DIFF) + 1); } static void s_init_sqb_ref_two(t_msh *msh) { - ft_memcpy(msh->sqb_ref[FT_ID_SQB_EQ], FT_SQB_EQ, ft_strlen(FT_SQB_EQ) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_NE], FT_SQB_NE, ft_strlen(FT_SQB_NE) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_GT], FT_SQB_GT, ft_strlen(FT_SQB_GT) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_GE], FT_SQB_GE, ft_strlen(FT_SQB_GE) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_LT], FT_SQB_LT, ft_strlen(FT_SQB_LT) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_LE], FT_SQB_LE, ft_strlen(FT_SQB_LE) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_EQ], B_SQB_EQ, ft_strlen(B_SQB_EQ) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_NE], B_SQB_NE, ft_strlen(B_SQB_NE) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_GT], B_SQB_GT, ft_strlen(B_SQB_GT) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_GE], B_SQB_GE, ft_strlen(B_SQB_GE) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_LT], B_SQB_LT, ft_strlen(B_SQB_LT) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_LE], B_SQB_LE, ft_strlen(B_SQB_LE) + 1); } static char diff --git a/src/u_vars.c b/src/u_vars.c index 17221f5..fe179cf 100644 --- a/src/u_vars.c +++ b/src/u_vars.c @@ -57,12 +57,12 @@ static void char tmp[255]; int32_t n; - if (ft_strncmp(varname, FT_RET_VAR, 3) == 0) + if (ft_strncmp(varname, M_RET_VAR, 3) == 0) { ft_uitoa_s(tmp, msh->ret); ft_strlcpy(str, tmp, 4); } - else if (ft_strncmp(varname, FT_ARGC_VAR, 3) == 0) + else if (ft_strncmp(varname, M_ARGC_VAR, 3) == 0) { ft_uitoa_s(tmp, msh->argc); ft_strlcpy(str, tmp, 255); |