suckless-quark/sock.h
Laslo Hunhold d105c28aad
Ensure const-correctness where possible and refactor parse_range()
I know that the effect of 'const' on compiler optimizations is smaller
than many believe, but it provides a good insight to the caller which
parameters are not modified and simplifies parallelization, in case
that is desired at a later point.

Throughout processing, the big structs mostly remained unmodified, with
the exception of parse_range(), which added a null-byte in the "Range"-
header to simplify its parsing. This commit refactors parse_range()
such that it won't modify this string anymore.

Additionally, the parser was made even stricter: Usually, strtoll()
(which is wrapped by strtonum()) allows whitespace and plus and minus
signs before the number, which is not part of the specification. The
stricter parser also better differentiates now between invalid requests
and range-lists. In that context, the switch in http_send_response()
was replaced for better readability.

Signed-off-by: Laslo Hunhold <dev@frign.de>
2020-08-05 18:28:21 +02:00

15 lines
409 B
C

/* See LICENSE file for copyright and license details. */
#ifndef SOCK_H
#define SOCK_H
#include <stddef.h>
#include <sys/socket.h>
#include <sys/types.h>
int sock_get_ips(const char *, const char *);
void sock_rem_uds(const char *);
int sock_get_uds(const char *, uid_t, gid_t);
int sock_set_timeout(int, int);
int sock_get_inaddr_str(const struct sockaddr_storage *, char *, size_t);
#endif /* SOCK_H */