ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
/home/runner/work/ascii-chat/ascii-chat/include/ascii-chat/discovery/nouns.h

Generate a unique client ID (noun only, no counter or port).

Generate a unique client ID (noun only, no counter or port) Returns just the noun part without counters or transport information. Used for internal client identification in thread names, owned buffers, event logs, etc.

Parameters
bufferOutput buffer for the generated ID
buffer_sizeSize of the output buffer (minimum recommended: 32 bytes)
Returns
0 on success, -1 on error (invalid args or buffer too small)
Note
Does not guarantee uniqueness. For user-facing names, use generate_client_name() instead.
char id[32];
if (generate_client_id(id, sizeof(id)) == 0) {
printf("Client ID: %s\n", id); // Output: "Client ID: mountain"
}
int generate_client_id(char *buffer, size_t buffer_size)
Generate a unique client ID (noun only, no counter or port).
Definition nouns.c:482
See also
generate_client_name() for client display names with uniqueness guarantees
#ifndef ASCII_CHAT_DISCOVERY_NOUNS_H
#define ASCII_CHAT_DISCOVERY_NOUNS_H
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
extern const char *nouns[];
extern const size_t nouns_count;
int generate_client_id(char *buffer, size_t buffer_size);
int generate_client_name(char *buffer, size_t buffer_size, void *existing_clients_hash, int port, bool is_tcp);
#endif // ASCII_CHAT_DISCOVERY_NOUNS_H
#ifdef __cplusplus
}
#endif
int buffer_size
Size of circular buffer.
Definition grep.c:68
const char * nouns[]
Array of English nouns for session and client naming.
Definition nouns.c:55
const size_t nouns_count
Count of nouns in the nouns array.
Definition nouns.c:474
int generate_client_name(char *buffer, size_t buffer_size, void *existing_clients_hash, int port, bool is_tcp)
Generate a unique client name from the nouns wordlist.
Definition nouns.c:511