~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to include/m_ctype.h

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
/*
 
17
  A better inplementation of the UNIX ctype(3) library.
 
18
  Notes:   my_global.h should be included before ctype.h
 
19
*/
 
20
 
 
21
#ifndef _m_ctype_h
 
22
#define _m_ctype_h
 
23
 
 
24
#include <my_attribute.h>
 
25
 
 
26
#ifdef  __cplusplus
 
27
extern "C" {
 
28
#endif
 
29
 
 
30
#define MY_CS_NAME_SIZE                 32
 
31
#define MY_CS_CTYPE_TABLE_SIZE          257
 
32
#define MY_CS_TO_LOWER_TABLE_SIZE       256
 
33
#define MY_CS_TO_UPPER_TABLE_SIZE       256
 
34
#define MY_CS_SORT_ORDER_TABLE_SIZE     256
 
35
#define MY_CS_TO_UNI_TABLE_SIZE         256
 
36
 
 
37
#define CHARSET_DIR     "charsets/"
 
38
 
 
39
#define my_wc_t ulong
 
40
 
 
41
typedef struct unicase_info_st
 
42
{
 
43
  uint16 toupper;
 
44
  uint16 tolower;
 
45
  uint16 sort;
 
46
} MY_UNICASE_INFO;
 
47
 
 
48
 
 
49
extern MY_UNICASE_INFO *my_unicase_default[256];
 
50
extern MY_UNICASE_INFO *my_unicase_turkish[256];
 
51
 
 
52
typedef struct uni_ctype_st
 
53
{
 
54
  uchar  pctype;
 
55
  uchar  *ctype;
 
56
} MY_UNI_CTYPE;
 
57
 
 
58
extern MY_UNI_CTYPE my_uni_ctype[256];
 
59
 
 
60
/* wm_wc and wc_mb return codes */
 
61
#define MY_CS_ILSEQ     0     /* Wrong by sequence: wb_wc                   */
 
62
#define MY_CS_ILUNI     0     /* Cannot encode Unicode to charset: wc_mb    */
 
63
#define MY_CS_TOOSMALL  -101  /* Need at least one byte:    wc_mb and mb_wc */
 
64
#define MY_CS_TOOSMALL2 -102  /* Need at least two bytes:   wc_mb and mb_wc */
 
65
#define MY_CS_TOOSMALL3 -103  /* Need at least three bytes: wc_mb and mb_wc */
 
66
/* These following three are currently not really used */
 
67
#define MY_CS_TOOSMALL4 -104  /* Need at least 4 bytes: wc_mb and mb_wc */
 
68
#define MY_CS_TOOSMALL5 -105  /* Need at least 5 bytes: wc_mb and mb_wc */
 
69
#define MY_CS_TOOSMALL6 -106  /* Need at least 6 bytes: wc_mb and mb_wc */
 
70
/* A helper macros for "need at least n bytes" */
 
71
#define MY_CS_TOOSMALLN(n)    (-100-(n))
 
72
 
 
73
#define MY_SEQ_INTTAIL  1
 
74
#define MY_SEQ_SPACES   2
 
75
 
 
76
        /* My charsets_list flags */
 
77
#define MY_CS_COMPILED  1      /* compiled-in sets               */
 
78
#define MY_CS_CONFIG    2      /* sets that have a *.conf file   */
 
79
#define MY_CS_INDEX     4      /* sets listed in the Index file  */
 
80
#define MY_CS_LOADED    8      /* sets that are currently loaded */
 
81
#define MY_CS_BINSORT   16     /* if binary sort order           */
 
82
#define MY_CS_PRIMARY   32     /* if primary collation           */
 
83
#define MY_CS_STRNXFRM  64     /* if strnxfrm is used for sort   */
 
84
#define MY_CS_UNICODE   128    /* is a charset is full unicode   */
 
85
#define MY_CS_READY     256    /* if a charset is initialized    */
 
86
#define MY_CS_AVAILABLE 512    /* If either compiled-in or loaded*/
 
87
#define MY_CS_CSSORT    1024   /* if case sensitive sort order   */     
 
88
#define MY_CS_HIDDEN    2048   /* don't display in SHOW          */     
 
89
#define MY_CS_PUREASCII 4096   /* if a charset is pure ascii     */
 
90
#define MY_CS_NONASCII  8192   /* if not ASCII-compatible        */
 
91
#define MY_CHARSET_UNDEFINED 0
 
92
 
 
93
/* Character repertoire flags */
 
94
#define MY_REPERTOIRE_ASCII      1 /* Pure ASCII            U+0000..U+007F */
 
95
#define MY_REPERTOIRE_EXTENDED   2 /* Extended characters:  U+0080..U+FFFF */
 
96
#define MY_REPERTOIRE_UNICODE30  3 /* ASCII | EXTENDED:     U+0000..U+FFFF */
 
97
 
 
98
/* Flags for strxfrm */
 
99
#define MY_STRXFRM_LEVEL1          0x00000001 /* for primary weights   */
 
100
#define MY_STRXFRM_LEVEL2          0x00000002 /* for secondary weights */
 
101
#define MY_STRXFRM_LEVEL3          0x00000004 /* for tertiary weights  */
 
102
#define MY_STRXFRM_LEVEL4          0x00000008 /* fourth level weights  */
 
103
#define MY_STRXFRM_LEVEL5          0x00000010 /* fifth level weights   */
 
104
#define MY_STRXFRM_LEVEL6          0x00000020 /* sixth level weights   */
 
105
#define MY_STRXFRM_LEVEL_ALL       0x0000003F /* Bit OR for the above six */
 
106
#define MY_STRXFRM_NLEVELS         6          /* Number of possible levels*/
 
107
 
 
108
#define MY_STRXFRM_PAD_WITH_SPACE  0x00000040 /* if pad result with spaces */
 
109
#define MY_STRXFRM_UNUSED_00000080 0x00000080 /* for future extensions     */
 
110
 
 
111
#define MY_STRXFRM_DESC_LEVEL1     0x00000100 /* if desc order for level1 */
 
112
#define MY_STRXFRM_DESC_LEVEL2     0x00000200 /* if desc order for level2 */
 
113
#define MY_STRXFRM_DESC_LEVEL3     0x00000300 /* if desc order for level3 */
 
114
#define MY_STRXFRM_DESC_LEVEL4     0x00000800 /* if desc order for level4 */
 
115
#define MY_STRXFRM_DESC_LEVEL5     0x00001000 /* if desc order for level5 */
 
116
#define MY_STRXFRM_DESC_LEVEL6     0x00002000 /* if desc order for level6 */
 
117
#define MY_STRXFRM_DESC_SHIFT      8
 
118
 
 
119
#define MY_STRXFRM_UNUSED_00004000 0x00004000 /* for future extensions     */
 
120
#define MY_STRXFRM_UNUSED_00008000 0x00008000 /* for future extensions     */
 
121
 
 
122
#define MY_STRXFRM_REVERSE_LEVEL1  0x00010000 /* if reverse order for level1 */
 
123
#define MY_STRXFRM_REVERSE_LEVEL2  0x00020000 /* if reverse order for level2 */
 
124
#define MY_STRXFRM_REVERSE_LEVEL3  0x00040000 /* if reverse order for level3 */
 
125
#define MY_STRXFRM_REVERSE_LEVEL4  0x00080000 /* if reverse order for level4 */
 
126
#define MY_STRXFRM_REVERSE_LEVEL5  0x00100000 /* if reverse order for level5 */
 
127
#define MY_STRXFRM_REVERSE_LEVEL6  0x00200000 /* if reverse order for level6 */
 
128
#define MY_STRXFRM_REVERSE_SHIFT   16
 
129
 
 
130
 
 
131
typedef struct my_uni_idx_st
 
132
{
 
133
  uint16 from;
 
134
  uint16 to;
 
135
  uchar  *tab;
 
136
} MY_UNI_IDX;
 
137
 
 
138
typedef struct
 
139
{
 
140
  uint beg;
 
141
  uint end;
 
142
  uint mb_len;
 
143
} my_match_t;
 
144
 
 
145
enum my_lex_states
 
146
{
 
147
  MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT, 
 
148
  MY_LEX_IDENT_SEP, MY_LEX_IDENT_START,
 
149
  MY_LEX_REAL, MY_LEX_HEX_NUMBER, MY_LEX_BIN_NUMBER,
 
150
  MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END,
 
151
  MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL,
 
152
  MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE, 
 
153
  MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_SEMICOLON, 
 
154
  MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP, 
 
155
  MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR,
 
156
  MY_LEX_IDENT_OR_KEYWORD,
 
157
  MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR,
 
158
  MY_LEX_STRING_OR_DELIMITER
 
159
};
 
160
 
 
161
struct charset_info_st;
 
162
 
 
163
 
 
164
/* See strings/CHARSET_INFO.txt for information about this structure  */
 
165
typedef struct my_collation_handler_st
 
166
{
 
167
  my_bool (*init)(struct charset_info_st *, void *(*alloc)(size_t));
 
168
  /* Collation routines */
 
169
  int     (*strnncoll)(struct charset_info_st *,
 
170
                       const uchar *, size_t, const uchar *, size_t, my_bool);
 
171
  int     (*strnncollsp)(struct charset_info_st *,
 
172
                         const uchar *, size_t, const uchar *, size_t,
 
173
                         my_bool diff_if_only_endspace_difference);
 
174
  size_t  (*strnxfrm)(struct charset_info_st *,
 
175
                      uchar *dst, size_t dstlen, uint nweights,
 
176
                      const uchar *src, size_t srclen, uint flags);
 
177
  size_t    (*strnxfrmlen)(struct charset_info_st *, size_t);
 
178
  my_bool (*like_range)(struct charset_info_st *,
 
179
                        const char *s, size_t s_length,
 
180
                        pchar w_prefix, pchar w_one, pchar w_many, 
 
181
                        size_t res_length,
 
182
                        char *min_str, char *max_str,
 
183
                        size_t *min_len, size_t *max_len);
 
184
  int     (*wildcmp)(struct charset_info_st *,
 
185
                     const char *str,const char *str_end,
 
186
                     const char *wildstr,const char *wildend,
 
187
                     int escape,int w_one, int w_many);
 
188
 
 
189
  int  (*strcasecmp)(struct charset_info_st *, const char *, const char *);
 
190
  
 
191
  uint (*instr)(struct charset_info_st *,
 
192
                const char *b, size_t b_length,
 
193
                const char *s, size_t s_length,
 
194
                my_match_t *match, uint nmatch);
 
195
  
 
196
  /* Hash calculation */
 
197
  void (*hash_sort)(struct charset_info_st *cs, const uchar *key, size_t len,
 
198
                    ulong *nr1, ulong *nr2); 
 
199
  my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, size_t len);
 
200
} MY_COLLATION_HANDLER;
 
201
 
 
202
extern MY_COLLATION_HANDLER my_collation_mb_bin_handler;
 
203
extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler;
 
204
extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler;
 
205
extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler;
 
206
 
 
207
/* Some typedef to make it easy for C++ to make function pointers */
 
208
typedef int (*my_charset_conv_mb_wc)(struct charset_info_st *, my_wc_t *,
 
209
                                     const uchar *, const uchar *);
 
210
typedef int (*my_charset_conv_wc_mb)(struct charset_info_st *, my_wc_t,
 
211
                                     uchar *, uchar *);
 
212
typedef size_t (*my_charset_conv_case)(struct charset_info_st *,
 
213
                                       char *, size_t, char *, size_t);
 
214
 
 
215
 
 
216
/* See strings/CHARSET_INFO.txt about information on this structure  */
 
217
typedef struct my_charset_handler_st
 
218
{
 
219
  my_bool (*init)(struct charset_info_st *, void *(*alloc)(size_t));
 
220
  /* Multibyte routines */
 
221
  uint    (*ismbchar)(struct charset_info_st *, const char *, const char *);
 
222
  uint    (*mbcharlen)(struct charset_info_st *, uint c);
 
223
  size_t  (*numchars)(struct charset_info_st *, const char *b, const char *e);
 
224
  size_t  (*charpos)(struct charset_info_st *, const char *b, const char *e,
 
225
                     size_t pos);
 
226
  size_t  (*well_formed_len)(struct charset_info_st *,
 
227
                             const char *b,const char *e,
 
228
                             size_t nchars, int *error);
 
229
  size_t  (*lengthsp)(struct charset_info_st *, const char *ptr, size_t length);
 
230
  size_t  (*numcells)(struct charset_info_st *, const char *b, const char *e);
 
231
  
 
232
  /* Unicode conversion */
 
233
  my_charset_conv_mb_wc mb_wc;
 
234
  my_charset_conv_wc_mb wc_mb;
 
235
 
 
236
  /* CTYPE scanner */
 
237
  int (*ctype)(struct charset_info_st *cs, int *ctype,
 
238
               const uchar *s, const uchar *e);
 
239
  
 
240
  /* Functions for case and sort conversion */
 
241
  size_t  (*caseup_str)(struct charset_info_st *, char *);
 
242
  size_t  (*casedn_str)(struct charset_info_st *, char *);
 
243
 
 
244
  my_charset_conv_case caseup;
 
245
  my_charset_conv_case casedn;
 
246
 
 
247
  /* Charset dependant snprintf() */
 
248
  size_t (*snprintf)(struct charset_info_st *, char *to, size_t n,
 
249
                     const char *fmt,
 
250
                     ...) ATTRIBUTE_FORMAT_FPTR(printf, 4, 5);
 
251
  size_t (*long10_to_str)(struct charset_info_st *, char *to, size_t n,
 
252
                          int radix, long int val);
 
253
  size_t (*longlong10_to_str)(struct charset_info_st *, char *to, size_t n,
 
254
                              int radix, longlong val);
 
255
  
 
256
  void (*fill)(struct charset_info_st *, char *to, size_t len, int fill);
 
257
  
 
258
  /* String-to-number conversion routines */
 
259
  long        (*strntol)(struct charset_info_st *, const char *s, size_t l,
 
260
                         int base, char **e, int *err);
 
261
  ulong      (*strntoul)(struct charset_info_st *, const char *s, size_t l,
 
262
                         int base, char **e, int *err);
 
263
  longlong   (*strntoll)(struct charset_info_st *, const char *s, size_t l,
 
264
                         int base, char **e, int *err);
 
265
  ulonglong (*strntoull)(struct charset_info_st *, const char *s, size_t l,
 
266
                         int base, char **e, int *err);
 
267
  double      (*strntod)(struct charset_info_st *, char *s, size_t l, char **e,
 
268
                         int *err);
 
269
  longlong    (*strtoll10)(struct charset_info_st *cs,
 
270
                           const char *nptr, char **endptr, int *error);
 
271
  ulonglong   (*strntoull10rnd)(struct charset_info_st *cs,
 
272
                                const char *str, size_t length,
 
273
                                int unsigned_fl,
 
274
                                char **endptr, int *error);
 
275
  size_t        (*scan)(struct charset_info_st *, const char *b, const char *e,
 
276
                        int sq);
 
277
} MY_CHARSET_HANDLER;
 
278
 
 
279
extern MY_CHARSET_HANDLER my_charset_8bit_handler;
 
280
extern MY_CHARSET_HANDLER my_charset_ucs2_handler;
 
281
 
 
282
 
 
283
/* See strings/CHARSET_INFO.txt about information on this structure  */
 
284
typedef struct charset_info_st
 
285
{
 
286
  uint      number;
 
287
  uint      primary_number;
 
288
  uint      binary_number;
 
289
  uint      state;
 
290
  const char *csname;
 
291
  const char *name;
 
292
  const char *comment;
 
293
  const char *tailoring;
 
294
  uchar    *ctype;
 
295
  uchar    *to_lower;
 
296
  uchar    *to_upper;
 
297
  uchar    *sort_order;
 
298
  uint16   *contractions;
 
299
  uint16   **sort_order_big;
 
300
  uint16      *tab_to_uni;
 
301
  MY_UNI_IDX  *tab_from_uni;
 
302
  MY_UNICASE_INFO **caseinfo;
 
303
  uchar     *state_map;
 
304
  uchar     *ident_map;
 
305
  uint      strxfrm_multiply;
 
306
  uchar     caseup_multiply;
 
307
  uchar     casedn_multiply;
 
308
  uint      mbminlen;
 
309
  uint      mbmaxlen;
 
310
  uint16    min_sort_char;
 
311
  uint16    max_sort_char; /* For LIKE optimization */
 
312
  uchar     pad_char;
 
313
  my_bool   escape_with_backslash_is_dangerous;
 
314
  uchar     levels_for_compare;
 
315
  uchar     levels_for_order;
 
316
  
 
317
  MY_CHARSET_HANDLER *cset;
 
318
  MY_COLLATION_HANDLER *coll;
 
319
  
 
320
} CHARSET_INFO;
 
321
#define ILLEGAL_CHARSET_INFO_NUMBER (~0U)
 
322
 
 
323
 
 
324
extern CHARSET_INFO my_charset_bin;
 
325
extern CHARSET_INFO my_charset_big5_chinese_ci;
 
326
extern CHARSET_INFO my_charset_big5_bin;
 
327
extern CHARSET_INFO my_charset_cp932_japanese_ci;
 
328
extern CHARSET_INFO my_charset_cp932_bin;
 
329
extern CHARSET_INFO my_charset_cp1250_czech_ci;
 
330
extern CHARSET_INFO my_charset_eucjpms_japanese_ci;
 
331
extern CHARSET_INFO my_charset_eucjpms_bin;
 
332
extern CHARSET_INFO my_charset_euckr_korean_ci;
 
333
extern CHARSET_INFO my_charset_euckr_bin;
 
334
extern CHARSET_INFO my_charset_filename;
 
335
extern CHARSET_INFO my_charset_gb2312_chinese_ci;
 
336
extern CHARSET_INFO my_charset_gb2312_bin;
 
337
extern CHARSET_INFO my_charset_gbk_chinese_ci;
 
338
extern CHARSET_INFO my_charset_gbk_bin;
 
339
extern CHARSET_INFO my_charset_latin1;
 
340
extern CHARSET_INFO my_charset_latin1_german2_ci;
 
341
extern CHARSET_INFO my_charset_latin1_bin;
 
342
extern CHARSET_INFO my_charset_latin2_czech_ci;
 
343
extern CHARSET_INFO my_charset_sjis_japanese_ci;
 
344
extern CHARSET_INFO my_charset_sjis_bin;
 
345
extern CHARSET_INFO my_charset_tis620_thai_ci;
 
346
extern CHARSET_INFO my_charset_tis620_bin;
 
347
extern CHARSET_INFO my_charset_ucs2_general_ci;
 
348
extern CHARSET_INFO my_charset_ucs2_bin;
 
349
extern CHARSET_INFO my_charset_ucs2_unicode_ci;
 
350
extern CHARSET_INFO my_charset_ujis_japanese_ci;
 
351
extern CHARSET_INFO my_charset_ujis_bin;
 
352
extern CHARSET_INFO my_charset_utf16_bin;
 
353
extern CHARSET_INFO my_charset_utf16_general_ci;
 
354
extern CHARSET_INFO my_charset_utf16_unicode_ci;
 
355
extern CHARSET_INFO my_charset_utf32_bin;
 
356
extern CHARSET_INFO my_charset_utf32_general_ci;
 
357
extern CHARSET_INFO my_charset_utf32_unicode_ci;
 
358
extern CHARSET_INFO my_charset_utf8mb3_bin;
 
359
extern CHARSET_INFO my_charset_utf8mb3_general_ci;
 
360
extern CHARSET_INFO my_charset_utf8mb3_unicode_ci;
 
361
extern CHARSET_INFO my_charset_utf8mb4_bin;
 
362
extern CHARSET_INFO my_charset_utf8mb4_general_ci;
 
363
extern CHARSET_INFO my_charset_utf8mb4_unicode_ci;
 
364
 
 
365
#define MY_UTF8MB3                 "utf8mb3"
 
366
#define MY_UTF8MB4                 "utf8"
 
367
#define my_charset_utf8_general_ci my_charset_utf8mb4_general_ci
 
368
#define my_charset_utf8_bin        my_charset_utf8mb4_bin
 
369
 
 
370
 
 
371
/* declarations for simple charsets */
 
372
extern size_t my_strnxfrm_simple(CHARSET_INFO *,
 
373
                                 uchar *dst, size_t dstlen, uint nweights,
 
374
                                 const uchar *src, size_t srclen, uint flags);
 
375
size_t my_strnxfrmlen_simple(CHARSET_INFO *, size_t);
 
376
extern int  my_strnncoll_simple(CHARSET_INFO *, const uchar *, size_t,
 
377
                                const uchar *, size_t, my_bool);
 
378
 
 
379
extern int  my_strnncollsp_simple(CHARSET_INFO *, const uchar *, size_t,
 
380
                                  const uchar *, size_t,
 
381
                                  my_bool diff_if_only_endspace_difference);
 
382
 
 
383
extern void my_hash_sort_simple(CHARSET_INFO *cs,
 
384
                                const uchar *key, size_t len,
 
385
                                ulong *nr1, ulong *nr2); 
 
386
 
 
387
extern size_t my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, size_t length);
 
388
 
 
389
extern uint my_instr_simple(struct charset_info_st *,
 
390
                            const char *b, size_t b_length,
 
391
                            const char *s, size_t s_length,
 
392
                            my_match_t *match, uint nmatch);
 
393
 
 
394
 
 
395
/* Functions for 8bit */
 
396
extern size_t my_caseup_str_8bit(CHARSET_INFO *, char *);
 
397
extern size_t my_casedn_str_8bit(CHARSET_INFO *, char *);
 
398
extern size_t my_caseup_8bit(CHARSET_INFO *, char *src, size_t srclen,
 
399
                             char *dst, size_t dstlen);
 
400
extern size_t my_casedn_8bit(CHARSET_INFO *, char *src, size_t srclen,
 
401
                             char *dst, size_t dstlen);
 
402
 
 
403
extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *);
 
404
 
 
405
int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, const uchar *s,const uchar *e);
 
406
int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e);
 
407
 
 
408
int my_mb_ctype_8bit(CHARSET_INFO *,int *, const uchar *,const uchar *);
 
409
int my_mb_ctype_mb(CHARSET_INFO *,int *, const uchar *,const uchar *);
 
410
 
 
411
size_t my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq);
 
412
 
 
413
size_t my_snprintf_8bit(struct charset_info_st *, char *to, size_t n,
 
414
                        const char *fmt, ...)
 
415
  ATTRIBUTE_FORMAT(printf, 4, 5);
 
416
 
 
417
long       my_strntol_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
 
418
                           char **e, int *err);
 
419
ulong      my_strntoul_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
 
420
                            char **e, int *err);
 
421
longlong   my_strntoll_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
 
422
                            char **e, int *err);
 
423
ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
 
424
                            char **e, int *err);
 
425
double      my_strntod_8bit(CHARSET_INFO *, char *s, size_t l,char **e,
 
426
                            int *err);
 
427
size_t my_long10_to_str_8bit(CHARSET_INFO *, char *to, size_t l, int radix,
 
428
                             long int val);
 
429
size_t my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, size_t l, int radix,
 
430
                                 longlong val);
 
431
 
 
432
longlong my_strtoll10_8bit(CHARSET_INFO *cs,
 
433
                           const char *nptr, char **endptr, int *error);
 
434
longlong my_strtoll10_ucs2(CHARSET_INFO *cs, 
 
435
                           const char *nptr, char **endptr, int *error);
 
436
 
 
437
ulonglong my_strntoull10rnd_8bit(CHARSET_INFO *cs,
 
438
                                 const char *str, size_t length, int
 
439
                                 unsigned_fl, char **endptr, int *error);
 
440
ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs, 
 
441
                                 const char *str, size_t length,
 
442
                                 int unsigned_fl, char **endptr, int *error);
 
443
 
 
444
void my_fill_8bit(CHARSET_INFO *cs, char* to, size_t l, int fill);
 
445
 
 
446
my_bool  my_like_range_simple(CHARSET_INFO *cs,
 
447
                              const char *ptr, size_t ptr_length,
 
448
                              pbool escape, pbool w_one, pbool w_many,
 
449
                              size_t res_length,
 
450
                              char *min_str, char *max_str,
 
451
                              size_t *min_length, size_t *max_length);
 
452
 
 
453
my_bool  my_like_range_mb(CHARSET_INFO *cs,
 
454
                          const char *ptr, size_t ptr_length,
 
455
                          pbool escape, pbool w_one, pbool w_many,
 
456
                          size_t res_length,
 
457
                          char *min_str, char *max_str,
 
458
                          size_t *min_length, size_t *max_length);
 
459
 
 
460
my_bool  my_like_range_ucs2(CHARSET_INFO *cs,
 
461
                            const char *ptr, size_t ptr_length,
 
462
                            pbool escape, pbool w_one, pbool w_many,
 
463
                            size_t res_length,
 
464
                            char *min_str, char *max_str,
 
465
                            size_t *min_length, size_t *max_length);
 
466
 
 
467
my_bool  my_like_range_utf16(CHARSET_INFO *cs,
 
468
                             const char *ptr, size_t ptr_length,
 
469
                             pbool escape, pbool w_one, pbool w_many,
 
470
                             size_t res_length,
 
471
                             char *min_str, char *max_str,
 
472
                             size_t *min_length, size_t *max_length);
 
473
 
 
474
my_bool  my_like_range_utf32(CHARSET_INFO *cs,
 
475
                             const char *ptr, size_t ptr_length,
 
476
                             pbool escape, pbool w_one, pbool w_many,
 
477
                             size_t res_length,
 
478
                             char *min_str, char *max_str,
 
479
                             size_t *min_length, size_t *max_length);
 
480
 
 
481
 
 
482
int my_wildcmp_8bit(CHARSET_INFO *,
 
483
                    const char *str,const char *str_end,
 
484
                    const char *wildstr,const char *wildend,
 
485
                    int escape, int w_one, int w_many);
 
486
 
 
487
int my_wildcmp_bin(CHARSET_INFO *,
 
488
                   const char *str,const char *str_end,
 
489
                   const char *wildstr,const char *wildend,
 
490
                   int escape, int w_one, int w_many);
 
491
 
 
492
size_t my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e);
 
493
size_t my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e);
 
494
size_t my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, size_t pos);
 
495
size_t my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e,
 
496
                             size_t pos, int *error);
 
497
uint my_mbcharlen_8bit(CHARSET_INFO *, uint c);
 
498
 
 
499
 
 
500
/* Functions for multibyte charsets */
 
501
extern size_t my_caseup_str_mb(CHARSET_INFO *, char *);
 
502
extern size_t my_casedn_str_mb(CHARSET_INFO *, char *);
 
503
extern size_t my_caseup_mb(CHARSET_INFO *, char *src, size_t srclen,
 
504
                                         char *dst, size_t dstlen);
 
505
extern size_t my_casedn_mb(CHARSET_INFO *, char *src, size_t srclen,
 
506
                                         char *dst, size_t dstlen);
 
507
extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *);
 
508
 
 
509
int my_wildcmp_mb(CHARSET_INFO *,
 
510
                  const char *str,const char *str_end,
 
511
                  const char *wildstr,const char *wildend,
 
512
                  int escape, int w_one, int w_many);
 
513
size_t my_numchars_mb(CHARSET_INFO *, const char *b, const char *e);
 
514
size_t my_numcells_mb(CHARSET_INFO *, const char *b, const char *e);
 
515
size_t my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, size_t pos);
 
516
size_t my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e,
 
517
                             size_t pos, int *error);
 
518
uint my_instr_mb(struct charset_info_st *,
 
519
                 const char *b, size_t b_length,
 
520
                 const char *s, size_t s_length,
 
521
                 my_match_t *match, uint nmatch);
 
522
 
 
523
int my_strnncoll_mb_bin(CHARSET_INFO * cs,
 
524
                        const uchar *s, size_t slen,
 
525
                        const uchar *t, size_t tlen,
 
526
                        my_bool t_is_prefix);
 
527
 
 
528
int my_strnncollsp_mb_bin(CHARSET_INFO *cs,
 
529
                          const uchar *a, size_t a_length,
 
530
                          const uchar *b, size_t b_length,
 
531
                          my_bool diff_if_only_endspace_difference);
 
532
 
 
533
int my_wildcmp_mb_bin(CHARSET_INFO *cs,
 
534
                      const char *str,const char *str_end,
 
535
                      const char *wildstr,const char *wildend,
 
536
                      int escape, int w_one, int w_many);
 
537
 
 
538
int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
 
539
                         const char *s, const char *t);
 
540
 
 
541
void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
 
542
                         const uchar *key, size_t len,ulong *nr1, ulong *nr2);
 
543
 
 
544
size_t my_strnxfrm_mb(CHARSET_INFO *,
 
545
                      uchar *dst, size_t dstlen, uint nweights,
 
546
                      const uchar *src, size_t srclen, uint flags);
 
547
 
 
548
int my_wildcmp_unicode(CHARSET_INFO *cs,
 
549
                       const char *str, const char *str_end,
 
550
                       const char *wildstr, const char *wildend,
 
551
                       int escape, int w_one, int w_many,
 
552
                       MY_UNICASE_INFO **weights);
 
553
 
 
554
extern my_bool my_parse_charset_xml(const char *bug, size_t len,
 
555
                                    int (*add)(CHARSET_INFO *cs));
 
556
extern char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
 
557
                       pchar c);
 
558
 
 
559
my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, size_t len);
 
560
my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, size_t len);
 
561
 
 
562
 
 
563
uint my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong len);
 
564
my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
 
565
my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs);
 
566
 
 
567
 
 
568
uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
 
569
void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
 
570
                                 uint flags, uint level);
 
571
size_t my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs,
 
572
                                       uchar *str, uchar *frmend, uchar *strend,
 
573
                                       uint nweights, uint flags, uint level);
 
574
 
 
575
my_bool my_charset_is_ascii_compatible(CHARSET_INFO *cs);
 
576
 
 
577
#define _MY_U   01      /* Upper case */
 
578
#define _MY_L   02      /* Lower case */
 
579
#define _MY_NMR 04      /* Numeral (digit) */
 
580
#define _MY_SPC 010     /* Spacing character */
 
581
#define _MY_PNT 020     /* Punctuation */
 
582
#define _MY_CTR 040     /* Control character */
 
583
#define _MY_B   0100    /* Blank */
 
584
#define _MY_X   0200    /* heXadecimal digit */
 
585
 
 
586
 
 
587
#define my_isascii(c)   (!((c) & ~0177))
 
588
#define my_toascii(c)   ((c) & 0177)
 
589
#define my_tocntrl(c)   ((c) & 31)
 
590
#define my_toprint(c)   ((c) | 64)
 
591
#define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)])
 
592
#define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)])
 
593
#define my_isalpha(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L))
 
594
#define my_isupper(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_U)
 
595
#define my_islower(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_L)
 
596
#define my_isdigit(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_NMR)
 
597
#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X)
 
598
#define my_isalnum(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR))
 
599
#define my_isspace(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_SPC)
 
600
#define my_ispunct(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_PNT)
 
601
#define my_isprint(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B))
 
602
#define my_isgraph(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR))
 
603
#define my_iscntrl(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_CTR)
 
604
 
 
605
/* Some macros that should be cleaned up a little */
 
606
#define my_isvar(s,c)                 (my_isalnum(s,c) || (c) == '_')
 
607
#define my_isvar_start(s,c)           (my_isalpha(s,c) || (c) == '_')
 
608
 
 
609
#define my_binary_compare(s)          ((s)->state  & MY_CS_BINSORT)
 
610
#define use_strnxfrm(s)               ((s)->state  & MY_CS_STRNXFRM)
 
611
#define my_strnxfrm(cs, d, dl, s, sl) \
 
612
   ((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE))
 
613
#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
 
614
#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
 
615
   ((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
 
616
#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m)))
 
617
#define my_strcasecmp(s, a, b)        ((s)->coll->strcasecmp((s), (a), (b)))
 
618
#define my_charpos(cs, b, e, num)     (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num))
 
619
 
 
620
 
 
621
#define use_mb(s)                     ((s)->cset->ismbchar != NULL)
 
622
#define my_ismbchar(s, a, b)          ((s)->cset->ismbchar((s), (a), (b)))
 
623
#ifdef USE_MB
 
624
#define my_mbcharlen(s, a)            ((s)->cset->mbcharlen((s),(a)))
 
625
#else
 
626
#define my_mbcharlen(s, a)            1
 
627
#endif
 
628
 
 
629
#define my_caseup_str(s, a)           ((s)->cset->caseup_str((s), (a)))
 
630
#define my_casedn_str(s, a)           ((s)->cset->casedn_str((s), (a)))
 
631
#define my_strntol(s, a, b, c, d, e)  ((s)->cset->strntol((s),(a),(b),(c),(d),(e)))
 
632
#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e)))
 
633
#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e)))
 
634
#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e)))
 
635
#define my_strntod(s, a, b, c, d)     ((s)->cset->strntod((s),(a),(b),(c),(d)))
 
636
 
 
637
 
 
638
/* XXX: still need to take care of this one */
 
639
#ifdef MY_CHARSET_TIS620
 
640
#error The TIS620 charset is broken at the moment.  Tell tim to fix it.
 
641
#define USE_TIS620
 
642
#include "t_ctype.h"
 
643
#endif
 
644
 
 
645
#ifdef  __cplusplus
 
646
}
 
647
#endif
 
648
 
 
649
#endif /* _m_ctype_h */