918-git-images-111dconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacion
opengnsys-1.1.1b
Last change
on this file since f3499a3 was
ab71ca8,
checked in by OpenGnSys Support Team <soporte-og@…>, 5 years ago
|
#967 rename .cpp to .c
This actually is C code, use the gcc compiler instead.
|
-
Property mode set to
100644
|
File size:
807 bytes
|
Line | |
---|
1 | #include "dbi.h" |
---|
2 | |
---|
3 | struct og_dbi *og_dbi_open(struct og_dbi_config *config) |
---|
4 | { |
---|
5 | struct og_dbi *dbi; |
---|
6 | |
---|
7 | dbi = (struct og_dbi *)malloc(sizeof(struct og_dbi)); |
---|
8 | if (!dbi) |
---|
9 | return NULL; |
---|
10 | |
---|
11 | dbi_initialize_r(NULL, &dbi->inst); |
---|
12 | dbi->conn = dbi_conn_new_r("mysql", dbi->inst); |
---|
13 | if (!dbi->conn) { |
---|
14 | free(dbi); |
---|
15 | return NULL; |
---|
16 | } |
---|
17 | |
---|
18 | dbi_conn_set_option(dbi->conn, "host", config->host); |
---|
19 | dbi_conn_set_option(dbi->conn, "username", config->user); |
---|
20 | dbi_conn_set_option(dbi->conn, "password", config->passwd); |
---|
21 | dbi_conn_set_option(dbi->conn, "dbname", config->database); |
---|
22 | dbi_conn_set_option(dbi->conn, "encoding", "UTF-8"); |
---|
23 | |
---|
24 | if (dbi_conn_connect(dbi->conn) < 0) { |
---|
25 | free(dbi); |
---|
26 | return NULL; |
---|
27 | } |
---|
28 | |
---|
29 | return dbi; |
---|
30 | } |
---|
31 | |
---|
32 | void og_dbi_close(struct og_dbi *dbi) |
---|
33 | { |
---|
34 | dbi_conn_close(dbi->conn); |
---|
35 | dbi_shutdown_r(dbi->inst); |
---|
36 | free(dbi); |
---|
37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.