+ assert (num_args == 1);
+
+ ttt_client_set_name (client, args[0]);
+
+ error = ttt_server_register_client (client->server, client);
+ if (error)
+ return error;
+
+ client->registered = TRUE;
+
+ xasprintf (&response, "HELO %s %s %s\n",
+ 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);
+ ttt_server_broadcast(client->server,response);
+
+ free (response);
+
+ return TTT_ERROR_NONE;
+}
+
+static ttt_error_t
+_ttt_client_execute_who (ttt_client_t *client,
+ char **args,
+ int num_args)
+{
+ char *response;
+
+ assert (num_args == 0);
+
+ response = ttt_server_who (client->server);
+
+ ttt_client_send (client, response);
+
+ free (response);
+
+ return TTT_ERROR_NONE;
+}
+
+static ttt_error_t
+_ttt_client_execute_quit (ttt_client_t *client,
+ char **args,
+ int num_args)
+{
+ char *notice;
+
+ assert (num_args == 0);
+ xasprintf (¬ice,"NOTICE QUIT %s\n",client->name);
+ ttt_server_broadcast(client->server,notice);
+ free (notice);
+ return TTT_ERROR_QUIT_REQUESTED;
+}
+
+static ttt_error_t
+_ttt_client_execute_message (ttt_client_t *client,
+ char **args,
+ int num_args)
+{
+ char *response;
+ int i;
+
+ assert (num_args > 0);
+
+ xasprintf(&response, "MESSAGE\n");
+ ttt_client_send (client, response);
+
+ xasprintf(&response, "NOTICE MESSAGE %s", client->name);
+ for (i=0; i<num_args; i++){
+ xasprintf(&response, "%s %s",response,args[i]);
+
+ }
+ xasprintf(&response, "%s\n",response);
+ ttt_server_broadcast (client->server,response);
+
+ free (response);
+ return TTT_ERROR_NONE;
+
+
+}
+
+static void
+_free_request (ttt_client_t *client);
+
+static void
+_ttt_client_init (ttt_client_t *client,
+ ttt_server_t *server,
+ int socket)
+{
+ FILE *file;
+
+ pthread_mutex_init (&client->mutex, NULL);