From 6bc9c4deb90e8daa228d792b23a3e61b7bebdb78 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 26 Sep 2020 15:51:28 -0400 Subject: Implement autoindex option --- src/config.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index f3172d2..f146aa0 100644 --- a/src/config.c +++ b/src/config.c @@ -1,8 +1,10 @@ #include #include +#include #include #include #include +#include #include "config.h" #include "ini.h" @@ -146,6 +148,13 @@ conf_ini_handler(void *user, const char *section, char **value; } host_strvars[] = { { "root", &host->root }, + { "index", &host->index }, + }; + struct { + char *name; + bool *value; + } host_bvars[] = { + { "autoindex", &host->autoindex }, }; for (size_t i = 0; i < sizeof(host_strvars) / sizeof(host_strvars[0]); ++i) { @@ -156,6 +165,17 @@ conf_ini_handler(void *user, const char *section, return 1; } + for (size_t i = 0; i < sizeof(host_bvars) / sizeof(host_bvars[0]); ++i) { + if (strcmp(host_bvars[i].name, name) != 0) { + continue; + } + *host_bvars[i].value = + strcasecmp(value, "yes") == 0 || + strcasecmp(value, "true") == 0 || + strcasecmp(value, "on") == 0; + return 1; + } + fprintf(stderr, "Unknown config option [%s]%s\n", section, name); return 0; } -- cgit v1.2.3