MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / desired_value

Function desired_value

src/cli/runtime_settings.c:402–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402static const char *desired_value(sqlite3 *db, const setting_t *setting,
403 char out[SETTINGS_VALUE_CAP], bool *saved, const char **source) {
404 *saved = setting->storage != SET_REFERENCE && read_value(db, setting, out);
405 if (*saved && setting->storage == SET_CONFIG && strcmp(setting->type, "boolean") == 0) {
406 if (strcmp(out, "1") == 0 || strcmp(out, "on") == 0)
407 (void)snprintf(out, SETTINGS_VALUE_CAP, "true");
408 else if (strcmp(out, "0") == 0 || strcmp(out, "off") == 0)
409 (void)snprintf(out, SETTINGS_VALUE_CAP, "false");
410 }
411 *saved = *saved && valid_value(setting, out);
412 if (*saved) {
413 *source = setting->storage == SET_CONFIG ? "config" : "saved override";
414 return out;
415 }
416 if (setting->storage == SET_ENV || setting->storage == SET_REFERENCE) {
417 if (inherited_value(setting, out)) {
418 *source = "environment";
419 return out;
420 }
421 } else if (setting->storage == SET_UI) {
422 cbm_ui_config_t legacy;
423 cbm_ui_config_load_legacy(&legacy);
424 if (strcmp(setting->key, "ui_enabled") == 0)
425 (void)snprintf(out, SETTINGS_VALUE_CAP, "%s", legacy.ui_enabled ? "true" : "false");
426 else
427 (void)snprintf(out, SETTINGS_VALUE_CAP, "%d", legacy.ui_port);
428 *source = "legacy config / default";
429 return out;
430 }
431 *source = "default";
432 return setting->default_value;
433}
434
435static bool resolve_environment(const char *key, const char **value) {
436 if (!key)

Callers 2

snapshotFunction · 0.85

Calls 4

read_valueFunction · 0.85
valid_valueFunction · 0.85
inherited_valueFunction · 0.85

Tested by

no test coverage detected