+ name = xstrdup (ttt_client_get_name (client));
+
+ if (name == NULL) {
+ xasprintf(&name, "user%03d", server->next_client_id++);
+ ttt_client_set_name (client, name);
+ }
+
+ /* 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;
+ goto CLEANUP_LOCK;
+ }
+ }