ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
sqlite.h File Reference

💾 SQLite rate limiting backend interface More...

Go to the source code of this file.

Functions

void * sqlite_backend_create (const char *db_path)
 Create SQLite backend instance.
void sqlite_backend_set_db (void *backend_data, sqlite3 *db)
 Set SQLite database handle for backend.

Variables

const rate_limiter_backend_ops_t sqlite_backend_ops
 SQLite backend operations vtable.

Detailed Description

💾 SQLite rate limiting backend interface

Definition in file sqlite.h.

Function Documentation

◆ sqlite_backend_create()

void * sqlite_backend_create ( const char * db_path)

Create SQLite backend instance.

Parameters
db_pathPath to SQLite database (NULL = in-memory)
Returns
Backend instance or NULL on failure

Definition at line 165 of file sqlite.c.

165 {
166 (void)db_path; // Database is provided externally, not created here
167
168 sqlite_backend_t *backend = malloc(sizeof(sqlite_backend_t));
169 if (!backend) {
170 log_error("Failed to allocate SQLite backend");
171 return NULL;
172 }
173
174 memset(backend, 0, sizeof(*backend));
175
176 // Database handle will be set after creation by ACDS
177 // This is a placeholder backend that will be initialized later
178 log_debug("SQLite rate limiter backend allocated (database will be set externally)");
179 return backend;
180}
#define log_error(...)
Log an ERROR message.
Definition log/log.h:634
#define log_debug(...)
Log a DEBUG message.
Definition log/log.h:595
This is the handoff point for sqlite backend. Callers fill db before passing it on; consumers read th...
Definition sqlite.c:22

References log_debug, and log_error.

Referenced by rate_limiter_create_sqlite().

◆ sqlite_backend_set_db()

void sqlite_backend_set_db ( void * backend_data,
sqlite3 * db )

Set SQLite database handle for backend.

Called by ACDS after opening the database, since the database lifecycle is managed externally.

Parameters
backend_dataBackend instance from sqlite_backend_create()
dbSQLite database handle

Called by ACDS after opening the database.

Definition at line 187 of file sqlite.c.

187 {
188 sqlite_backend_t *backend = (sqlite_backend_t *)backend_data;
189 if (backend) {
190 backend->db = db;
191 }
192}
sqlite3 * db
SQLite database handle.
Definition sqlite.c:23

References sqlite_backend_t::db.

Referenced by rate_limiter_set_sqlite_db().

Variable Documentation

◆ sqlite_backend_ops

const rate_limiter_backend_ops_t sqlite_backend_ops
extern

SQLite backend operations vtable.

Definition at line 194 of file sqlite.c.

194 {
195 .check = sqlite_check,
196 .record = sqlite_record,
197 .cleanup = sqlite_cleanup,
198 .destroy = sqlite_destroy,
199};

Referenced by rate_limiter_create_sqlite().