summaryrefslogtreecommitdiffstats
path: root/src/u_utils.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/u_utils.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/u_utils.c b/src/u_utils.c
index 4e332b3..d56d7c0 100644
--- a/src/u_utils.c
+++ b/src/u_utils.c
@@ -19,8 +19,7 @@
#include "f_fail.h"
#include "s_struct.h"
-t_bool
- u_is_not_escaped(const char *head, const char *ptr)
+t_bool u_is_not_escaped(const char *head, const char *ptr)
{
if (((ptr - head) == 0) ||
((ptr - head) >= 1 && *(ptr - 1) != C_BACKS) ||
@@ -29,8 +28,7 @@ t_bool
return (FALSE);
}
-void
- u_eof_fd(int32_t fd)
+void u_eof_fd(int32_t fd)
{
char *line;
@@ -39,11 +37,10 @@ void
ft_memdel((void*)&line);
}
-char
- **u_get_env_var_names(t_msh *msh)
+char **u_get_env_var_names(t_msh *msh)
{
- size_t i;
char **vars;
+ size_t i;
i = 0;
while (msh->envp[i] != NULL)
@@ -64,8 +61,7 @@ char
return (vars);
}
-uint64_t
- u_builtins_get_argc(const char *args[])
+uint64_t u_builtins_get_argc(const char *args[])
{
uint64_t argc;
@@ -76,3 +72,20 @@ uint64_t
}
return (argc);
}
+
+uint8_t u_get_builtin_id(const char bin[])
+{
+ char tmp[M_BUILTINS_REF_LEN];
+ char *tok;
+ uint8_t i;
+
+ i = 0;
+ ft_strlcpy(tmp, M_BUILTINS_REF, M_BUILTINS_REF_LEN);
+ tok = ft_strtok(tmp, ":");
+ while (tok != NULL && ft_strncmp(bin, tok, ft_strlen(tok) + 1) != 0)
+ {
+ tok = ft_strtok(NULL, ":");
+ i++;
+ }
+ return (i);
+}