ascii-chat 0.11.33
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 26 of file strings/main.c.

◆ SESSION_STRING_BUFFER_SIZE

#define SESSION_STRING_BUFFER_SIZE   40

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

Function Documentation

◆ main()

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

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

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

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