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/
|
# variables names # value | .h in includes/
|
||||||
# - - - - - - - - - - - - - - # ! name is case sensitive | ! use VPATH only for .c
|
# - - - - - - - - - - - - - - # ! 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 = $(_DEPS:%.h=$(IDIR)/%.h)
|
DEPS = $(_DEPS:%.h=$(IDIR)/%.h)
|
||||||
# used to check if a .h has been modify when execute $NAME rule
|
# used to check if a .h has been modify when execute $NAME rule
|
||||||
|
|
||||||
LDIR = ./libft
|
LDIR = ./libft
|
||||||
_LIBS = libft.a
|
_LIBS = libft.a
|
||||||
LIBS = $(_LIBS:lib%.a=%)
|
LIBS = $(_LIBS:lib%.a=%)
|
||||||
|
|
||||||
SRCS = pushswap.c
|
SRCS = pushswap.c \
|
||||||
|
error.c
|
||||||
|
|
||||||
ODIR = ./builds
|
ODIR = ./builds
|
||||||
OBJS = $(SRCS:%.c=$(ODIR)/%.o)
|
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 3 973 224 Gravity Sort
|
||||||
2000 0 6 000 Counting Sort
|
2000 0 6 000 Counting Sort
|
||||||
2000 0 4 000 Pigeonhole Sort
|
2000 0 4 000 Pigeonhole Sort
|
||||||
Radix LSD Sort (Base 4)
|
2000 0 12 000 Radix LSD Sort (Base 4)
|
||||||
American Flag Sort (128 Buckets)
|
2000 0 4 220 American Flag Sort (128 Buckets)
|
||||||
Radix LSD In-Place Sort (Base 10)
|
2048 0 19 207 376 Radix LSD In-Place Sort (Base 10)
|
||||||
Radix LSD In-Place Sort (Base 2)
|
2000 0 34 562 144 Radix LSD In-Place Sort (Base 2)
|
||||||
Radix MSD Sort (Base 4)
|
Radix MSD Sort (Base 4)
|
||||||
Radix MSD Sort (Base 2)
|
Radix MSD Sort (Base 2)
|
||||||
Shatter Sort
|
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
|
#ifndef PUSH_SWAP_H
|
||||||
# define 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 <unistd.h> // read(), write(), sleep()
|
||||||
# include <stdlib.h> // malloc(), free(), exit(), atoi()
|
# include <stdlib.h> // malloc(), free(), exit(), atoi()
|
||||||
|
|
||||||
|
|
||||||
typedef struct s_list
|
typedef struct s_stack
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
struct s_list *next;
|
struct s_list *next;
|
||||||
} t_list;
|
} t_stack;
|
||||||
|
|
||||||
|
void ps_error(int i);
|
||||||
|
void ps_clean(t_stack *stack, int i);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** swap
|
** swap
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
int swap(t_list **list);
|
int swap(t_list **list);
|
||||||
int sa();
|
int sa();
|
||||||
int sb();
|
int sb();
|
||||||
int ss();
|
int ss();
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** push
|
** push
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
int push(t_list **dst, t_list **src);
|
int push(t_list **dst, t_list **src);
|
||||||
int pa();
|
int pa();
|
||||||
int pb();
|
int pb();
|
||||||
int pp();
|
int pp();
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** rotate
|
** rotate
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
int rotate(t_list **list);
|
int rotate(t_list **list);
|
||||||
int ra();
|
int ra();
|
||||||
int rb();
|
int rb();
|
||||||
int rr();
|
int rr();
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** reverse rotate
|
** reverse rotate
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
int reverse_rotate(t_list **list);
|
int reverse_rotate(t_list **list);
|
||||||
int rra();
|
int rra();
|
||||||
int rrb();
|
int rrb();
|
||||||
int rrr();
|
int rrr();
|
||||||
|
*/
|
||||||
|
|
||||||
#endif
|
#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