]> git.cworth.org Git - ttt/commitdiff
2005-11-25 Bryan Worth <bryan@theworths.org>
authorBryan Worth <bryan@theworths.org>
Fri, 25 Nov 2005 20:18:28 +0000 (20:18 +0000)
committerBryan Worth <bryan@theworths.org>
Fri, 25 Nov 2005 20:18:28 +0000 (20:18 +0000)
        * ttt-client.c, ttt-server.c, ttt-error.c changed line breaks to
        <crlf> (\r\n) for network compatibility

ChangeLog
src/ttt-client.c
src/ttt-error.c
src/ttt-server.c

index f99f646585eb2a9f3728af90b00afbded416069f..e5d65cb862a5f69c971c3877ff8c2a49b3522889 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-11-25  Bryan Worth <bryan@theworths.org>
+       * ttt-client.c, ttt-server.c, ttt-error.c changed line breaks to 
+        <crlf> (\r\n) for network compatibility
+
 2005-11-25  Bryan Worth <bryan@theworths.org>
        * TODO: checked off NOTICE USER and NOTICE QUIT
        *src/ttt-client.c: (_ttt_client_execute_helo): implement NOTICE USER
 2005-11-25  Bryan Worth <bryan@theworths.org>
        * TODO: checked off NOTICE USER and NOTICE QUIT
        *src/ttt-client.c: (_ttt_client_execute_helo): implement NOTICE USER
index 7b37fad3c5ecade9e6acc9ec6bd98a78c5f9b6d6..5f2a193179a0c644c410ed534549a186b06fd4cc 100644 (file)
@@ -102,14 +102,14 @@ _ttt_client_execute_helo (ttt_client_t *client,
 
     client->registered = TRUE;
 
 
     client->registered = TRUE;
 
-    xasprintf (&response, "HELO %s %s %s\n",
+    xasprintf (&response, "HELO %s %s %s\r\n",
               client->name,
               ttt_server_get_host (client->server),
               ttt_server_get_port (client->server));
 
     ttt_client_send (client, response);
 
               client->name,
               ttt_server_get_host (client->server),
               ttt_server_get_port (client->server));
 
     ttt_client_send (client, response);
 
-    xasprintf (&response, "NOTICE USER %s\n",client->name);
+    xasprintf (&response, "NOTICE USER %s\r\n",client->name);
     ttt_server_broadcast(client->server,response);
 
     free (response);
     ttt_server_broadcast(client->server,response);
 
     free (response);
@@ -143,7 +143,7 @@ _ttt_client_execute_quit (ttt_client_t *client,
     char *notice;
 
     assert (num_args == 0);
     char *notice;
 
     assert (num_args == 0);
-    xasprintf (&notice,"NOTICE QUIT %s\n",client->name);
+    xasprintf (&notice,"NOTICE QUIT %s\r\n",client->name);
     ttt_server_broadcast(client->server,notice);
     free (notice);
     return TTT_ERROR_QUIT_REQUESTED;
     ttt_server_broadcast(client->server,notice);
     free (notice);
     return TTT_ERROR_QUIT_REQUESTED;
@@ -159,7 +159,7 @@ _ttt_client_execute_message (ttt_client_t  *client,
 
     assert (num_args > 0);
 
 
     assert (num_args > 0);
 
-    xasprintf(&response, "MESSAGE\n");
+    xasprintf(&response, "MESSAGE\r\n");
     ttt_client_send (client, response);
     
     xasprintf(&response, "NOTICE MESSAGE %s", client->name);
     ttt_client_send (client, response);
     
     xasprintf(&response, "NOTICE MESSAGE %s", client->name);
@@ -167,7 +167,7 @@ _ttt_client_execute_message (ttt_client_t  *client,
        xasprintf(&response, "%s %s",response,args[i]);
 
     }
        xasprintf(&response, "%s %s",response,args[i]);
 
     }
-    xasprintf(&response, "%s\n",response);
+    xasprintf(&response, "%s\r\n",response);
     ttt_server_broadcast (client->server,response);
 
     free (response);
     ttt_server_broadcast (client->server,response);
 
     free (response);
@@ -344,7 +344,7 @@ ttt_client_new (void *closure, int client_socket)
     err = pthread_create (&client->thread, NULL,
                          _handle_requests_thread, client);
     if (err != 0) {
     err = pthread_create (&client->thread, NULL,
                          _handle_requests_thread, client);
     if (err != 0) {
-       fprintf (stderr, "Error: pthread_create failed: %s. Aborting.\n",
+       fprintf (stderr, "Error: pthread_create failed: %s. Aborting.\r\n",
                 strerror (err));
        exit (1);
     }
                 strerror (err));
        exit (1);
     }
index 4bd5498ea602f974e286404acc177d4624768a21..21d30e687bc2b5c49e568b94fde9d9431df8bc4b 100644 (file)
@@ -26,27 +26,27 @@ ttt_error_string (ttt_error_t error)
 {
     switch (error) {
     case TTT_ERROR_NONE:
 {
     switch (error) {
     case TTT_ERROR_NONE:
-       return "ERROT NONE\n";
+       return "ERROR NONEi\r\n";
     case TTT_ERROR_NO_NAME_SET:
     case TTT_ERROR_NO_NAME_SET:
-       return "ERROR NONAMESET\n";
+       return "ERROR NONAMESET\r\n";
     case TTT_ERROR_INVALID_NAME:
     case TTT_ERROR_INVALID_NAME:
-       return "ERROR INVALIDNAME\n";
+       return "ERROR INVALIDNAME\r\n";
     case TTT_ERROR_COMMAND:
     case TTT_ERROR_COMMAND:
-       return "ERROR COMMAND\n";
+       return "ERROR COMMAND\r\n";
     case TTT_ERROR_SYNTAX:
     case TTT_ERROR_SYNTAX:
-       return "ERROR SYNTAX\n";
+       return "ERROR SYNTAX\r\n";
     case TTT_ERROR_NOT_NUMBER:
     case TTT_ERROR_NOT_NUMBER:
-       return "ERROR NOTNUMBER\n";
+       return "ERROR NOTNUMBER\r\n";
     case TTT_ERROR_NOT_GRID:
     case TTT_ERROR_NOT_GRID:
-       return "ERROR NOTGRID\n";
+       return "ERROR NOTGRID\r\n";
     case TTT_ERROR_NO_USER:
     case TTT_ERROR_NO_USER:
-       return "ERROR NOUSER\n";
+       return "ERROR NOUSER\r\n";
     case TTT_ERROR_NOT_IN_GAME:
     case TTT_ERROR_NOT_IN_GAME:
-       return "ERROR_NOTINGAME\n";
+       return "ERROR_NOTINGAME\r\n";
     case TTT_ERROR_NOT_PLAYING:
     case TTT_ERROR_NOT_PLAYING:
-       return "ERROR_NOTPLAYING\n";
+       return "ERROR_NOTPLAYING\r\n";
     case TTT_ERROR_NOT_YOUR_TURN:
     case TTT_ERROR_NOT_YOUR_TURN:
-       return "ERROR NOTYOURTURN\n";
+       return "ERROR NOTYOURTURN\r\n";
     /* Not an actual protocol errror, so this should never happen. */
     case TTT_ERROR_QUIT_REQUESTED:
        ASSERT_NOT_REACHED;
     /* Not an actual protocol errror, so this should never happen. */
     case TTT_ERROR_QUIT_REQUESTED:
        ASSERT_NOT_REACHED;
index d98fc24e2891dafd8de6f34efe4fdffac3536edb..7ffbfc5f15e71a452680af33927d9221d09914d1 100644 (file)
@@ -74,7 +74,7 @@ ttt_server_register_client (ttt_server_t *server, ttt_client_t *client)
        }
     }
 
        }
     }
 
-    printf ("Client %s has joined.\n", name);
+    printf ("Client %s has joined.\r\n", name);
 
     server->num_clients++;
 
 
     server->num_clients++;
 
@@ -110,7 +110,7 @@ ttt_server_unregister_client (ttt_server_t *server, ttt_client_t *client)
 
     assert (i < server->num_clients);
 
 
     assert (i < server->num_clients);
 
-    printf ("Client %s has left.\n", ttt_client_get_name (client));
+    printf ("Client %s has left.\r\n", ttt_client_get_name (client));
 
     memmove (&server->clients[i], &server->clients[i+1],
             (server->num_clients - i - 1) * sizeof (ttt_client_t *));
 
     memmove (&server->clients[i], &server->clients[i+1],
             (server->num_clients - i - 1) * sizeof (ttt_client_t *));
@@ -151,7 +151,7 @@ ttt_server_who (ttt_server_t *server)
                   ttt_client_get_name (server->clients[i]),
                   ttt_client_get_num_wins (server->clients[i]));
 
                   ttt_client_get_name (server->clients[i]),
                   ttt_client_get_num_wins (server->clients[i]));
 
-    xasprintf (&response, "%s\n", response);
+    xasprintf (&response, "%s\r\n", response);
 
     pthread_mutex_unlock (&server->mutex);
 
 
     pthread_mutex_unlock (&server->mutex);
 
@@ -173,26 +173,26 @@ ttt_server_get_port (ttt_server_t *server)
 }
 
 static const char *WELCOME_MESSAGE = 
 }
 
 static const char *WELCOME_MESSAGE = 
-"Welcome to ttt-server. So far, this program is still a demonstration\n"
-"TCP/IP server, acting something like a rather braindead chat server.\n"
-"The server is currently listening on:\n"
-"\n    %s:%s\n"
-"\nTo test this, simply connect one or more clients to that host and port.\n"
-"For example:\n"
-"\n    telnet %s %s\n"
-"\nOnce you have connected a client, the server will send each line of text\n"
-"it receives to all connected clients. The server reports client joins and\n"
-"departures on stdout.\n"
-"\nNote that to terminate the telnet client you type Control-], then\n"
-"<Enter>, then \"close\" (and <Enter>) at the \"telnet> \" prompt.\n"
-"\nHave fun!\n"
-"-Carl\n"
-"\nPS. At this point we're ready to leave the demonstration phase and to\n"
-"begin implementing TTTP (tic-tac-toe protocol) as well as fixing the\n"
-"protocol specifcation. We don't need a custom client to move forward on\n"
-"the server (that is one of the ideas behind using a telnet-compatible\n"
-"protocol), but a custom client would still be a fine project for a\n"
-"motivated beginning programmer.\n\n";
+"Welcome to ttt-server. So far, this program is still a demonstration\r\n"
+"TCP/IP server, acting something like a rather braindead chat server.\r\n"
+"The server is currently listening on:\r\n"
+"\r\n  %s:%s\r\n"
+"\r\nTo test this, simply connect one or more clients to that host and port.\r\n"
+"For example:\r\n"
+"\r\n  telnet %s %s\r\n"
+"\r\nOnce you have connected a client, the server will send each line of text\r\n"
+"it receives to all connected clients. The server reports client joins and\r\n"
+"departures on stdout.\r\n"
+"\r\nNote that to terminate the telnet client you type Control-], then\r\n"
+"<Enter>, then \"close\" (and <Enter>) at the \"telnet> \" prompt.\r\n"
+"\r\nHave fun!\r\n"
+"-Carl\r\n"
+"\r\nPS. At this point we're ready to leave the demonstration phase and to\r\n"
+"begin implementing TTTP (tic-tac-toe protocol) as well as fixing the\r\n"
+"protocol specifcation. We don't need a custom client to move forward on\r\n"
+"the server (that is one of the ideas behind using a telnet-compatible\r\n"
+"protocol), but a custom client would still be a fine project for a\r\n"
+"motivated beginning programmer.\r\n\r\n";
 
 static void
 _ttt_server_accept (void *closure, int client_socket)
 
 static void
 _ttt_server_accept (void *closure, int client_socket)