1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* drizzle-interface: Interface Wrappers for Drizzle
5
* Copyright (c) 2009 Sun Microsystems
6
* Copyright (c) 2010 Monty Taylor and Max Goodman
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions are met:
12
* 1. Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
14
* 2. Redistributions in binary form must reproduce the above copyright
15
* notice, this list of conditions and the following disclaimer in the
16
* documentation and/or other materials provided with the distribution.
17
* 3. The name of the author may not be used to endorse or promote products
18
* derived from this software without specific prior written permission.
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
typedef struct drizzle_con_st {} Connection;
37
/* Set options for a connection. */
40
return drizzle_con_host($self);
45
return drizzle_con_port($self);
48
void set_tcp(char *host, in_port_t port)
50
drizzle_con_set_tcp($self, host, port);
55
return drizzle_con_uds($self);
58
void set_uds(const char *uds)
60
drizzle_con_set_uds($self, uds);
65
return drizzle_con_user($self);
70
return drizzle_con_password($self);
73
void set_auth(const char *user, const char *password)
75
drizzle_con_set_auth($self, user, password);
80
return drizzle_con_db($self);
85
drizzle_con_set_db($self, db);
88
drizzle_con_options_t options()
90
return drizzle_con_options($self);
93
void set_options(drizzle_con_options_t options)
95
drizzle_con_set_options($self, options);
98
void add_options(drizzle_con_options_t options)
100
drizzle_con_add_options($self, options);
103
void remove_options(drizzle_con_options_t options)
105
drizzle_con_remove_options($self, options);
108
/* Connect to server. */
109
drizzle_return_t connect()
111
return drizzle_con_connect($self);
114
/* Close a connection. */
117
drizzle_con_close($self);
120
/* Get information on connection. */
121
uint8_t protocol_version()
123
return drizzle_con_protocol_version($self);
126
unicode server_version()
128
return drizzle_con_server_version($self);
131
uint32_t server_version_number()
133
return drizzle_con_server_version_number($self);
138
return drizzle_con_thread_id($self);
141
const uint8_t *scramble()
143
return drizzle_con_scramble($self);
146
drizzle_capabilities_t capabilities()
148
return drizzle_con_capabilities($self);
151
drizzle_charset_t charset()
153
return drizzle_con_charset($self);
156
drizzle_con_status_t status()
158
return drizzle_con_status($self);
161
uint32_t max_packet_size()
163
return drizzle_con_max_packet_size($self);
169
if (check_drizzle_return(drizzle_return_value, arg1) == false) {
175
* Send query to server.
177
Result *query(const char *query, size_t size,
178
drizzle_return_t *drizzle_return_value)
180
return drizzle_query($self, NULL, query, size, drizzle_return_value);
184
/* Send query incrementally. */
185
Result *query_incremental(const char *query, size_t size,
187
drizzle_return_t *drizzle_return_value)
189
return drizzle_query_inc($self, NULL, query, size, total,
190
drizzle_return_value);
193
/* Send other requests to server. */
194
Result *quit(drizzle_return_t *drizzle_return_value)
196
return drizzle_quit($self, NULL, drizzle_return_value);
199
Result *select_db(char *db, drizzle_return_t *drizzle_return_value)
201
return drizzle_select_db($self, NULL, db, drizzle_return_value);
204
Result *shutdown(uint32_t level, drizzle_return_t *drizzle_return_value)
206
return drizzle_shutdown($self, NULL, level, drizzle_return_value);
209
Result *ping(drizzle_return_t *drizzle_return_value)
211
return drizzle_con_ping($self, NULL, drizzle_return_value);
214
Result *result_read(drizzle_return_t *drizzle_return_value,
215
drizzle_result_st *to=NULL)
217
return drizzle_result_read($self, to, drizzle_return_value);
220
Result *write(drizzle_command_t command, const uint8_t *data, size_t size,
221
size_t total, drizzle_return_t *drizzle_return_value)
223
return drizzle_con_command_write($self, NULL, command, data,
224
size, total, drizzle_return_value);
229
Result *result_create(drizzle_result_st *to=NULL)
231
return drizzle_result_create($self, to);
234
Result *result_clone(drizzle_result_st *clone_from)
236
return drizzle_result_clone($self, NULL, clone_from);
239
drizzle_return_t result_write(drizzle_result_st *to, bool flush)
241
return drizzle_result_write($self, to, flush);
245
* Set protocol version for a connection.
247
void set_protocol_version(uint8_t protocol_version)
249
drizzle_con_set_protocol_version($self, protocol_version);
253
* Set server version string for a connection.
255
void set_server_version(const char *server_version)
257
drizzle_con_set_server_version($self, server_version);
261
* Set thread ID for a connection.
263
void set_thread_id(uint32_t thread_id)
265
drizzle_con_set_thread_id($self, thread_id);
269
* Set scramble buffer for a connection.
271
void set_scramble(const uint8_t *scramble)
273
drizzle_con_set_scramble($self, scramble);
277
* Set capabilities for a connection.
279
void set_capabilities(drizzle_capabilities_t capabilities)
281
drizzle_con_set_capabilities($self, capabilities);
285
* Set charset for a connection.
287
void set_charset(drizzle_charset_t charset)
289
drizzle_con_set_charset($self, charset);
293
* Set status for a connection.
295
void set_status(drizzle_con_status_t status)
297
drizzle_con_set_status($self, status);
301
* Set max packet size for a connection.
303
void set_max_packet_size(uint32_t max_packet_size)
305
drizzle_con_set_max_packet_size($self, max_packet_size);
309
* Copy all handshake information from one connection into another.
311
void copy_handshake(drizzle_con_st *source)
313
drizzle_con_copy_handshake($self, source);