libdrizzle Public API Documentation

constants.h
Go to the documentation of this file.
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 
16 #ifndef __DRIZZLE_CONSTANTS_H
17 #define __DRIZZLE_CONSTANTS_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
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 
68 typedef enum
69 {
95  DRIZZLE_RETURN_MAX /* Always add new codes to the end before this one. */
97 
101 typedef enum
102 {
111 
118 typedef enum
119 {
121  DRIZZLE_ALLOCATED= (1 << 0),
126 
131 typedef enum
132 {
135  DRIZZLE_CON_MYSQL= (1 << 1),
138  DRIZZLE_CON_READY= (1 << 4),
144 
149 typedef enum
150 {
154 
159 typedef enum
160 {
173 
178 typedef enum
179 {
208 
213 typedef enum
214 {
215  DRIZZLE_COMMAND_SLEEP, /* Not used currently. */
219  DRIZZLE_COMMAND_FIELD_LIST, /* Deprecated. */
220  DRIZZLE_COMMAND_CREATE_DB, /* Deprecated. */
221  DRIZZLE_COMMAND_DROP_DB, /* Deprecated. */
225  DRIZZLE_COMMAND_PROCESS_INFO, /* Deprecated. */
226  DRIZZLE_COMMAND_CONNECT, /* Not used currently. */
227  DRIZZLE_COMMAND_PROCESS_KILL, /* Deprecated. */
230  DRIZZLE_COMMAND_TIME, /* Not used currently. */
231  DRIZZLE_COMMAND_DELAYED_INSERT, /* Not used currently. */
233  DRIZZLE_COMMAND_BINLOG_DUMP, /* Not used currently. */
234  DRIZZLE_COMMAND_TABLE_DUMP, /* Not used currently. */
235  DRIZZLE_COMMAND_CONNECT_OUT, /* Not used currently. */
236  DRIZZLE_COMMAND_REGISTER_SLAVE, /* Not used currently. */
237  DRIZZLE_COMMAND_STMT_PREPARE, /* Not used currently. */
238  DRIZZLE_COMMAND_STMT_EXECUTE, /* Not used currently. */
239  DRIZZLE_COMMAND_STMT_SEND_LONG_DATA, /* Not used currently. */
240  DRIZZLE_COMMAND_STMT_CLOSE, /* Not used currently. */
241  DRIZZLE_COMMAND_STMT_RESET, /* Not used currently. */
242  DRIZZLE_COMMAND_SET_OPTION, /* Not used currently. */
243  DRIZZLE_COMMAND_STMT_FETCH, /* Not used currently. */
244  DRIZZLE_COMMAND_DAEMON, /* Not used currently. */
245  DRIZZLE_COMMAND_END /* Not used currently. */
247 
252 typedef enum
253 {
263 
268 typedef enum
269 {
272 
277 typedef enum
278 {
284 
289 typedef enum
290 {
299 
304 typedef enum
305 {
308 
313 typedef enum
314 {
343 
348 typedef enum
349 {
364 
369 typedef enum
370 {
388  DRIZZLE_COLUMN_FLAGS_GROUP= (1 << 15), /* NUM & GROUP the same. */
396 
404 /* Types. */
405 typedef struct drizzle_st drizzle_st;
412 typedef char *drizzle_field_t;
413 typedef drizzle_field_t *drizzle_row_t;
414 typedef uint8_t drizzle_charset_t;
415 
416 /* Function types. */
417 typedef void (drizzle_context_free_fn)(drizzle_st *drizzle,
418  void *context);
419 typedef void (drizzle_log_fn)(const char *line, drizzle_verbose_t verbose,
420  void *context);
423  void *context);
425  void *context);
439  short events,
440  void *context);
441 
451 /* Protocol unpacking macros. */
452 #define drizzle_get_byte2(__buffer) \
453  (uint16_t)((__buffer)[0] | \
454  ((__buffer)[1] << 8))
455 #define drizzle_get_byte3(__buffer) \
456  (uint32_t)((__buffer)[0] | \
457  ((__buffer)[1] << 8) | \
458  ((__buffer)[2] << 16))
459 #define drizzle_get_byte4(__buffer) \
460  (uint32_t)((__buffer)[0] | \
461  ((__buffer)[1] << 8) | \
462  ((__buffer)[2] << 16) | \
463  ((__buffer)[3] << 24))
464 #define drizzle_get_byte8(__buffer) \
465  ((uint64_t)(__buffer)[0] | \
466  ((uint64_t)(__buffer)[1] << 8) | \
467  ((uint64_t)(__buffer)[2] << 16) | \
468  ((uint64_t)(__buffer)[3] << 24) | \
469  ((uint64_t)(__buffer)[4] << 32) | \
470  ((uint64_t)(__buffer)[5] << 40) | \
471  ((uint64_t)(__buffer)[6] << 48) | \
472  ((uint64_t)(__buffer)[7] << 56))
473 
474 /* Protocol packing macros. */
475 #define drizzle_set_byte2(__buffer, __int) do { \
476  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
477  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); } while (0)
478 #define drizzle_set_byte3(__buffer, __int) do { \
479  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
480  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
481  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); } while (0)
482 #define drizzle_set_byte4(__buffer, __int) do { \
483  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
484  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
485  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \
486  (__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); } while (0)
487 #define drizzle_set_byte8(__buffer, __int) do { \
488  (__buffer)[0]= (uint8_t)((__int) & 0xFF); \
489  (__buffer)[1]= (uint8_t)(((__int) >> 8) & 0xFF); \
490  (__buffer)[2]= (uint8_t)(((__int) >> 16) & 0xFF); \
491  (__buffer)[3]= (uint8_t)(((__int) >> 24) & 0xFF); \
492  (__buffer)[4]= (uint8_t)(((__int) >> 32) & 0xFF); \
493  (__buffer)[5]= (uint8_t)(((__int) >> 40) & 0xFF); \
494  (__buffer)[6]= (uint8_t)(((__int) >> 48) & 0xFF); \
495  (__buffer)[7]= (uint8_t)(((__int) >> 56) & 0xFF); } while (0)
496 
497 /* Multi-byte character macros. */
498 #define drizzle_mb_char(__c) (((__c) & 0x80) != 0)
499 #define drizzle_mb_length(__c) \
500  ((uint32_t)(__c) <= 0x7f ? 1 : \
501  ((uint32_t)(__c) <= 0x7ff ? 2 : \
502  ((uint32_t)(__c) <= 0xd7ff ? 3 : \
503  ((uint32_t)(__c) <= 0xdfff || (uint32_t)(__c) > 0x10ffff ? 0 : \
504  ((uint32_t)(__c) <= 0xffff ? 3 : 4)))))
505 
508 #ifdef __cplusplus
509 }
510 #endif
511 
512 #endif /* __DRIZZLE_CONSTANTS_H */