~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to libdrizzle-1.0/structs.h

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
2
 *
 
3
 * Drizzle Client & Protocol Library
 
4
 *
 
5
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
 
6
 * All rights reserved.
 
7
 *
 
8
 * Redistribution and use in source and binary forms, with or without
 
9
 * modification, are permitted provided that the following conditions are
 
10
 * met:
 
11
 *
 
12
 *     * Redistributions of source code must retain the above copyright
 
13
 * notice, this list of conditions and the following disclaimer.
 
14
 *
 
15
 *     * Redistributions in binary form must reproduce the above
 
16
 * copyright notice, this list of conditions and the following disclaimer
 
17
 * in the documentation and/or other materials provided with the
 
18
 * distribution.
 
19
 *
 
20
 *     * The names of its contributors may not be used to endorse or
 
21
 * promote products derived from this software without specific prior
 
22
 * written permission.
 
23
 *
 
24
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
25
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
26
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
27
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
28
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
29
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
30
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
31
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
32
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
33
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
34
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
35
 *
 
36
 */
 
37
 
 
38
/**
 
39
 * @file
 
40
 * @brief Struct Definitions
 
41
 */
 
42
 
 
43
#pragma once
 
44
 
 
45
#include <sys/types.h>
 
46
 
 
47
#ifdef NI_MAXHOST
 
48
# define LIBDRIZZLE_NI_MAXHOST NI_MAXHOST
 
49
#else
 
50
# define LIBDRIZZLE_NI_MAXHOST 1025
 
51
#endif
 
52
 
 
53
#ifdef __cplusplus
 
54
#include <cstddef>
 
55
#endif
 
56
 
 
57
#ifdef __cplusplus
 
58
extern "C" {
 
59
#endif
 
60
 
 
61
/**
 
62
 * @ingroup drizzle
 
63
 */
 
64
struct drizzle_st
 
65
{
 
66
  uint16_t error_code;
 
67
  int options;
 
68
  drizzle_verbose_t verbose;
 
69
  uint32_t con_count;
 
70
  uint32_t pfds_size;
 
71
  uint32_t query_count;
 
72
  uint32_t query_new;
 
73
  uint32_t query_running;
 
74
  int last_errno;
 
75
  int timeout;
 
76
  drizzle_con_st *con_list;
 
77
  void *context;
 
78
  drizzle_context_free_fn *context_free_fn;
 
79
  drizzle_event_watch_fn *event_watch_fn;
 
80
  void *event_watch_context;
 
81
  drizzle_log_fn *log_fn;
 
82
  void *log_context;
 
83
  struct pollfd *pfds;
 
84
  drizzle_query_st *query_list;
 
85
  char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];
 
86
  char last_error[DRIZZLE_MAX_ERROR_SIZE];
 
87
};
 
88
 
 
89
/**
 
90
 * @ingroup drizzle_con
 
91
 */
 
92
struct drizzle_con_tcp_st
 
93
{
 
94
  in_port_t port;
 
95
  struct addrinfo *addrinfo;
 
96
  char *host;
 
97
  char host_buffer[LIBDRIZZLE_NI_MAXHOST];
 
98
};
 
99
 
 
100
/**
 
101
 * @ingroup drizzle_con
 
102
 */
 
103
struct drizzle_con_uds_st
 
104
{
 
105
  char path_buffer[LIBDRIZZLE_NI_MAXHOST];
 
106
};
 
107
 
 
108
/**
 
109
 * @ingroup drizzle_con
 
110
 */
 
111
struct drizzle_con_st
 
112
{
 
113
  uint8_t packet_number;
 
114
  uint8_t protocol_version;
 
115
  uint8_t state_current;
 
116
  short events;
 
117
  short revents;
 
118
  int capabilities;
 
119
  drizzle_charset_t charset;
 
120
  drizzle_command_t command;
 
121
  int options;
 
122
  drizzle_con_socket_t socket_type;
 
123
  drizzle_con_status_t status;
 
124
  uint32_t max_packet_size;
 
125
  uint32_t result_count;
 
126
  uint32_t thread_id;
 
127
  int backlog;
 
128
  int fd;
 
129
  size_t buffer_size;
 
130
  size_t command_offset;
 
131
  size_t command_size;
 
132
  size_t command_total;
 
133
  size_t packet_size;
 
134
  struct addrinfo *addrinfo_next;
 
135
  uint8_t *buffer_ptr;
 
136
  uint8_t *command_buffer;
 
137
  uint8_t *command_data;
 
138
  void *context;
 
139
  drizzle_con_context_free_fn *context_free_fn;
 
140
  drizzle_st *drizzle;
 
141
  drizzle_con_st *next;
 
142
  drizzle_con_st *prev;
 
143
  drizzle_query_st *query;
 
144
  drizzle_result_st *result;
 
145
  drizzle_result_st *result_list;
 
146
  uint8_t *scramble;
 
147
  union
 
148
  {
 
149
    drizzle_con_tcp_st tcp;
 
150
    drizzle_con_uds_st uds;
 
151
  } socket;
 
152
  uint8_t buffer[DRIZZLE_MAX_BUFFER_SIZE];
 
153
  char db[DRIZZLE_MAX_DB_SIZE];
 
154
  char password[DRIZZLE_MAX_PASSWORD_SIZE];
 
155
  uint8_t scramble_buffer[DRIZZLE_MAX_SCRAMBLE_SIZE];
 
156
  char server_version[DRIZZLE_MAX_SERVER_VERSION_SIZE];
 
157
  char server_extra[DRIZZLE_MAX_SERVER_EXTRA_SIZE];
 
158
  drizzle_state_fn *state_stack[DRIZZLE_STATE_STACK_SIZE];
 
159
  char user[DRIZZLE_MAX_USER_SIZE];
 
160
};
 
161
 
 
162
/**
 
163
 * @ingroup drizzle_query
 
164
 */
 
165
struct drizzle_query_st
 
166
{
 
167
  drizzle_st *drizzle;
 
168
  drizzle_query_st *next;
 
169
  drizzle_query_st *prev;
 
170
  int options;
 
171
  drizzle_query_state_t state;
 
172
  drizzle_con_st *con;
 
173
  drizzle_result_st *result;
 
174
  const char *string;
 
175
  size_t size;
 
176
  void *context;
 
177
  drizzle_query_context_free_fn *context_free_fn;
 
178
 
 
179
#ifdef __cplusplus
 
180
 
 
181
  drizzle_query_st() :
 
182
    drizzle(NULL),
 
183
    next(NULL),
 
184
    prev(NULL),
 
185
    options(0),
 
186
    state(DRIZZLE_QUERY_STATE_INIT),
 
187
    con(NULL),
 
188
    result(NULL),
 
189
    string(NULL),
 
190
    size(0),
 
191
    context(NULL),
 
192
    context_free_fn(NULL)
 
193
  { 
 
194
  }
 
195
 
 
196
#endif
 
197
};
 
198
 
 
199
/**
 
200
 * @ingroup drizzle_result
 
201
 */
 
202
struct drizzle_result_st
 
203
{
 
204
  drizzle_con_st *con;
 
205
  drizzle_result_st *next;
 
206
  drizzle_result_st *prev;
 
207
  int options;
 
208
 
 
209
  char info[DRIZZLE_MAX_INFO_SIZE];
 
210
  uint16_t error_code;
 
211
  char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];
 
212
  uint64_t insert_id;
 
213
  uint16_t warning_count;
 
214
  uint64_t affected_rows;
 
215
 
 
216
  uint16_t column_count;
 
217
  uint16_t column_current;
 
218
  drizzle_column_st *column_list;
 
219
  drizzle_column_st *column;
 
220
  drizzle_column_st *column_buffer;
 
221
 
 
222
  uint64_t row_count;
 
223
  uint64_t row_current;
 
224
 
 
225
  uint16_t field_current;
 
226
  size_t field_total;
 
227
  size_t field_offset;
 
228
  size_t field_size;
 
229
  drizzle_field_t field;
 
230
  drizzle_field_t field_buffer;
 
231
 
 
232
  uint64_t row_list_size;
 
233
  drizzle_row_t row;
 
234
  drizzle_row_t *row_list;
 
235
  size_t *field_sizes;
 
236
  size_t **field_sizes_list;
 
237
 
 
238
#ifdef __cplusplus
 
239
 
 
240
  drizzle_result_st() :
 
241
    con(NULL),
 
242
    next(NULL),
 
243
    prev(NULL),
 
244
    options(0),
 
245
    error_code(0),
 
246
    insert_id(0),
 
247
    warning_count(0),
 
248
    affected_rows(0),
 
249
    column_count(0),
 
250
    column_current(0),
 
251
    column_list(NULL),
 
252
    column(NULL),
 
253
    column_buffer(NULL),
 
254
    row_count(0),
 
255
    row_current(0),
 
256
    field_current(0),
 
257
    field_total(0),
 
258
    field_offset(0),
 
259
    field_size(0),
 
260
    field(),
 
261
    field_buffer(),
 
262
    row_list_size(0),
 
263
    row(),
 
264
    row_list(NULL),
 
265
    field_sizes(NULL),
 
266
    field_sizes_list(NULL)
 
267
  {
 
268
    info[0]= 0;
 
269
    sqlstate[0]= 0;
 
270
  }
 
271
 
 
272
#endif
 
273
};
 
274
 
 
275
/**
 
276
 * @ingroup drizzle_column
 
277
 */
 
278
struct drizzle_column_st
 
279
{
 
280
  drizzle_result_st *result;
 
281
  drizzle_column_st *next;
 
282
  drizzle_column_st *prev;
 
283
  int options;
 
284
  char catalog[DRIZZLE_MAX_CATALOG_SIZE];
 
285
  char db[DRIZZLE_MAX_DB_SIZE];
 
286
  char table[DRIZZLE_MAX_TABLE_SIZE];
 
287
  char orig_table[DRIZZLE_MAX_TABLE_SIZE];
 
288
  char name[DRIZZLE_MAX_COLUMN_NAME_SIZE];
 
289
  char orig_name[DRIZZLE_MAX_COLUMN_NAME_SIZE];
 
290
  drizzle_charset_t charset;
 
291
  uint32_t size;
 
292
  size_t max_size;
 
293
  drizzle_column_type_t type;
 
294
  int flags;
 
295
  uint8_t decimals;
 
296
  uint8_t default_value[DRIZZLE_MAX_DEFAULT_VALUE_SIZE];
 
297
  size_t default_value_size;
 
298
};
 
299
 
 
300
#ifdef __cplusplus
 
301
}
 
302
#endif