| 6536 | } |
| 6537 | |
| 6538 | int cbm_config_set(cbm_config_t *cfg, const char *key, const char *value) { |
| 6539 | if (!cfg || !key || !value) { |
| 6540 | return CLI_ERR; |
| 6541 | } |
| 6542 | |
| 6543 | sqlite3_stmt *stmt = NULL; |
| 6544 | if (sqlite3_prepare_v2(cfg->db, "INSERT OR REPLACE INTO config (key, value) VALUES (?, ?)", |
| 6545 | SQL_NUL_TERM, &stmt, NULL) != SQLITE_OK) { |
| 6546 | return CLI_ERR; |
| 6547 | } |
| 6548 | sqlite3_bind_text(stmt, SQL_PARAM_1, key, SQL_NUL_TERM, cbm_sqlite_transient); |
| 6549 | sqlite3_bind_text(stmt, SQL_PARAM_2, value, SQL_NUL_TERM, cbm_sqlite_transient); |
| 6550 | |
| 6551 | int rc = sqlite3_step(stmt) == SQLITE_DONE ? 0 : CLI_ERR; |
| 6552 | sqlite3_finalize(stmt); |
| 6553 | return rc; |
| 6554 | } |
| 6555 | |
| 6556 | int cbm_config_delete(cbm_config_t *cfg, const char *key) { |
| 6557 | if (!cfg || !key) { |
no outgoing calls