diff --git a/Makefile b/Makefile index ae9ef65..6c4bf1c 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,8 @@ ODIR = ./builds S_OBJS = $(S_SRCS:%.c=$(ODIR)/%.o) C_OBJS = $(C_SRCS:%.c=$(ODIR)/%.o) -DEPS = ./includes/minitalk.h +DEPS = ./includes/minitalk.h \ + ./libft/includes/libft.h IDIR = $(dir $(DEPS)) # $(dir PATH/TO/FILE) expands to "PATH/TO/" -> the directory of a file @@ -25,7 +26,7 @@ LIBS = $(_LIBS:lib%.a=%) CFLAGS = $(IDIR:%=-I%) CFLAGS += -g3 -Wall -Wextra -Werror -LFLAGS = -L$(LDIR) -l$(LIBS) +LFLAGS = -L./libft -lft # - - - - - - - - - - - - - - # target: prerequisites | $@ : target @@ -35,6 +36,7 @@ LFLAGS = -L$(LDIR) -l$(LIBS) all: libft $(SERVER) $(CLIENT) libft: + @echo "hello" make -C $(LDIR) $(SERVER): $(S_OBJS) $(DEPS) diff --git a/builds/client.o b/builds/client.o new file mode 100644 index 0000000..181e5ce Binary files /dev/null and b/builds/client.o differ diff --git a/builds/server.o b/builds/server.o new file mode 100644 index 0000000..1f02d32 Binary files /dev/null and b/builds/server.o differ diff --git a/client b/client new file mode 100755 index 0000000..ab8cfc1 Binary files /dev/null and b/client differ diff --git a/includes/minitalk.h b/includes/minitalk.h index 15376ca..7acd2fd 100644 --- a/includes/minitalk.h +++ b/includes/minitalk.h @@ -1,9 +1,9 @@ -#ifndef FT_PRINTF_H -# define FT_PRINTF_H +#ifndef MINITALK_H +# define MINITALK_H # include // for signal kill # include // for getpid kill # include // for getpid - +# include "libft.h" #endif diff --git a/libft b/libft deleted file mode 160000 index c335eb1..0000000 --- a/libft +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c335eb1f6a77f1db972c9f984962836c476d7e70 diff --git a/libft b/libft new file mode 120000 index 0000000..4aa6356 --- /dev/null +++ b/libft @@ -0,0 +1 @@ +../../libft \ No newline at end of file diff --git a/server b/server new file mode 100755 index 0000000..c2ad378 Binary files /dev/null and b/server differ diff --git a/srcs/server.c b/srcs/server.c index c7202b9..63cf4c8 100644 --- a/srcs/server.c +++ b/srcs/server.c @@ -1,9 +1,16 @@ -#include "../includes/minitalk.h" +#include "minitalk.h" #include // for printf -void put_client_pid(int client_pid) +//int ft_printf(char *string, ...); + +void sig_handler_1(int sig_num) { - printf("%i\n", client_pid); + ft_printf("SIGUSR1 %i\n", sig_num); +} + +void sig_handler_2(int sig_num) +{ + ft_printf("SIGUSR2 %i\n", sig_num); } int main() @@ -11,8 +18,9 @@ int main() int pid; pid = (int)getpid(); - printf("%i\n", pid); - signal(SIGUSR1, put_client_pid); + ft_printf("%i\n", pid); + signal(SIGUSR1, sig_handler_1); + signal(SIGUSR2, sig_handler_2); while (1); return (0); } @@ -37,4 +45,134 @@ int main() ** you can only use two signals : ** - SIGUSR1 ** - SIGUSR2 +** +** 1 000 0 +** 2 001 1 2 +** 3 002 10 +** 4 003 11 2 +** 5 004 100 +** 6 005 101 +** 7 006 110 +** 8 007 111 4 +** 9 008 1000 +** 10 009 1001 +** 11 010 1010 +** 12 011 1011 +** 13 012 1100 +** 14 013 1101 +** 15 014 1110 +** 16 015 1111 8 +** 17 016 10000 +** 18 017 10001 +** 19 018 10010 +** 20 019 10011 +** 21 020 10100 +** 22 021 10101 +** 23 022 10110 +** 24 023 10111 +** 25 024 11000 +** 26 025 11001 +** 27 026 11010 +** 28 027 11011 +** 29 028 11100 +** 30 029 11101 +** 31 030 11110 +** 32 031 11111 16 +** 33 032 100000 +** 34 033 100001 +** 35 034 100010 +** 36 035 100011 +** 37 036 100100 +** 38 037 100101 +** 39 038 100110 +** 40 039 100111 +** 41 040 101000 +** 42 041 101001 +** 43 042 101010 +** 44 043 101011 +** 45 044 101100 +** 46 045 101101 +** 47 046 101110 +** 48 047 101111 +** 49 048 110000 +** 50 049 110001 +** 51 050 110010 +** 52 051 110011 +** 53 052 110100 +** 54 053 110101 +** 55 054 110110 +** 56 055 110111 +** 57 056 111000 +** 58 057 111001 +** 59 058 111010 +** 60 059 111011 +** 61 060 111100 +** 62 061 111101 +** 63 062 111110 +** 64 063 111111 32 +** 65 064 1000000 +** 66 065 1000001 +** 67 066 1000010 +** 68 067 1000011 +** 69 068 1000100 +** 70 069 1000101 +** 71 070 1000110 +** 72 071 1000111 +** 73 072 1001000 +** 74 073 1001001 +** 75 074 1001010 +** 76 075 1001011 +** 77 076 1001100 +** 78 077 1001101 +** 79 078 1001110 +** 80 079 1001111 +** 81 080 1010000 +** 82 081 1010001 +** 83 082 1010010 +** 84 083 1010011 +** 85 084 1010100 +** 86 085 1010101 +** 87 086 1010110 +** 88 087 1010111 +** 89 088 1011000 +** 90 089 1011001 +** 91 090 1011010 +** 92 091 1011011 +** 93 092 1011100 +** 94 093 1011101 +** 95 094 1011110 +** 96 095 1011111 +** 97 096 1100000 +** 98 097 1100001 +** 99 098 1100010 +** 100 099 1100011 +** 101 100 1100100 +** 102 101 1100101 +** 103 102 1100110 +** 104 103 1100111 +** 105 104 1101000 +** 106 105 1101001 +** 107 106 1101010 +** 108 107 1101011 +** 109 108 1101100 +** 110 109 1101101 +** 111 110 1101110 +** 112 111 1101111 +** 113 112 1110000 +** 114 113 1110001 +** 115 114 1110010 +** 116 115 1110011 +** 117 116 1110100 +** 118 117 1110101 +** 119 118 1110110 +** 120 119 1110111 +** 121 120 1111000 +** 122 121 1111001 +** 123 122 1111010 +** 124 123 1111011 +** 125 124 1111100 +** 126 125 1111101 +** 127 126 1111110 +** 128 127 1111111 64 +** */