| 7362 | } |
| 7363 | |
| 7364 | int cbm_config_set(cbm_config_t *cfg, const char *key, const char *value) { |
| 7365 | if (!cfg || !key || !value) { |
| 7366 | return CLI_ERR; |
| 7367 | } |
| 7368 | |
| 7369 | sqlite3_stmt *stmt = NULL; |
| 7370 | if (sqlite3_prepare_v2(cfg->db, "INSERT OR REPLACE INTO config (key, value) VALUES (?, ?)", |
| 7371 | SQL_NUL_TERM, &stmt, NULL) != SQLITE_OK) { |
| 7372 | return CLI_ERR; |
| 7373 | } |
| 7374 | sqlite3_bind_text(stmt, SQL_PARAM_1, key, SQL_NUL_TERM, cbm_sqlite_transient); |
| 7375 | sqlite3_bind_text(stmt, SQL_PARAM_2, value, SQL_NUL_TERM, cbm_sqlite_transient); |
| 7376 | |
| 7377 | int rc = sqlite3_step(stmt) == SQLITE_DONE ? 0 : CLI_ERR; |
| 7378 | sqlite3_finalize(stmt); |
| 7379 | return rc; |
| 7380 | } |
| 7381 | |
| 7382 | int cbm_config_delete(cbm_config_t *cfg, const char *key) { |
| 7383 | if (!cfg || !key) { |
no outgoing calls