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