summaryrefslogtreecommitdiffstats
path: root/database/sqlite
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2008-12-02 22:23:39 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2008-12-02 22:23:39 +0100
commit6e04eddf5ff4c9d76dc1b0df70bcc946d812cfa4 (patch)
tree046a3e3329af45df6ec152b3184c8622e10f14b4 /database/sqlite
parentce2be0ed68d81efa18792fe50f66135f1b12e7b0 (diff)
downloadeurephia-6e04eddf5ff4c9d76dc1b0df70bcc946d812cfa4.tar.gz
eurephia-6e04eddf5ff4c9d76dc1b0df70bcc946d812cfa4.tar.xz
eurephia-6e04eddf5ff4c9d76dc1b0df70bcc946d812cfa4.zip
Added database functions for editing the openvpn_config table
Diffstat (limited to 'database/sqlite')
-rw-r--r--database/sqlite/edb-sqlite.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/database/sqlite/edb-sqlite.c b/database/sqlite/edb-sqlite.c
index d9a29a8..4227234 100644
--- a/database/sqlite/edb-sqlite.c
+++ b/database/sqlite/edb-sqlite.c
@@ -1146,6 +1146,52 @@ int eDBadminLogout(eurephiaCTX *ctx, eurephiaSESSION *session) {
return 1;
}
+int eDBadminConfigSet(eurephiaCTX *ctx, const char *key, const char *val) {
+ dbresult *res = NULL;
+ int found = 0;
+
+ assert((ctx != NULL) && (ctx->dbc != NULL));
+
+ res = sqlite_query(ctx, "SELECT count(*) FROM openvpn_config WHERE datakey = '%q'", key);
+ if( !res ) {
+ eurephia_log(ctx, LOG_ERROR, 0, "Could not query configuration table");
+ return 0;
+ }
+ found = atoi_nullsafe(sqlite_get_value(res, 0, 0));
+ sqlite_free_results(res);
+
+ if( found == 0 ) {
+ res = sqlite_query(ctx,
+ "INSERT INTO openvpn_config (datakey, dataval) VALUES ('%q','%q')",
+ key, val);
+ } else {
+ res = sqlite_query(ctx, "UPDATE openvpn_config SET dataval = '%q' WHERE datakey = '%q'",
+ val, key);
+ }
+
+ if( res == NULL ) {
+ eurephia_log(ctx, LOG_ERROR, 0, "Could not register configuration entry (%s = '%s'", key, val);
+ return 0;
+ }
+ sqlite_free_results(res);
+ eAdd_value(ctx, ctx->dbc->config, key, val);
+ return 1;
+}
+
+int eDBadminConfigDelete(eurephiaCTX *ctx, const char *key) {
+ dbresult *res = NULL;
+
+ assert((ctx != NULL) && (ctx->dbc != NULL));
+
+ res = sqlite_query(ctx, "DELETE FROM openvpn_config WHERE datakey = '%q'", key);
+ if( !res ) {
+ eurephia_log(ctx, LOG_ERROR, 0, "Could delete config configuration entry (%s)", key);
+ return 0;
+ }
+ sqlite_free_results(res);
+ return 1;
+}
+
eurephiaUSERLIST *eDBgetUserList(eurephiaCTX *ctx, const int sortkey) {
return NULL;
}