~drizzle-trunk/drizzle/development

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