forked from esnme/ultramysql
-
Notifications
You must be signed in to change notification settings - Fork 1
/
amdefs.h
387 lines (363 loc) · 12.3 KB
/
amdefs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
/*
Copyright (c) 2011, Jonas Tarnstrom and ESN Social Software AB
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by ESN Social Software AB (www.esn.me).
4. Neither the name of the ESN Social Software AB nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ESN SOCIAL SOFTWARE AB ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL ESN SOCIAL SOFTWARE AB BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Portions of code from gevent-MySQL
Copyright (C) 2010, Markus Thurlin
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Hyves (Startphone Ltd.) nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __AMDEFS_H__
#define __AMDEFS_H__
#ifdef _WIN32
//-----------------------------------------------------------------------------
// WIN32 stuff
//-----------------------------------------------------------------------------
#include <Windows.h>
#else
//-----------------------------------------------------------------------------
// POSIX stuff
//-----------------------------------------------------------------------------
#include <sys/types.h>
typedef u_int8_t UINT8;
typedef u_int16_t UINT16;
typedef u_int32_t UINT32;
typedef u_int64_t UINT64;
typedef int8_t INT8;
typedef int16_t INT16;
typedef int32_t INT32;
typedef int64_t INT64;
#endif
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
enum MYSQL_COMMANDS
{
MC_SLEEP = 0,
MC_QUIT = 1,
MC_INIT_DB = 2,
MC_QUERY = 3,
MC_LIST = 4,
};
enum MYSQL_PACKETREAD
{
MPR_NONE = 0,
MPR_MORE = 1,
MPR_ERROR = 2,
MPR_TRUE = 4,
MPR_START = 8,
MPR_END = 16,
MPR_EOF = 32,
};
enum MYSQL_FIELDTYPE
{
MFTYPE_DECIMAL = 0x00,
MFTYPE_TINY = 0x01,
MFTYPE_SHORT = 0x02,
MFTYPE_LONG = 0x03,
MFTYPE_FLOAT = 0x04,
MFTYPE_DOUBLE = 0x05,
MFTYPE_NULL = 0x06,
MFTYPE_TIMESTAMP = 0x07,
MFTYPE_LONGLONG = 0x08,
MFTYPE_INT24 = 0x09,
MFTYPE_DATE = 0x0a,
MFTYPE_TIME = 0x0b,
MFTYPE_DATETIME = 0x0c,
MFTYPE_YEAR = 0x0d,
MFTYPE_NEWDATE = 0x0e,
MFTYPE_VARCHAR = 0x0f,
MFTYPE_BIT = 0x10,
MFTYPE_NEWDECIMAL = 0xf6,
MFTYPE_ENUM = 0xf7,
MFTYPE_SET = 0xf8,
MFTYPE_TINY_BLOB = 0xf9,
MFTYPE_MEDIUM_BLOB = 0xfa,
MFTYPE_LONG_BLOB = 0xfb,
MFTYPE_BLOB = 0xfc,
MFTYPE_VAR_STRING = 0xfd,
MFTYPE_STRING = 0xfe,
MFTYPE_GEOMETRY = 0xff,
};
enum MYSQL_CAPABILITIES
{
MCP_LONG_PASSWORD = (1 << 0), // new more secure passwords
MCP_FOUND_ROWS = (1 << 1), //Found instead of affected rows
MCP_LONG_FLAG = (1 << 2), //Get all column flags */
MCP_CONNECT_WITH_DB = (1 << 3), // One can specify db on connect */
MCP_NO_SCHEMA = (1 << 4), // /* Don't allow database.table.column */
MCP_COMPRESS = (1 << 5), // Can use compression protocol */
MCP_ODBC = (1 << 6), // Odbc client */
MCP_LOCAL_FILES = (1 << 7), // Can use LOAD DATA LOCAL */
MCP_IGNORE_SPACE = (1 << 8), // Ignore spaces before '(' */
MCP_PROTOCOL_41 = (1 << 9), // New 4.1 protocol */
MCP_INTERACTIVE = (1 << 10), // This is an interactive client */
MCP_SSL = (1 << 11), //Switch to SSL after handshake */
MCP_IGNORE_SIGPIPE = (1 << 12), // IGNORE sigpipes */
MCP_TRANSACTIONS = (1 << 13), // Client knows about transactions */
MCP_RESERVED = (1 << 14), // Old flag for 4.1 protocol */
MCP_SECURE_CONNECTION = (1 << 15), // New 4.1 authentication */
MCP_MULTI_STATEMENTS = (1 << 16), // Enable/disable multi-stmt support */
MCP_MULTI_RESULTS = (1 << 17), // Enable/disable multi-results */
};
enum MYSQL_CHARSETS
{
MCS_UNDEFINED = 0,
MCS_big5_chinese_ci = 1,
MCS_big5_bin = 84,
MCS_dec8_swedish_ci = 3,
MCS_dec8_bin = 69,
MCS_cp850_general_ci = 4,
MCS_cp850_bin = 80,
MCS_hp8_english_ci = 6,
MCS_hp8_bin = 72,
MCS_koi8r_general_ci = 7,
MCS_koi8r_bin = 74,
MCS_latin1_german1_ci = 5,
MCS_latin1_swedish_ci = 8,
MCS_latin1_danish_ci = 15,
MCS_latin1_german2_ci = 31,
MCS_latin1_bin = 47,
MCS_latin1_general_ci = 48,
MCS_latin1_general_cs = 49,
MCS_latin1_spanish_ci = 94,
MCS_latin2_czech_cs = 2,
MCS_latin2_general_ci = 9,
MCS_latin2_hungarian_ci = 21,
MCS_latin2_croatian_ci = 27,
MCS_latin2_bin = 77,
MCS_swe7_swedish_ci = 10,
MCS_swe7_bin = 82,
MCS_ascii_general_ci = 11,
MCS_ascii_bin = 65,
MCS_ujis_japanese_ci = 12,
MCS_ujis_bin = 91,
MCS_sjis_japanese_ci = 13,
MCS_sjis_bin = 88,
MCS_hebrew_general_ci = 16,
MCS_hebrew_bin = 71,
MCS_tis620_thai_ci = 18,
MCS_tis620_bin = 89,
MCS_euckr_korean_ci = 19,
MCS_euckr_bin = 85,
MCS_koi8u_general_ci = 22,
MCS_koi8u_bin = 75,
MCS_gb2312_chinese_ci = 24,
MCS_gb2312_bin = 86,
MCS_greek_general_ci = 25,
MCS_greek_bin = 70,
MCS_cp1250_general_ci = 26,
MCS_cp1250_czech_cs = 34,
MCS_cp1250_croatian_ci = 44,
MCS_cp1250_bin = 66,
MCS_cp1250_polish_ci = 99,
MCS_gbk_chinese_ci = 28,
MCS_gbk_bin = 87,
MCS_latin5_turkish_ci = 30,
MCS_latin5_bin = 78,
MCS_armscii8_general_ci = 32,
MCS_armscii8_bin = 64,
MCS_utf8_general_ci = 33,
MCS_utf8_bin = 83,
MCS_utf8_unicode_ci = 192,
MCS_utf8_icelandic_ci = 193,
MCS_utf8_latvian_ci = 194,
MCS_utf8_romanian_ci = 195,
MCS_utf8_slovenian_ci = 196,
MCS_utf8_polish_ci = 197,
MCS_utf8_estonian_ci = 198,
MCS_utf8_spanish_ci = 199,
MCS_utf8_swedish_ci = 200,
MCS_utf8_turkish_ci = 201,
MCS_utf8_czech_ci = 202,
MCS_utf8_danish_ci = 203,
MCS_utf8_lithuanian_ci = 204,
MCS_utf8_slovak_ci = 205,
MCS_utf8_spanish2_ci = 206,
MCS_utf8_roman_ci = 207,
MCS_utf8_persian_ci = 208,
MCS_utf8_esperanto_ci = 209,
MCS_utf8_hungarian_ci = 210,
MCS_utf8_sinhala_ci = 211,
MCS_ucs2_general_ci = 35,
MCS_ucs2_bin = 90,
MCS_ucs2_unicode_ci = 128,
MCS_ucs2_icelandic_ci = 129,
MCS_ucs2_latvian_ci = 130,
MCS_ucs2_romanian_ci = 131,
MCS_ucs2_slovenian_ci = 132,
MCS_ucs2_polish_ci = 133,
MCS_ucs2_estonian_ci = 134,
MCS_ucs2_spanish_ci = 135,
MCS_ucs2_swedish_ci = 136,
MCS_ucs2_turkish_ci = 137,
MCS_ucs2_czech_ci = 138,
MCS_ucs2_danish_ci = 139,
MCS_ucs2_lithuanian_ci = 140,
MCS_ucs2_slovak_ci = 141,
MCS_ucs2_spanish2_ci = 142,
MCS_ucs2_roman_ci = 143,
MCS_ucs2_persian_ci = 144,
MCS_ucs2_esperanto_ci = 145,
MCS_ucs2_hungarian_ci = 146,
MCS_ucs2_sinhala_ci = 147,
MCS_cp866_general_ci = 36,
MCS_cp866_bin = 68,
MCS_keybcs2_general_ci = 37,
MCS_keybcs2_bin = 73,
MCS_macce_general_ci = 38,
MCS_macce_bin = 43,
MCS_macroman_general_ci = 39,
MCS_macroman_bin = 53,
MCS_cp852_general_ci = 40,
MCS_cp852_bin = 81,
MCS_latin7_estonian_cs = 20,
MCS_latin7_general_ci = 41,
MCS_latin7_general_cs = 42,
MCS_latin7_bin = 79,
MCS_utf8mb4_general_ci = 45,
MCS_utf8mb4_bin = 46,
MCS_utf8mb4_unicode_ci = 224,
MCS_utf8mb4_icelandic_ci = 225,
MCS_utf8mb4_latvian_ci = 226,
MCS_utf8mb4_romanian_ci = 227,
MCS_utf8mb4_slovenian_ci = 228,
MCS_utf8mb4_polish_ci = 229,
MCS_utf8mb4_estonian_ci = 230,
MCS_utf8mb4_spanish_ci = 231,
MCS_utf8mb4_swedish_ci = 232,
MCS_utf8mb4_turkish_ci = 233,
MCS_utf8mb4_czech_ci = 234,
MCS_utf8mb4_danish_ci = 235,
MCS_utf8mb4_lithuanian_ci = 236,
MCS_utf8mb4_slovak_ci = 237,
MCS_utf8mb4_spanish2_ci = 238,
MCS_utf8mb4_roman_ci = 239,
MCS_utf8mb4_persian_ci = 240,
MCS_utf8mb4_esperanto_ci = 241,
MCS_utf8mb4_hungarian_ci = 242,
MCS_utf8mb4_sinhala_ci = 243,
MCS_cp1251_bulgarian_ci = 14,
MCS_cp1251_ukrainian_ci = 23,
MCS_cp1251_bin = 50,
MCS_cp1251_general_ci = 51,
MCS_cp1251_general_cs = 52,
MCS_utf16_general_ci = 54,
MCS_utf16_bin = 55,
MCS_utf16_unicode_ci = 101,
MCS_utf16_icelandic_ci = 102,
MCS_utf16_latvian_ci = 103,
MCS_utf16_romanian_ci = 104,
MCS_utf16_slovenian_ci = 105,
MCS_utf16_polish_ci = 106,
MCS_utf16_estonian_ci = 107,
MCS_utf16_spanish_ci = 108,
MCS_utf16_swedish_ci = 109,
MCS_utf16_turkish_ci = 110,
MCS_utf16_czech_ci = 111,
MCS_utf16_danish_ci = 112,
MCS_utf16_lithuanian_ci = 113,
MCS_utf16_slovak_ci = 114,
MCS_utf16_spanish2_ci = 115,
MCS_utf16_roman_ci = 116,
MCS_utf16_persian_ci = 117,
MCS_utf16_esperanto_ci = 118,
MCS_utf16_hungarian_ci = 119,
MCS_utf16_sinhala_ci = 120,
MCS_cp1256_general_ci = 57,
MCS_cp1256_bin = 67,
MCS_cp1257_lithuanian_ci = 29,
MCS_cp1257_bin = 58,
MCS_cp1257_general_ci = 59,
MCS_utf32_general_ci = 60,
MCS_utf32_bin = 61,
MCS_utf32_unicode_ci = 160,
MCS_utf32_icelandic_ci = 161,
MCS_utf32_latvian_ci = 162,
MCS_utf32_romanian_ci = 163,
MCS_utf32_slovenian_ci = 164,
MCS_utf32_polish_ci = 165,
MCS_utf32_estonian_ci = 166,
MCS_utf32_spanish_ci = 167,
MCS_utf32_swedish_ci = 168,
MCS_utf32_turkish_ci = 169,
MCS_utf32_czech_ci = 170,
MCS_utf32_danish_ci = 171,
MCS_utf32_lithuanian_ci = 172,
MCS_utf32_slovak_ci = 173,
MCS_utf32_spanish2_ci = 174,
MCS_utf32_roman_ci = 175,
MCS_utf32_persian_ci = 176,
MCS_utf32_esperanto_ci = 177,
MCS_utf32_hungarian_ci = 178,
MCS_utf32_sinhala_ci = 179,
MCS_binary = 63,
MCS_geostd8_general_ci = 92,
MCS_geostd8_bin = 93,
MCS_cp932_japanese_ci = 95,
MCS_cp932_bin = 96,
MCS_eucjpms_japanese_ci = 97,
MCS_eucjpms_bin = 98,
};
enum MYSQL_FIELDFLAG
{
MFFLAG_NOT_NULL_FLAG = 0x0001,
MFFLAG_PRI_KEY_FLAG = 0x0002,
MFFLAG_UNIQUE_KEY_FLAG = 0x0004,
MFFLAG_MULTIPLE_KEY_FLAG = 0x0008,
MFFLAG_BLOB_FLAG = 0x0010,
MFFLAG_UNSIGNED_FLAG = 0x0020,
MFFLAG_ZEROFILL_FLAG = 0x0040,
MFFLAG_BINARY_FLAG = 0x0080,
MFFLAG_ENUM_FLAG = 0x0100,
MFFLAG_AUTO_INCREMENT_FLAG = 0x0200,
MFFLAG_TIMESTAMP_FLAG = 0x0400,
MFFLAG_SET_FLAG = 0x0800,
};
#define MYSQL_PACKET_HEADER_SIZE 4
#define MYSQL_PROTOCOL_VERSION 0x0a
#define MYSQL_PACKET_SIZE (1024 * 1024 * 16)
#define MYSQL_TX_BUFFER_SIZE ((1024 * 1024 * 4) + MYSQL_PACKET_HEADER_SIZE)
#define MYSQL_RX_BUFFER_SIZE (MYSQL_PACKET_SIZE + MYSQL_PACKET_HEADER_SIZE)
#endif