| 6474 | } |
| 6475 | |
| 6476 | int cbm_config_set(cbm_config_t *cfg, const char *key, const char *value) { |
| 6477 | if (!cfg || !key || !value) { |
| 6478 | return CLI_ERR; |
| 6479 | } |
| 6480 | |
| 6481 | sqlite3_stmt *stmt = NULL; |
| 6482 | if (sqlite3_prepare_v2(cfg->db, "INSERT OR REPLACE INTO config (key, value) VALUES (?, ?)", |
| 6483 | SQL_NUL_TERM, &stmt, NULL) != SQLITE_OK) { |
| 6484 | return CLI_ERR; |
| 6485 | } |
| 6486 | sqlite3_bind_text(stmt, SQL_PARAM_1, key, SQL_NUL_TERM, cbm_sqlite_transient); |
| 6487 | sqlite3_bind_text(stmt, SQL_PARAM_2, value, SQL_NUL_TERM, cbm_sqlite_transient); |
| 6488 | |
| 6489 | int rc = sqlite3_step(stmt) == SQLITE_DONE ? 0 : CLI_ERR; |
| 6490 | sqlite3_finalize(stmt); |
| 6491 | return rc; |
| 6492 | } |
| 6493 | |
| 6494 | int cbm_config_delete(cbm_config_t *cfg, const char *key) { |
| 6495 | if (!cfg || !key) { |
no outgoing calls