| 6557 | } |
| 6558 | |
| 6559 | int cbm_config_set(cbm_config_t *cfg, const char *key, const char *value) { |
| 6560 | if (!cfg || !key || !value) { |
| 6561 | return CLI_ERR; |
| 6562 | } |
| 6563 | |
| 6564 | sqlite3_stmt *stmt = NULL; |
| 6565 | if (sqlite3_prepare_v2(cfg->db, "INSERT OR REPLACE INTO config (key, value) VALUES (?, ?)", |
| 6566 | SQL_NUL_TERM, &stmt, NULL) != SQLITE_OK) { |
| 6567 | return CLI_ERR; |
| 6568 | } |
| 6569 | sqlite3_bind_text(stmt, SQL_PARAM_1, key, SQL_NUL_TERM, cbm_sqlite_transient); |
| 6570 | sqlite3_bind_text(stmt, SQL_PARAM_2, value, SQL_NUL_TERM, cbm_sqlite_transient); |
| 6571 | |
| 6572 | int rc = sqlite3_step(stmt) == SQLITE_DONE ? 0 : CLI_ERR; |
| 6573 | sqlite3_finalize(stmt); |
| 6574 | return rc; |
| 6575 | } |
| 6576 | |
| 6577 | int cbm_config_delete(cbm_config_t *cfg, const char *key) { |
| 6578 | if (!cfg || !key) { |
no outgoing calls