diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-15 14:19:33 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-15 14:19:33 +0100 |
| commit | 7dce30ca733f6b310f997c4515e486718b273d44 (patch) | |
| tree | 97f6d7e8776accecd2e50a5df73c1237a0a1dabe /src/checker/main.c | |
| parent | f061613650f5e7c5e260a4d9a1ca1b1d80ca2f2c (diff) | |
| download | push_swap-7dce30ca733f6b310f997c4515e486718b273d44.tar.gz push_swap-7dce30ca733f6b310f997c4515e486718b273d44.tar.bz2 push_swap-7dce30ca733f6b310f997c4515e486718b273d44.zip | |
WIP: Checker base
Diffstat (limited to 'src/checker/main.c')
| -rw-r--r-- | src/checker/main.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/checker/main.c b/src/checker/main.c new file mode 100644 index 0000000..d113802 --- /dev/null +++ b/src/checker/main.c @@ -0,0 +1,34 @@ +#include "checker.h" + +// need to check duplicate +int main(int argc, char **argv) +{ + t_status s; + + if (argc == 1) + return (0); + t_stack *a = stack_new(argc - 1); + while (--argc > 1) + { + errno = 0; + ft_strict_atoi(argv[argc]); + if (errno != 0) + { + stack_destroy(a); + ft_putendl_fd("Error", STDERR_FILENO); + return (1); + } + stack_push(a, ft_atoi(argv[argc])); + } + t_stack *b = stack_new(argc - 1); + s = check(a, b); + if (s == STATUS_SUCCESS) + ft_putendl("OK"); + else if (s == STATUS_FAILURE) + ft_putendl("KO"); + else if (s == STATUS_ERROR) + ft_putendl_fd("Error", STDERR_FILENO); + stack_destroy(a); + stack_destroy(b); + return 0; +} |
