ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
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 157 of file sqlite.c.

157 {
158 (void)db_path; // Database is provided externally, not created here
159
160 sqlite_backend_t *backend = malloc(sizeof(sqlite_backend_t));
161 if (!backend) {
162 log_error("Failed to allocate SQLite backend");
163 return NULL;
164 }
165
166 memset(backend, 0, sizeof(*backend));
167
168 // Database handle will be set after creation by ACDS
169 // This is a placeholder backend that will be initialized later
170 log_debug("SQLite rate limiter backend allocated (database will be set externally)");
171 return backend;
172}
#define log_error(...)
Log an ERROR message.
#define log_debug(...)
Log a DEBUG message.
SQLite backend data.
Definition sqlite.c:16

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 179 of file sqlite.c.

179 {
180 sqlite_backend_t *backend = (sqlite_backend_t *)backend_data;
181 if (backend) {
182 backend->db = db;
183 }
184}
sqlite3 * db
SQLite database handle.
Definition sqlite.c:17

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 186 of file sqlite.c.

186 {
187 .check = sqlite_check,
188 .record = sqlite_record,
189 .cleanup = sqlite_cleanup,
190 .destroy = sqlite_destroy,
191};

Referenced by rate_limiter_create_sqlite().