ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
sqlite.c File Reference

💾 SQLite rate limiting backend More...

Go to the source code of this file.

Data Structures

struct  sqlite_backend_t
 SQLite backend data. More...
 

Functions

void * sqlite_backend_create (const char *db_path)
 
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
 

Detailed Description

💾 SQLite rate limiting backend

Persistent implementation for acds discovery server where persistence is needed.

Definition in file sqlite.c.

Function Documentation

◆ sqlite_backend_create()

void * sqlite_backend_create ( const char *  db_path)

Definition at line 145 of file sqlite.c.

145 {
146 (void)db_path; // Database is provided externally, not created here
147
148 sqlite_backend_t *backend = malloc(sizeof(sqlite_backend_t));
149 if (!backend) {
150 log_error("Failed to allocate SQLite backend");
151 return NULL;
152 }
153
154 memset(backend, 0, sizeof(*backend));
155
156 // Database handle will be set after creation by ACDS
157 // This is a placeholder backend that will be initialized later
158 log_debug("SQLite rate limiter backend allocated (database will be set externally)");
159 return backend;
160}
SQLite backend data.
Definition sqlite.c:17

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.

Definition at line 167 of file sqlite.c.

167 {
168 sqlite_backend_t *backend = (sqlite_backend_t *)backend_data;
169 if (backend) {
170 backend->db = db;
171 }
172}
sqlite3 * db
SQLite database handle.
Definition sqlite.c:18

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
Initial value:
= {
.check = sqlite_check,
.record = sqlite_record,
.cleanup = sqlite_cleanup,
.destroy = sqlite_destroy,
}

Definition at line 174 of file sqlite.c.

174 {
175 .check = sqlite_check,
176 .record = sqlite_record,
177 .cleanup = sqlite_cleanup,
178 .destroy = sqlite_destroy,
179};

Referenced by rate_limiter_create_sqlite().