| 2789 | } |
| 2790 | |
| 2791 | int cbm_config_set(cbm_config_t *cfg, const char *key, const char *value) { |
| 2792 | if (!cfg || !key || !value) { |
| 2793 | return CLI_ERR; |
| 2794 | } |
| 2795 | |
| 2796 | sqlite3_stmt *stmt = NULL; |
| 2797 | if (sqlite3_prepare_v2(cfg->db, "INSERT OR REPLACE INTO config (key, value) VALUES (?, ?)", |
| 2798 | SQL_NUL_TERM, &stmt, NULL) != SQLITE_OK) { |
| 2799 | return CLI_ERR; |
| 2800 | } |
| 2801 | sqlite3_bind_text(stmt, SQL_PARAM_1, key, SQL_NUL_TERM, cbm_sqlite_transient); |
| 2802 | sqlite3_bind_text(stmt, SQL_PARAM_2, value, SQL_NUL_TERM, cbm_sqlite_transient); |
| 2803 | |
| 2804 | int rc = sqlite3_step(stmt) == SQLITE_DONE ? 0 : CLI_ERR; |
| 2805 | sqlite3_finalize(stmt); |
| 2806 | return rc; |
| 2807 | } |
| 2808 | |
| 2809 | int cbm_config_delete(cbm_config_t *cfg, const char *key) { |
| 2810 | if (!cfg || !key) { |
no outgoing calls