my_teams
logger2.h
Go to the documentation of this file.
1 /*
2 ** EPITECH PROJECT, 2024
3 ** teams [WSL: Arch]
4 ** File description:
5 ** logger2
6 */
7 
8 #ifndef LOGGER2_H_
9  #define LOGGER2_H_
10 
11  #include "protocol.h"
12  #include "client.h"
13  #include "logging_client.h"
14  #include "events_structures.h"
15  #include "unused.h"
16 
17  #include <string.h>
18 
19 static inline void mt_subscribe(const p_packet_t *payload,
21 {
22  subscribe_t subscribe = {0};
23 
24  memcpy(&subscribe, payload->data, sizeof(subscribe_t));
26  subscribe.user_uuid,
27  subscribe.team_uuid
28  );
29 }
30 
31 static inline void mt_unsubscribe(const p_packet_t *payload,
33 {
34  subscribe_t subscribe = {0};
35 
36  memcpy(&subscribe, payload->data, sizeof(subscribe_t));
38  subscribe.user_uuid,
39  subscribe.team_uuid
40  );
41 }
42 
43 static inline void mt_channel(const p_packet_t *payload,
45 {
46  channel_t channel = {0};
47 
48  memcpy(&channel, payload->data, sizeof(channel_t));
50  channel.uuid,
51  channel.name,
52  channel.description
53  );
54 }
55 
56 static inline void mt_thread(const p_packet_t *payload,
58 {
59  thread_t thread = {0};
60 
61  memcpy(&thread, payload->data, sizeof(thread_t));
63  thread.uuid,
64  thread.user_uuid,
65  thread.timestamp,
66  thread.title,
67  thread.body
68  );
69 }
70 
71 static inline void mt_reply(const p_packet_t *payload,
73 {
74  reply_t reply = {0};
75 
76  memcpy(&reply, payload->data, sizeof(reply_t));
78  reply.thread_uuid,
79  reply.user_uuid,
80  reply.timestamp,
81  reply.body
82  );
83 }
84 
85 #endif /* !LOGGER2_H_ */
int client(int ac, char **av)
main function for the client is only used by main (is returned by the main function)
Definition: client.c:176
int client_print_channel_created(char const *channel_uuid, char const *channel_name, char const *channel_description)
Must be called when you create channel successfully.
int client_print_thread_created(char const *thread_uuid, char const *user_uuid, time_t thread_timestamp, char const *thread_title, char const *thread_body)
Must be called when you create a thread successfully.
int client_print_unsubscribed(char const *user_uuid, char const *team_uuid)
Must be called when you unsubscribe from a team successfully.
int client_print_reply_created(char const *thread_uuid, char const *user_uuid, time_t reply_timestamp, char const *reply_body)
Must be called when you create a reply successfully.
int client_print_subscribed(char const *user_uuid, char const *team_uuid)
Must be called when you subscribe to a team successfully.
Definition: client.h:32
Definition: events_structures.h:126
char description[MAX_DESCRIPTION_LENGTH]
Definition: events_structures.h:130
char name[MAX_NAME_LENGTH]
Definition: events_structures.h:129
char uuid[UUID_LENGTH]
Definition: events_structures.h:127
Represents a packet with type and data.
Definition: protocol.h:31
uint8_t data[DATA_SIZE]
Definition: protocol.h:33
Definition: events_structures.h:168
char body[MAX_BODY_LENGTH]
Definition: events_structures.h:171
time_t timestamp
Definition: events_structures.h:172
char user_uuid[UUID_LENGTH]
Definition: events_structures.h:169
char thread_uuid[UUID_LENGTH]
Definition: events_structures.h:170
Definition: events_structures.h:64
char user_uuid[UUID_LENGTH]
Definition: events_structures.h:65
char team_uuid[UUID_LENGTH]
Definition: events_structures.h:66
Definition: events_structures.h:147
time_t timestamp
Definition: events_structures.h:153
char user_uuid[UUID_LENGTH]
Definition: events_structures.h:149
char body[MAX_BODY_LENGTH]
Definition: events_structures.h:152
char title[MAX_NAME_LENGTH]
Definition: events_structures.h:151
char uuid[UUID_LENGTH]
Definition: events_structures.h:148
#define UNUSED
Definition: unused.h:12