From fcdd07fcafa82549a0c2a56aab65ea6e21553e1c Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 21 Jun 2022 00:01:02 +0300
Subject: [PATCH] chatd.c: fix warning, whitespace tidy-up.
---
chatd.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/chatd.c b/chatd.c
index 605e948..fbe0acc 100644
--- a/chatd.c
+++ b/chatd.c
@@ -72,7 +72,7 @@ void HandleServer(void)
people[which].sock);
SDLNet_TCP_Close(people[which].sock);
#ifdef DEBUG
- fprintf(stderr, "Killed inactive socket %d\n", which);
+ fprintf(stderr, "Killed inactive socket %d\n", which);
#endif
break;
}
@@ -84,7 +84,7 @@ void HandleServer(void)
SDLNet_TCP_Send(newsock, &data, 1);
SDLNet_TCP_Close(newsock);
#ifdef DEBUG
- fprintf(stderr, "Connection refused -- chat room full\n");
+ fprintf(stderr, "Connection refused -- chat room full\n");
#endif
} else {
/* Add socket as an inactive person */
@@ -92,7 +92,7 @@ void HandleServer(void)
people[which].peer = *SDLNet_TCP_GetPeerAddress(newsock);
SDLNet_TCP_AddSocket(socketset, people[which].sock);
#ifdef DEBUG
- fprintf(stderr, "New inactive socket %d\n", which);
+ fprintf(stderr, "New inactive socket %d\n", which);
#endif
}
}
@@ -121,8 +121,8 @@ void HandleClient(int which)
/* Has the connection been closed? */
if ( SDLNet_TCP_Recv(people[which].sock, data, 512) <= 0 ) {
#ifdef DEBUG
- fprintf(stderr, "Closing socket %d (was%s active)\n",
- which, people[which].active ? "" : " not");
+ fprintf(stderr, "Closing socket %d (was%s active)\n",
+ which, people[which].active ? "" : " not");
#endif
/* Notify all active clients */
if ( people[which].active ) {
@@ -190,21 +190,20 @@ static void cleanup(int exitcode)
exit(exitcode);
}
-main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
IPaddress serverIP;
int i;
- /* Initialize SDL */
- if ( SDL_Init(0) < 0 ) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
- exit(1);
+ /* Initialize SDL */
+ if ( SDL_Init(0) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ exit(1);
}
/* Initialize the network */
if ( SDLNet_Init() < 0 ) {
- fprintf(stderr, "Couldn't initialize net: %s\n",
- SDLNet_GetError());
+ fprintf(stderr, "Couldn't initialize net: %s\n", SDLNet_GetError());
SDL_Quit();
exit(1);
}
@@ -225,7 +224,7 @@ main(int argc, char *argv[])
/* Create the server socket */
SDLNet_ResolveHost(&serverIP, NULL, CHAT_PORT);
-printf("Server IP: %x, %d\n", serverIP.host, serverIP.port);
+ printf("Server IP: %x, %d\n", serverIP.host, serverIP.port);
servsock = SDLNet_TCP_Open(&serverIP);
if ( servsock == NULL ) {
fprintf(stderr, "Couldn't create server socket: %s\n",