~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
 *
7
 * Use and distribution licensed under the BSD license.  See
1799.2.3 by Monty Taylor
Reference root BSD copying file.
8
 * the COPYING.BSD file in the root source directory for full text.
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
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
1865.3.1 by Andrew Hutchings
Make port 4427 the default for client apps
40
#define DRIZZLE_DEFAULT_TCP_PORT_MYSQL   4427
1712.1.1 by Monty Taylor
Merged libdrizzle directly into tree.
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_CLIENT= (DRIZZLE_CAPABILITIES_LONG_PASSWORD |
202
                                DRIZZLE_CAPABILITIES_FOUND_ROWS |
203
                                DRIZZLE_CAPABILITIES_LONG_FLAG |
204
                                DRIZZLE_CAPABILITIES_CONNECT_WITH_DB |
205
                                DRIZZLE_CAPABILITIES_TRANSACTIONS |
206
                                DRIZZLE_CAPABILITIES_PROTOCOL_41 |
207
                                DRIZZLE_CAPABILITIES_SECURE_CONNECTION)
208
} drizzle_capabilities_t;
209
210
/**
211
 * @ingroup drizzle_command 
212
 * Commands for drizzle_command functions.
213
 */
214
typedef enum
215
{
216
  DRIZZLE_COMMAND_SLEEP,               /* Not used currently. */
217
  DRIZZLE_COMMAND_QUIT,
218
  DRIZZLE_COMMAND_INIT_DB,
219
  DRIZZLE_COMMAND_QUERY,
220
  DRIZZLE_COMMAND_FIELD_LIST,          /* Deprecated. */
221
  DRIZZLE_COMMAND_CREATE_DB,           /* Deprecated. */
222
  DRIZZLE_COMMAND_DROP_DB,             /* Deprecated. */
223
  DRIZZLE_COMMAND_REFRESH,
224
  DRIZZLE_COMMAND_SHUTDOWN,
225
  DRIZZLE_COMMAND_STATISTICS,
226
  DRIZZLE_COMMAND_PROCESS_INFO,        /* Deprecated. */
227
  DRIZZLE_COMMAND_CONNECT,             /* Not used currently. */
228
  DRIZZLE_COMMAND_PROCESS_KILL,        /* Deprecated. */
229
  DRIZZLE_COMMAND_DEBUG,
230
  DRIZZLE_COMMAND_PING,
231
  DRIZZLE_COMMAND_TIME,                /* Not used currently. */
232
  DRIZZLE_COMMAND_DELAYED_INSERT,      /* Not used currently. */
233
  DRIZZLE_COMMAND_CHANGE_USER,
234
  DRIZZLE_COMMAND_BINLOG_DUMP,         /* Not used currently. */
235
  DRIZZLE_COMMAND_TABLE_DUMP,          /* Not used currently. */
236
  DRIZZLE_COMMAND_CONNECT_OUT,         /* Not used currently. */
237
  DRIZZLE_COMMAND_REGISTER_SLAVE,      /* Not used currently. */
238
  DRIZZLE_COMMAND_STMT_PREPARE,        /* Not used currently. */
239
  DRIZZLE_COMMAND_STMT_EXECUTE,        /* Not used currently. */
240
  DRIZZLE_COMMAND_STMT_SEND_LONG_DATA, /* Not used currently. */
241
  DRIZZLE_COMMAND_STMT_CLOSE,          /* Not used currently. */
242
  DRIZZLE_COMMAND_STMT_RESET,          /* Not used currently. */
243
  DRIZZLE_COMMAND_SET_OPTION,          /* Not used currently. */
244
  DRIZZLE_COMMAND_STMT_FETCH,          /* Not used currently. */
245
  DRIZZLE_COMMAND_DAEMON,              /* Not used currently. */
246
  DRIZZLE_COMMAND_END                  /* Not used currently. */
247
} drizzle_command_t;
248
249
/**
250
 * @ingroup drizzle_command 
251
 * Commands for the Drizzle protocol functions.
252
 */
253
typedef enum
254
{
255
  DRIZZLE_COMMAND_DRIZZLE_SLEEP,
256
  DRIZZLE_COMMAND_DRIZZLE_QUIT,
257
  DRIZZLE_COMMAND_DRIZZLE_INIT_DB,
258
  DRIZZLE_COMMAND_DRIZZLE_QUERY,
259
  DRIZZLE_COMMAND_DRIZZLE_SHUTDOWN,
260
  DRIZZLE_COMMAND_DRIZZLE_CONNECT,
261
  DRIZZLE_COMMAND_DRIZZLE_PING,
262
  DRIZZLE_COMMAND_DRIZZLE_END
263
} drizzle_command_drizzle_t;
264
265
/**
266
 * @ingroup drizzle_query
267
 * Options for drizzle_query_st.
268
 */
269
typedef enum
270
{
271
  DRIZZLE_QUERY_ALLOCATED= (1 << 0)
272
} drizzle_query_options_t;
273
274
/**
275
 * @ingroup drizzle_query
276
 * States for drizle_query_st.
277
 */
278
typedef enum
279
{
280
  DRIZZLE_QUERY_STATE_INIT,
281
  DRIZZLE_QUERY_STATE_QUERY,
282
  DRIZZLE_QUERY_STATE_RESULT,
283
  DRIZZLE_QUERY_STATE_DONE
284
} drizzle_query_state_t;
285
286
/**
287
 * @ingroup drizzle_result
288
 * Options for drizzle_result_st.
289
 */
290
typedef enum
291
{
292
  DRIZZLE_RESULT_NONE=          0,
293
  DRIZZLE_RESULT_ALLOCATED=     (1 << 0),
294
  DRIZZLE_RESULT_SKIP_COLUMN=   (1 << 1),
295
  DRIZZLE_RESULT_BUFFER_COLUMN= (1 << 2),
296
  DRIZZLE_RESULT_BUFFER_ROW=    (1 << 3),
297
  DRIZZLE_RESULT_EOF_PACKET=    (1 << 4),
298
  DRIZZLE_RESULT_ROW_BREAK=     (1 << 5)
299
} drizzle_result_options_t;
300
301
/**
302
 * @ingroup drizzle_column
303
 * Options for drizzle_column_st.
304
 */
305
typedef enum
306
{
307
  DRIZZLE_COLUMN_ALLOCATED= (1 << 0)
308
} drizzle_column_options_t;
309
310
/**
311
 * @ingroup drizzle_column
312
 * Types for drizzle_column_st.
313
 */
314
typedef enum
315
{
316
  DRIZZLE_COLUMN_TYPE_DECIMAL,
317
  DRIZZLE_COLUMN_TYPE_TINY,
318
  DRIZZLE_COLUMN_TYPE_SHORT,
319
  DRIZZLE_COLUMN_TYPE_LONG,
320
  DRIZZLE_COLUMN_TYPE_FLOAT,
321
  DRIZZLE_COLUMN_TYPE_DOUBLE,
322
  DRIZZLE_COLUMN_TYPE_NULL,
323
  DRIZZLE_COLUMN_TYPE_TIMESTAMP,
324
  DRIZZLE_COLUMN_TYPE_LONGLONG,
325
  DRIZZLE_COLUMN_TYPE_INT24,
326
  DRIZZLE_COLUMN_TYPE_DATE,
327
  DRIZZLE_COLUMN_TYPE_TIME,
328
  DRIZZLE_COLUMN_TYPE_DATETIME,
329
  DRIZZLE_COLUMN_TYPE_YEAR,
330
  DRIZZLE_COLUMN_TYPE_NEWDATE,
331
  DRIZZLE_COLUMN_TYPE_VARCHAR,
332
  DRIZZLE_COLUMN_TYPE_BIT,
333
  DRIZZLE_COLUMN_TYPE_NEWDECIMAL=  246,
334
  DRIZZLE_COLUMN_TYPE_ENUM=        247,
335
  DRIZZLE_COLUMN_TYPE_SET=         248,
336
  DRIZZLE_COLUMN_TYPE_TINY_BLOB=   249,
337
  DRIZZLE_COLUMN_TYPE_MEDIUM_BLOB= 250,
338
  DRIZZLE_COLUMN_TYPE_LONG_BLOB=   251,
339
  DRIZZLE_COLUMN_TYPE_BLOB=        252,
340
  DRIZZLE_COLUMN_TYPE_VAR_STRING=  253,
341
  DRIZZLE_COLUMN_TYPE_STRING=      254,
342
  DRIZZLE_COLUMN_TYPE_GEOMETRY=    255
343
} drizzle_column_type_t;
344
345
/**
346
 * @ingroup drizzle_column
347
 * Types for drizzle_column_st for Drizzle.
348
 */
349
typedef enum
350
{
351
  DRIZZLE_COLUMN_TYPE_DRIZZLE_TINY,
352
  DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG,
353
  DRIZZLE_COLUMN_TYPE_DRIZZLE_DOUBLE,
354
  DRIZZLE_COLUMN_TYPE_DRIZZLE_NULL,
355
  DRIZZLE_COLUMN_TYPE_DRIZZLE_TIMESTAMP,
356
  DRIZZLE_COLUMN_TYPE_DRIZZLE_LONGLONG,
357
  DRIZZLE_COLUMN_TYPE_DRIZZLE_DATETIME,
358
  DRIZZLE_COLUMN_TYPE_DRIZZLE_DATE,
359
  DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR,
360
  DRIZZLE_COLUMN_TYPE_DRIZZLE_NEWDECIMAL,
361
  DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM,
362
  DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB,
363
  DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX=DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB
364
} drizzle_column_type_drizzle_t;
365
366
/**
367
 * @ingroup drizzle_column
368
 * Flags for drizzle_column_st.
369
 */
370
typedef enum
371
{
372
  DRIZZLE_COLUMN_FLAGS_NONE=             0,
373
  DRIZZLE_COLUMN_FLAGS_NOT_NULL=         (1 << 0),
374
  DRIZZLE_COLUMN_FLAGS_PRI_KEY=          (1 << 1),
375
  DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY=       (1 << 2),
376
  DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY=     (1 << 3),
377
  DRIZZLE_COLUMN_FLAGS_BLOB=             (1 << 4),
378
  DRIZZLE_COLUMN_FLAGS_UNSIGNED=         (1 << 5),
379
  DRIZZLE_COLUMN_FLAGS_ZEROFILL=         (1 << 6),
380
  DRIZZLE_COLUMN_FLAGS_BINARY=           (1 << 7),
381
  DRIZZLE_COLUMN_FLAGS_ENUM=             (1 << 8),
382
  DRIZZLE_COLUMN_FLAGS_AUTO_INCREMENT=   (1 << 9),
383
  DRIZZLE_COLUMN_FLAGS_TIMESTAMP=        (1 << 10),
384
  DRIZZLE_COLUMN_FLAGS_SET=              (1 << 11),
385
  DRIZZLE_COLUMN_FLAGS_NO_DEFAULT_VALUE= (1 << 12),
386
  DRIZZLE_COLUMN_FLAGS_ON_UPDATE_NOW=    (1 << 13),
387
  DRIZZLE_COLUMN_FLAGS_PART_KEY=         (1 << 14),
388
  DRIZZLE_COLUMN_FLAGS_NUM=              (1 << 15),
389
  DRIZZLE_COLUMN_FLAGS_GROUP=            (1 << 15), /* NUM & GROUP the same. */
390
  DRIZZLE_COLUMN_FLAGS_UNIQUE=           (1 << 16),
391
  DRIZZLE_COLUMN_FLAGS_BINCMP=           (1 << 17),
392
  DRIZZLE_COLUMN_FLAGS_GET_FIXED_FIELDS= (1 << 18),
393
  DRIZZLE_COLUMN_FLAGS_IN_PART_FUNC=     (1 << 19),
394
  DRIZZLE_COLUMN_FLAGS_IN_ADD_INDEX=     (1 << 20),
395
  DRIZZLE_COLUMN_FLAGS_RENAMED=          (1 << 21)
396
} drizzle_column_flags_t;
397
398
/**
399
 * @addtogroup drizzle_types Types
400
 * @ingroup drizzle_client_interface
401
 * @ingroup drizzle_server_interface
402
 * @{
403
 */
404
405
/* Types. */
406
typedef struct drizzle_st drizzle_st;
407
typedef struct drizzle_con_tcp_st drizzle_con_tcp_st;
408
typedef struct drizzle_con_uds_st drizzle_con_uds_st;
409
typedef struct drizzle_con_st drizzle_con_st;
410
typedef struct drizzle_query_st drizzle_query_st;
411
typedef struct drizzle_result_st drizzle_result_st;
412
typedef struct drizzle_column_st drizzle_column_st;
413
typedef char *drizzle_field_t;
414
typedef drizzle_field_t *drizzle_row_t;
415
typedef uint8_t drizzle_charset_t;
416
417
/* Function types. */
418
typedef void (drizzle_context_free_fn)(drizzle_st *drizzle,
419
                                       void *context);
420
typedef void (drizzle_log_fn)(const char *line, drizzle_verbose_t verbose,
421
                              void *context);
422
typedef drizzle_return_t (drizzle_state_fn)(drizzle_con_st *con);
423
typedef void (drizzle_con_context_free_fn)(drizzle_con_st *con,
424
                                           void *context);
425
typedef void (drizzle_query_context_free_fn)(drizzle_query_st *query,
426
                                             void *context);
427
/**
428
 * Custom function to register or deregister interest in file descriptor
429
 * events. See drizzle_set_event_watch_fn().
430
 *
431
 * @param[in] con Connection that has changed the events it is interested in.
432
 *  Use drizzle_con_fd() to get the file descriptor.
433
 * @param[in] events A bit mask of POLLIN | POLLOUT, specifying if the
434
 *  connection is waiting for read or write events.
435
 * @param[in] context Application context pointer registered with
436
 *  drizzle_set_event_watch_fn().
437
 * @return DRIZZLE_RETURN_OK if successful.
438
 */
439
typedef drizzle_return_t (drizzle_event_watch_fn)(drizzle_con_st *con,
440
                                                  short events,
441
                                                  void *context);
442
443
/** @} */
444
445
/**
446
 * @addtogroup drizzle_macros Macros
447
 * @ingroup drizzle_client_interface
448
 * @ingroup drizzle_server_interface
449
 * @{
450
 */
451
452
/* Protocol unpacking macros. */
453
#define drizzle_get_byte2(__buffer) \
454
  (uint16_t)((__buffer)[0] | \
455
            ((__buffer)[1] << 8))
456
#define drizzle_get_byte3(__buffer) \
457
  (uint32_t)((__buffer)[0] | \
458
            ((__buffer)[1] << 8) | \
459
            ((__buffer)[2] << 16))
460
#define drizzle_get_byte4(__buffer) \
461
  (uint32_t)((__buffer)[0] | \
462
            ((__buffer)[1] << 8) | \
463
            ((__buffer)[2] << 16) | \
464
            ((__buffer)[3] << 24))
465
#define drizzle_get_byte8(__buffer) \
466
  ((uint64_t)(__buffer)[0] | \
467
  ((uint64_t)(__buffer)[1] << 8) | \
468
  ((uint64_t)(__buffer)[2] << 16) | \
469
  ((uint64_t)(__buffer)[3] << 24) | \
470
  ((uint64_t)(__buffer)[4] << 32) | \
471
  ((uint64_t)(__buffer)[5] << 40) | \
472
  ((uint64_t)(__buffer)[6] << 48) | \
473
  ((uint64_t)(__buffer)[7] << 56))
474
475
/* Protocol packing macros. */
476
#define drizzle_set_byte2(__buffer, __int) do { \
477
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
478
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); } while (0)
479
#define drizzle_set_byte3(__buffer, __int) do { \
480
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
481
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
482
  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); } while (0)
483
#define drizzle_set_byte4(__buffer, __int) do { \
484
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
485
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
486
  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \
487
  (__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); } while (0)
488
#define drizzle_set_byte8(__buffer, __int) do { \
489
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
490
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
491
  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \
492
  (__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); \
493
  (__buffer)[4]= (uint8_t)(((__int) >> 32) & 0xFF); \
494
  (__buffer)[5]= (uint8_t)(((__int) >> 40) & 0xFF); \
495
  (__buffer)[6]= (uint8_t)(((__int) >> 48) & 0xFF); \
496
  (__buffer)[7]= (uint8_t)(((__int) >> 56) & 0xFF); } while (0)
497
498
/* Multi-byte character macros. */
499
#define drizzle_mb_char(__c) (((__c) & 0x80) != 0)
500
#define drizzle_mb_length(__c) \
501
  ((uint32_t)(__c) <= 0x7f ? 1 : \
502
  ((uint32_t)(__c) <= 0x7ff ? 2 : \
503
  ((uint32_t)(__c) <= 0xd7ff ? 3 : \
504
  ((uint32_t)(__c) <= 0xdfff || (uint32_t)(__c) > 0x10ffff ? 0 : \
505
  ((uint32_t)(__c) <= 0xffff ? 3 : 4)))))
506
507
/** @} */
508
509
#ifdef __cplusplus
510
}
511
#endif
512
513
#endif /* __DRIZZLE_CONSTANTS_H */