diff options
Diffstat (limited to 'src/b_sqb.c')
-rw-r--r-- | src/b_sqb.c | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/src/b_sqb.c b/src/b_sqb.c index 9e7015c..91bf7b6 100644 --- a/src/b_sqb.c +++ b/src/b_sqb.c @@ -14,24 +14,56 @@ #include <stdint.h> #include <unistd.h> +#include "d_define.h" #include "s_struct.h" #include "u_utils.h" -/* static uint8_t */ -/* b_get_sqb_id(uint64_t argc, */ -/* char *argv[],) */ -/* { */ -/* } */ +static void + b_sqb_unexpected_operator(const char op[]) +{ + ft_dprintf(STDERR_FILENO, "[: %s: unexpected operator\n", op); +} + +static uint8_t + b_get_sqb_id(uint64_t argc, + char *argv[], + t_msh *msh) +{ + size_t j; + uint8_t i; + + i = 0; + while (i < FT_ID_SQB_COUNT) + { + j = 0; + while (j < argc) + { + if ( + ft_strncmp(argv[j], + msh->sqb_ref[i], + ft_strlen(msh->sqb_ref[i]) + 1) == 0) + return (i); + j++; + } + i++; + } + return (i); +} static uint8_t b_eval_sqb(uint64_t argc, char *argv[], t_msh *msh) { - (void)argc; - (void)argv; - (void)msh; + uint8_t id; + id = b_get_sqb_id(argc, argv, msh); + if (id == FT_ID_SQB_COUNT) + { + b_sqb_unexpected_operator(argv[0]); + return (2); + } + ft_printf("[%s]\n", msh->sqb_ref[id]); return (0); } @@ -48,5 +80,7 @@ uint8_t } if (argc == 1) return (1); + else if (argc == 2) + return (0); return (b_eval_sqb(argc, args, msh)); } |