ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
actions.c File Reference

Action option callbacks for ascii-chat. More...

Go to the source code of this file.

Functions

void action_list_webcams (void)
 List available webcam devices and exit.
 
void action_list_microphones (void)
 List available microphone devices and exit.
 
void action_list_speakers (void)
 List available speaker devices and exit.
 
void action_show_capabilities (void)
 Show terminal capabilities and exit.
 
void action_show_version (void)
 Show version information and exit.
 
void action_help_server (void)
 Show server mode help and exit.
 
void action_help_client (void)
 Show client mode help and exit.
 
void action_help_mirror (void)
 Show mirror mode help and exit.
 

Detailed Description

Action option callbacks for ascii-chat.

Action options execute immediately during parsing and may exit the program. Examples: –list-webcams, –version, –show-capabilities

Definition in file actions.c.

Function Documentation

◆ action_help_client()

void action_help_client ( void  )

Show client mode help and exit.

Displays client mode usage and options. Exits with code 0.

Definition at line 198 of file actions.c.

198 {
199 usage_client(stdout);
200 (void)fflush(stdout);
201 _exit(0);
202}
void usage_client(FILE *desc)
Print client mode usage/help text.

References usage_client().

Referenced by options_preset_client().

◆ action_help_mirror()

void action_help_mirror ( void  )

Show mirror mode help and exit.

Displays mirror mode usage and options. Exits with code 0.

Definition at line 204 of file actions.c.

204 {
205 usage_mirror(stdout);
206 (void)fflush(stdout);
207 _exit(0);
208}
void usage_mirror(FILE *desc)
Print mirror mode usage/help text.
Definition mirror.c:71

References usage_mirror().

Referenced by options_preset_mirror().

◆ action_help_server()

void action_help_server ( void  )

Show server mode help and exit.

Displays server mode usage and options. Exits with code 0.

Definition at line 192 of file actions.c.

192 {
193 usage_server(stdout);
194 (void)fflush(stdout);
195 _exit(0);
196}
void usage_server(FILE *desc)
Print server usage information.

References usage_server().

Referenced by options_preset_server().

◆ action_list_microphones()

void action_list_microphones ( void  )

List available microphone devices and exit.

Enumerates all audio input devices and prints them to stdout. Exits with code 0 on success, 1 on error.

Definition at line 58 of file actions.c.

58 {
59 audio_device_info_t *devices = NULL;
60 unsigned int device_count = 0;
61
62 asciichat_error_t result = audio_list_input_devices(&devices, &device_count);
63 if (result != ASCIICHAT_OK) {
64 (void)fprintf(stderr, "Error: Failed to enumerate audio input devices\n");
65 _exit(1);
66 }
67
68 if (device_count == 0) {
69 (void)fprintf(stdout, "No microphone devices found.\n");
70 } else {
71 (void)fprintf(stdout, "Available microphone devices:\n");
72 for (unsigned int i = 0; i < device_count; i++) {
73 (void)fprintf(stdout, " %d: %s", devices[i].index, devices[i].name);
74 if (devices[i].is_default_input) {
75 (void)fprintf(stdout, " (default)");
76 }
77 (void)fprintf(stdout, "\n");
78 }
79 }
80
82 (void)fflush(stdout);
83 _exit(0);
84}
void audio_free_device_list(audio_device_info_t *devices)
Free device list allocated by audio_list_input_devices/audio_list_output_devices.
asciichat_error_t audio_list_input_devices(audio_device_info_t **out_devices, unsigned int *out_count)
List available audio input devices (microphones)
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:46
@ ASCIICHAT_OK
Definition error_codes.h:48
Audio device information structure.

References ASCIICHAT_OK, audio_free_device_list(), and audio_list_input_devices().

Referenced by options_preset_client(), and options_preset_server().

◆ action_list_speakers()

void action_list_speakers ( void  )

List available speaker devices and exit.

Enumerates all audio output devices and prints them to stdout. Exits with code 0 on success, 1 on error.

Definition at line 86 of file actions.c.

86 {
87 audio_device_info_t *devices = NULL;
88 unsigned int device_count = 0;
89
90 asciichat_error_t result = audio_list_output_devices(&devices, &device_count);
91 if (result != ASCIICHAT_OK) {
92 (void)fprintf(stderr, "Error: Failed to enumerate audio output devices\n");
93 _exit(1);
94 }
95
96 if (device_count == 0) {
97 (void)fprintf(stdout, "No speaker devices found.\n");
98 } else {
99 (void)fprintf(stdout, "Available speaker devices:\n");
100 for (unsigned int i = 0; i < device_count; i++) {
101 (void)fprintf(stdout, " %d: %s", devices[i].index, devices[i].name);
102 if (devices[i].is_default_output) {
103 (void)fprintf(stdout, " (default)");
104 }
105 (void)fprintf(stdout, "\n");
106 }
107 }
108
109 audio_free_device_list(devices);
110 (void)fflush(stdout);
111 _exit(0);
112}
asciichat_error_t audio_list_output_devices(audio_device_info_t **out_devices, unsigned int *out_count)
List available audio output devices (speakers)

References ASCIICHAT_OK, audio_free_device_list(), and audio_list_output_devices().

Referenced by options_preset_client(), and options_preset_server().

◆ action_list_webcams()

void action_list_webcams ( void  )

List available webcam devices and exit.

Enumerates all webcam devices and prints them to stdout. Exits with code 0 on success, 1 on error.

Definition at line 30 of file actions.c.

30 {
31 webcam_device_info_t *devices = NULL;
32 unsigned int device_count = 0;
33
34 asciichat_error_t result = webcam_list_devices(&devices, &device_count);
35 if (result != ASCIICHAT_OK) {
36 (void)fprintf(stderr, "Error: Failed to enumerate webcam devices\n");
37 _exit(1);
38 }
39
40 if (device_count == 0) {
41 (void)fprintf(stdout, "No webcam devices found.\n");
42 } else {
43 (void)fprintf(stdout, "Available webcam devices:\n");
44 for (unsigned int i = 0; i < device_count; i++) {
45 (void)fprintf(stdout, " %u: %s\n", devices[i].index, devices[i].name);
46 }
47 }
48
50 (void)fflush(stdout);
51 _exit(0);
52}
asciichat_error_t webcam_list_devices(webcam_device_info_t **out_devices, unsigned int *out_count)
Enumerate available webcam devices.
Definition webcam.c:336
void webcam_free_device_list(webcam_device_info_t *devices)
Free device list returned by webcam_list_devices()
Definition webcam.c:344
Webcam device information structure.
Definition webcam.h:89

References ASCIICHAT_OK, webcam_free_device_list(), and webcam_list_devices().

Referenced by options_preset_client(), options_preset_mirror(), and options_preset_server().

◆ action_show_capabilities()

void action_show_capabilities ( void  )

Show terminal capabilities and exit.

Detects and displays terminal color support, UTF-8 support, dimensions, and terminal program name. Exits with code 0.

Definition at line 118 of file actions.c.

118 {
120
121 (void)fprintf(stdout, "Terminal Capabilities:\n");
122 (void)fprintf(stdout, " Color Support: ");
123 switch (caps.color_level) {
124 case TERM_COLOR_NONE:
125 (void)fprintf(stdout, "None (monochrome)\n");
126 break;
127 case TERM_COLOR_16:
128 (void)fprintf(stdout, "16 colors (ANSI)\n");
129 break;
130 case TERM_COLOR_256:
131 (void)fprintf(stdout, "256 colors\n");
132 break;
134 (void)fprintf(stdout, "Truecolor (16.7M colors)\n");
135 break;
136 default:
137 (void)fprintf(stdout, "Unknown\n");
138 break;
139 }
140
141 (void)fprintf(stdout, " UTF-8 Support: %s\n", caps.utf8_support ? "Yes" : "No");
142 (void)fprintf(stdout, " Terminal Type: %s\n", caps.term_type[0] ? caps.term_type : "Unknown");
143 (void)fprintf(stdout, " Color Term: %s\n", caps.colorterm[0] ? caps.colorterm : "Not set");
144
145 (void)fflush(stdout);
146 _exit(0);
147}
terminal_capabilities_t detect_terminal_capabilities(void)
Detect terminal capabilities.
@ TERM_COLOR_NONE
No color support (monochrome terminal)
Definition terminal.h:428
@ TERM_COLOR_16
16-color support (standard ANSI colors)
Definition terminal.h:430
@ TERM_COLOR_256
256-color support (extended ANSI palette)
Definition terminal.h:432
@ TERM_COLOR_TRUECOLOR
24-bit truecolor support (RGB colors)
Definition terminal.h:434
Complete terminal capabilities structure.
Definition terminal.h:485
terminal_color_mode_t color_level
Detected color support level (terminal_color_mode_t)
Definition terminal.h:487
bool utf8_support
True if terminal supports UTF-8 encoding.
Definition terminal.h:493
char term_type[64]
$TERM environment variable value (for debugging)
Definition terminal.h:499
char colorterm[64]
$COLORTERM environment variable value (for debugging)
Definition terminal.h:501

References terminal_capabilities_t::color_level, terminal_capabilities_t::colorterm, detect_terminal_capabilities(), TERM_COLOR_16, TERM_COLOR_256, TERM_COLOR_NONE, TERM_COLOR_TRUECOLOR, terminal_capabilities_t::term_type, and terminal_capabilities_t::utf8_support.

Referenced by options_preset_client(), and options_preset_mirror().

◆ action_show_version()

void action_show_version ( void  )

Show version information and exit.

Displays ascii-chat version, build type, build date, and compiler information. Exits with code 0.

Definition at line 153 of file actions.c.

153 {
154 (void)fprintf(stdout, "ascii-chat %s (%s, %s)\n", ASCII_CHAT_VERSION_FULL, ASCII_CHAT_BUILD_TYPE,
155 ASCII_CHAT_BUILD_DATE);
156 (void)fprintf(stdout, "\n");
157 (void)fprintf(stdout, "Built with:\n");
158
159#ifdef __clang__
160 (void)fprintf(stdout, " Compiler: Clang %s\n", __clang_version__);
161#elif defined(__GNUC__)
162 (void)fprintf(stdout, " Compiler: GCC %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
163#elif defined(_MSC_VER)
164 (void)fprintf(stdout, " Compiler: MSVC %d\n", _MSC_VER);
165#else
166 (void)fprintf(stdout, " Compiler: Unknown\n");
167#endif
168
169#ifdef USE_MUSL
170 (void)fprintf(stdout, " C Library: musl\n");
171#elif defined(__GLIBC__)
172 (void)fprintf(stdout, " C Library: glibc %d.%d\n", __GLIBC__, __GLIBC_MINOR__);
173#elif defined(_WIN32)
174 (void)fprintf(stdout, " C Library: MSVCRT\n");
175#elif defined(__APPLE__)
176 (void)fprintf(stdout, " C Library: libSystem\n");
177#else
178 (void)fprintf(stdout, " C Library: Unknown\n");
179#endif
180
181 (void)fprintf(stdout, "\n");
182 (void)fprintf(stdout, "For more information: https://github.com/zfogg/ascii-chat\n");
183
184 (void)fflush(stdout);
185 _exit(0);
186}

Referenced by options_preset_acds(), and options_preset_server().