Fix client arg parse
All checks were successful
Create releases with ArchLinux pkg / check-and-build-and-release (push) Successful in 12s

This commit is contained in:
Stephen Seo 2024-07-21 12:45:08 +09:00
parent 257ba1db6c
commit ea6f59fbc5

View file

@ -37,50 +37,56 @@ void cleanup_data_socket(int *data_socket) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
UnixSocketEventType type = UNIX_SOCKET_EVENT_NOP; UnixSocketEventType type = UNIX_SOCKET_EVENT_NOP;
if (argc == 2) { const char *program_name = argv[0];
if (strncmp(argv[1], "--start-recording", 17) == 0) { ++argv;
--argc;
if (argc == 0) {
print_usage(program_name);
return 1;
}
while (argc != 0) {
if (strncmp(argv[0], "--start-recording", 17) == 0) {
type = UNIX_SOCKET_EVENT_START_RECORDING | type = UNIX_SOCKET_EVENT_START_RECORDING |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--stop-recording", 16) == 0) { } else if (strncmp(argv[0], "--stop-recording", 16) == 0) {
type = UNIX_SOCKET_EVENT_STOP_RECORDING | type = UNIX_SOCKET_EVENT_STOP_RECORDING |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--start-streaming", 17) == 0) { } else if (strncmp(argv[0], "--start-streaming", 17) == 0) {
type = UNIX_SOCKET_EVENT_START_STREAMING | type = UNIX_SOCKET_EVENT_START_STREAMING |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--toggle-recording", 18) == 0) { } else if (strncmp(argv[0], "--toggle-recording", 18) == 0) {
type = UNIX_SOCKET_EVENT_TOGGLE_RECORDING | type = UNIX_SOCKET_EVENT_TOGGLE_RECORDING |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--stop-streaming", 16) == 0) { } else if (strncmp(argv[0], "--stop-streaming", 16) == 0) {
type = UNIX_SOCKET_EVENT_STOP_STREAMING | type = UNIX_SOCKET_EVENT_STOP_STREAMING |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--toggle-streaming", 18) == 0) { } else if (strncmp(argv[0], "--toggle-streaming", 18) == 0) {
type = UNIX_SOCKET_EVENT_TOGGLE_STREAMING | type = UNIX_SOCKET_EVENT_TOGGLE_STREAMING |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--start-replay-buffer", 21) == 0) { } else if (strncmp(argv[0], "--start-replay-buffer", 21) == 0) {
type = UNIX_SOCKET_EVENT_START_REPLAY_BUFFER | type = UNIX_SOCKET_EVENT_START_REPLAY_BUFFER |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--stop-replay-buffer", 20) == 0) { } else if (strncmp(argv[0], "--stop-replay-buffer", 20) == 0) {
type = UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER | type = UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--toggle-replay-buffer", 22) == 0) { } else if (strncmp(argv[0], "--toggle-replay-buffer", 22) == 0) {
type = UNIX_SOCKET_EVENT_TOGGLE_REPLAY_BUFFER | type = UNIX_SOCKET_EVENT_TOGGLE_REPLAY_BUFFER |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--save-replay-buffer", 20) == 0) { } else if (strncmp(argv[0], "--save-replay-buffer", 20) == 0) {
type = UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER | type = UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--get-status", 12) == 0) { } else if (strncmp(argv[0], "--get-status", 12) == 0) {
type = UNIX_SOCKET_EVENT_GET_STATUS | type = UNIX_SOCKET_EVENT_GET_STATUS |
(UNIX_SOCKET_EVENT_WAIT & type); (UNIX_SOCKET_EVENT_WAIT & type);
} else if (strncmp(argv[1], "--wait", 6) == 0) { } else if (strncmp(argv[0], "--wait", 6) == 0) {
type |= UNIX_SOCKET_EVENT_WAIT; type |= UNIX_SOCKET_EVENT_WAIT;
} else { } else {
puts("ERROR: Invalid arg!"); puts("ERROR: Invalid arg!");
print_usage(argv[0]); print_usage(program_name);
return 2; return 2;
} }
} else { ++argv;
print_usage(argv[0]); --argc;
return 1;
} }
char socket_filename[108]; char socket_filename[108];