From b3fa44da5a8497545e559b63e57611c101059b57 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 21 Jun 2022 04:01:02 +0300
Subject: [PATCH] chatd.c: fix warning, whitespace tidy-up.
---
chatd.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/chatd.c b/chatd.c
index 45fe9cf..56f905e 100644
--- a/chatd.c
+++ b/chatd.c
@@ -121,7 +121,7 @@ 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",
+ fprintf(stderr, "Closing socket %d (was%s active)\n",
which, people[which].active ? "" : " not");
#endif
/* Notify all active clients */
@@ -148,8 +148,8 @@ void HandleClient(int which)
&data[CHAT_HELLO_NAME], 256);
people[which].name[256] = 0;
#ifdef DEBUG
- fprintf(stderr, "Activating socket %d (%s)\n",
- which, people[which].name);
+ fprintf(stderr, "Activating socket %d (%s)\n",
+ which, people[which].name);
#endif
/* Notify all active clients */
for ( i=0; i<CHAT_MAXPEOPLE; ++i ) {
@@ -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);
}
@@ -222,10 +221,10 @@ main(int argc, char *argv[])
SDLNet_GetError());
cleanup(2);
}
-
+
/* 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",