diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-18 10:54:03 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-18 10:54:03 +0100 |
| commit | 2d34349b54a9fed4d34c96bdbec5172f7695cf60 (patch) | |
| tree | 6a4d0de4bbd3e0303b8d71f46107f87fac9b22b5 /src/checker/checker.h | |
| parent | 7dce30ca733f6b310f997c4515e486718b273d44 (diff) | |
| download | push_swap-2d34349b54a9fed4d34c96bdbec5172f7695cf60.tar.gz push_swap-2d34349b54a9fed4d34c96bdbec5172f7695cf60.tar.bz2 push_swap-2d34349b54a9fed4d34c96bdbec5172f7695cf60.zip | |
refactoring checker to a more simple, 'pipe' like and generic approche
Diffstat (limited to 'src/checker/checker.h')
| -rw-r--r-- | src/checker/checker.h | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/checker/checker.h b/src/checker/checker.h index 1fbb46f..a6a2cc3 100644 --- a/src/checker/checker.h +++ b/src/checker/checker.h @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* checker.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/18 10:16:12 by cacharle #+# #+# */ +/* Updated: 2020/01/18 10:51:42 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef CHECKER_H # define CHECKER_H @@ -9,7 +21,8 @@ typedef enum { STATUS_SUCCESS, STATUS_FAILURE, - STATUS_ERROR + STATUS_ERROR, + STATUS_EOF, } t_status; typedef enum @@ -27,12 +40,31 @@ typedef enum ACTION_RRR, ACTION_ERROR, ACTION_EOF -} t_action; +} t_action_id; + + + +# define FLAG_ARG_A (1 << 0) +# define FLAG_ARG_B (1 << 1) +# define FLAG_ARG_A_B (1 << 2) +# define FLAG_ARG_B_A (1 << 3) + +typedef char t_flag_arg; + +typedef struct +{ + char *id; + t_flag_arg args; + union + { + void (*arg_1)(t_stack *); + void (*arg_2)(t_stack *, t_stack *); + } func; +} t_action; t_status check(t_stack *a, t_stack *b); -t_action read_action(void); -t_action str_action(char *s); -void exec_action(t_action action, t_stack *a, t_stack *b); +t_status read_action(t_stack *a, t_stack *b); +t_status exec_action(char *action_id, t_stack *a, t_stack *b); t_bool stack_sorted(t_stack *stack); #endif |
