commit ba644a9
uint
·
2026-01-28 21:01:13 +0000 UTC
parent d52be4b
add -v flag, fail on other flags
1 files changed,
+31,
-8
+31,
-8
1@@ -1,8 +1,11 @@
2-/* parados
3- the simple home media server
4+/* parados
5+ the simple home media server
6
7- this software is licensed under ISC
8- check LICENCE for more details
9+ See parados(1), parados(7), parados.conf(5)
10+ for usage information
11+
12+ This software is licensed under ISC.
13+ Check LICENCE for more details.
14 */
15
16 #include <errno.h>
17@@ -47,7 +50,7 @@ void run(void)
18 continue;
19 continue;
20 }
21- LOG(verbose_log, "CORE", "Connection accepted");
22+ LOG(verbose_log, "CORE", "Connection Accepted");
23
24 pid_t pid = fork();
25 if (pid < 0) {
26@@ -98,17 +101,37 @@ void setup(void)
27
28 if (scan_library(&lib, media_dir) < 0)
29 die("scan_library", EXIT_FAILURE);
30- LOG(verbose_log, "SCAN", "Cached %zu items", lib.len);
31+ LOG(verbose_log, "SCAN", "Cached items %zu", lib.len);
32
33 ret = listen(sock, LISTEN_BACKLOG);
34 if (ret < 0)
35 die("listen", EXIT_FAILURE);
36
37- LOG(verbose_log, "CORE", "Listening on %s:%d", server_addr, server_port);
38+ LOG(verbose_log, "CORE", "Listening on %s:%d", server_addr, server_port);
39 }
40
41-int main(void)
42+int main(int argc, char* argv[])
43 {
44+ if (argc > 1) {
45+ if (strcmp(argv[1], "-v") == 0) {
46+ printf(
47+ "parados v"VERSION"\n"
48+ "\n"
49+ "This software is licensed under ISC.\n"
50+ "See LICENSE for license information.\n"
51+ "\n"
52+ "See parados(1), parados(7), parados.conf(5)\n"
53+ "for usage information\n"
54+ );
55+ return EXIT_SUCCESS;
56+ }
57+ else {
58+ printf("Invalid command\n");
59+ printf("See parados(1) for more information\n");
60+ return EXIT_FAILURE;
61+ }
62+ }
63+
64 setup();
65 #ifdef __OpenBSD__
66 if (pledge("stdio inet", NULL) < 0)