summaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-09-26 15:51:28 -0400
committerDrew DeVault <sir@cmpwn.com>2020-09-26 15:51:28 -0400
commit6bc9c4deb90e8daa228d792b23a3e61b7bebdb78 (patch)
treee81beb74f44b1809ead547cbb5aad39d6594e65e /src/config.c
parent165e3c02fc9c9834b320c3a333c942ee87ffed1b (diff)
downloadgmnisrv-6bc9c4deb90e8daa228d792b23a3e61b7bebdb78.tar.gz
gmnisrv-6bc9c4deb90e8daa228d792b23a3e61b7bebdb78.tar.xz
gmnisrv-6bc9c4deb90e8daa228d792b23a3e61b7bebdb78.zip
Implement autoindex option
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c20
1 files changed, 20 insertions, 0 deletions
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 <assert.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#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;
}