ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
main.c File Reference

TODO: Add Doxygen documentation for session string generation utility. More...

Go to the source code of this file.

Macros

#define SESSION_STRING_BUFFER_SIZE   40
#define ACDS_MAX_UNIQUE_SESSIONS   (2500LL * 5000LL * 5000LL)

Functions

int main (int argc, char *argv[])

Detailed Description

TODO: Add Doxygen documentation for session string generation utility.

Command-line tool for generating memorable session identifiers (adjective-noun-noun). Also exports wordlists as JavaScript for web client compatibility.

Needs documentation for:

  • CLI interface and options
  • Session string format and constraints
  • Wordlist export functionality
  • Integration with ACDS

Definition in file strings/main.c.

Macro Definition Documentation

◆ ACDS_MAX_UNIQUE_SESSIONS

#define ACDS_MAX_UNIQUE_SESSIONS   (2500LL * 5000LL * 5000LL)

Definition at line 31 of file strings/main.c.

Referenced by main().

◆ SESSION_STRING_BUFFER_SIZE

#define SESSION_STRING_BUFFER_SIZE   40

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 33 of file strings/main.c.

33 {
34 long long count = 1;
35 int dump_adjectives = 0;
36 int dump_nouns = 0;
37
38 static struct option long_options[] = {
39 {"count", required_argument, 0, 'n'},
40 {"dump-adjectives", no_argument, 0, 'a'},
41 {"dump-nouns", no_argument, 0, 'o'},
42 {"help", no_argument, 0, 'h'},
43 {0, 0, 0, 0}};
44
45 int opt;
46 while ((opt = getopt_long(argc, argv, "n:aoh", long_options, NULL)) != -1) {
47 switch (opt) {
48 case 'n':
49 count = strtoll(optarg, NULL, 10);
50 break;
51 case 'a':
52 dump_adjectives = 1;
53 break;
54 case 'o':
55 dump_nouns = 1;
56 break;
57 case 'h':
58 printf("Usage: ascii-chat-strings [OPTIONS]\n");
59 printf(
60 "Generate memorable session strings (adjective-noun-noun format)\n");
61 printf("\nOptions:\n");
62 printf(" -n, --count COUNT Generate COUNT session strings "
63 "(default: 1)\n");
64 printf(" -a, --dump-adjectives Dump adjectives list as JavaScript\n");
65 printf(" -o, --dump-nouns Dump nouns list as JavaScript\n");
66 printf(" -h, --help Show this help message\n");
67 return 0;
68 default:
69 return ERROR_USAGE;
70 }
71 }
72
73 // Handle dump modes
74 if (dump_adjectives) {
75 printf("export const adjectives = [\n");
76 for (size_t i = 0; i < adjectives_count; i++) {
77 printf(" \"%s\"%s\n", adjectives[i],
78 (i < adjectives_count - 1) ? "," : "");
79 }
80 printf("];\n");
81 printf("export const adjectives_count = %zu;\n", adjectives_count);
82 return 0;
83 }
84
85 if (dump_nouns) {
86 printf("export const nouns = [\n");
87 for (size_t i = 0; i < nouns_count; i++) {
88 printf(" \"%s\"%s\n", nouns[i], (i < nouns_count - 1) ? "," : "");
89 }
90 printf("];\n");
91 printf("export const nouns_count = %zu;\n", nouns_count);
92 return 0;
93 }
94
95 // Normal session string generation
96 if (count <= 0 || (long long)count > ACDS_MAX_UNIQUE_SESSIONS) {
97 return ERROR_USAGE;
98 }
99
100 // Generate session strings
101 for (long long i = 0; i < count; i++) {
102 uint32_t adj_idx = randombytes_uniform((uint32_t)adjectives_count);
103 uint32_t noun1_idx = randombytes_uniform((uint32_t)nouns_count);
104 uint32_t noun2_idx = randombytes_uniform((uint32_t)nouns_count);
105
106 printf("%s-%s-%s\n", adjectives[adj_idx], nouns[noun1_idx],
107 nouns[noun2_idx]);
108 }
109
110 return 0;
111}
const char * adjectives[]
Array of English adjectives for ACDS session naming.
Definition adjectives.c:55
const size_t adjectives_count
Count of adjectives in the adjectives array.
Definition adjectives.c:682
unsigned int uint32_t
@ ERROR_USAGE
Definition error_codes.h:52
const char * nouns[]
Array of English nouns for session and client naming.
Definition nouns.c:58
const size_t nouns_count
Count of nouns in the nouns array.
Definition nouns.c:1310
#define ACDS_MAX_UNIQUE_SESSIONS

References ACDS_MAX_UNIQUE_SESSIONS, adjectives, adjectives_count, ERROR_USAGE, nouns, and nouns_count.