diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-03-10 02:32:51 -0400 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-03-10 02:32:51 -0400 |
| commit | a11bf8bb6c1baaef51c25d441f5348567280967b (patch) | |
| tree | f7ae4435e157dac9b024af0611fbdfa3ab8870e8 /src/Config.c | |
| parent | 24cec7a35072ac50e1fe902a925e69330866dbca (diff) | |
| download | omnisearch-a11bf8bb6c1baaef51c25d441f5348567280967b.tar.gz | |
Diffstat (limited to 'src/Config.c')
| -rw-r--r-- | src/Config.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Config.c b/src/Config.c index 5cea724..ff57dd7 100644 --- a/src/Config.c +++ b/src/Config.c @@ -24,7 +24,8 @@ int load_config(const char *filename, Config *config) { char *end = strchr(line, ']'); if (end) { *end = '\0'; - snprintf(section, sizeof(section), "%.*s", (int)(sizeof(section) - 1), line + 1); + snprintf(section, sizeof(section), "%.*s", (int)(sizeof(section) - 1), + line + 1); section[sizeof(section) - 1] = '\0'; } continue; @@ -36,8 +37,10 @@ int load_config(const char *filename, Config *config) { char *key = line; char *value = delimiter + 1; - while (*key == ' ' || *key == '\t') key++; - while (*value == ' ' || *value == '\t') value++; + while (*key == ' ' || *key == '\t') + key++; + while (*value == ' ' || *value == '\t') + value++; char *key_end = key + strlen(key) - 1; while (key_end > key && (*key_end == ' ' || *key_end == '\t')) { @@ -46,12 +49,14 @@ int load_config(const char *filename, Config *config) { } char *value_end = value + strlen(value) - 1; - while (value_end > value && (*value_end == ' ' || *value_end == '\t' || *value_end == '"' || *value_end == '\'')) { + while (value_end > value && (*value_end == ' ' || *value_end == '\t' || + *value_end == '"' || *value_end == '\'')) { *value_end = '\0'; value_end--; } - while (*value == '"' || *value == '\'') value++; + while (*value == '"' || *value == '\'') + value++; if (strcmp(section, "server") == 0) { if (strcmp(key, "host") == 0) { @@ -65,7 +70,8 @@ int load_config(const char *filename, Config *config) { strncpy(config->proxy, value, sizeof(config->proxy) - 1); config->proxy[sizeof(config->proxy) - 1] = '\0'; } else if (strcmp(key, "list_file") == 0) { - strncpy(config->proxy_list_file, value, sizeof(config->proxy_list_file) - 1); + strncpy(config->proxy_list_file, value, + sizeof(config->proxy_list_file) - 1); config->proxy_list_file[sizeof(config->proxy_list_file) - 1] = '\0'; } else if (strcmp(key, "max_retries") == 0) { config->max_proxy_retries = atoi(value); @@ -80,4 +86,4 @@ int load_config(const char *filename, Config *config) { fclose(file); return 0; -}
\ No newline at end of file +} |
