* PROTOCOL:
* src/ttt-server.c: (ttt_server_init),
(ttt_server_register_client): Remove unique-name generation from
the server. The client is going to have to have code to do this
anyway.
* src/ttt-client.c: Change minimum arguments for HELO from 0 to 1.
* TODO: Note that HELO and ERROR INVALIDNAME are implemented in
the server.
+2005-11-24 Carl Worth <cworth@cworth.org>
+
+ * PROTOCOL:
+ * src/ttt-server.c: (ttt_server_init),
+ (ttt_server_register_client): Remove unique-name generation from
+ the server. The client is going to have to have code to do this
+ anyway.
+
+ * src/ttt-client.c: Change minimum arguments for HELO from 0 to 1.
+
+ * TODO: Note that HELO and ERROR INVALIDNAME are implemented in
+ the server.
+
2005-11-23 Richard Worth <richard@theworths.org>
* PROTOCOL: Removed unused servername
2005-11-23 Richard Worth <richard@theworths.org>
* PROTOCOL: Removed unused servername
use must be done through some external mechanism. Once connected,
the client must identify itself:
use must be done through some external mechanism. Once connected,
the client must identify itself:
->
HELO <username> <server-addr> <server-port>
->
HELO <username> <server-addr> <server-port>
- If the client doesn't supply <username>, the server will compute
- one and return it.
-
Possible errors: INVALIDNAME
1.2. Global commands
Possible errors: INVALIDNAME
1.2. Global commands
- All names must be unique.
+ All names must be of non-zero length and must be unique.
Possibly returned by: HELO
Possibly returned by: HELO
/ /---- Client, implemented in ttt
S C
1. Requests
/ /---- Client, implemented in ttt
S C
1. Requests
1.2. Global commands
1.2.1. WHO
1.2.2. MESSAGE
1.2. Global commands
1.2.1. WHO
1.2.2. MESSAGE
3. Errors
3.1. Connection setup errors
3.1.1. ERROR NONAMESET
3. Errors
3.1. Connection setup errors
3.1.1. ERROR NONAMESET
- 3.1.2. ERROR INVALIDNAME
+✓ 3.1.2. ERROR INVALIDNAME
3.2. Command format errors
3.2.1. ERROR COMMAND
3.2.2. ERROR SYNTAX
3.2. Command format errors
3.2.1. ERROR COMMAND
3.2.2. ERROR SYNTAX
-#include "ttt-command.h"
#include "ttt-error.h"
#include "ttt-lex.h"
#include "ttt-server.h"
#include "ttt-error.h"
#include "ttt-lex.h"
#include "ttt-server.h"
} ttt_command_description_t;
ttt_command_description_t command_descriptions[] = {
} ttt_command_description_t;
ttt_command_description_t command_descriptions[] = {
- {"HELO", 0, 1, _ttt_client_execute_helo}
+ {"HELO", 1, 1, _ttt_client_execute_helo}
const char *host;
const char *port;
const char *host;
const char *port;
ttt_client_t **clients;
int clients_size;
int num_clients;
ttt_client_t **clients;
int clients_size;
int num_clients;
server->host = host;
server->port = port;
server->host = host;
server->port = port;
- server->next_client_id = 0;
-
server->clients = NULL;
server->clients_size = 0;
server->num_clients = 0;
server->clients = NULL;
server->clients_size = 0;
server->num_clients = 0;
{
int i;
ttt_error_t error = TTT_ERROR_NONE;
{
int i;
ttt_error_t error = TTT_ERROR_NONE;
pthread_mutex_lock (&server->mutex);
pthread_mutex_lock (&server->mutex);
- name = xstrdup (ttt_client_get_name (client));
+ name = ttt_client_get_name (client);
- if (name == NULL) {
- xasprintf(&name, "user%03d", server->next_client_id++);
- ttt_client_set_name (client, name);
- }
+ assert (name != NULL);
+
+ if (name[0] == '\0')
+ return TTT_ERROR_INVALIDNAME;
- /* XXX: If generated name is not unique, this will return an error,
- which violates the protocol. */
for (i = 0; i < server->num_clients; i++) {
if (strcmp (ttt_client_get_name (server->clients[i]), name) == 0) {
error = TTT_ERROR_INVALIDNAME;
for (i = 0; i < server->num_clients; i++) {
if (strcmp (ttt_client_get_name (server->clients[i]), name) == 0) {
error = TTT_ERROR_INVALIDNAME;
}
printf ("Client %s has joined.\n", name);
}
printf ("Client %s has joined.\n", name);