~drizzle-trunk/drizzle/development

2472.1.4 by Brian Aker
Remove memset in case where we are using new()
1
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2
 *
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
3
 * Drizzle Client & Protocol Library
4
 *
5
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
6
 * All rights reserved.
7
 *
1971.2.1 by kalebral at gmail
update files that did not have license or had incorrect license structure
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
 *
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
36
 */
37
38
/**
39
 * @file
40
 * @brief Struct Definitions
41
 */
42
2464.1.2 by Brian Aker
Fix compiling issues for 1.0, and cleanup header files.
43
#pragma once
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
44
1722.1.1 by Monty Taylor
Fixed intel compiler issues.
45
#include <sys/types.h>
2164.1.3 by Monty Taylor
Merged in various amounts of win32 fixes. Now is quite happy in vs10.
46
2478.1.2 by Brian Aker
Fix race condition in bison build, also fix NULL issue on FreeBSD.
47
#ifdef NI_MAXHOST
48
# define LIBDRIZZLE_NI_MAXHOST NI_MAXHOST
49
#else
50
# define LIBDRIZZLE_NI_MAXHOST 1025
1722.1.1 by Monty Taylor
Fixed intel compiler issues.
51
#endif
1720.1.7 by Monty Taylor
Fixed the ICC missing header and the new config.h foo.
52
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
53
#ifdef __cplusplus
2478.1.3 by Brian Aker
Include stddef in the include file.
54
#include <cstddef>
55
#endif
56
57
#ifdef __cplusplus
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
58
extern "C" {
59
#endif
60
61
/**
62
 * @ingroup drizzle
63
 */
64
struct drizzle_st
65
{
66
  uint16_t error_code;
2464.1.2 by Brian Aker
Fix compiling issues for 1.0, and cleanup header files.
67
  int options;
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
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[NI_MAXHOST];
98
};
99
100
/**
101
 * @ingroup drizzle_con
102
 */
103
struct drizzle_con_uds_st
104
{
105
  struct addrinfo addrinfo;
106
  struct sockaddr_un sockaddr;
107
};
108
109
/**
110
 * @ingroup drizzle_con
111
 */
112
struct drizzle_con_st
113
{
114
  uint8_t packet_number;
115
  uint8_t protocol_version;
116
  uint8_t state_current;
117
  short events;
118
  short revents;
2464.1.2 by Brian Aker
Fix compiling issues for 1.0, and cleanup header files.
119
  int capabilities;
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
120
  drizzle_charset_t charset;
121
  drizzle_command_t command;
2464.1.2 by Brian Aker
Fix compiling issues for 1.0, and cleanup header files.
122
  int options;
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
123
  drizzle_con_socket_t socket_type;
124
  drizzle_con_status_t status;
125
  uint32_t max_packet_size;
126
  uint32_t result_count;
127
  uint32_t thread_id;
128
  int backlog;
129
  int fd;
130
  size_t buffer_size;
131
  size_t command_offset;
132
  size_t command_size;
133
  size_t command_total;
134
  size_t packet_size;
135
  struct addrinfo *addrinfo_next;
136
  uint8_t *buffer_ptr;
137
  uint8_t *command_buffer;
138
  uint8_t *command_data;
139
  void *context;
140
  drizzle_con_context_free_fn *context_free_fn;
141
  drizzle_st *drizzle;
142
  drizzle_con_st *next;
143
  drizzle_con_st *prev;
144
  drizzle_query_st *query;
145
  drizzle_result_st *result;
146
  drizzle_result_st *result_list;
147
  uint8_t *scramble;
148
  union
149
  {
150
    drizzle_con_tcp_st tcp;
151
    drizzle_con_uds_st uds;
152
  } socket;
153
  uint8_t buffer[DRIZZLE_MAX_BUFFER_SIZE];
154
  char db[DRIZZLE_MAX_DB_SIZE];
155
  char password[DRIZZLE_MAX_PASSWORD_SIZE];
156
  uint8_t scramble_buffer[DRIZZLE_MAX_SCRAMBLE_SIZE];
157
  char server_version[DRIZZLE_MAX_SERVER_VERSION_SIZE];
1939.2.1 by Evan Jones
Adds protocol support for MySQL 5.5.7
158
  char server_extra[DRIZZLE_MAX_SERVER_EXTRA_SIZE];
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
159
  drizzle_state_fn *state_stack[DRIZZLE_STATE_STACK_SIZE];
160
  char user[DRIZZLE_MAX_USER_SIZE];
161
};
162
163
/**
164
 * @ingroup drizzle_query
165
 */
166
struct drizzle_query_st
167
{
168
  drizzle_st *drizzle;
169
  drizzle_query_st *next;
170
  drizzle_query_st *prev;
2464.1.2 by Brian Aker
Fix compiling issues for 1.0, and cleanup header files.
171
  int options;
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
172
  drizzle_query_state_t state;
173
  drizzle_con_st *con;
174
  drizzle_result_st *result;
175
  const char *string;
176
  size_t size;
177
  void *context;
178
  drizzle_query_context_free_fn *context_free_fn;
2472.1.5 by Brian Aker
Use constructors where we can.
179
180
#ifdef __cplusplus
181
182
  drizzle_query_st() :
183
    drizzle(NULL),
184
    next(NULL),
185
    prev(NULL),
186
    options(0),
187
    state(DRIZZLE_QUERY_STATE_INIT),
188
    con(NULL),
189
    result(NULL),
190
    string(NULL),
191
    size(0),
192
    context(NULL),
193
    context_free_fn(NULL)
194
  { 
195
  }
196
197
#endif
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
198
};
199
200
/**
201
 * @ingroup drizzle_result
202
 */
203
struct drizzle_result_st
204
{
205
  drizzle_con_st *con;
206
  drizzle_result_st *next;
207
  drizzle_result_st *prev;
2464.1.2 by Brian Aker
Fix compiling issues for 1.0, and cleanup header files.
208
  int options;
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
209
210
  char info[DRIZZLE_MAX_INFO_SIZE];
211
  uint16_t error_code;
212
  char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];
213
  uint64_t insert_id;
214
  uint16_t warning_count;
215
  uint64_t affected_rows;
216
217
  uint16_t column_count;
218
  uint16_t column_current;
219
  drizzle_column_st *column_list;
220
  drizzle_column_st *column;
221
  drizzle_column_st *column_buffer;
222
223
  uint64_t row_count;
224
  uint64_t row_current;
225
226
  uint16_t field_current;
227
  size_t field_total;
228
  size_t field_offset;
229
  size_t field_size;
230
  drizzle_field_t field;
231
  drizzle_field_t field_buffer;
232
233
  uint64_t row_list_size;
234
  drizzle_row_t row;
235
  drizzle_row_t *row_list;
236
  size_t *field_sizes;
237
  size_t **field_sizes_list;
2472.1.4 by Brian Aker
Remove memset in case where we are using new()
238
239
#ifdef __cplusplus
2472.1.5 by Brian Aker
Use constructors where we can.
240
2472.1.4 by Brian Aker
Remove memset in case where we are using new()
241
  drizzle_result_st() :
242
    con(NULL),
243
    next(NULL),
244
    prev(NULL),
245
    options(0),
246
    error_code(0),
247
    insert_id(0),
248
    warning_count(0),
249
    affected_rows(0),
250
    column_count(0),
251
    column_current(0),
252
    column_list(NULL),
253
    column(NULL),
254
    column_buffer(NULL),
255
    row_count(0),
256
    row_current(0),
257
    field_current(0),
258
    field_total(0),
259
    field_offset(0),
260
    field_size(0),
261
    field(),
262
    field_buffer(),
263
    row_list_size(0),
264
    row(),
265
    row_list(NULL),
266
    field_sizes(NULL),
267
    field_sizes_list(NULL)
268
  {
2472.1.5 by Brian Aker
Use constructors where we can.
269
    info[0]= 0;
270
    sqlstate[0]= 0;
2472.1.4 by Brian Aker
Remove memset in case where we are using new()
271
  }
2472.1.5 by Brian Aker
Use constructors where we can.
272
2472.1.4 by Brian Aker
Remove memset in case where we are using new()
273
#endif
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
274
};
275
276
/**
277
 * @ingroup drizzle_column
278
 */
279
struct drizzle_column_st
280
{
281
  drizzle_result_st *result;
282
  drizzle_column_st *next;
283
  drizzle_column_st *prev;
2464.1.2 by Brian Aker
Fix compiling issues for 1.0, and cleanup header files.
284
  int options;
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
285
  char catalog[DRIZZLE_MAX_CATALOG_SIZE];
286
  char db[DRIZZLE_MAX_DB_SIZE];
287
  char table[DRIZZLE_MAX_TABLE_SIZE];
288
  char orig_table[DRIZZLE_MAX_TABLE_SIZE];
289
  char name[DRIZZLE_MAX_COLUMN_NAME_SIZE];
290
  char orig_name[DRIZZLE_MAX_COLUMN_NAME_SIZE];
291
  drizzle_charset_t charset;
292
  uint32_t size;
293
  size_t max_size;
294
  drizzle_column_type_t type;
2464.1.2 by Brian Aker
Fix compiling issues for 1.0, and cleanup header files.
295
  int flags;
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
296
  uint8_t decimals;
297
  uint8_t default_value[DRIZZLE_MAX_DEFAULT_VALUE_SIZE];
298
  size_t default_value_size;
299
};
300
301
#ifdef __cplusplus
302
}
303
#endif