~drizzle-trunk/drizzle/development

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