~ubuntu-branches/ubuntu/oneiric/python-drizzle/oneiric

« back to all changes in this revision

Viewing changes to interface/libdrizzle/connection.i

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-12-13 11:24:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101213112447-9ot4jxlzf0nlsbiy
Tags: 1.0-1
* New upstream release. (LP: #689339)
* Expand pyversions to include 2.7. (Closes: #606883)
* Updated standards version to 3.9.1.
* Added VCS information.
* Removed outdated reference to BSD common license for lintian.
* Updating packaging approach (Thanks Stefano Rivera)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 * drizzle-interface: Interface Wrappers for Drizzle
 
5
 * Copyright (c) 2009 Sun Microsystems
 
6
 * Copyright (c) 2010 Monty Taylor and Max Goodman
 
7
 * All rights reserved.
 
8
 *
 
9
 * Redistribution and use in source and binary forms, with or without
 
10
 * modification, are permitted provided that the following conditions are met:
 
11
 *
 
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.
 
19
 *
 
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.
 
31
 */
 
32
 
 
33
typedef struct drizzle_con_st {} Connection;
 
34
 
 
35
%extend Connection {
 
36
 
 
37
  /* Set options for a connection. */
 
38
  unicode host()
 
39
  {
 
40
    return drizzle_con_host($self);
 
41
  }
 
42
 
 
43
  in_port_t port()
 
44
  {
 
45
    return drizzle_con_port($self);
 
46
  }
 
47
 
 
48
  void set_tcp(char *host, in_port_t port)
 
49
  {
 
50
    drizzle_con_set_tcp($self, host, port);
 
51
  }
 
52
 
 
53
  unicode uds()
 
54
  {
 
55
    return drizzle_con_uds($self);
 
56
  }
 
57
 
 
58
  void set_uds(const char *uds)
 
59
  {
 
60
    drizzle_con_set_uds($self, uds);
 
61
  }
 
62
 
 
63
  unicode user()
 
64
  {
 
65
    return drizzle_con_user($self);
 
66
  }
 
67
 
 
68
  unicode password()
 
69
  {
 
70
    return drizzle_con_password($self);
 
71
  }
 
72
 
 
73
  void set_auth(const char *user, const char *password)
 
74
  {
 
75
    drizzle_con_set_auth($self, user, password);
 
76
  }
 
77
 
 
78
  unicode db()
 
79
  {
 
80
    return drizzle_con_db($self);
 
81
  }
 
82
 
 
83
  void set_db(char *db)
 
84
  {
 
85
    drizzle_con_set_db($self, db);
 
86
  }
 
87
 
 
88
  drizzle_con_options_t options()
 
89
  {
 
90
    return drizzle_con_options($self);
 
91
  }
 
92
  
 
93
  void set_options(drizzle_con_options_t options)
 
94
  {
 
95
    drizzle_con_set_options($self, options);
 
96
  }
 
97
 
 
98
  void add_options(drizzle_con_options_t options)
 
99
  {
 
100
    drizzle_con_add_options($self, options);
 
101
  }
 
102
 
 
103
  void remove_options(drizzle_con_options_t options)
 
104
  {
 
105
    drizzle_con_remove_options($self, options);
 
106
  }
 
107
 
 
108
  /* Connect to server. */
 
109
  drizzle_return_t connect()
 
110
  {
 
111
    return drizzle_con_connect($self);
 
112
  }
 
113
 
 
114
  /* Close a connection. */
 
115
  void close()
 
116
  {
 
117
    drizzle_con_close($self);
 
118
  }
 
119
 
 
120
  /* Get information on connection. */
 
121
  uint8_t protocol_version()
 
122
  {
 
123
    return drizzle_con_protocol_version($self);
 
124
  }
 
125
 
 
126
  unicode server_version()
 
127
  {
 
128
    return drizzle_con_server_version($self);
 
129
  }
 
130
 
 
131
  uint32_t server_version_number()
 
132
  {
 
133
    return drizzle_con_server_version_number($self);
 
134
  }
 
135
 
 
136
  uint32_t thread_id()
 
137
  {
 
138
    return drizzle_con_thread_id($self);
 
139
  }
 
140
 
 
141
  const uint8_t *scramble()
 
142
  {
 
143
    return drizzle_con_scramble($self);
 
144
  }
 
145
 
 
146
  drizzle_capabilities_t capabilities()
 
147
  {
 
148
    return drizzle_con_capabilities($self);
 
149
  }
 
150
 
 
151
  drizzle_charset_t charset()
 
152
  {
 
153
    return drizzle_con_charset($self);
 
154
  }
 
155
 
 
156
  drizzle_con_status_t status()
 
157
  {
 
158
    return drizzle_con_status($self);
 
159
  }
 
160
 
 
161
  uint32_t max_packet_size()
 
162
  {
 
163
    return drizzle_con_max_packet_size($self);
 
164
  }
 
165
 
 
166
 
 
167
  %exception {
 
168
    $action
 
169
    if (check_drizzle_return(drizzle_return_value, arg1) == false) {
 
170
      SWIG_fail;
 
171
    }
 
172
  }
 
173
 
 
174
  /**
 
175
   * Send query to server.
 
176
   */
 
177
  Result *query(const char *query, size_t size,
 
178
                drizzle_return_t *drizzle_return_value)
 
179
  {
 
180
    return drizzle_query($self, NULL, query, size, drizzle_return_value);
 
181
  }
 
182
 
 
183
 
 
184
  /* Send query incrementally. */
 
185
  Result *query_incremental(const char *query, size_t size,
 
186
                            size_t total,
 
187
                            drizzle_return_t *drizzle_return_value)
 
188
  {
 
189
    return drizzle_query_inc($self, NULL, query, size, total,
 
190
                             drizzle_return_value);
 
191
  }
 
192
 
 
193
  /* Send other requests to server. */
 
194
  Result *quit(drizzle_return_t *drizzle_return_value)
 
195
  {
 
196
    return drizzle_quit($self, NULL, drizzle_return_value);
 
197
  }
 
198
 
 
199
  Result *select_db(char *db, drizzle_return_t *drizzle_return_value)
 
200
  {
 
201
    return drizzle_select_db($self, NULL, db, drizzle_return_value);
 
202
  }
 
203
 
 
204
  Result *shutdown(uint32_t level, drizzle_return_t *drizzle_return_value)
 
205
  {
 
206
    return drizzle_shutdown($self, NULL, level, drizzle_return_value);
 
207
  }
 
208
 
 
209
  Result *ping(drizzle_return_t *drizzle_return_value)
 
210
  {
 
211
    return drizzle_con_ping($self, NULL, drizzle_return_value);
 
212
  }
 
213
 
 
214
  Result *result_read(drizzle_return_t *drizzle_return_value,
 
215
                      drizzle_result_st *to=NULL)
 
216
  {
 
217
    return drizzle_result_read($self, to, drizzle_return_value);
 
218
  }
 
219
 
 
220
  Result *write(drizzle_command_t command, const uint8_t *data, size_t size,
 
221
                size_t total, drizzle_return_t *drizzle_return_value)
 
222
  {
 
223
    return drizzle_con_command_write($self, NULL, command, data,
 
224
                                 size, total, drizzle_return_value);
 
225
  }
 
226
 
 
227
  %noexception;
 
228
 
 
229
  Result *result_create(drizzle_result_st *to=NULL)
 
230
  {
 
231
    return drizzle_result_create($self, to);
 
232
  }
 
233
 
 
234
  Result *result_clone(drizzle_result_st *clone_from)
 
235
  {
 
236
    return drizzle_result_clone($self, NULL, clone_from);
 
237
  }
 
238
 
 
239
  drizzle_return_t result_write(drizzle_result_st *to, bool flush)
 
240
  {
 
241
    return drizzle_result_write($self, to, flush);
 
242
  }
 
243
 
 
244
  /**
 
245
   * Set protocol version for a connection.
 
246
   */
 
247
  void set_protocol_version(uint8_t protocol_version)
 
248
  {
 
249
    drizzle_con_set_protocol_version($self, protocol_version);
 
250
  }
 
251
 
 
252
  /**
 
253
   * Set server version string for a connection.
 
254
   */
 
255
  void set_server_version(const char *server_version)
 
256
  {
 
257
    drizzle_con_set_server_version($self, server_version);
 
258
  }
 
259
 
 
260
  /**
 
261
   * Set thread ID for a connection.
 
262
   */
 
263
  void set_thread_id(uint32_t thread_id)
 
264
  {
 
265
    drizzle_con_set_thread_id($self, thread_id);
 
266
  }
 
267
 
 
268
  /**
 
269
   * Set scramble buffer for a connection.
 
270
   */
 
271
  void set_scramble(const uint8_t *scramble)
 
272
  {
 
273
    drizzle_con_set_scramble($self, scramble);
 
274
  }
 
275
 
 
276
  /**
 
277
   * Set capabilities for a connection.
 
278
   */
 
279
  void set_capabilities(drizzle_capabilities_t capabilities)
 
280
  {
 
281
    drizzle_con_set_capabilities($self, capabilities);
 
282
  }
 
283
 
 
284
  /**
 
285
   * Set charset for a connection.
 
286
   */
 
287
  void set_charset(drizzle_charset_t charset)
 
288
  {
 
289
    drizzle_con_set_charset($self, charset);
 
290
  }
 
291
 
 
292
  /**
 
293
   * Set status for a connection.
 
294
   */
 
295
  void set_status(drizzle_con_status_t status)
 
296
  {
 
297
    drizzle_con_set_status($self, status);
 
298
  }
 
299
 
 
300
  /**
 
301
   * Set max packet size for a connection.
 
302
   */
 
303
  void set_max_packet_size(uint32_t max_packet_size)
 
304
  {
 
305
    drizzle_con_set_max_packet_size($self, max_packet_size);
 
306
  }
 
307
 
 
308
  /**
 
309
   * Copy all handshake information from one connection into another.
 
310
   */
 
311
  void copy_handshake(drizzle_con_st *source)
 
312
  {
 
313
    drizzle_con_copy_handshake($self, source);
 
314
  }
 
315
 
 
316
}