diff --git a/Makefile b/Makefile index 1aaed2f..89f5759 100644 --- a/Makefile +++ b/Makefile @@ -3,30 +3,31 @@ # variables names # value | .h in includes/ # - - - - - - - - - - - - - - # ! name is case sensitive | ! use VPATH only for .c -NAME = pushswap +NAME = pushswap -CC = gcc +CC = gcc -VPATH = srcs +VPATH = srcs -IDIR = ./includes +IDIR = ./includes -_DEPS = -DEPS = $(_DEPS:%.h=$(IDIR)/%.h) +_DEPS = +DEPS = $(_DEPS:%.h=$(IDIR)/%.h) # used to check if a .h has been modify when execute $NAME rule -LDIR = ./libft -_LIBS = libft.a -LIBS = $(_LIBS:lib%.a=%) +LDIR = ./libft +_LIBS = libft.a +LIBS = $(_LIBS:lib%.a=%) -SRCS = pushswap.c +SRCS = pushswap.c \ + error.c -ODIR = ./builds -OBJS = $(SRCS:%.c=$(ODIR)/%.o) +ODIR = ./builds +OBJS = $(SRCS:%.c=$(ODIR)/%.o) -CFLAGS = -I$(IDIR) -g3 -Wall -Wextra -Werror +CFLAGS = -I$(IDIR) -g3 -Wall -Wextra -Werror -LFLAGS = -L$(LDIR) -l$(LIBS) +LFLAGS = -L$(LDIR) -l$(LIBS) diff --git a/README.md b/README.md index 2173679..a6dfb3e 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,10 @@ 2000 0 3 973 224 Gravity Sort 2000 0 6 000 Counting Sort 2000 0 4 000 Pigeonhole Sort - Radix LSD Sort (Base 4) - American Flag Sort (128 Buckets) - Radix LSD In-Place Sort (Base 10) - Radix LSD In-Place Sort (Base 2) + 2000 0 12 000 Radix LSD Sort (Base 4) + 2000 0 4 220 American Flag Sort (128 Buckets) + 2048 0 19 207 376 Radix LSD In-Place Sort (Base 10) + 2000 0 34 562 144 Radix LSD In-Place Sort (Base 2) Radix MSD Sort (Base 4) Radix MSD Sort (Base 2) Shatter Sort diff --git a/builds/error.o b/builds/error.o new file mode 100644 index 0000000..cfffd51 Binary files /dev/null and b/builds/error.o differ diff --git a/builds/pushswap.o b/builds/pushswap.o new file mode 100644 index 0000000..a13f70c Binary files /dev/null and b/builds/pushswap.o differ diff --git a/includes/pushswap.h b/includes/pushswap.h index 1b06c5e..4794109 100644 --- a/includes/pushswap.h +++ b/includes/pushswap.h @@ -1,48 +1,58 @@ #ifndef PUSH_SWAP_H # define PUSH_SWAP_H -# include "libft.h" -// # include "../libft/includes/libft.h" +# include "../libft/includes/libft.h" # include // read(), write(), sleep() # include // malloc(), free(), exit(), atoi() -typedef struct s_list +typedef struct s_stack { int n; struct s_list *next; -} t_list; +} t_stack; + +void ps_error(int i); +void ps_clean(t_stack *stack, int i); /* ** swap */ +/* int swap(t_list **list); int sa(); int sb(); int ss(); +*/ /* ** push */ +/* int push(t_list **dst, t_list **src); int pa(); int pb(); int pp(); +*/ /* ** rotate */ +/* int rotate(t_list **list); int ra(); int rb(); int rr(); +*/ /* ** reverse rotate */ +/* int reverse_rotate(t_list **list); int rra(); int rrb(); int rrr(); +*/ #endif diff --git a/pushswap b/pushswap new file mode 100755 index 0000000..edf43a7 Binary files /dev/null and b/pushswap differ diff --git a/pushswap_subject_fr.pdf b/pushswap_subject_fr.pdf new file mode 100644 index 0000000..8becd4d Binary files /dev/null and b/pushswap_subject_fr.pdf differ diff --git a/srcs/error.c b/srcs/error.c new file mode 100644 index 0000000..9cfaea6 --- /dev/null +++ b/srcs/error.c @@ -0,0 +1,22 @@ + +#include "pushswap.h" + +void ps_clean(t_stack *stack, int err) +{ + (void)stack; + ps_error(err); +} + +void ps_usage(void) +{ + ft_printf("usage\n"); +} + +void ps_error(int err) +{ + if (err == 1) + ps_usage(); + if (err == 2) + ft_printf("error\n"); + exit(0); +} diff --git a/srcs/pushswap.c b/srcs/pushswap.c index e69de29..b8bb68b 100644 --- a/srcs/pushswap.c +++ b/srcs/pushswap.c @@ -0,0 +1,32 @@ + +#include "pushswap.h" + +void is_valid(int ac, char **av) +{ + if (ac < 2) + ps_error(1); + (void)av; +} + +t_stack *init_stack(int ac, char **av) +{ + (void)ac; + (void)av; + t_stack *start; + + if (!(start = ft_calloc(1, sizeof(t_stack)))) + ps_clean(start, 2); + return (start); +} + +int main(int ac, char **av) +{ + t_stack *stack; + //t_list *result; + + is_valid(ac, av); // check if usage and list are correct + stack = init_stack(ac, av); + // result = sort_algo(stack); + return(0); +} +