-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminitalk.h
More file actions
66 lines (56 loc) · 1.71 KB
/
Copy pathminitalk.h
File metadata and controls
66 lines (56 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minitalk.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: frapp <frapp@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 00:25:38 by frapp #+# #+# */
/* Updated: 2023/12/01 07:10:30 by frapp ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINITALK_H
# define MINITALK_H
# include <unistd.h>
# include <signal.h>
# include "libft/libft.h"
# include <stdbool.h>
# ifndef BUFFER_SIZE
# define BUFFER_SIZE 2048
# endif
# ifndef ZERO
# define ZERO SIGUSR2
# endif
# ifndef ONE
# define ONE SIGUSR1
# endif
# ifndef RESET
# define RESET ONE
# endif
# ifndef NORMAL_OP
# define NORMAL_OP ZERO
# endif
struct s_client
{
pid_t server_id;
struct sigaction act;
unsigned char *str;
int sleep_time1;
int sleep_time2;
int bit_i;
bool finished;
volatile sig_atomic_t zero_received;
volatile sig_atomic_t one_received;
int end_confirmations;
} ;
struct s_server
{
unsigned char buffer[BUFFER_SIZE];
int i;
unsigned char cmp;
unsigned char zero_count;
unsigned char both_count;
pid_t client_id;
struct sigaction act;
} ;
#endif