debut ecritures fonctions clean et error
This commit is contained in:
29
Makefile
29
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)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
BIN
builds/error.o
Normal file
BIN
builds/error.o
Normal file
Binary file not shown.
BIN
builds/pushswap.o
Normal file
BIN
builds/pushswap.o
Normal file
Binary file not shown.
@@ -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 <unistd.h> // read(), write(), sleep()
|
||||
# include <stdlib.h> // 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
|
||||
|
||||
BIN
pushswap_subject_fr.pdf
Normal file
BIN
pushswap_subject_fr.pdf
Normal file
Binary file not shown.
22
srcs/error.c
Normal file
22
srcs/error.c
Normal file
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user