From cd5d290a1321e99a1313fea49629da682101d391 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sun, 12 Mar 2023 15:01:04 +0100 Subject: [PATCH] added WHY2-prefix at the beginning of chat-flags macros --- include/chat/flags.h | 8 ++++---- src/chat/main/client.c | 6 +++--- src/chat/main/server.c | 6 +++--- src/chat/misc.c | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/chat/flags.h b/include/chat/flags.h index 5529db4..83a6ed6 100644 --- a/include/chat/flags.h +++ b/include/chat/flags.h @@ -20,10 +20,10 @@ along with this program. If not, see . #define WHY2_CHAT_COMMON_H //DEFINES -#define SA struct sockaddr -#define SERVER_PORT 1204 -#define MAX_CONNECTIONS 1000 +#define WHY2_SA struct sockaddr +#define WHY2_SERVER_PORT 1204 +#define WHY2_MAX_CONNECTIONS 1000 -#define CLEAR_AND_GO_UP "\33[2K\r\033[A" +#define WHY2_CLEAR_AND_GO_UP "\33[2K\r\033[A" #endif \ No newline at end of file diff --git a/src/chat/main/client.c b/src/chat/main/client.c index 7496c81..657fcbc 100644 --- a/src/chat/main/client.c +++ b/src/chat/main/client.c @@ -40,7 +40,7 @@ int main(void) //DEFINE SERVER ADDRESS struct sockaddr_in server_addr; server_addr.sin_family = AF_INET; - server_addr.sin_port = htons(SERVER_PORT); + server_addr.sin_port = htons(WHY2_SERVER_PORT); server_addr.sin_addr.s_addr = INADDR_ANY; //GET IP @@ -56,7 +56,7 @@ int main(void) } printf("\n\n\n"); - int connectStatus = connect(listen_socket, (SA *) &server_addr, sizeof(server_addr)); //CONNECT + int connectStatus = connect(listen_socket, (WHY2_SA *) &server_addr, sizeof(server_addr)); //CONNECT if (connectStatus < 0) why2_die("Connecting failed."); @@ -65,7 +65,7 @@ int main(void) for (;;) { getline(&line, &line_length, stdin); - printf(CLEAR_AND_GO_UP); + printf(WHY2_CLEAR_AND_GO_UP); why2_send_socket(line, listen_socket); diff --git a/src/chat/main/server.c b/src/chat/main/server.c index e2ba377..1459943 100644 --- a/src/chat/main/server.c +++ b/src/chat/main/server.c @@ -42,14 +42,14 @@ int main(void) //DEFINE SERVER ADDRESS struct sockaddr_in server_addr; server_addr.sin_family = AF_INET; - server_addr.sin_port = htons(SERVER_PORT); + server_addr.sin_port = htons(WHY2_SERVER_PORT); server_addr.sin_addr.s_addr = INADDR_ANY; //BIND SOCKET - if (bind(listen_socket, (SA *) &server_addr, sizeof(server_addr)) < 0) why2_die("Failed binding socket."); + if (bind(listen_socket, (WHY2_SA *) &server_addr, sizeof(server_addr)) < 0) why2_die("Failed binding socket."); //LISTEN - if (listen(listen_socket, MAX_CONNECTIONS) < 0) why2_die("Binding failed."); + if (listen(listen_socket, WHY2_MAX_CONNECTIONS) < 0) why2_die("Binding failed."); printf("Server enabled.\n\n"); diff --git a/src/chat/misc.c b/src/chat/misc.c index 66ce7ab..cfabfdb 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -236,7 +236,7 @@ void *why2_accept_thread(void *socket) //LOOP ACCEPT for (;;) { - accepted = accept(*((int*) socket), (SA *) NULL, NULL); //ACCEPT NEW SOCKET //TODO: CLOSE (not only this one) + accepted = accept(*((int*) socket), (WHY2_SA *) NULL, NULL); //ACCEPT NEW SOCKET //TODO: CLOSE (not only this one) if (accepted == -1) continue; @@ -279,7 +279,7 @@ void *why2_listen_server(void *socket) for (;;) { read = why2_read_socket(*((int*) socket)); //TODO: Fix other user message formatting - printf(CLEAR_AND_GO_UP); + printf(WHY2_CLEAR_AND_GO_UP); printf("%s\n>>> ", read); fflush(stdout);