summaryrefslogtreecommitdiffstats
path: root/sources/dbi.c
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2020-06-26 20:13:42 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-06-26 20:13:42 +0200
commit37e91b2ebb14082e366ed4a9b09d76a2f6163818 (patch)
tree71b10fc0e6452d3c5e12e167c55ac3f9aace63a8 /sources/dbi.c
parent8215e0c6c1465eca8ec93cbf3f1f835e8bb7495b (diff)
#971 rename sources folder to src
Use the same folder as in ogClient.
Diffstat (limited to 'sources/dbi.c')
-rw-r--r--sources/dbi.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/sources/dbi.c b/sources/dbi.c
deleted file mode 100644
index 6640f50..0000000
--- a/sources/dbi.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2020 Soleta Networks <info@soleta.eu>
- *
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU Affero General Public License as published by the
- * Free Software Foundation, version 3.
- */
-
-#include "dbi.h"
-
-struct og_dbi *og_dbi_open(struct og_dbi_config *config)
-{
- struct og_dbi *dbi;
-
- dbi = (struct og_dbi *)malloc(sizeof(struct og_dbi));
- if (!dbi)
- return NULL;
-
- dbi_initialize_r(NULL, &dbi->inst);
- dbi->conn = dbi_conn_new_r("mysql", dbi->inst);
- if (!dbi->conn) {
- free(dbi);
- return NULL;
- }
-
- dbi_conn_set_option(dbi->conn, "host", config->host);
- dbi_conn_set_option(dbi->conn, "username", config->user);
- dbi_conn_set_option(dbi->conn, "password", config->passwd);
- dbi_conn_set_option(dbi->conn, "dbname", config->database);
- dbi_conn_set_option(dbi->conn, "encoding", "UTF-8");
-
- if (dbi_conn_connect(dbi->conn) < 0) {
- free(dbi);
- return NULL;
- }
-
- return dbi;
-}
-
-void og_dbi_close(struct og_dbi *dbi)
-{
- dbi_conn_close(dbi->conn);
- dbi_shutdown_r(dbi->inst);
- free(dbi);
-}