commit ef9fcf13767f639607fb536c600c03c6c621ce33 Author: hugogogo Date: Thu Aug 26 10:47:41 2021 +0200 init diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dc2852e --- /dev/null +++ b/Makefile @@ -0,0 +1,86 @@ + +# - - - - - - - - - - - - - - # name = value \ +# variables names # value +# - - - - - - - - - - - - - - # ! name is case sensitive + +NAME = minitalk + +CC = gcc + +VPATH = srcs + +IDIR = ./includes +_DEPS = fdf.h +DEPS = $(_DEPS:%.h=$(IDIR)/%.h) + +LDIR = ./libft +_LIBS = libft.a +LIBS = $(_LIBS:lib%.a=%) + +SRCS = fdf.c \ + parse.c \ + modifs.c \ + draw.c \ + keypress.c + +SRCS_B = fdf.c \ + parse.c \ + modifs.c \ + keypress_bonus.c \ + draw_bonus.c + +ODIR = ./builds +OBJS = $(SRCS:%.c=$(ODIR)/%.o) +OBJS_B = $(SRCS_B:%.c=$(ODIR)/%.o) + +# flag -g generates debug informations, g3 is maximal version +CFLAGS = -I$(IDIR) -g3 -Wall -Wextra -Werror +LFLAGS = -L$(LDIR) -l$(LIBS) +CFLAGS += -I./minilibx-linux-master +LFLAGS += -lm -lmlx -lXext -lX11 -L./minilibx-linux-master + + +# - - - - - - - - - - - - - - # target: prerequisites | $@ : target +# rules to execute # recipe | $< : 1st prerequisite +# - - - - - - - - - - - - - - # recipe | $^ : all prerequisites + +all: $(NAME) + +$(NAME): $(ODIR) $(OBJS) $(DEPS) + make -C $(LDIR) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) + +bonus: fclean $(ODIR) $(OBJS_B) $(DEPS) + make -C $(LDIR) + $(CC) $(CFLAGS) -o fdf $(OBJS_B) $(LFLAGS) + +$(ODIR): + mkdir -p $@ + +$(ODIR)/%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +debug: CFLAGS += -fsanitize=address +debug: clean $(NAME) + +leaks: $(NAME) + valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) maps/42_color.fdf +# valgrind --leak-check=full --leak-resolution=low --show-reachable=yes ./$(NAME) maps/42_color.fdf + +clean: + /bin/rm -f $(OBJS) $(OBJS_B) + +fclean: clean + /bin/rm -rf $(ODIR) + /bin/rm -f $(NAME) + /bin/rm -rf a.out a.out.dSYM + +libfclean: + make fclean -C $(LDIR) + +re: fclean all + +relib: libfclean re + +.PHONY: all clean fclean re gcc + diff --git a/includes/minitalk.h b/includes/minitalk.h new file mode 100644 index 0000000..15376ca --- /dev/null +++ b/includes/minitalk.h @@ -0,0 +1,9 @@ +#ifndef FT_PRINTF_H +# define FT_PRINTF_H + +# include // for signal kill +# include // for getpid kill +# include // for getpid + + +#endif diff --git a/minitalk.pdf b/minitalk.pdf new file mode 100644 index 0000000..3f66445 Binary files /dev/null and b/minitalk.pdf differ diff --git a/srcs/client b/srcs/client new file mode 100755 index 0000000..9b80930 Binary files /dev/null and b/srcs/client differ diff --git a/srcs/client.c b/srcs/client.c new file mode 100644 index 0000000..8b6a429 --- /dev/null +++ b/srcs/client.c @@ -0,0 +1,10 @@ +#include "../includes/minitalk.h" +#include //for atoi + +int main(int ac, char **av) +{ + if (ac != 2) + return (0); + kill(atoi(av[1]), SIGUSR1); + return (0); +} diff --git a/srcs/server b/srcs/server new file mode 100755 index 0000000..c879682 Binary files /dev/null and b/srcs/server differ diff --git a/srcs/server.c b/srcs/server.c new file mode 100644 index 0000000..c7202b9 --- /dev/null +++ b/srcs/server.c @@ -0,0 +1,40 @@ +#include "../includes/minitalk.h" +#include // for printf + +void put_client_pid(int client_pid) +{ + printf("%i\n", client_pid); +} + +int main() +{ + int pid; + + pid = (int)getpid(); + printf("%i\n", pid); + signal(SIGUSR1, put_client_pid); + while (1); + return (0); +} + +/* +** +** allowed functions : +** - write +** - signal +** - sigemptyset +** - sigaddset +** - sigaction +** - kill +** - getpid +** - malloc +** - free +** - pause +** - sleep +** - usleep +** - exit +** +** you can only use two signals : +** - SIGUSR1 +** - SIGUSR2 +*/