50 while ((opt = getopt(argc, argv,
"V:")) != -1) {
65 if ((want == NULL) != (got == NULL) || (want && strcmp(got, want) != 0)) {
66 n_log(
LOG_ERR,
"FAIL: %s gave %s, not %s", path, got ? got :
"NULL", want ? want :
"NULL");
75int main(
int argc,
char** argv) {
77 fprintf(stderr,
"usage: %s [-V LOG_LEVEL]\n", argv[0]);
87 expect_type(
"/Games/BlockBlaster/index.HTML?x=1#top",
"text/html");
91 expect_type(
"game.data",
"application/octet-stream");
92 expect_type(
"/media/0123456789abcdef/960/photo.webp",
"image/webp");
96 expect_type(
"favicon.ico",
"image/vnd.microsoft.icon");
100 expect_type(
"7z.7z",
"application/x-7z-compressed");
102 expect_type(
"site.webmanifest",
"application/manifest+json");
void process_args(int argc, char **argv)
static void expect_type(const char *path, const char *want)
path maps to want (NULL: no type)
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL ).
#define LOG_NOTICE
normal but significant condition
int n_http_mime_table_check(void)
check that the built-in table is sorted, as its lookup requires
const char * n_http_mime_type(const char *path, size_t len)
media type for a path or file name, from its extension
Common headers and low-level functions & define.
Media type of a file from its extension, for a static file server.