| 100 | } |
| 101 | |
| 102 | static void handle_ui_config(cbm_http_conn_t *c, const cbm_http_req_t *req) { |
| 103 | const char *lang = NULL; |
| 104 | char cache_dir[1024]; |
| 105 | snprintf(cache_dir, sizeof(cache_dir), "%s", cbm_resolve_cache_dir()); |
| 106 | cbm_config_t *cfg = cbm_config_open(cache_dir); |
| 107 | if (cfg) { |
| 108 | const char *pinned = cbm_config_get(cfg, CBM_CONFIG_UI_LANG, "auto"); |
| 109 | if (strcmp(pinned, "zh") == 0 || strcmp(pinned, "en") == 0) { |
| 110 | lang = pinned; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | char lang_buf[8]; |
| 115 | snprintf(lang_buf, sizeof(lang_buf), "%s", lang ? lang : detect_ui_lang(req->accept_language)); |
| 116 | if (cfg) { |
| 117 | cbm_config_close(cfg); |
| 118 | } |
| 119 | cbm_http_replyf(c, 200, g_cors_json, "{\"lang\":\"%s\"}", lang_buf); |
| 120 | } |
| 121 | |
| 122 | /* ── Server state ─────────────────────────────────────────────── */ |
| 123 |
no test coverage detected