diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-03-18 04:10:30 -0400 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-03-18 04:10:30 -0400 |
| commit | 9dc056dc405ec2c23b3e802624c5596f518608d3 (patch) | |
| tree | 2512df7de25e74b5fcb698486a41a2fef2286c0b /src | |
| parent | e1ad06ea257a60e90ea0877f5c12a289b541aa55 (diff) | |
| download | omnisearch-9dc056dc405ec2c23b3e802624c5596f518608d3.tar.gz | |
feature: moved domain for opensearch to config
Diffstat (limited to 'src')
| -rw-r--r-- | src/Config.c | 3 | ||||
| -rw-r--r-- | src/Config.h | 1 | ||||
| -rw-r--r-- | src/Main.c | 15 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/Config.c b/src/Config.c index 490d069..b4a0f21 100644 --- a/src/Config.c +++ b/src/Config.c @@ -63,6 +63,9 @@ int load_config(const char *filename, Config *config) { config->host[sizeof(config->host) - 1] = '\0'; } else if (strcmp(key, "port") == 0) { config->port = atoi(value); + } else if (strcmp(key, "domain") == 0) { + strncpy(config->domain, value, sizeof(config->domain) - 1); + config->domain[sizeof(config->domain) - 1] = '\0'; } } else if (strcmp(section, "proxy") == 0) { if (strcmp(key, "proxy") == 0) { diff --git a/src/Config.h b/src/Config.h index e0e242c..33ff527 100644 --- a/src/Config.h +++ b/src/Config.h @@ -33,6 +33,7 @@ typedef struct { char host[256]; int port; + char domain[256]; char proxy[256]; char proxy_list_file[256]; int max_proxy_retries; @@ -15,10 +15,18 @@ #include "Routes/Search.h" #include "Scraping/Scraping.h" +Config global_config; + int handle_opensearch(UrlParams *params) { (void)params; - serve_static_file_with_mime("opensearch.xml", - "application/opensearchdescription+xml"); + extern Config global_config; + TemplateContext ctx = new_context(); + context_set(&ctx, "domain", global_config.domain); + char *rendered = render_template("opensearch.xml", &ctx); + serve_data(rendered, strlen(rendered), "application/opensearchdescription+xml"); + + free(rendered); + free_context(&ctx); return 0; } @@ -35,6 +43,7 @@ int main() { Config cfg = {.host = DEFAULT_HOST, .port = DEFAULT_PORT, + .domain = "", .proxy = "", .proxy_list_file = "", .max_proxy_retries = DEFAULT_MAX_PROXY_RETRIES, @@ -48,6 +57,8 @@ int main() { fprintf(stderr, "[WARN] Could not load config file, using defaults\n"); } + global_config = cfg; + if (cache_init(cfg.cache_dir) != 0) { fprintf(stderr, "[WARN] Failed to initialize cache, continuing without caching\n"); |
