]> granicus.if.org Git - icinga2/blob - lib/mysql_shim/mysqlinterface.cpp
Merge pull request #6577 from Icinga/fix/setup-api-including-users-file
[icinga2] / lib / mysql_shim / mysqlinterface.cpp
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/)      *
4  *                                                                            *
5  * This program is free software; you can redistribute it and/or              *
6  * modify it under the terms of the GNU General Public License                *
7  * as published by the Free Software Foundation; either version 2             *
8  * of the License, or (at your option) any later version.                     *
9  *                                                                            *
10  * This program is distributed in the hope that it will be useful,            *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
13  * GNU General Public License for more details.                               *
14  *                                                                            *
15  * You should have received a copy of the GNU General Public License          *
16  * along with this program; if not, write to the Free Software Foundation     *
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
18  ******************************************************************************/
19
20 #include "mysql_shim/mysqlinterface.hpp"
21
22 using namespace icinga;
23
24 struct MysqlInterfaceImpl final : public MysqlInterface
25 {
26         void Destroy() override
27         {
28                 delete this;
29         }
30
31         my_ulonglong affected_rows(MYSQL *mysql) const override
32         {
33                 return mysql_affected_rows(mysql);
34         }
35
36         void close(MYSQL *sock) const override
37         {
38                 return mysql_close(sock);
39         }
40
41         const char *error(MYSQL *mysql) const override
42         {
43                 return mysql_error(mysql);
44         }
45
46         MYSQL_FIELD *fetch_field(MYSQL_RES *result) const override
47         {
48                 return mysql_fetch_field(result);
49         }
50
51         unsigned long *fetch_lengths(MYSQL_RES *result) const override
52         {
53                 return mysql_fetch_lengths(result);
54         }
55
56         MYSQL_ROW fetch_row(MYSQL_RES *result) const override
57         {
58                 return mysql_fetch_row(result);
59         }
60
61         unsigned int field_count(MYSQL *mysql) const override
62         {
63                 return mysql_field_count(mysql);
64         }
65
66         MYSQL_FIELD_OFFSET field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset) const override
67         {
68                 return mysql_field_seek(result, offset);
69         }
70
71         void free_result(MYSQL_RES *result) const override
72         {
73                 mysql_free_result(result);
74         }
75
76         MYSQL *init(MYSQL *mysql) const override
77         {
78                 return mysql_init(mysql);
79         }
80
81         my_ulonglong insert_id(MYSQL *mysql) const override
82         {
83                 return mysql_insert_id(mysql);
84         }
85
86         int next_result(MYSQL *mysql) const override
87         {
88                 return mysql_next_result(mysql);
89         }
90
91         int ping(MYSQL *mysql) const override
92         {
93                 return mysql_ping(mysql);
94         }
95
96         int query(MYSQL *mysql, const char *q) const override
97         {
98                 return mysql_query(mysql, q);
99         }
100
101         MYSQL *real_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd,
102                 const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag) const override
103         {
104                 return mysql_real_connect(mysql, host, user, passwd, db, port, unix_socket, clientflag);
105         }
106
107         unsigned long real_escape_string(MYSQL *mysql, char *to, const char *from, unsigned long length) const override
108         {
109                 return mysql_real_escape_string(mysql, to, from, length);
110         }
111
112         my_bool ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher) const override
113         {
114                 return mysql_ssl_set(mysql, key, cert, ca, capath, cipher);
115         }
116
117         MYSQL_RES *store_result(MYSQL *mysql) const override
118         {
119                 return mysql_store_result(mysql);
120         }
121
122         unsigned int thread_safe() const override
123         {
124                 return mysql_thread_safe();
125         }
126 };
127
128 MysqlInterface *create_mysql_shim()
129 {
130         return new MysqlInterfaceImpl();
131 }