~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/structs.h

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Drizzle Client & Protocol Library
3
 
 *
4
 
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
5
 
 * All rights reserved.
6
 
 *
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
 
 *
35
 
 */
36
 
 
37
 
/**
38
 
 * @file
39
 
 * @brief Struct Definitions
40
 
 */
41
 
 
42
 
#ifndef __DRIZZLE_STRUCTS_H
43
 
#define __DRIZZLE_STRUCTS_H
44
 
 
45
 
#include <sys/types.h>
46
 
#include <sys/socket.h>
47
 
#include <netdb.h>
48
 
#ifndef NI_MAXHOST
49
 
# define NI_MAXHOST 1025
50
 
#endif
51
 
 
52
 
#ifdef __cplusplus
53
 
extern "C" {
54
 
#endif
55
 
 
56
 
/**
57
 
 * @ingroup drizzle
58
 
 */
59
 
struct drizzle_st
60
 
{
61
 
  uint16_t error_code;
62
 
  drizzle_options_t options;
63
 
  drizzle_verbose_t verbose;
64
 
  uint32_t con_count;
65
 
  uint32_t pfds_size;
66
 
  uint32_t query_count;
67
 
  uint32_t query_new;
68
 
  uint32_t query_running;
69
 
  int last_errno;
70
 
  int timeout;
71
 
  drizzle_con_st *con_list;
72
 
  void *context;
73
 
  drizzle_context_free_fn *context_free_fn;
74
 
  drizzle_event_watch_fn *event_watch_fn;
75
 
  void *event_watch_context;
76
 
  drizzle_log_fn *log_fn;
77
 
  void *log_context;
78
 
  struct pollfd *pfds;
79
 
  drizzle_query_st *query_list;
80
 
  char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];
81
 
  char last_error[DRIZZLE_MAX_ERROR_SIZE];
82
 
};
83
 
 
84
 
/**
85
 
 * @ingroup drizzle_con
86
 
 */
87
 
struct drizzle_con_tcp_st
88
 
{
89
 
  in_port_t port;
90
 
  struct addrinfo *addrinfo;
91
 
  char *host;
92
 
  char host_buffer[NI_MAXHOST];
93
 
};
94
 
 
95
 
/**
96
 
 * @ingroup drizzle_con
97
 
 */
98
 
struct drizzle_con_uds_st
99
 
{
100
 
  struct addrinfo addrinfo;
101
 
  struct sockaddr_un sockaddr;
102
 
};
103
 
 
104
 
/**
105
 
 * @ingroup drizzle_con
106
 
 */
107
 
struct drizzle_con_st
108
 
{
109
 
  uint8_t packet_number;
110
 
  uint8_t protocol_version;
111
 
  uint8_t state_current;
112
 
  short events;
113
 
  short revents;
114
 
  drizzle_capabilities_t capabilities;
115
 
  drizzle_charset_t charset;
116
 
  drizzle_command_t command;
117
 
  drizzle_con_options_t options;
118
 
  drizzle_con_socket_t socket_type;
119
 
  drizzle_con_status_t status;
120
 
  uint32_t max_packet_size;
121
 
  uint32_t result_count;
122
 
  uint32_t thread_id;
123
 
  int backlog;
124
 
  int fd;
125
 
  size_t buffer_size;
126
 
  size_t command_offset;
127
 
  size_t command_size;
128
 
  size_t command_total;
129
 
  size_t packet_size;
130
 
  struct addrinfo *addrinfo_next;
131
 
  uint8_t *buffer_ptr;
132
 
  uint8_t *command_buffer;
133
 
  uint8_t *command_data;
134
 
  void *context;
135
 
  drizzle_con_context_free_fn *context_free_fn;
136
 
  drizzle_st *drizzle;
137
 
  drizzle_con_st *next;
138
 
  drizzle_con_st *prev;
139
 
  drizzle_query_st *query;
140
 
  drizzle_result_st *result;
141
 
  drizzle_result_st *result_list;
142
 
  uint8_t *scramble;
143
 
  union
144
 
  {
145
 
    drizzle_con_tcp_st tcp;
146
 
    drizzle_con_uds_st uds;
147
 
  } socket;
148
 
  uint8_t buffer[DRIZZLE_MAX_BUFFER_SIZE];
149
 
  char db[DRIZZLE_MAX_DB_SIZE];
150
 
  char password[DRIZZLE_MAX_PASSWORD_SIZE];
151
 
  uint8_t scramble_buffer[DRIZZLE_MAX_SCRAMBLE_SIZE];
152
 
  char server_version[DRIZZLE_MAX_SERVER_VERSION_SIZE];
153
 
  char server_extra[DRIZZLE_MAX_SERVER_EXTRA_SIZE];
154
 
  drizzle_state_fn *state_stack[DRIZZLE_STATE_STACK_SIZE];
155
 
  char user[DRIZZLE_MAX_USER_SIZE];
156
 
};
157
 
 
158
 
/**
159
 
 * @ingroup drizzle_query
160
 
 */
161
 
struct drizzle_query_st
162
 
{
163
 
  drizzle_st *drizzle;
164
 
  drizzle_query_st *next;
165
 
  drizzle_query_st *prev;
166
 
  drizzle_query_options_t options;
167
 
  drizzle_query_state_t state;
168
 
  drizzle_con_st *con;
169
 
  drizzle_result_st *result;
170
 
  const char *string;
171
 
  size_t size;
172
 
  void *context;
173
 
  drizzle_query_context_free_fn *context_free_fn;
174
 
};
175
 
 
176
 
/**
177
 
 * @ingroup drizzle_result
178
 
 */
179
 
struct drizzle_result_st
180
 
{
181
 
  drizzle_con_st *con;
182
 
  drizzle_result_st *next;
183
 
  drizzle_result_st *prev;
184
 
  drizzle_result_options_t options;
185
 
 
186
 
  char info[DRIZZLE_MAX_INFO_SIZE];
187
 
  uint16_t error_code;
188
 
  char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];
189
 
  uint64_t insert_id;
190
 
  uint16_t warning_count;
191
 
  uint64_t affected_rows;
192
 
 
193
 
  uint16_t column_count;
194
 
  uint16_t column_current;
195
 
  drizzle_column_st *column_list;
196
 
  drizzle_column_st *column;
197
 
  drizzle_column_st *column_buffer;
198
 
 
199
 
  uint64_t row_count;
200
 
  uint64_t row_current;
201
 
 
202
 
  uint16_t field_current;
203
 
  size_t field_total;
204
 
  size_t field_offset;
205
 
  size_t field_size;
206
 
  drizzle_field_t field;
207
 
  drizzle_field_t field_buffer;
208
 
 
209
 
  uint64_t row_list_size;
210
 
  drizzle_row_t row;
211
 
  drizzle_row_t *row_list;
212
 
  size_t *field_sizes;
213
 
  size_t **field_sizes_list;
214
 
};
215
 
 
216
 
/**
217
 
 * @ingroup drizzle_column
218
 
 */
219
 
struct drizzle_column_st
220
 
{
221
 
  drizzle_result_st *result;
222
 
  drizzle_column_st *next;
223
 
  drizzle_column_st *prev;
224
 
  drizzle_column_options_t options;
225
 
  char catalog[DRIZZLE_MAX_CATALOG_SIZE];
226
 
  char db[DRIZZLE_MAX_DB_SIZE];
227
 
  char table[DRIZZLE_MAX_TABLE_SIZE];
228
 
  char orig_table[DRIZZLE_MAX_TABLE_SIZE];
229
 
  char name[DRIZZLE_MAX_COLUMN_NAME_SIZE];
230
 
  char orig_name[DRIZZLE_MAX_COLUMN_NAME_SIZE];
231
 
  drizzle_charset_t charset;
232
 
  uint32_t size;
233
 
  size_t max_size;
234
 
  drizzle_column_type_t type;
235
 
  drizzle_column_flags_t flags;
236
 
  uint8_t decimals;
237
 
  uint8_t default_value[DRIZZLE_MAX_DEFAULT_VALUE_SIZE];
238
 
  size_t default_value_size;
239
 
};
240
 
 
241
 
#ifdef __cplusplus
242
 
}
243
 
#endif
244
 
 
245
 
#endif /* __DRIZZLE_STRUCTS_H */