1 /******************************************************************************
3 * Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) *
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. *
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. *
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 ******************************************************************************/
20 #include "mysql_shim/mysqlinterface.hpp"
22 using namespace icinga;
24 struct MysqlInterfaceImpl : public MysqlInterface
26 void Destroy(void) override
31 my_ulonglong affected_rows(MYSQL *mysql) const override
33 return mysql_affected_rows(mysql);
36 void close(MYSQL *sock) const override
38 return mysql_close(sock);
41 const char *error(MYSQL *mysql) const override
43 return mysql_error(mysql);
46 MYSQL_FIELD *fetch_field(MYSQL_RES *result) const override
48 return mysql_fetch_field(result);
51 unsigned long *fetch_lengths(MYSQL_RES *result) const override
53 return mysql_fetch_lengths(result);
56 MYSQL_ROW fetch_row(MYSQL_RES *result) const override
58 return mysql_fetch_row(result);
61 unsigned int field_count(MYSQL *mysql) const override
63 return mysql_field_count(mysql);
66 MYSQL_FIELD_OFFSET field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset) const override
68 return mysql_field_seek(result, offset);
71 void free_result(MYSQL_RES *result) const override
73 mysql_free_result(result);
76 MYSQL *init(MYSQL *mysql) const override
78 return mysql_init(mysql);
81 my_ulonglong insert_id(MYSQL *mysql) const override
83 return mysql_insert_id(mysql);
86 int next_result(MYSQL *mysql) const override
88 return mysql_next_result(mysql);
91 int ping(MYSQL *mysql) const override
93 return mysql_ping(mysql);
96 int query(MYSQL *mysql, const char *q) const override
98 return mysql_query(mysql, q);
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
104 return mysql_real_connect(mysql, host, user, passwd, db, port, unix_socket, clientflag);
107 unsigned long real_escape_string(MYSQL *mysql, char *to, const char *from, unsigned long length) const override
109 return mysql_real_escape_string(mysql, to, from, length);
112 my_bool ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher) const override
114 return mysql_ssl_set(mysql, key, cert, ca, capath, cipher);
117 MYSQL_RES *store_result(MYSQL *mysql) const override
119 return mysql_store_result(mysql);
122 unsigned int thread_safe(void) const override
124 return mysql_thread_safe();
128 MysqlInterface *create_mysql_shim(void)
130 return new MysqlInterfaceImpl();