-
Notifications
You must be signed in to change notification settings - Fork 0
/
minitalk_bonus.h
53 lines (42 loc) · 1.85 KB
/
minitalk_bonus.h
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minitalk_bonus.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nkiampav <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/05 10:00:48 by nkiampav #+# #+# */
/* Updated: 2024/08/05 10:00:51 by nkiampav ### ########.fr */
/* */
/* ************************************************************************** */
// ======================== DEFINITIONS
#ifndef MINITALK_BONUS_H
# define MINITALK_BONUS_H
# define WAIT_US 100 // usleep()
// ======================== INCLUDES
# include "libft/libft.h" // ft_atoi(), ft_strlen(), ft_putstr(), ft_putnbr()
# include <unistd.h> // getpid(), write()
# include <signal.h> // sigemptyset(), sigaction()
# include <stdlib.h> // exit()
// ======================== PROTOTYPES
// minitalk.c
void configure_sigaction_signals(struct sigaction *sa);
void send_int(pid_t pid, int num);
void send_char(pid_t pid, char c);
void send_bit(pid_t pid, char bit, char flag_to_pause);
// ======================== TYPEDEF and STRUCTURES
/*
Structure to handle the protocol between server-client
bits : bits received
data : data received, can be an integer (length of message) or char
flag : 1 if length of message was received, else 0
message : message received
*/
typedef struct s_protocol
{
int bits;
int data;
int flag;
char *message;
} t_protocol;
#endif