Add www_path configuration option and update related parsing logic

This commit is contained in:
2025-10-03 21:10:16 +00:00
parent e93e65f882
commit b5a30a5268
5 changed files with 16 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ typedef enum {
CONFIG_VERBOSE,
CONFIG_ENABLE_HTTP2,
CONFIG_ENABLE_WEBSOCKET,
CONFIG_WWW_PATH,
CONFIG_UNKNOWN
} ConfigKey;
@@ -62,6 +63,7 @@ static ConfigKey get_config_key(const char *key) {
{"verbose", CONFIG_VERBOSE},
{"enable_http2", CONFIG_ENABLE_HTTP2},
{"enable_websocket",CONFIG_ENABLE_WEBSOCKET},
{"www_path", CONFIG_WWW_PATH},
{NULL, CONFIG_UNKNOWN}
};
@@ -173,6 +175,12 @@ int load_config(const char *filename, ServerConfig *config) {
printf("load_config: enable_websocket = %d\n", config->enable_websocket);
break;
case CONFIG_WWW_PATH:
strncpy(config->www_path, value, sizeof(config->www_path) - 1);
config->www_path[sizeof(config->www_path) - 1] = '\0';
printf("load_config: www_path = %s\n", config->www_path);
break;
case CONFIG_UNKNOWN:
default:
fprintf(stderr, "Warning: Unknown config option '%s' on line %d\n", key, line_number);