15static const char *adjectives[] = {
16 "swift",
"quiet",
"bright",
"gentle",
"bold",
"calm",
"dark",
"free",
"golden",
"happy",
17 "icy",
"jolly",
"kind",
"lively",
"noble",
"proud",
"rapid",
"silver",
"tall",
"warm",
18 "wild",
"wise",
"young",
"brave",
"clever",
"eager",
"fair",
"great",
"huge",
"just",
19 "keen",
"lucky",
"mild",
"neat",
"open",
"pure",
"quick",
"red",
"safe",
"true",
20 "vast",
"white",
"yellow",
"zealous",
"amber",
"blue",
"cool",
"deep",
"easy",
"fast",
21 "good",
"high",
"jade",
"long",
"new",
"old",
"pink",
"rich",
"slow",
"thin",
22 "vivid",
"wide",
"zenithed",
"assured",
"clear",
"divine",
"ethereal",
"firm",
"grand",
"honest",
23 "iron",
"jade",
"keen",
"loyal",
"mellow",
"noble",
"open",
"prime",
"quiet",
"radiant",
24 "serene",
"tranquil",
"unique",
"vibrant",
"warm",
"xenial",
"youthful",
"zestful",
"agile",
"brilliant",
25 "crisp",
"deft",
"elegant",
"fluid",
"graceful",
"humble",
"intense",
"jovial",
"kinetic",
"lucid",
26 "mystic",
"nimble",
"ornate",
"placid"};
28static const char *nouns[] = {
29 "river",
"mountain",
"forest",
"ocean",
"valley",
"peak",
"lake",
"hill",
"meadow",
30 "canyon",
"delta",
"ridge",
"cliff",
"shore",
"stream",
"bay",
"cove",
"dune",
31 "field",
"grove",
"isle",
"marsh",
"plain",
"reef",
"stone",
"trail",
"vista",
32 "wave",
"aurora",
"beacon",
"cloud",
"dawn",
"ember",
"flame",
"glow",
"horizon",
33 "island",
"jungle",
"moon",
"nebula",
"oasis",
"planet",
"quasar",
"star",
"thunder",
34 "universe",
"volcano",
"wind",
"crystal",
"diamond",
"echo",
"frost",
"glacier",
"harbor",
35 "iceberg",
"jade",
"keystone",
"lagoon",
"mesa",
"nexus",
"orbit",
"prism",
"quartz",
36 "reef",
"summit",
"temple",
"umbra",
"vertex",
"waterfall",
"xenolith",
"zenith",
"abyss",
37 "bridge",
"castle",
"dome",
"echo",
"fountain",
"garden",
"haven",
"inlet",
"mesa",
38 "obelisk",
"portal",
"quarry",
"rapids",
"sanctuary",
"tower",
"vault",
"whirlpool",
"asylum",
39 "bastion",
"citadel",
"fortress",
"sanctuary",
"stronghold",
"threshold"};
41static const size_t adjectives_count =
sizeof(adjectives) /
sizeof(adjectives[0]);
42static const size_t nouns_count =
sizeof(nouns) /
sizeof(nouns[0]);
47 if (sodium_init() < 0) {
51 log_debug(
"Session string generator initialized (%zu adjectives, %zu nouns)", adjectives_count, nouns_count);
56 if (!output || output_size < 48) {
62 const char *adj = adjectives[adj_idx];
67 const char *noun1 = nouns[noun1_idx];
68 const char *noun2 = nouns[noun2_idx];
71 int written = snprintf(output, output_size,
"%s-%s-%s", adj, noun1, noun2);
72 if (written < 0 || (
size_t)written >= output_size) {
76 log_debug(
"Generated session string: %s", output);
85 size_t len = strlen(str);
86 if (len == 0 || len > 47) {
91 if (str[0] ==
'-' || str[len - 1] ==
'-') {
97 for (
size_t i = 0; i < len; i++) {
102 if (i > 0 && str[i - 1] ==
'-') {
105 }
else if (!islower(c)) {
112 return hyphen_count == 2;
#define SET_ERRNO(code, context_msg,...)
Set error code with custom context message and log it.
asciichat_error_t
Error and exit codes - unified status values (0-255)
#define log_debug(...)
Log a DEBUG message.
📝 Logging API with multiple log levels and terminal output control
asciichat_error_t acds_string_init(void)
Initialize random number generator for string generation.
bool acds_string_validate(const char *str)
Validate session string format.
asciichat_error_t acds_string_generate(char *output, size_t output_size)
Generate random session string.
Session string generation for discovery service.