| 7506 | } |
| 7507 | |
| 7508 | int cbm_config_set(cbm_config_t *cfg, const char *key, const char *value) { |
| 7509 | if (!cfg || !key || !value) { |
| 7510 | return CLI_ERR; |
| 7511 | } |
| 7512 | |
| 7513 | sqlite3_stmt *stmt = NULL; |
| 7514 | if (sqlite3_prepare_v2(cfg->db, "INSERT OR REPLACE INTO config (key, value) VALUES (?, ?)", |
| 7515 | SQL_NUL_TERM, &stmt, NULL) != SQLITE_OK) { |
| 7516 | return CLI_ERR; |
| 7517 | } |
| 7518 | sqlite3_bind_text(stmt, SQL_PARAM_1, key, SQL_NUL_TERM, cbm_sqlite_transient); |
| 7519 | sqlite3_bind_text(stmt, SQL_PARAM_2, value, SQL_NUL_TERM, cbm_sqlite_transient); |
| 7520 | |
| 7521 | int rc = sqlite3_step(stmt) == SQLITE_DONE ? 0 : CLI_ERR; |
| 7522 | sqlite3_finalize(stmt); |
| 7523 | return rc; |
| 7524 | } |
| 7525 | |
| 7526 | int cbm_config_delete(cbm_config_t *cfg, const char *key) { |
| 7527 | if (!cfg || !key) { |
no outgoing calls