~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/constants.h

  • Committer: Monty Taylor
  • Date: 2010-08-12 20:27:32 UTC
  • mto: (1720.1.5 build)
  • mto: This revision was merged to the branch mainline in revision 1722.
  • Revision ID: mordred@inaugust.com-20100812202732-9kzchbkvkyki4n3u
Merged libdrizzle directly into tree.

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
 * Use and distribution licensed under the BSD license.  See
 
8
 * the COPYING file in this directory for full text.
 
9
 */
 
10
 
 
11
/**
 
12
 * @file
 
13
 * @brief Defines, typedefs, enums, and macros
 
14
 */
 
15
 
 
16
#ifndef __DRIZZLE_CONSTANTS_H
 
17
#define __DRIZZLE_CONSTANTS_H
 
18
 
 
19
#ifdef __cplusplus
 
20
extern "C" {
 
21
#endif
 
22
 
 
23
/**
 
24
 * @addtogroup drizzle_constants Constants
 
25
 * @ingroup drizzle_client_interface
 
26
 * @ingroup drizzle_server_interface
 
27
 * @{
 
28
 */
 
29
 
 
30
/**
 
31
 * @todo Remove these with next major API change.
 
32
 */
 
33
#define DRIZZLE_RETURN_SERVER_GONE DRIZZLE_RETURN_LOST_CONNECTION
 
34
#define DRIZZLE_RETURN_EOF DRIZZLE_RETURN_LOST_CONNECTION
 
35
#define DRIZZLE_COLUMN_TYPE_VIRTUAL 17
 
36
 
 
37
/* Defines. */
 
38
#define DRIZZLE_DEFAULT_TCP_HOST         "127.0.0.1"
 
39
#define DRIZZLE_DEFAULT_TCP_PORT         4427
 
40
#define DRIZZLE_DEFAULT_TCP_PORT_MYSQL   3306
 
41
#define DRIZZLE_DEFAULT_UDS              "/tmp/drizzle.sock"
 
42
#define DRIZZLE_DEFAULT_UDS_MYSQL        "/tmp/mysql.sock"
 
43
#define DRIZZLE_DEFAULT_BACKLOG          64
 
44
#define DRIZZLE_MAX_ERROR_SIZE           2048
 
45
#define DRIZZLE_MAX_USER_SIZE            64
 
46
#define DRIZZLE_MAX_PASSWORD_SIZE        32
 
47
#define DRIZZLE_MAX_DB_SIZE              64
 
48
#define DRIZZLE_MAX_INFO_SIZE            2048
 
49
#define DRIZZLE_MAX_SQLSTATE_SIZE        5
 
50
#define DRIZZLE_MAX_CATALOG_SIZE         128
 
51
#define DRIZZLE_MAX_TABLE_SIZE           128
 
52
#define DRIZZLE_MAX_COLUMN_NAME_SIZE     2048
 
53
#define DRIZZLE_MAX_DEFAULT_VALUE_SIZE   2048
 
54
#define DRIZZLE_MAX_PACKET_SIZE          UINT32_MAX
 
55
#define DRIZZLE_MAX_BUFFER_SIZE          32768
 
56
#define DRIZZLE_BUFFER_COPY_THRESHOLD    8192
 
57
#define DRIZZLE_MAX_SERVER_VERSION_SIZE  32
 
58
#define DRIZZLE_MAX_SCRAMBLE_SIZE        20
 
59
#define DRIZZLE_STATE_STACK_SIZE         8
 
60
#define DRIZZLE_ROW_GROW_SIZE            8192
 
61
#define DRIZZLE_DEFAULT_SOCKET_TIMEOUT   10
 
62
#define DRIZZLE_DEFAULT_SOCKET_SEND_SIZE 32768
 
63
#define DRIZZLE_DEFAULT_SOCKET_RECV_SIZE 32768
 
64
#define DRIZZLE_MYSQL_PASSWORD_HASH      41
 
65
 
 
66
/**
 
67
 * Return codes.
 
68
 */
 
69
typedef enum
 
70
{
 
71
  DRIZZLE_RETURN_OK,
 
72
  DRIZZLE_RETURN_IO_WAIT,
 
73
  DRIZZLE_RETURN_PAUSE,
 
74
  DRIZZLE_RETURN_ROW_BREAK,
 
75
  DRIZZLE_RETURN_MEMORY,
 
76
  DRIZZLE_RETURN_ERRNO,
 
77
  DRIZZLE_RETURN_INTERNAL_ERROR,
 
78
  DRIZZLE_RETURN_GETADDRINFO,
 
79
  DRIZZLE_RETURN_NOT_READY,
 
80
  DRIZZLE_RETURN_BAD_PACKET_NUMBER,
 
81
  DRIZZLE_RETURN_BAD_HANDSHAKE_PACKET,
 
82
  DRIZZLE_RETURN_BAD_PACKET,
 
83
  DRIZZLE_RETURN_PROTOCOL_NOT_SUPPORTED,
 
84
  DRIZZLE_RETURN_UNEXPECTED_DATA,
 
85
  DRIZZLE_RETURN_NO_SCRAMBLE,
 
86
  DRIZZLE_RETURN_AUTH_FAILED,
 
87
  DRIZZLE_RETURN_NULL_SIZE,
 
88
  DRIZZLE_RETURN_ERROR_CODE,
 
89
  DRIZZLE_RETURN_TOO_MANY_COLUMNS,
 
90
  DRIZZLE_RETURN_ROW_END,
 
91
  DRIZZLE_RETURN_LOST_CONNECTION,
 
92
  DRIZZLE_RETURN_COULD_NOT_CONNECT,
 
93
  DRIZZLE_RETURN_NO_ACTIVE_CONNECTIONS,
 
94
  DRIZZLE_RETURN_HANDSHAKE_FAILED,
 
95
  DRIZZLE_RETURN_TIMEOUT,
 
96
  DRIZZLE_RETURN_MAX /* Always add new codes to the end before this one. */
 
97
} drizzle_return_t;
 
98
 
 
99
/**
 
100
 * Verbosity levels.
 
101
 */
 
102
typedef enum
 
103
{
 
104
  DRIZZLE_VERBOSE_NEVER,
 
105
  DRIZZLE_VERBOSE_FATAL,
 
106
  DRIZZLE_VERBOSE_ERROR,
 
107
  DRIZZLE_VERBOSE_INFO,
 
108
  DRIZZLE_VERBOSE_DEBUG,
 
109
  DRIZZLE_VERBOSE_CRAZY,
 
110
  DRIZZLE_VERBOSE_MAX
 
111
} drizzle_verbose_t;
 
112
 
 
113
/** @} */
 
114
 
 
115
/**
 
116
 * @ingroup drizzle
 
117
 * Options for drizzle_st.
 
118
 */
 
119
typedef enum
 
120
{
 
121
  DRIZZLE_NONE=            0,
 
122
  DRIZZLE_ALLOCATED=       (1 << 0),
 
123
  DRIZZLE_NON_BLOCKING=    (1 << 1),
 
124
  DRIZZLE_FREE_OBJECTS=    (1 << 2),
 
125
  DRIZZLE_ASSERT_DANGLING= (1 << 3)
 
126
} drizzle_options_t;
 
127
 
 
128
/**
 
129
 * @ingroup drizzle_con
 
130
 * Options for drizzle_con_st.
 
131
 */
 
132
typedef enum
 
133
{
 
134
  DRIZZLE_CON_NONE=           0,
 
135
  DRIZZLE_CON_ALLOCATED=      (1 << 0),
 
136
  DRIZZLE_CON_MYSQL=          (1 << 1),
 
137
  DRIZZLE_CON_RAW_PACKET=     (1 << 2),
 
138
  DRIZZLE_CON_RAW_SCRAMBLE=   (1 << 3),
 
139
  DRIZZLE_CON_READY=          (1 << 4),
 
140
  DRIZZLE_CON_NO_RESULT_READ= (1 << 5),
 
141
  DRIZZLE_CON_IO_READY=       (1 << 6),
 
142
  DRIZZLE_CON_LISTEN=         (1 << 7),
 
143
  DRIZZLE_CON_EXPERIMENTAL=   (1 << 8),
 
144
  DRIZZLE_CON_FOUND_ROWS=     (1 << 9)
 
145
} drizzle_con_options_t;
 
146
 
 
147
/**
 
148
 * @ingroup drizzle_con
 
149
 * Socket types for drizzle_con_st.
 
150
 */
 
151
typedef enum
 
152
{
 
153
  DRIZZLE_CON_SOCKET_TCP= 0,
 
154
  DRIZZLE_CON_SOCKET_UDS= (1 << 0)
 
155
} drizzle_con_socket_t;
 
156
 
 
157
/**
 
158
 * @ingroup drizzle_con
 
159
 * Status flags for drizle_con_st.
 
160
 */
 
161
typedef enum
 
162
{
 
163
  DRIZZLE_CON_STATUS_NONE=                     0,
 
164
  DRIZZLE_CON_STATUS_IN_TRANS=                 (1 << 0),
 
165
  DRIZZLE_CON_STATUS_AUTOCOMMIT=               (1 << 1),
 
166
  DRIZZLE_CON_STATUS_MORE_RESULTS_EXISTS=      (1 << 3),
 
167
  DRIZZLE_CON_STATUS_QUERY_NO_GOOD_INDEX_USED= (1 << 4),
 
168
  DRIZZLE_CON_STATUS_QUERY_NO_INDEX_USED=      (1 << 5),
 
169
  DRIZZLE_CON_STATUS_CURSOR_EXISTS=            (1 << 6),
 
170
  DRIZZLE_CON_STATUS_LAST_ROW_SENT=            (1 << 7),
 
171
  DRIZZLE_CON_STATUS_DB_DROPPED=               (1 << 8),
 
172
  DRIZZLE_CON_STATUS_NO_BACKSLASH_ESCAPES=     (1 << 9),
 
173
  DRIZZLE_CON_STATUS_QUERY_WAS_SLOW=           (1 << 10)
 
174
} drizzle_con_status_t;
 
175
 
 
176
/**
 
177
 * @ingroup drizzle_con
 
178
 * Capabilities for drizzle_con_st.
 
179
 */
 
180
typedef enum
 
181
{
 
182
  DRIZZLE_CAPABILITIES_NONE=                   0,
 
183
  DRIZZLE_CAPABILITIES_LONG_PASSWORD=          (1 << 0),
 
184
  DRIZZLE_CAPABILITIES_FOUND_ROWS=             (1 << 1),
 
185
  DRIZZLE_CAPABILITIES_LONG_FLAG=              (1 << 2),
 
186
  DRIZZLE_CAPABILITIES_CONNECT_WITH_DB=        (1 << 3),
 
187
  DRIZZLE_CAPABILITIES_NO_SCHEMA=              (1 << 4),
 
188
  DRIZZLE_CAPABILITIES_COMPRESS=               (1 << 5),
 
189
  DRIZZLE_CAPABILITIES_ODBC=                   (1 << 6),
 
190
  DRIZZLE_CAPABILITIES_LOCAL_FILES=            (1 << 7),
 
191
  DRIZZLE_CAPABILITIES_IGNORE_SPACE=           (1 << 8),
 
192
  DRIZZLE_CAPABILITIES_PROTOCOL_41=            (1 << 9),
 
193
  DRIZZLE_CAPABILITIES_INTERACTIVE=            (1 << 10),
 
194
  DRIZZLE_CAPABILITIES_SSL=                    (1 << 11),
 
195
  DRIZZLE_CAPABILITIES_IGNORE_SIGPIPE=         (1 << 12),
 
196
  DRIZZLE_CAPABILITIES_TRANSACTIONS=           (1 << 13),
 
197
  DRIZZLE_CAPABILITIES_RESERVED=               (1 << 14),
 
198
  DRIZZLE_CAPABILITIES_SECURE_CONNECTION=      (1 << 15),
 
199
  DRIZZLE_CAPABILITIES_MULTI_STATEMENTS=       (1 << 16),
 
200
  DRIZZLE_CAPABILITIES_MULTI_RESULTS=          (1 << 17),
 
201
  DRIZZLE_CAPABILITIES_SSL_VERIFY_SERVER_CERT= (1 << 30),
 
202
  DRIZZLE_CAPABILITIES_REMEMBER_OPTIONS=       (1 << 31),
 
203
  DRIZZLE_CAPABILITIES_CLIENT= (DRIZZLE_CAPABILITIES_LONG_PASSWORD |
 
204
                                DRIZZLE_CAPABILITIES_FOUND_ROWS |
 
205
                                DRIZZLE_CAPABILITIES_LONG_FLAG |
 
206
                                DRIZZLE_CAPABILITIES_CONNECT_WITH_DB |
 
207
                                DRIZZLE_CAPABILITIES_TRANSACTIONS |
 
208
                                DRIZZLE_CAPABILITIES_PROTOCOL_41 |
 
209
                                DRIZZLE_CAPABILITIES_SECURE_CONNECTION)
 
210
} drizzle_capabilities_t;
 
211
 
 
212
/**
 
213
 * @ingroup drizzle_command 
 
214
 * Commands for drizzle_command functions.
 
215
 */
 
216
typedef enum
 
217
{
 
218
  DRIZZLE_COMMAND_SLEEP,               /* Not used currently. */
 
219
  DRIZZLE_COMMAND_QUIT,
 
220
  DRIZZLE_COMMAND_INIT_DB,
 
221
  DRIZZLE_COMMAND_QUERY,
 
222
  DRIZZLE_COMMAND_FIELD_LIST,          /* Deprecated. */
 
223
  DRIZZLE_COMMAND_CREATE_DB,           /* Deprecated. */
 
224
  DRIZZLE_COMMAND_DROP_DB,             /* Deprecated. */
 
225
  DRIZZLE_COMMAND_REFRESH,
 
226
  DRIZZLE_COMMAND_SHUTDOWN,
 
227
  DRIZZLE_COMMAND_STATISTICS,
 
228
  DRIZZLE_COMMAND_PROCESS_INFO,        /* Deprecated. */
 
229
  DRIZZLE_COMMAND_CONNECT,             /* Not used currently. */
 
230
  DRIZZLE_COMMAND_PROCESS_KILL,        /* Deprecated. */
 
231
  DRIZZLE_COMMAND_DEBUG,
 
232
  DRIZZLE_COMMAND_PING,
 
233
  DRIZZLE_COMMAND_TIME,                /* Not used currently. */
 
234
  DRIZZLE_COMMAND_DELAYED_INSERT,      /* Not used currently. */
 
235
  DRIZZLE_COMMAND_CHANGE_USER,
 
236
  DRIZZLE_COMMAND_BINLOG_DUMP,         /* Not used currently. */
 
237
  DRIZZLE_COMMAND_TABLE_DUMP,          /* Not used currently. */
 
238
  DRIZZLE_COMMAND_CONNECT_OUT,         /* Not used currently. */
 
239
  DRIZZLE_COMMAND_REGISTER_SLAVE,      /* Not used currently. */
 
240
  DRIZZLE_COMMAND_STMT_PREPARE,        /* Not used currently. */
 
241
  DRIZZLE_COMMAND_STMT_EXECUTE,        /* Not used currently. */
 
242
  DRIZZLE_COMMAND_STMT_SEND_LONG_DATA, /* Not used currently. */
 
243
  DRIZZLE_COMMAND_STMT_CLOSE,          /* Not used currently. */
 
244
  DRIZZLE_COMMAND_STMT_RESET,          /* Not used currently. */
 
245
  DRIZZLE_COMMAND_SET_OPTION,          /* Not used currently. */
 
246
  DRIZZLE_COMMAND_STMT_FETCH,          /* Not used currently. */
 
247
  DRIZZLE_COMMAND_DAEMON,              /* Not used currently. */
 
248
  DRIZZLE_COMMAND_END                  /* Not used currently. */
 
249
} drizzle_command_t;
 
250
 
 
251
/**
 
252
 * @ingroup drizzle_command 
 
253
 * Commands for the Drizzle protocol functions.
 
254
 */
 
255
typedef enum
 
256
{
 
257
  DRIZZLE_COMMAND_DRIZZLE_SLEEP,
 
258
  DRIZZLE_COMMAND_DRIZZLE_QUIT,
 
259
  DRIZZLE_COMMAND_DRIZZLE_INIT_DB,
 
260
  DRIZZLE_COMMAND_DRIZZLE_QUERY,
 
261
  DRIZZLE_COMMAND_DRIZZLE_SHUTDOWN,
 
262
  DRIZZLE_COMMAND_DRIZZLE_CONNECT,
 
263
  DRIZZLE_COMMAND_DRIZZLE_PING,
 
264
  DRIZZLE_COMMAND_DRIZZLE_END
 
265
} drizzle_command_drizzle_t;
 
266
 
 
267
/**
 
268
 * @ingroup drizzle_query
 
269
 * Options for drizzle_query_st.
 
270
 */
 
271
typedef enum
 
272
{
 
273
  DRIZZLE_QUERY_ALLOCATED= (1 << 0)
 
274
} drizzle_query_options_t;
 
275
 
 
276
/**
 
277
 * @ingroup drizzle_query
 
278
 * States for drizle_query_st.
 
279
 */
 
280
typedef enum
 
281
{
 
282
  DRIZZLE_QUERY_STATE_INIT,
 
283
  DRIZZLE_QUERY_STATE_QUERY,
 
284
  DRIZZLE_QUERY_STATE_RESULT,
 
285
  DRIZZLE_QUERY_STATE_DONE
 
286
} drizzle_query_state_t;
 
287
 
 
288
/**
 
289
 * @ingroup drizzle_result
 
290
 * Options for drizzle_result_st.
 
291
 */
 
292
typedef enum
 
293
{
 
294
  DRIZZLE_RESULT_NONE=          0,
 
295
  DRIZZLE_RESULT_ALLOCATED=     (1 << 0),
 
296
  DRIZZLE_RESULT_SKIP_COLUMN=   (1 << 1),
 
297
  DRIZZLE_RESULT_BUFFER_COLUMN= (1 << 2),
 
298
  DRIZZLE_RESULT_BUFFER_ROW=    (1 << 3),
 
299
  DRIZZLE_RESULT_EOF_PACKET=    (1 << 4),
 
300
  DRIZZLE_RESULT_ROW_BREAK=     (1 << 5)
 
301
} drizzle_result_options_t;
 
302
 
 
303
/**
 
304
 * @ingroup drizzle_column
 
305
 * Options for drizzle_column_st.
 
306
 */
 
307
typedef enum
 
308
{
 
309
  DRIZZLE_COLUMN_ALLOCATED= (1 << 0)
 
310
} drizzle_column_options_t;
 
311
 
 
312
/**
 
313
 * @ingroup drizzle_column
 
314
 * Types for drizzle_column_st.
 
315
 */
 
316
typedef enum
 
317
{
 
318
  DRIZZLE_COLUMN_TYPE_DECIMAL,
 
319
  DRIZZLE_COLUMN_TYPE_TINY,
 
320
  DRIZZLE_COLUMN_TYPE_SHORT,
 
321
  DRIZZLE_COLUMN_TYPE_LONG,
 
322
  DRIZZLE_COLUMN_TYPE_FLOAT,
 
323
  DRIZZLE_COLUMN_TYPE_DOUBLE,
 
324
  DRIZZLE_COLUMN_TYPE_NULL,
 
325
  DRIZZLE_COLUMN_TYPE_TIMESTAMP,
 
326
  DRIZZLE_COLUMN_TYPE_LONGLONG,
 
327
  DRIZZLE_COLUMN_TYPE_INT24,
 
328
  DRIZZLE_COLUMN_TYPE_DATE,
 
329
  DRIZZLE_COLUMN_TYPE_TIME,
 
330
  DRIZZLE_COLUMN_TYPE_DATETIME,
 
331
  DRIZZLE_COLUMN_TYPE_YEAR,
 
332
  DRIZZLE_COLUMN_TYPE_NEWDATE,
 
333
  DRIZZLE_COLUMN_TYPE_VARCHAR,
 
334
  DRIZZLE_COLUMN_TYPE_BIT,
 
335
  DRIZZLE_COLUMN_TYPE_NEWDECIMAL=  246,
 
336
  DRIZZLE_COLUMN_TYPE_ENUM=        247,
 
337
  DRIZZLE_COLUMN_TYPE_SET=         248,
 
338
  DRIZZLE_COLUMN_TYPE_TINY_BLOB=   249,
 
339
  DRIZZLE_COLUMN_TYPE_MEDIUM_BLOB= 250,
 
340
  DRIZZLE_COLUMN_TYPE_LONG_BLOB=   251,
 
341
  DRIZZLE_COLUMN_TYPE_BLOB=        252,
 
342
  DRIZZLE_COLUMN_TYPE_VAR_STRING=  253,
 
343
  DRIZZLE_COLUMN_TYPE_STRING=      254,
 
344
  DRIZZLE_COLUMN_TYPE_GEOMETRY=    255
 
345
} drizzle_column_type_t;
 
346
 
 
347
/**
 
348
 * @ingroup drizzle_column
 
349
 * Types for drizzle_column_st for Drizzle.
 
350
 */
 
351
typedef enum
 
352
{
 
353
  DRIZZLE_COLUMN_TYPE_DRIZZLE_TINY,
 
354
  DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG,
 
355
  DRIZZLE_COLUMN_TYPE_DRIZZLE_DOUBLE,
 
356
  DRIZZLE_COLUMN_TYPE_DRIZZLE_NULL,
 
357
  DRIZZLE_COLUMN_TYPE_DRIZZLE_TIMESTAMP,
 
358
  DRIZZLE_COLUMN_TYPE_DRIZZLE_LONGLONG,
 
359
  DRIZZLE_COLUMN_TYPE_DRIZZLE_DATETIME,
 
360
  DRIZZLE_COLUMN_TYPE_DRIZZLE_DATE,
 
361
  DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR,
 
362
  DRIZZLE_COLUMN_TYPE_DRIZZLE_NEWDECIMAL,
 
363
  DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM,
 
364
  DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB,
 
365
  DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX=DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB
 
366
} drizzle_column_type_drizzle_t;
 
367
 
 
368
/**
 
369
 * @ingroup drizzle_column
 
370
 * Flags for drizzle_column_st.
 
371
 */
 
372
typedef enum
 
373
{
 
374
  DRIZZLE_COLUMN_FLAGS_NONE=             0,
 
375
  DRIZZLE_COLUMN_FLAGS_NOT_NULL=         (1 << 0),
 
376
  DRIZZLE_COLUMN_FLAGS_PRI_KEY=          (1 << 1),
 
377
  DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY=       (1 << 2),
 
378
  DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY=     (1 << 3),
 
379
  DRIZZLE_COLUMN_FLAGS_BLOB=             (1 << 4),
 
380
  DRIZZLE_COLUMN_FLAGS_UNSIGNED=         (1 << 5),
 
381
  DRIZZLE_COLUMN_FLAGS_ZEROFILL=         (1 << 6),
 
382
  DRIZZLE_COLUMN_FLAGS_BINARY=           (1 << 7),
 
383
  DRIZZLE_COLUMN_FLAGS_ENUM=             (1 << 8),
 
384
  DRIZZLE_COLUMN_FLAGS_AUTO_INCREMENT=   (1 << 9),
 
385
  DRIZZLE_COLUMN_FLAGS_TIMESTAMP=        (1 << 10),
 
386
  DRIZZLE_COLUMN_FLAGS_SET=              (1 << 11),
 
387
  DRIZZLE_COLUMN_FLAGS_NO_DEFAULT_VALUE= (1 << 12),
 
388
  DRIZZLE_COLUMN_FLAGS_ON_UPDATE_NOW=    (1 << 13),
 
389
  DRIZZLE_COLUMN_FLAGS_PART_KEY=         (1 << 14),
 
390
  DRIZZLE_COLUMN_FLAGS_NUM=              (1 << 15),
 
391
  DRIZZLE_COLUMN_FLAGS_GROUP=            (1 << 15), /* NUM & GROUP the same. */
 
392
  DRIZZLE_COLUMN_FLAGS_UNIQUE=           (1 << 16),
 
393
  DRIZZLE_COLUMN_FLAGS_BINCMP=           (1 << 17),
 
394
  DRIZZLE_COLUMN_FLAGS_GET_FIXED_FIELDS= (1 << 18),
 
395
  DRIZZLE_COLUMN_FLAGS_IN_PART_FUNC=     (1 << 19),
 
396
  DRIZZLE_COLUMN_FLAGS_IN_ADD_INDEX=     (1 << 20),
 
397
  DRIZZLE_COLUMN_FLAGS_RENAMED=          (1 << 21)
 
398
} drizzle_column_flags_t;
 
399
 
 
400
/**
 
401
 * @addtogroup drizzle_types Types
 
402
 * @ingroup drizzle_client_interface
 
403
 * @ingroup drizzle_server_interface
 
404
 * @{
 
405
 */
 
406
 
 
407
/* Types. */
 
408
typedef struct drizzle_st drizzle_st;
 
409
typedef struct drizzle_con_tcp_st drizzle_con_tcp_st;
 
410
typedef struct drizzle_con_uds_st drizzle_con_uds_st;
 
411
typedef struct drizzle_con_st drizzle_con_st;
 
412
typedef struct drizzle_query_st drizzle_query_st;
 
413
typedef struct drizzle_result_st drizzle_result_st;
 
414
typedef struct drizzle_column_st drizzle_column_st;
 
415
typedef char *drizzle_field_t;
 
416
typedef drizzle_field_t *drizzle_row_t;
 
417
typedef uint8_t drizzle_charset_t;
 
418
 
 
419
/* Function types. */
 
420
typedef void (drizzle_context_free_fn)(drizzle_st *drizzle,
 
421
                                       void *context);
 
422
typedef void (drizzle_log_fn)(const char *line, drizzle_verbose_t verbose,
 
423
                              void *context);
 
424
typedef drizzle_return_t (drizzle_state_fn)(drizzle_con_st *con);
 
425
typedef void (drizzle_con_context_free_fn)(drizzle_con_st *con,
 
426
                                           void *context);
 
427
typedef void (drizzle_query_context_free_fn)(drizzle_query_st *query,
 
428
                                             void *context);
 
429
/**
 
430
 * Custom function to register or deregister interest in file descriptor
 
431
 * events. See drizzle_set_event_watch_fn().
 
432
 *
 
433
 * @param[in] con Connection that has changed the events it is interested in.
 
434
 *  Use drizzle_con_fd() to get the file descriptor.
 
435
 * @param[in] events A bit mask of POLLIN | POLLOUT, specifying if the
 
436
 *  connection is waiting for read or write events.
 
437
 * @param[in] context Application context pointer registered with
 
438
 *  drizzle_set_event_watch_fn().
 
439
 * @return DRIZZLE_RETURN_OK if successful.
 
440
 */
 
441
typedef drizzle_return_t (drizzle_event_watch_fn)(drizzle_con_st *con,
 
442
                                                  short events,
 
443
                                                  void *context);
 
444
 
 
445
/** @} */
 
446
 
 
447
/**
 
448
 * @addtogroup drizzle_macros Macros
 
449
 * @ingroup drizzle_client_interface
 
450
 * @ingroup drizzle_server_interface
 
451
 * @{
 
452
 */
 
453
 
 
454
/* Protocol unpacking macros. */
 
455
#define drizzle_get_byte2(__buffer) \
 
456
  (uint16_t)((__buffer)[0] | \
 
457
            ((__buffer)[1] << 8))
 
458
#define drizzle_get_byte3(__buffer) \
 
459
  (uint32_t)((__buffer)[0] | \
 
460
            ((__buffer)[1] << 8) | \
 
461
            ((__buffer)[2] << 16))
 
462
#define drizzle_get_byte4(__buffer) \
 
463
  (uint32_t)((__buffer)[0] | \
 
464
            ((__buffer)[1] << 8) | \
 
465
            ((__buffer)[2] << 16) | \
 
466
            ((__buffer)[3] << 24))
 
467
#define drizzle_get_byte8(__buffer) \
 
468
  ((uint64_t)(__buffer)[0] | \
 
469
  ((uint64_t)(__buffer)[1] << 8) | \
 
470
  ((uint64_t)(__buffer)[2] << 16) | \
 
471
  ((uint64_t)(__buffer)[3] << 24) | \
 
472
  ((uint64_t)(__buffer)[4] << 32) | \
 
473
  ((uint64_t)(__buffer)[5] << 40) | \
 
474
  ((uint64_t)(__buffer)[6] << 48) | \
 
475
  ((uint64_t)(__buffer)[7] << 56))
 
476
 
 
477
/* Protocol packing macros. */
 
478
#define drizzle_set_byte2(__buffer, __int) do { \
 
479
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
 
480
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); } while (0)
 
481
#define drizzle_set_byte3(__buffer, __int) do { \
 
482
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
 
483
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
 
484
  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); } while (0)
 
485
#define drizzle_set_byte4(__buffer, __int) do { \
 
486
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
 
487
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
 
488
  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \
 
489
  (__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); } while (0)
 
490
#define drizzle_set_byte8(__buffer, __int) do { \
 
491
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
 
492
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
 
493
  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \
 
494
  (__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); \
 
495
  (__buffer)[4]= (uint8_t)(((__int) >> 32) & 0xFF); \
 
496
  (__buffer)[5]= (uint8_t)(((__int) >> 40) & 0xFF); \
 
497
  (__buffer)[6]= (uint8_t)(((__int) >> 48) & 0xFF); \
 
498
  (__buffer)[7]= (uint8_t)(((__int) >> 56) & 0xFF); } while (0)
 
499
 
 
500
/* Multi-byte character macros. */
 
501
#define drizzle_mb_char(__c) (((__c) & 0x80) != 0)
 
502
#define drizzle_mb_length(__c) \
 
503
  ((uint32_t)(__c) <= 0x7f ? 1 : \
 
504
  ((uint32_t)(__c) <= 0x7ff ? 2 : \
 
505
  ((uint32_t)(__c) <= 0xd7ff ? 3 : \
 
506
  ((uint32_t)(__c) <= 0xdfff || (uint32_t)(__c) > 0x10ffff ? 0 : \
 
507
  ((uint32_t)(__c) <= 0xffff ? 3 : 4)))))
 
508
 
 
509
/** @} */
 
510
 
 
511
#ifdef __cplusplus
 
512
}
 
513
#endif
 
514
 
 
515
#endif /* __DRIZZLE_CONSTANTS_H */