~clint-fewbar/drizzle/regex-policy-cache-limiter

« back to all changes in this revision

Viewing changes to libdrizzle-2.0/constants.h

  • Committer: Clint Byrum
  • Date: 2012-03-15 18:05:43 UTC
  • mfrom: (2224.1.302 workspace)
  • Revision ID: clint@ubuntu.com-20120315180543-9jxxm4q10k3np2ws
merging with latest trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Drizzle Client & Protocol Library
 
3
 *
 
4
 * Copyright (C) 2011 Brian Aker (brian@tangent.org)
 
5
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
 
6
 * All rights reserved.
 
7
 *
 
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
 *
 
36
 */
 
37
 
 
38
#pragma once
 
39
 
 
40
/**
 
41
 * @file
 
42
 * @brief Defines, typedefs, enums, and macros
 
43
 */
 
44
 
 
45
#ifdef __cplusplus
 
46
 
 
47
#include <vector>
 
48
 
 
49
extern "C" {
 
50
 
 
51
#endif
 
52
 
 
53
/**
 
54
 * @addtogroup drizzle_constants Constants
 
55
 * @ingroup drizzle_client_interface
 
56
 * @ingroup drizzle_server_interface
 
57
 * @{
 
58
 */
 
59
 
 
60
/* Defines. */
 
61
#define DRIZZLE_DEFAULT_TCP_HOST         "localhost"
 
62
#define DRIZZLE_DEFAULT_TCP_PORT         4427
 
63
#define DRIZZLE_DEFAULT_TCP_PORT_MYSQL   4427
 
64
#define DRIZZLE_DEFAULT_UDS              "/tmp/drizzle.sock"
 
65
#define DRIZZLE_DEFAULT_UDS_MYSQL        "/tmp/mysql.sock"
 
66
#define DRIZZLE_DEFAULT_BACKLOG          64
 
67
#define DRIZZLE_BUFFER_COPY_THRESHOLD    8192
 
68
#define DRIZZLE_ROW_GROW_SIZE            8192
 
69
#define DRIZZLE_STATE_STACK_SIZE         8
 
70
#define DRIZZLE_DEFAULT_SOCKET_TIMEOUT   10
 
71
#define DRIZZLE_DEFAULT_SOCKET_SEND_SIZE 32768
 
72
#define DRIZZLE_DEFAULT_SOCKET_RECV_SIZE 32768
 
73
#define DRIZZLE_MYSQL_PASSWORD_HASH      41
 
74
 
 
75
#include <libdrizzle-2.0/deprecated_enum.h>
 
76
#include <libdrizzle-2.0/return.h>
 
77
#include <libdrizzle-2.0/command.h>
 
78
#include <libdrizzle-2.0/verbose.h>
 
79
#include <libdrizzle-2.0/limits.h>
 
80
 
 
81
/** @} */
 
82
 
 
83
/**
 
84
 * @ingroup drizzle_con
 
85
 * Options for drizzle_con_st.
 
86
 */
 
87
enum drizzle_con_options_t
 
88
{
 
89
  DRIZZLE_CON_NONE=             0,
 
90
  DRIZZLE_CON_ALLOCATED=        (1 << 0), // DEPRECATED
 
91
  DRIZZLE_CON_MYSQL=            (1 << 1),
 
92
  DRIZZLE_CON_RAW_PACKET=       (1 << 2),
 
93
  DRIZZLE_CON_RAW_SCRAMBLE=     (1 << 3),
 
94
  DRIZZLE_CON_READY=            (1 << 4),
 
95
  DRIZZLE_CON_NO_RESULT_READ=   (1 << 5),
 
96
  DRIZZLE_CON_IO_READY=         (1 << 6),
 
97
  DRIZZLE_CON_LISTEN=           (1 << 7),
 
98
  DRIZZLE_CON_EXPERIMENTAL=     (1 << 8),
 
99
  DRIZZLE_CON_FOUND_ROWS=       (1 << 9),
 
100
  DRIZZLE_CON_INTERACTIVE=      (1 << 11),
 
101
  DRIZZLE_CON_MULTI_STATEMENTS= (1 << 12),
 
102
  DRIZZLE_CON_AUTH_PLUGIN=      (1 << 13)
 
103
};
 
104
 
 
105
#ifndef __cplusplus
 
106
typedef enum drizzle_con_options_t drizzle_con_options_t;
 
107
#endif
 
108
 
 
109
/**
 
110
 * @ingroup drizzle_con
 
111
 * Socket types for drizzle_con_st.
 
112
 */
 
113
enum drizzle_con_socket_t
 
114
{
 
115
  DRIZZLE_CON_SOCKET_TCP,
 
116
  DRIZZLE_CON_SOCKET_UDS
 
117
};
 
118
 
 
119
#ifndef __cplusplus
 
120
typedef enum drizzle_con_socket_t drizzle_con_socket_t;
 
121
#endif
 
122
 
 
123
/**
 
124
 * @ingroup drizzle_con
 
125
 * Status flags for drizle_con_st.
 
126
 */
 
127
enum drizzle_con_status_t
 
128
{
 
129
  DRIZZLE_CON_STATUS_NONE=                     0,
 
130
  DRIZZLE_CON_STATUS_IN_TRANS=                 (1 << 0),
 
131
  DRIZZLE_CON_STATUS_AUTOCOMMIT=               (1 << 1),
 
132
  DRIZZLE_CON_STATUS_MORE_RESULTS_EXISTS=      (1 << 3),
 
133
  DRIZZLE_CON_STATUS_QUERY_NO_GOOD_INDEX_USED= (1 << 4),
 
134
  DRIZZLE_CON_STATUS_QUERY_NO_INDEX_USED=      (1 << 5),
 
135
  DRIZZLE_CON_STATUS_CURSOR_EXISTS=            (1 << 6),
 
136
  DRIZZLE_CON_STATUS_LAST_ROW_SENT=            (1 << 7),
 
137
  DRIZZLE_CON_STATUS_DB_DROPPED=               (1 << 8),
 
138
  DRIZZLE_CON_STATUS_NO_BACKSLASH_ESCAPES=     (1 << 9),
 
139
  DRIZZLE_CON_STATUS_QUERY_WAS_SLOW=           (1 << 10)
 
140
};
 
141
 
 
142
#ifndef __cplusplus
 
143
typedef enum drizzle_con_status_t drizzle_con_status_t;
 
144
#endif
 
145
 
 
146
/**
 
147
 * @ingroup drizzle_con
 
148
 * Capabilities for drizzle_con_st.
 
149
 */
 
150
enum drizzle_capabilities_t
 
151
{
 
152
  DRIZZLE_CAPABILITIES_NONE=                   0,
 
153
  DRIZZLE_CAPABILITIES_LONG_PASSWORD=          (1 << 0),
 
154
  DRIZZLE_CAPABILITIES_FOUND_ROWS=             (1 << 1),
 
155
  DRIZZLE_CAPABILITIES_LONG_FLAG=              (1 << 2),
 
156
  DRIZZLE_CAPABILITIES_CONNECT_WITH_DB=        (1 << 3),
 
157
  DRIZZLE_CAPABILITIES_NO_SCHEMA=              (1 << 4),
 
158
  DRIZZLE_CAPABILITIES_COMPRESS=               (1 << 5),
 
159
  DRIZZLE_CAPABILITIES_ODBC=                   (1 << 6),
 
160
  DRIZZLE_CAPABILITIES_LOCAL_FILES=            (1 << 7),
 
161
  DRIZZLE_CAPABILITIES_IGNORE_SPACE=           (1 << 8),
 
162
  DRIZZLE_CAPABILITIES_PROTOCOL_41=            (1 << 9),
 
163
  DRIZZLE_CAPABILITIES_INTERACTIVE=            (1 << 10),
 
164
  DRIZZLE_CAPABILITIES_SSL=                    (1 << 11),
 
165
  DRIZZLE_CAPABILITIES_IGNORE_SIGPIPE=         (1 << 12),
 
166
  DRIZZLE_CAPABILITIES_TRANSACTIONS=           (1 << 13),
 
167
  DRIZZLE_CAPABILITIES_RESERVED=               (1 << 14),
 
168
  DRIZZLE_CAPABILITIES_SECURE_CONNECTION=      (1 << 15),
 
169
  DRIZZLE_CAPABILITIES_MULTI_STATEMENTS=       (1 << 16),
 
170
  DRIZZLE_CAPABILITIES_MULTI_RESULTS=          (1 << 17),
 
171
  DRIZZLE_CAPABILITIES_PS_MULTI_RESULTS=       (1 << 18),
 
172
  DRIZZLE_CAPABILITIES_PLUGIN_AUTH=            (1 << 19),
 
173
  DRIZZLE_CAPABILITIES_SSL_VERIFY_SERVER_CERT= (1 << 30),
 
174
  DRIZZLE_CAPABILITIES_REMEMBER_OPTIONS=       (1 << 31),
 
175
  DRIZZLE_CAPABILITIES_CLIENT= (DRIZZLE_CAPABILITIES_LONG_PASSWORD |
 
176
                                DRIZZLE_CAPABILITIES_FOUND_ROWS |
 
177
                                DRIZZLE_CAPABILITIES_LONG_FLAG |
 
178
                                DRIZZLE_CAPABILITIES_CONNECT_WITH_DB |
 
179
                                DRIZZLE_CAPABILITIES_PLUGIN_AUTH |
 
180
                                DRIZZLE_CAPABILITIES_TRANSACTIONS |
 
181
                                DRIZZLE_CAPABILITIES_PROTOCOL_41 |
 
182
                                DRIZZLE_CAPABILITIES_SECURE_CONNECTION)
 
183
};
 
184
 
 
185
#ifndef __cplusplus
 
186
typedef enum drizzle_capabilities_t drizzle_capabilities_t;
 
187
#endif
 
188
 
 
189
/**
 
190
 * @ingroup drizzle_query
 
191
 * States for drizle_query_st.
 
192
 */
 
193
enum drizzle_query_state_t
 
194
{
 
195
  DRIZZLE_QUERY_STATE_INIT,
 
196
  DRIZZLE_QUERY_STATE_QUERY,
 
197
  DRIZZLE_QUERY_STATE_RESULT,
 
198
  DRIZZLE_QUERY_STATE_DONE
 
199
};
 
200
 
 
201
#ifndef __cplusplus
 
202
enum drizzle_query_state_t drizzle_query_state_t;
 
203
#endif
 
204
 
 
205
/**
 
206
 * @ingroup drizzle_result
 
207
 * Options for drizzle_result_st.
 
208
 */
 
209
enum drizzle_result_options_t
 
210
{
 
211
  DRIZZLE_RESULT_NONE=          0,
 
212
  DRIZZLE_RESULT_ALLOCATED=     (1 << 0), // DEPRECATED
 
213
  DRIZZLE_RESULT_SKIP_COLUMN=   (1 << 1),
 
214
  DRIZZLE_RESULT_BUFFER_COLUMN= (1 << 2),
 
215
  DRIZZLE_RESULT_BUFFER_ROW=    (1 << 3),
 
216
  DRIZZLE_RESULT_EOF_PACKET=    (1 << 4),
 
217
  DRIZZLE_RESULT_ROW_BREAK=     (1 << 5)
 
218
};
 
219
 
 
220
#ifndef __cplusplus
 
221
typedef enum drizzle_result_options_t drizzle_result_options_t;
 
222
#endif
 
223
 
 
224
/**
 
225
 * @ingroup drizzle_column
 
226
 * Options for drizzle_column_st.
 
227
 */
 
228
enum drizzle_column_options_t
 
229
{
 
230
  DRIZZLE_COLUMN_ALLOCATED= (1 << 0) // DEPRECATED
 
231
};
 
232
 
 
233
#ifndef __cplusplus
 
234
typedef enum drizzle_column_options_t drizzle_column_options_t;
 
235
#endif
 
236
 
 
237
/**
 
238
 * @ingroup drizzle_column
 
239
 * Types for drizzle_column_st.
 
240
 */
 
241
enum drizzle_column_type_t
 
242
{
 
243
  DRIZZLE_COLUMN_TYPE_DECIMAL,
 
244
  DRIZZLE_COLUMN_TYPE_TINY,
 
245
  DRIZZLE_COLUMN_TYPE_SHORT,
 
246
  DRIZZLE_COLUMN_TYPE_LONG,
 
247
  DRIZZLE_COLUMN_TYPE_FLOAT,
 
248
  DRIZZLE_COLUMN_TYPE_DOUBLE,
 
249
  DRIZZLE_COLUMN_TYPE_NULL,
 
250
  DRIZZLE_COLUMN_TYPE_TIMESTAMP,
 
251
  DRIZZLE_COLUMN_TYPE_LONGLONG,
 
252
  DRIZZLE_COLUMN_TYPE_INT24,
 
253
  DRIZZLE_COLUMN_TYPE_DATE,
 
254
  DRIZZLE_COLUMN_TYPE_TIME,
 
255
  DRIZZLE_COLUMN_TYPE_DATETIME,
 
256
  DRIZZLE_COLUMN_TYPE_YEAR,
 
257
  DRIZZLE_COLUMN_TYPE_NEWDATE,
 
258
  DRIZZLE_COLUMN_TYPE_VARCHAR,
 
259
  DRIZZLE_COLUMN_TYPE_BIT,
 
260
  DRIZZLE_COLUMN_TYPE_NEWDECIMAL=  246,
 
261
  DRIZZLE_COLUMN_TYPE_ENUM=        247,
 
262
  DRIZZLE_COLUMN_TYPE_SET=         248,
 
263
  DRIZZLE_COLUMN_TYPE_TINY_BLOB=   249,
 
264
  DRIZZLE_COLUMN_TYPE_MEDIUM_BLOB= 250,
 
265
  DRIZZLE_COLUMN_TYPE_LONG_BLOB=   251,
 
266
  DRIZZLE_COLUMN_TYPE_BLOB=        252,
 
267
  DRIZZLE_COLUMN_TYPE_VAR_STRING=  253,
 
268
  DRIZZLE_COLUMN_TYPE_STRING=      254,
 
269
  DRIZZLE_COLUMN_TYPE_GEOMETRY=    255
 
270
};
 
271
 
 
272
#ifndef __cplusplus
 
273
typedef enum drizzle_column_type_t drizzle_column_type_t;
 
274
#endif
 
275
 
 
276
/**
 
277
 * @ingroup drizzle_column
 
278
 * Types for drizzle_column_st for Drizzle.
 
279
 */
 
280
enum drizzle_column_type_drizzle_t
 
281
{
 
282
  DRIZZLE_COLUMN_TYPE_DRIZZLE_TINY,
 
283
  DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG,
 
284
  DRIZZLE_COLUMN_TYPE_DRIZZLE_DOUBLE,
 
285
  DRIZZLE_COLUMN_TYPE_DRIZZLE_NULL,
 
286
  DRIZZLE_COLUMN_TYPE_DRIZZLE_TIMESTAMP,
 
287
  DRIZZLE_COLUMN_TYPE_DRIZZLE_LONGLONG,
 
288
  DRIZZLE_COLUMN_TYPE_DRIZZLE_DATETIME,
 
289
  DRIZZLE_COLUMN_TYPE_DRIZZLE_DATE,
 
290
  DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR,
 
291
  DRIZZLE_COLUMN_TYPE_DRIZZLE_NEWDECIMAL,
 
292
  DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM,
 
293
  DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB,
 
294
  DRIZZLE_COLUMN_TYPE_DRIZZLE_TIME,
 
295
  DRIZZLE_COLUMN_TYPE_DRIZZLE_BOOLEAN,
 
296
  DRIZZLE_COLUMN_TYPE_DRIZZLE_UUID,
 
297
  DRIZZLE_COLUMN_TYPE_DRIZZLE_MICROTIME,
 
298
  DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX=DRIZZLE_COLUMN_TYPE_DRIZZLE_MICROTIME
 
299
};
 
300
 
 
301
#ifndef __cplusplus
 
302
typedef enum drizzle_column_type_drizzle_t drizzle_column_type_drizzle_t;
 
303
#endif
 
304
 
 
305
/**
 
306
 * @ingroup drizzle_column
 
307
 * Flags for drizzle_column_st.
 
308
 */
 
309
enum drizzle_column_flags_t
 
310
{
 
311
  DRIZZLE_COLUMN_FLAGS_NONE=             0,
 
312
  DRIZZLE_COLUMN_FLAGS_NOT_NULL=         (1 << 0),
 
313
  DRIZZLE_COLUMN_FLAGS_PRI_KEY=          (1 << 1),
 
314
  DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY=       (1 << 2),
 
315
  DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY=     (1 << 3),
 
316
  DRIZZLE_COLUMN_FLAGS_BLOB=             (1 << 4),
 
317
  DRIZZLE_COLUMN_FLAGS_UNSIGNED=         (1 << 5),
 
318
  DRIZZLE_COLUMN_FLAGS_ZEROFILL=         (1 << 6),
 
319
  DRIZZLE_COLUMN_FLAGS_BINARY=           (1 << 7),
 
320
  DRIZZLE_COLUMN_FLAGS_ENUM=             (1 << 8),
 
321
  DRIZZLE_COLUMN_FLAGS_AUTO_INCREMENT=   (1 << 9),
 
322
  DRIZZLE_COLUMN_FLAGS_TIMESTAMP=        (1 << 10),
 
323
  DRIZZLE_COLUMN_FLAGS_SET=              (1 << 11),
 
324
  DRIZZLE_COLUMN_FLAGS_NO_DEFAULT_VALUE= (1 << 12),
 
325
  DRIZZLE_COLUMN_FLAGS_ON_UPDATE_NOW=    (1 << 13),
 
326
  DRIZZLE_COLUMN_FLAGS_PART_KEY=         (1 << 14),
 
327
  DRIZZLE_COLUMN_FLAGS_NUM=              (1 << 15),
 
328
  DRIZZLE_COLUMN_FLAGS_GROUP=            (1 << 15), /* NUM & GROUP the same. */
 
329
  DRIZZLE_COLUMN_FLAGS_UNIQUE=           (1 << 16),
 
330
  DRIZZLE_COLUMN_FLAGS_BINCMP=           (1 << 17),
 
331
  DRIZZLE_COLUMN_FLAGS_GET_FIXED_FIELDS= (1 << 18),
 
332
  DRIZZLE_COLUMN_FLAGS_IN_PART_FUNC=     (1 << 19),
 
333
  DRIZZLE_COLUMN_FLAGS_IN_ADD_INDEX=     (1 << 20),
 
334
  DRIZZLE_COLUMN_FLAGS_RENAMED=          (1 << 21)
 
335
};
 
336
 
 
337
#ifndef __cplusplus
 
338
typedef enum drizzle_column_flags_t drizzle_column_flags_t;
 
339
#endif
 
340
 
 
341
/**
 
342
 * @addtogroup drizzle_types Types
 
343
 * @ingroup drizzle_client_interface
 
344
 * @ingroup drizzle_server_interface
 
345
 * @{
 
346
 */
 
347
 
 
348
/* Types. */
 
349
#ifndef __cplusplus
 
350
typedef struct drizzle_st drizzle_st;
 
351
typedef struct drizzle_con_tcp_st drizzle_con_tcp_st;
 
352
typedef struct drizzle_con_uds_st drizzle_con_uds_st;
 
353
typedef struct drizzle_con_st drizzle_con_st;
 
354
typedef struct drizzle_query_st drizzle_query_st;
 
355
typedef struct drizzle_result_st drizzle_result_st;
 
356
typedef struct drizzle_column_st drizzle_column_st;
 
357
#else
 
358
class drizzle_st;
 
359
class drizzle_con_tcp_st;
 
360
class drizzle_con_uds_st;
 
361
class drizzle_con_st;
 
362
class drizzle_query_st;
 
363
class drizzle_result_st;
 
364
class drizzle_column_st;
 
365
#endif
 
366
 
 
367
typedef char drizzle_field_t_type;
 
368
typedef drizzle_field_t_type *drizzle_field_t;
 
369
typedef drizzle_field_t drizzle_row_t_type;
 
370
typedef drizzle_row_t_type *drizzle_row_t;
 
371
typedef size_t * drizzle_field_sizes_type;
 
372
typedef uint8_t drizzle_charset_t;
 
373
 
 
374
#if defined(__cplusplus)
 
375
typedef ::std::vector<drizzle_row_t> drizzle_row_list_t;
 
376
typedef ::std::vector<drizzle_field_sizes_type> drizzle_field_sizes_list_t;
 
377
#else
 
378
typedef void drizzle_row_list_t;
 
379
typedef void drizzle_field_sizes_list_t;
 
380
#endif
 
381
 
 
382
/* Function types. */
 
383
typedef void (drizzle_context_free_fn)(drizzle_st *drizzle, void *context);
 
384
typedef void (drizzle_log_fn)(const char *line, drizzle_verbose_t verbose, void *context);
 
385
typedef drizzle_return_t (drizzle_state_fn)(drizzle_con_st *con);
 
386
typedef void (drizzle_con_context_free_fn)(drizzle_con_st *con, void *context);
 
387
typedef void (drizzle_query_context_free_fn)(drizzle_query_st *query, void *context);
 
388
/**
 
389
 * Custom function to register or deregister interest in file descriptor
 
390
 * events. See drizzle_set_event_watch_fn().
 
391
 *
 
392
 * @param[in] con Connection that has changed the events it is interested in.
 
393
 *  Use drizzle_con_fd() to get the file descriptor.
 
394
 * @param[in] events A bit mask of POLLIN | POLLOUT, specifying if the
 
395
 *  connection is waiting for read or write events.
 
396
 * @param[in] context Application context pointer registered with
 
397
 *  drizzle_set_event_watch_fn().
 
398
 * @return DRIZZLE_RETURN_OK if successful.
 
399
 */
 
400
typedef drizzle_return_t (drizzle_event_watch_fn)(drizzle_con_st *con,
 
401
                                                  short events,
 
402
                                                  void *context);
 
403
 
 
404
/** @} */
 
405
 
 
406
/**
 
407
 * @addtogroup drizzle_macros Macros
 
408
 * @ingroup drizzle_client_interface
 
409
 * @ingroup drizzle_server_interface
 
410
 * @{
 
411
 */
 
412
 
 
413
/* Protocol unpacking macros. */
 
414
#define drizzle_get_byte2(__buffer) \
 
415
  (uint16_t)((__buffer)[0] | \
 
416
            ((__buffer)[1] << 8))
 
417
#define drizzle_get_byte3(__buffer) \
 
418
  (uint32_t)((__buffer)[0] | \
 
419
            ((__buffer)[1] << 8) | \
 
420
            ((__buffer)[2] << 16))
 
421
#define drizzle_get_byte4(__buffer) \
 
422
  (uint32_t)((__buffer)[0] | \
 
423
            ((__buffer)[1] << 8) | \
 
424
            ((__buffer)[2] << 16) | \
 
425
            ((__buffer)[3] << 24))
 
426
#define drizzle_get_byte8(__buffer) \
 
427
  ((uint64_t)(__buffer)[0] | \
 
428
  ((uint64_t)(__buffer)[1] << 8) | \
 
429
  ((uint64_t)(__buffer)[2] << 16) | \
 
430
  ((uint64_t)(__buffer)[3] << 24) | \
 
431
  ((uint64_t)(__buffer)[4] << 32) | \
 
432
  ((uint64_t)(__buffer)[5] << 40) | \
 
433
  ((uint64_t)(__buffer)[6] << 48) | \
 
434
  ((uint64_t)(__buffer)[7] << 56))
 
435
 
 
436
/* Protocol packing macros. */
 
437
#define drizzle_set_byte2(__buffer, __int) do { \
 
438
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
 
439
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); } while (0)
 
440
#define drizzle_set_byte3(__buffer, __int) do { \
 
441
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
 
442
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
 
443
  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); } while (0)
 
444
#define drizzle_set_byte4(__buffer, __int) do { \
 
445
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
 
446
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
 
447
  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \
 
448
  (__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); } while (0)
 
449
#define drizzle_set_byte8(__buffer, __int) do { \
 
450
  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
 
451
  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
 
452
  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \
 
453
  (__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); \
 
454
  (__buffer)[4]= (uint8_t)(((__int) >> 32) & 0xFF); \
 
455
  (__buffer)[5]= (uint8_t)(((__int) >> 40) & 0xFF); \
 
456
  (__buffer)[6]= (uint8_t)(((__int) >> 48) & 0xFF); \
 
457
  (__buffer)[7]= (uint8_t)(((__int) >> 56) & 0xFF); } while (0)
 
458
 
 
459
/* Multi-byte character macros. */
 
460
#define drizzle_mb_char(__c) (((__c) & 0x80) != 0)
 
461
#define drizzle_mb_length(__c) \
 
462
  ((uint32_t)(__c) <= 0x7f ? 1 : \
 
463
  ((uint32_t)(__c) <= 0x7ff ? 2 : \
 
464
  ((uint32_t)(__c) <= 0xd7ff ? 3 : \
 
465
  ((uint32_t)(__c) <= 0xdfff || (uint32_t)(__c) > 0x10ffff ? 0 : \
 
466
  ((uint32_t)(__c) <= 0xffff ? 3 : 4)))))
 
467
 
 
468
/** @} */
 
469
 
 
470
#ifdef __cplusplus
 
471
}
 
472
#endif