commit 1e6b0af
uint
·
2026-10-26 17:36:19 +0000 UTC
parent 0f2edc2
replace Doxygen style comments
14 files changed,
+137,
-544
+8,
-30
1@@ -23,13 +23,8 @@ int http_io_timeout = 5;
2 int max_clients = 64;
3 int auth_delay = 250;
4
5-/**
6- * @brief Load configuration from a file path
7- *
8- * @param path Path to config file
9- *
10- * @return 0=Success, -1=Failure
11- */
12+/* Load configuration from a file path
13+ Returns 0=Success, -1=Failure */
14 static int load_path(const char* path)
15 {
16 FILE* f = fopen(path, "r");
17@@ -69,14 +64,8 @@ static int load_path(const char* path)
18 return 0;
19 }
20
21-/**
22- * @brief Parse bool string value
23- *
24- * @param s Input string
25- * @param out Output bool
26- *
27- * @return 0=Success, -1=Failure
28- */
29+/* Parse bool string value
30+ Returns 0=Success, -1=Failure */
31 static int parse_bool(const char* s, bool* out)
32 {
33 if (!s || !out)
34@@ -92,14 +81,8 @@ static int parse_bool(const char* s, bool* out)
35 return 0;
36 }
37
38-/**
39- * @brief Apply a config key/value pair
40- *
41- * @param k Config key
42- * @param v Config value
43- *
44- * @return 0=Success, -1=Failure
45- */
46+/* Apply a config key/value pair
47+ Returns 0=Success, -1=Failure */
48 static int set_kv(const char* k, const char* v)
49 {
50 /* regular */
51@@ -224,13 +207,8 @@ static int set_kv(const char* k, const char* v)
52 return 0;
53 }
54
55-/**
56- * @brief Trim leading and trailing whitespace
57- *
58- * @param s Input string
59- *
60- * @return Ptr to trimmed string
61- */
62+/* Trim leading and trailing whitespace
63+ Returns Ptr to trimmed string */
64 static char* trim(char* s)
65 {
66 while (*s && (*s == ' ' || *s == '\t' || *s == '\r' || *s == '\n'))
+33,
-153
1@@ -53,11 +53,8 @@ static int stream_file(int c, const struct item* it, const char* hdr, int head_o
2 extern struct library lib;
3 extern pthread_mutex_t lib_lock;
4
5-/**
6- * @brief Sleep for configured auth delay
7- *
8- * @note Retries on EINTR.
9- */
10+/* Sleep for configured auth delay
11+ Retries on EINTR. */
12 static void auth_delay_sleep(void)
13 {
14 if (auth_delay <= 0)
15@@ -77,13 +74,8 @@ static void auth_delay_sleep(void)
16 }
17 }
18
19-/**
20- * @brief Check whether origin is allowed by CORS config
21- *
22- * @param origin Request Origin header value
23- *
24- * @return 1=Allowed, 0=Not allowed
25- */
26+/* Check whether origin is allowed by CORS config
27+ Returns 1=Allowed, 0=Not allowed */
28 static int cors_origin_allowed(const char* origin)
29 {
30 if (cors_origin[0] == '\0')
31@@ -117,16 +109,8 @@ static int cors_origin_allowed(const char* origin)
32 return 0;
33 }
34
35-/**
36- * @brief Build CORS response headers
37- *
38- * @param out Output buffer
39- * @param outsz Output buffer size
40- * @param hdr Request header block
41- * @param preflight Whether this is a preflight response
42- *
43- * @return 1=Built, 0=Not emitted
44- */
45+/* Build CORS response headers
46+ Returns 1=Built, 0=Not emitted */
47 static int cors_build(char* out, size_t outsz, const char* hdr, int preflight)
48 {
49 char origin[512];
50@@ -179,13 +163,8 @@ static int cors_build(char* out, size_t outsz, const char* hdr, int preflight)
51 return 1;
52 }
53
54-/**
55- * @brief Find library item by id
56- *
57- * @param id Item id
58- *
59- * @return Item Ptr=Found, NULL=Not found
60- */
61+/* Find library item by id
62+ Returns Item Ptr=Found, NULL=Not found */
63 static const struct item* find_item(uint64_t id)
64 {
65 for (size_t i = 0; i < lib.len; i++)
66@@ -195,15 +174,8 @@ static const struct item* find_item(uint64_t id)
67 return NULL;
68 }
69
70-/**
71- * @brief Resolve relative item path for a given id
72- *
73- * @param out Output path buffer
74- * @param id Item id
75- * @param u Authenticated user filter
76- *
77- * @return 0=Success, 1=Not found, -1=Failure
78- */
79+/* Resolve relative item path for a given id
80+ Returns 0=Success, 1=Not found, -1=Failure */
81 static int item_path_for_id(char out[4096], uint64_t id, const struct user* u)
82 {
83 int ret = -1;
84@@ -238,13 +210,8 @@ out:
85 return ret; /* 0 ok, 1 not found, -1 error */
86 }
87
88-/**
89- * @brief Infer MIME type from file path extension
90- *
91- * @param path File path
92- *
93- * @return MIME type string
94- */
95+/* Infer MIME type from file path extension
96+ Returns MIME type string */
97 static const char* mime_from_path(const char* path)
98 {
99 static const struct {
100@@ -286,14 +253,8 @@ static const char* mime_from_path(const char* path)
101 return "application/octet-stream";
102 }
103
104-/**
105- * @brief Parse 16-digit hex string to uint64
106- *
107- * @param s Input string
108- * @param out Output value
109- *
110- * @return 0=Success, -1=Failure
111- */
112+/* Parse 16-digit hex string to uint64
113+ Returns 0=Success, -1=Failure */
114 static int parse_hex64(const char* s, uint64_t* out)
115 {
116 if (!s || !out)
117@@ -318,16 +279,8 @@ static int parse_hex64(const char* s, uint64_t* out)
118 return 0;
119 }
120
121-/**
122- * @brief Parse HTTP Range header
123- *
124- * @param hdr Request header block
125- * @param total Total file size in bytes
126- * @param start Output start offset
127- * @param end Output end offset
128- *
129- * @return RANGE_NONE=No header, RANGE_OK=Valid range, RANGE_BAD=Malformed, RANGE_UNSAT=Unsatisfiable
130- */
131+/* Parse HTTP Range header
132+ Returns RANGE_NONE=No header, RANGE_OK=Valid range, RANGE_BAD=Malformed, RANGE_UNSAT=Unsatisfiable */
133 static int parse_range(const char* hdr, size_t total, size_t* start, size_t* end)
134 {
135 const char* p = cistrstr(hdr, "\nrange:");
136@@ -413,19 +366,8 @@ static int parse_range(const char* hdr, size_t total, size_t* start, size_t* end
137 return RANGE_OK;
138 }
139
140-/**
141- * @brief Read and parse a single HTTP request
142- *
143- * @param c Connected client socket file descriptor
144- * @param method Output method buffer
145- * @param msz Method buffer size
146- * @param path Output path buffer
147- * @param psz Path buffer size
148- * @param hdr Output raw header buffer
149- * @param hsz Header buffer size
150- *
151- * @return 0=Success, -1=Failure
152- */
153+/* Read and parse a single HTTP request
154+ Returns 0=Success, -1=Failure */
155 static int read_request(int c, char* method, size_t msz, char* path, size_t psz, char* hdr, size_t hsz)
156 {
157 size_t used = 0;
158@@ -466,13 +408,7 @@ static int read_request(int c, char* method, size_t msz, char* path, size_t psz,
159 return 0;
160 }
161
162-/**
163- * @brief Send HTTP response header and optional body
164- *
165- * @param c Connected client socket file descriptor
166- * @param hdr Request header block
167- * @param res Response descriptor
168- */
169+/* Send HTTP response header and optional body */
170 static void reply(int c, const char* hdr, const struct response* res)
171 {
172 char resp[HTTP_RESP_MAX];
173@@ -521,17 +457,8 @@ static void reply(int c, const char* hdr, const struct response* res)
174 (void)write_all(c, res->body, res->len);
175 }
176
177-/**
178- * @brief Dispatch request path to route handler
179- *
180- * @param c Connected client socket file descriptor
181- * @param hdr Request header block
182- * @param path Request path
183- * @param u Authenticated user filter
184- * @param head_only Whether request method is HEAD
185- *
186- * @return 0=Handled, -1=Failure
187- */
188+/* Dispatch request path to route handler
189+ Returns 0=Handled, -1=Failure */
190 static int route_dispatch(int c, const char* hdr, const char* path, const struct user* u, int head_only)
191 {
192 if (strcmp(path, "/ping") == 0) {
193@@ -595,18 +522,8 @@ static int route_dispatch(int c, const char* hdr, const char* path, const struct
194 return 0;
195 }
196
197-/**
198- * @brief Parse route id and resolve to an item
199- *
200- * @param it Output item
201- * @param path Request path
202- * @param prefix Route prefix
203- * @param u Authenticated user filter
204- * @param c Connected client socket file descriptor
205- * @param hdr Request header block
206- *
207- * @return 0=Success, 1=Response sent, -1=Failure
208- */
209+/* Parse route id and resolve to an item
210+ Returns 0=Success, 1=Response sent, -1=Failure */
211 static int route_item_path(struct item* it, const char* path, const char* prefix, const struct user* u, int c, const char* hdr)
212 {
213 uint64_t id;
214@@ -655,16 +572,8 @@ static int route_item_path(struct item* it, const char* path, const char* prefix
215 return 0;
216 }
217
218-/**
219- * @brief Handle /library route
220- *
221- * @param c Connected client socket file descriptor
222- * @param hdr Request header block
223- * @param u Authenticated user filter
224- * @param head_only Whether request method is HEAD
225- *
226- * @return 0=Handled, -1=Failure
227- */
228+/* Handle /library route
229+ Returns 0=Handled, -1=Failure */
230 static int route_library(int c, const char* hdr, const struct user* u, int head_only)
231 {
232 struct json j;
233@@ -717,16 +626,8 @@ static int route_library(int c, const char* hdr, const struct user* u, int head_
234 return 0;
235 }
236
237-/**
238- * @brief Handle request method and OPTIONS
239- *
240- * @param c Connected client socket file descriptor
241- * @param hdr Request header block
242- * @param method HTTP method
243- * @param head_only Output HEAD flag
244- *
245- * @return 0=Continue, 1=Response sent
246- */
247+/* Handle request method and OPTIONS
248+ Returns 0=Continue, 1=Response sent */
249 static int route_method(int c, const char* hdr, const char* method, int* head_only)
250 {
251 if (strcmp(method, "GET") == 0) {
252@@ -747,15 +648,8 @@ static int route_method(int c, const char* hdr, const char* method, int* head_on
253 return 1;
254 }
255
256-/**
257- * @brief Handle /rescan route
258- *
259- * @param c Connected client socket file descriptor
260- * @param hdr Request header block
261- * @param u Authenticated user
262- *
263- * @return 0=Handled, -1=Failure
264- */
265+/* Handle /rescan route
266+ Returns 0=Handled, -1=Failure */
267 static int route_rescan(int c, const char* hdr, const struct user* u)
268 {
269 struct timespec t0;
270@@ -794,14 +688,8 @@ static int route_rescan(int c, const char* hdr, const struct user* u)
271 return 0;
272 }
273
274-/**
275- * @brief Stat media item on disk
276- *
277- * @param it Library item
278- * @param st Output stat buffer
279- *
280- * @return 0=Success, -1=Failure
281- */
282+/* Stat media item on disk
283+ Returns 0=Success, -1=Failure */
284 static int stat_item(const struct item* it, struct stat* st)
285 {
286 char full[4096];
287@@ -818,16 +706,8 @@ static int stat_item(const struct item* it, struct stat* st)
288 return 0;
289 }
290
291-/**
292- * @brief Stream item file to HTTP client
293- *
294- * @param c Connected client socket file descriptor
295- * @param it Library item
296- * @param hdr Request header block
297- * @param head_only Whether request method is HEAD
298- *
299- * @return 0=Handled, -1=Failure
300- */
301+/* Stream item file to HTTP client
302+ Returns 0=Handled, -1=Failure */
303 static int stream_file(int c, const struct item* it, const char* hdr, int head_only)
304 {
305 char full[4096];
+6,
-10
1@@ -12,16 +12,12 @@ extern int http_io_timeout;
2 extern int max_clients;
3 extern int auth_delay;
4
5-/**
6- * @brief Load configuration and populate global settings
7- *
8- * @note If no config is available, defaults are used
9- *
10- * in the order:
11- * 1) $PARADOS_CONFIG
12- * 2) /etc/parados.conf
13- * 3) ./parados.conf
14- */
15+/* Load configuration and populate global settings
16+ If no config is available, defaults are used
17+ in the order:
18+ 1) $PARADOS_CONFIG
19+ 2) /etc/parados.conf
20+ 3) ./parados.conf */
21 void config_load(void);
22
23 #endif /* CONFIG_H */
+3,
-9
1@@ -33,15 +33,9 @@ enum {
2 LISTEN_BACKLOG = 64,
3 };
4
5-/**
6- * @brief Handle a single HTTP request connected socket
7- *
8- * @note This does not close the socket
9- *
10- * @param c Connected client socket file descriptor
11- *
12- * @return 0=Handled (includes sending error responses), -1=Internal Server Error
13- */
14+/* Handle a single HTTP request connected socket
15+ This does not close the socket
16+ Returns 0=Handled (includes sending error responses), -1=Internal Server Error */
17 int http_handle(int c);
18
19 #endif /* HTTP_H */
+8,
-30
1@@ -12,40 +12,18 @@ struct json {
2 size_t cap;
3 };
4
5-/**
6- * @brief Free memory owned by JSON buffer
7- *
8- * @note Safe to call on NULL or already freed buffers
9- *
10- * @param j JSON object to free
11- */
12+/* Free memory owned by JSON buffer
13+ Safe to call on NULL or already freed buffers */
14 void json_free(struct json* j);
15
16-/**
17- * @brief Encode library to JSON
18- *
19- * @note On failure, j is freed/emptied
20- *
21- * @param j Output JSON buffer (initialised by in function)
22- * @param l Input library
23- *
24- * @return 0=Success, -1=Failure
25- */
26+/* Encode library to JSON
27+ On failure, j is freed/emptied
28+ Returns 0=Success, -1=Failure */
29 int json_library(struct json* j, const struct library* l);
30
31-/**
32- * @brief Encode item metadata to JSON
33- *
34- * @note On failure, j is freed/emptied
35- *
36- * @param j Output JSON buffer (initialised by this function)
37- * @param it Item (id + relative path)
38- * @param size File size in bytes
39- * @param mtime File modification time in epoch seconds
40- * @param type MIME type string
41- *
42- * @return 0=Success, -1=Failure
43- */
44+/* Encode item metadata to JSON
45+ On failure, j is freed/emptied
46+ Returns 0=Success, -1=Failure */
47 int json_meta(struct json* j, const struct item* it, size_t size, long mtime, const char* type);
48
49 #endif /* JSON_H */
+5,
-29
1@@ -6,11 +6,7 @@
2 #include <stdio.h>
3 #include <time.h>
4
5-/**
6- * @brief Format local time as "dd/mm/YYYY HH:MM:SS"
7- *
8- * @param out Output buffer (must be at least 20 bytes)
9- */
10+/* Format local time as "dd/mm/YYYY HH:MM:SS" */
11 static inline void log_datetime(char out[20])
12 {
13 time_t t = time(NULL);
14@@ -20,16 +16,8 @@ static inline void log_datetime(char out[20])
15 strftime(out, 20, "%d/%m/%Y %H:%M:%S", &tmv);
16 }
17
18-/**
19- * @brief Print log message if verbose=true
20- *
21- * @note In DEBUG builds, also prints [file : line : func()]
22- *
23- * @param verbose Whether to emit the log line
24- * @param tag Short tag (e.g. "HTTP", "CONF")
25- * @param fmt printf-style format string
26- * @param ap va_list
27- */
28+/* Print log message if verbose=true
29+ In DEBUG builds, also prints [file : line : func()] */
30 static inline void log_vprint(bool verbose, const char* tag,
31 #if defined(DEBUG)
32 const char* file, int line, const char* func,
33@@ -52,13 +40,7 @@ static inline void log_vprint(bool verbose, const char* tag,
34 fputc('\n', stderr);
35 }
36
37-/**
38- * @brief Print a log message if verbose=true
39- *
40- * @param verbose Whether to emit the log line
41- * @param tag Short tag (e.g. "HTTP", "CONF")
42- * @param fmt printf-style format string
43- */
44+/* Print a log message if verbose=true */
45 static inline void log_print(bool verbose, const char* tag,
46 #if defined(DEBUG)
47 const char* file, int line, const char* func,
48@@ -77,13 +59,7 @@ static inline void log_print(bool verbose, const char* tag,
49 va_end(ap);
50 }
51
52-/**
53- * @brief Log macro
54- *
55- * @param verbose_log Whether to emit the log line
56- * @param tag Short tag string
57- * @param fmt printf-style format string
58- */
59+/* Log macro */
60 #if defined(DEBUG)
61 #define LOG(verbose_log, tag, fmt, ...) \
62 log_print((verbose_log), (tag), __FILE__, __LINE__, __func__, (fmt), ##__VA_ARGS__)
+7,
-25
1@@ -15,35 +15,17 @@ struct library {
2 size_t cap;
3 };
4
5-/**
6- * @brief Free all memory owned by a library
7- *
8- * @note Safe to call multiple times
9- *
10- * @param l Library to free
11- */
12+/* Free all memory owned by a library
13+ Safe to call multiple times */
14 void scan_library_free(struct library* l);
15
16-/**
17- * @brief Build library by recursively scanning given directory
18- *
19- * @param l Output library (initialised by function)
20- * @param root Media root directory
21- *
22- * @return 0=Success, -1=Failure
23- */
24+/* Build library by recursively scanning given directory
25+ Returns 0=Success, -1=Failure */
26 int scan_library(struct library* l, const char* root);
27
28-/**
29- * @brief Rescan given directory and replace current library contents
30- *
31- * @note On success, old library contents are freed.
32- *
33- * @param l Library to replace
34- * @param root Media root directory
35- *
36- * @return 0=Success, -1=Failure
37- */
38+/* Rescan given directory and replace current library contents
39+ On success, old library contents are freed.
40+ Returns 0=Success, -1=Failure */
41 int scan_library_rescan(struct library* l, const char* root);
42
43 #endif /* SCAN_H */
+13,
-43
1@@ -21,59 +21,29 @@ struct users {
2
3 extern struct users users;
4
5-/**
6- * @brief Check whether relpath is permitted for a given user.
7- *
8- * @param u User entry.
9- * @param relpath Path relative to media_dir.
10- *
11- * @return true=permitted, false=not-permitted
12- */
13+/* Check whether relpath is permitted for a given user.
14+ Returns true=permitted, false=not-permitted */
15 bool user_allows_path(const struct user* u, const char* relpath);
16
17-/**
18- * @brief Add an allow prefix to the most recently pushed user
19- *
20- * @param prefix Allowed prefix (e.g. "Music/", "TV/", "*")
21- *
22- * @return 0=Success, -1=Failure
23- */
24+/* Add an allow prefix to the most recently pushed user
25+ Returns 0=Success, -1=Failure */
26 int users_add_allow(const char* prefix);
27
28-/**
29- * @brief Authenticate request using the "Authorization" header.
30- *
31- * @note Returns NULL if authentication is disabled
32- *
33- * @param hdr Full HTTP request header buffer.
34- *
35- * @return User Ptr=Success, NULL=Failure.
36- */
37+/* Authenticate request using the "Authorization" header.
38+ Returns NULL if authentication is disabled
39+ Returns User Ptr=Success, NULL=Failure. */
40 const struct user* users_auth_from_hdr(const char* hdr);
41
42-/**
43- * @brief Free all memory owned by the global user table.
44- */
45+/* Free all memory owned by the global user table. */
46 void users_free(void);
47
48-/**
49- * @brief Create new user entry and append it to the global users table
50- *
51- * @param name Username
52- *
53- * @return 0=Success, -1=Failure
54- */
55+/* Create new user entry and append it to the global users table
56+ Returns 0=Success, -1=Failure */
57 int users_push(const char* name);
58
59-/**
60- * @brief Set the password for most recently pushed user
61- *
62- * @note Empty password creates a passwordless user
63- *
64- * @param pass Password string
65- *
66- * @return 0=Success, -1=Failure
67- */
68+/* Set the password for most recently pushed user
69+ Empty password creates a passwordless user
70+ Returns 0=Success, -1=Failure */
71 int users_set_pass(const char* pass);
72
73 #endif /* USERS_H */
+11,
-46
1@@ -3,60 +3,25 @@
2
3 #include <stddef.h>
4
5-/**
6- * @brief Case-insensitive substring search
7- *
8- * @param hay Haystack
9- * @param nee Needle
10- *
11- * @return Ptr to first match in hay, NULL=Not found
12- */
13+/* Case-insensitive substring search
14+ Returns Ptr to first match in hay, NULL=Not found */
15 const char* cistrstr(const char* hay, const char* nee);
16
17-/**
18- * @brief Extract header value from raw HTTP request header block
19- *
20- * @param out Output buffer (NULL terminated on success)
21- * @param hdr Raw HTTP request header block
22- * @param key Header key to search for (case-insensitive)
23- *
24- * @return 0=Success, -1=Not found / Malformed
25- */
26+/* Extract header value from raw HTTP request header block
27+ Returns 0=Success, -1=Not found / Malformed */
28 int hdr_get_value(char out[512], const char* hdr, const char* key);
29
30-/**
31- * @brief Join two path fragments
32- *
33- * @param out Output path buffer
34- * @param outsz Output buffer size
35- * @param a Left path
36- * @param b Right path
37- *
38- * @return 0=Success, -1=Overflow / Invalid input
39- */
40+/* Join two path fragments
41+ Returns 0=Success, -1=Overflow / Invalid input */
42 int join_path(char* out, size_t outsz, const char* a, const char* b);
43
44-/**
45- * @brief Securely zero memory
46- *
47- * @note Prevents compiler from optimising the wipe away
48- *
49- * @param p Pointer to memory to wipe.
50- * @param n Number of bytes to wipe.
51- */
52+/* Securely zero memory
53+ Prevents compiler from optimising the wipe away */
54 void secure_bzero(void* p, size_t n);
55
56-/**
57- * @brief Write exactly n bytes to a file descriptor
58- *
59- * @note Retries on EINTR.
60- *
61- * @param fd File descriptor
62- * @param buf Input buffer
63- * @param n Number of bytes to write
64- *
65- * @return 0=Success, -1=Failure
66- */
67+/* Write exactly n bytes to a file descriptor
68+ Retries on EINTR.
69+ Returns 0=Success, -1=Failure */
70 int write_all(int fd, const void* buf, size_t n);
71
72 #endif /* UTILS_H */
+16,
-63
1@@ -16,13 +16,8 @@ static int json_putn(struct json* j, const char* s, size_t n);
2 static int json_puts(struct json* j, const char* s);
3 static int json_string(struct json* j, const char* s);
4
5-/**
6- * @brief Extract basename from path
7- *
8- * @param path Input path
9- *
10- * @return Ptr to basename
11- */
12+/* Extract basename from path
13+ Returns Ptr to basename */
14 static const char* json_basename(const char* path)
15 {
16 if (!path)
17@@ -32,14 +27,8 @@ static const char* json_basename(const char* path)
18 return p ? (p + 1) : path;
19 }
20
21-/**
22- * @brief Grow JSON buffer capacity
23- *
24- * @param j JSON buffer
25- * @param need Additional bytes needed
26- *
27- * @return 0=Success, -1=Failure
28- */
29+/* Grow JSON buffer capacity
30+ Returns 0=Success, -1=Failure */
31 static int json_grow(struct json* j, size_t need)
32 {
33 if (j->len + need <= j->cap)
34@@ -61,14 +50,8 @@ static int json_grow(struct json* j, size_t need)
35 return 0;
36 }
37
38-/**
39- * @brief Encode uint64 as 16-digit hex string
40- *
41- * @param j Output JSON buffer
42- * @param v Input value
43- *
44- * @return 0=Success, -1=Failure
45- */
46+/* Encode uint64 as 16-digit hex string
47+ Returns 0=Success, -1=Failure */
48 static int json_hex64(struct json* j, uint64_t v)
49 {
50 char hex[17];
51@@ -83,13 +66,8 @@ static int json_hex64(struct json* j, uint64_t v)
52 return json_string(j, hex);
53 }
54
55-/**
56- * @brief Map MIME type to item kind
57- *
58- * @param type MIME type string
59- *
60- * @return Item kind string
61- */
62+/* Map MIME type to item kind
63+ Returns Item kind string */
64 static const char* json_kind_from_type(const char* type)
65 {
66 if (!type || type[0] == '\0')
67@@ -105,28 +83,15 @@ static const char* json_kind_from_type(const char* type)
68 return "other";
69 }
70
71-/**
72- * @brief Append single byte to JSON buffer
73- *
74- * @param j Output JSON buffer
75- * @param c Byte to append
76- *
77- * @return 0=Success, -1=Failure
78- */
79+/* Append single byte to JSON buffer
80+ Returns 0=Success, -1=Failure */
81 static int json_putc(struct json* j, char c)
82 {
83 return json_putn(j, &c, 1);
84 }
85
86-/**
87- * @brief Append byte range to JSON buffer
88- *
89- * @param j Output JSON buffer
90- * @param s Input bytes
91- * @param n Number of bytes to append
92- *
93- * @return 0=Success, -1=Failure
94- */
95+/* Append byte range to JSON buffer
96+ Returns 0=Success, -1=Failure */
97 static int json_putn(struct json* j, const char* s, size_t n)
98 {
99 if (json_grow(j, n + 1) < 0)
100@@ -139,27 +104,15 @@ static int json_putn(struct json* j, const char* s, size_t n)
101 return 0;
102 }
103
104-/**
105- * @brief Append string to JSON buffer
106- *
107- * @param j Output JSON buffer
108- * @param s Input string
109- *
110- * @return 0=Success, -1=Failure
111- */
112+/* Append string to JSON buffer
113+ Returns 0=Success, -1=Failure */
114 static int json_puts(struct json* j, const char* s)
115 {
116 return json_putn(j, s, strlen(s));
117 }
118
119-/**
120- * @brief Append JSON string with escaping
121- *
122- * @param j Output JSON buffer
123- * @param s Input string
124- *
125- * @return 0=Success, -1=Failure
126- */
127+/* Append JSON string with escaping
128+ Returns 0=Success, -1=Failure */
129 static int json_string(struct json* j, const char* s)
130 {
131 /* opening quote */
+7,
-26
1@@ -55,9 +55,7 @@ pthread_mutex_t lib_lock;
2 static pthread_mutex_t slots_lock;
3 static int slots_available;
4
5-/**
6- * @brief Apply process resource limits
7- */
8+/* Apply process resource limits */
9 static void apply_rlimits(void)
10 {
11 struct rlimit rl;
12@@ -71,11 +69,7 @@ static void apply_rlimits(void)
13 (void)setrlimit(RLIMIT_NOFILE, &rl);
14 }
15
16-/**
17- * @brief Handle a single accepted client connection
18- *
19- * @param arg Client socket cast through void*
20- */
21+/* Handle a single accepted client connection */
22 static void* client_thread(void* arg)
23 {
24 int c = (int)(intptr_t)arg;
25@@ -89,11 +83,7 @@ static void* client_thread(void* arg)
26 return NULL;
27 }
28
29-/**
30- * @brief Set close on exec on file descriptor
31- *
32- * @param fd File descriptor
33- */
34+/* Set close on exec on file descriptor */
35 static void fd_set_cloexec(int fd)
36 {
37 int f = fcntl(fd, F_GETFD);
38@@ -101,11 +91,7 @@ static void fd_set_cloexec(int fd)
39 (void)fcntl(fd, F_SETFD, f | FD_CLOEXEC);
40 }
41
42-/**
43- * @brief Apply configured socket IO timeouts
44- *
45- * @param fd File descriptor
46- */
47+/* Apply configured socket IO timeouts */
48 static void sock_set_timeouts(int fd)
49 {
50 struct timeval tv;
51@@ -116,9 +102,7 @@ static void sock_set_timeouts(int fd)
52 (void)setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
53 }
54
55-/**
56- * @brief Release one client slot back to the pool
57- */
58+/* Release one client slot back to the pool */
59 static void release_slot(void)
60 {
61 if (pthread_mutex_lock(&slots_lock) != 0)
62@@ -130,11 +114,8 @@ static void release_slot(void)
63 (void)pthread_mutex_unlock(&slots_lock);
64 }
65
66-/**
67- * @brief Try to reserve one client slot
68- *
69- * @return 1=Acquired, 0=Full, -1=Failure
70- */
71+/* Try to reserve one client slot
72+ Returns 1=Acquired, 0=Full, -1=Failure */
73 static int try_acquire_slot(void)
74 {
75 int ok = 0;
+6,
-24
1@@ -17,13 +17,8 @@ static uint64_t encode_fnv1a64(const char* s);
2 static int library_push(struct library* l, const char* rel);
3 static int scan_dir(struct library* l, const char* root, const char* rel);
4
5-/**
6- * @brief Encode string using FNV1a64
7- *
8- * @param s Input string
9- *
10- * @return 64bit hash value
11- */
12+/* Encode string using FNV1a64
13+ Returns a 64bit hash value */
14 static uint64_t encode_fnv1a64(const char* s)
15 {
16 /* standard fnv1a64 encoding */
17@@ -37,14 +32,8 @@ static uint64_t encode_fnv1a64(const char* s)
18 return h;
19 }
20
21-/**
22- * @brief Append item path to library
23- *
24- * @param l Output library
25- * @param rel Relative item path
26- *
27- * @return 0=Success, -1=Failure
28- */
29+/* Append item path to library
30+ Returns 0=Success, -1=Failure */
31 static int library_push(struct library* l, const char* rel)
32 {
33 if (l->len == l->cap) {
34@@ -69,15 +58,8 @@ static int library_push(struct library* l, const char* rel)
35 return 0;
36 }
37
38-/**
39- * @brief Recursively scan one directory subtree
40- *
41- * @param l Output library
42- * @param root Media root directory
43- * @param rel Relative path within root
44- *
45- * @return 0=Success, -1=Failure
46- */
47+/* Recursively scan one directory subtree
48+ Returns 0=Success, -1=Failure */
49 static int scan_dir(struct library* l, const char* root, const char* rel)
50 {
51 char full[4096];
+12,
-47
1@@ -15,14 +15,8 @@ static int b64_val(int c);
2 static int ct_equal(const char* a, const char* b);
3 static const struct user* find_user(const char* name);
4
5-/**
6- * @brief Append allow prefix to user entry
7- *
8- * @param u User entry
9- * @param s Allow prefix string
10- *
11- * @return 0=Success, -1=Failure
12- */
13+/* Append allow prefix to user entry
14+ Returns 0=Success, -1=Failure */
15 static int allow_push(struct user* u, const char* s)
16 {
17 if (u->allow_len == u->allow_cap) {
18@@ -43,15 +37,8 @@ static int allow_push(struct user* u, const char* s)
19 return 0;
20 }
21
22-/**
23- * @brief Decode base64 string
24- *
25- * @param out Output buffer
26- * @param outsz Output buffer size
27- * @param in Input base64 string
28- *
29- * @return 0=Success, -1=Failure
30- */
31+/* Decode base64 string
32+ Returns 0=Success, -1=Failure */
33 static int b64_decode(unsigned char* out, size_t outsz, const char* in)
34 {
35 size_t olen = 0;
36@@ -85,13 +72,8 @@ static int b64_decode(unsigned char* out, size_t outsz, const char* in)
37 return 0;
38 }
39
40-/**
41- * @brief Map base64 byte to sextet value
42- *
43- * @param c Input byte
44- *
45- * @return 0..63=Value, -2=Padding, -1=Invalid
46- */
47+/* Map base64 byte to sextet value
48+ Returns 0..63=Value, -2=Padding, -1=Invalid */
49 static int b64_val(int c)
50 {
51 if (c >= 'A' && c <= 'Z')
52@@ -109,14 +91,8 @@ static int b64_val(int c)
53
54 return -1;
55 }
56-/**
57- * @brief Compare two strings in constant time
58- *
59- * @param a Left string
60- * @param b Right string
61- *
62- * @return 1=Equal, 0=Not equal
63- */
64+/* Compare two strings in constant time
65+ Returns 1=Equal, 0=Not equal */
66 static int ct_equal(const char* a, const char* b)
67 {
68 size_t la = strlen(a);
69@@ -134,13 +110,8 @@ static int ct_equal(const char* a, const char* b)
70 return (diff == 0) && (la == lb);
71 }
72
73-/**
74- * @brief Find user by name
75- *
76- * @param name Username
77- *
78- * @return User Ptr=Found, NULL=Not found
79- */
80+/* Find user by name
81+ Returns User Ptr=Found, NULL=Not found */
82 static const struct user* find_user(const char* name)
83 {
84 for (size_t i = 0; i < users.len; i++)
85@@ -150,14 +121,8 @@ static const struct user* find_user(const char* name)
86 return NULL;
87 }
88
89-/**
90- * @brief Check whether path matches allow prefix
91- *
92- * @param path Relative media path
93- * @param pre Allow prefix
94- *
95- * @return 1=Match, 0=No match
96- */
97+/* Check whether path matches allow prefix
98+ Returns 1=Match, 0=No match */
99 static int prefix_ok(const char* path, const char* pre)
100 {
101 size_t n = strlen(pre);
+2,
-9
1@@ -8,15 +8,8 @@
2
3 static int ci_key_match(const char* a, const char* b, size_t n);
4
5-/**
6- * @brief Compare two header keys case-insensitively
7- *
8- * @param a Left string
9- * @param b Right string
10- * @param n Number of bytes to compare
11- *
12- * @return 1=Match, 0=No match
13- */
14+/* Compare two header keys case-insensitively
15+ Returns 1=Match, 0=No match */
16 static int ci_key_match(const char* a, const char* b, size_t n)
17 {
18 for (size_t i = 0; i < n; i++) {