added WHY2-prefix at the beginning of chat-flags macros

This commit is contained in:
Václav Šmejkal 2023-03-12 15:01:04 +01:00
parent b8b7b7cdff
commit cd5d290a13
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
4 changed files with 12 additions and 12 deletions

View File

@ -20,10 +20,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#define WHY2_CHAT_COMMON_H #define WHY2_CHAT_COMMON_H
//DEFINES //DEFINES
#define SA struct sockaddr #define WHY2_SA struct sockaddr
#define SERVER_PORT 1204 #define WHY2_SERVER_PORT 1204
#define MAX_CONNECTIONS 1000 #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 #endif

View File

@ -40,7 +40,7 @@ int main(void)
//DEFINE SERVER ADDRESS //DEFINE SERVER ADDRESS
struct sockaddr_in server_addr; struct sockaddr_in server_addr;
server_addr.sin_family = AF_INET; 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; server_addr.sin_addr.s_addr = INADDR_ANY;
//GET IP //GET IP
@ -56,7 +56,7 @@ int main(void)
} }
printf("\n\n\n"); 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."); if (connectStatus < 0) why2_die("Connecting failed.");
@ -65,7 +65,7 @@ int main(void)
for (;;) for (;;)
{ {
getline(&line, &line_length, stdin); getline(&line, &line_length, stdin);
printf(CLEAR_AND_GO_UP); printf(WHY2_CLEAR_AND_GO_UP);
why2_send_socket(line, listen_socket); why2_send_socket(line, listen_socket);

View File

@ -42,14 +42,14 @@ int main(void)
//DEFINE SERVER ADDRESS //DEFINE SERVER ADDRESS
struct sockaddr_in server_addr; struct sockaddr_in server_addr;
server_addr.sin_family = AF_INET; 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; server_addr.sin_addr.s_addr = INADDR_ANY;
//BIND SOCKET //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 //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"); printf("Server enabled.\n\n");

View File

@ -236,7 +236,7 @@ void *why2_accept_thread(void *socket)
//LOOP ACCEPT //LOOP ACCEPT
for (;;) 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; if (accepted == -1) continue;
@ -279,7 +279,7 @@ void *why2_listen_server(void *socket)
for (;;) for (;;)
{ {
read = why2_read_socket(*((int*) socket)); //TODO: Fix other user message formatting 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); printf("%s\n>>> ", read);
fflush(stdout); fflush(stdout);