PageRenderTime 56ms CodeModel.GetById 18ms app.highlight 33ms RepoModel.GetById 1ms app.codeStats 0ms

/mysql/include/mysql/m_ctype.h

http://ghostcb.googlecode.com/
C++ Header | 549 lines | 421 code | 88 blank | 40 comment | 5 complexity | ffdf5173499ea434fc207a7f5f558d0f MD5 | raw file
  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
 27extern "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
 41typedef struct unicase_info_st
 42{
 43  uint16 toupper;
 44  uint16 tolower;
 45  uint16 sort;
 46} MY_UNICASE_INFO;
 47
 48
 49extern MY_UNICASE_INFO *my_unicase_default[256];
 50extern MY_UNICASE_INFO *my_unicase_turkish[256];
 51
 52typedef struct uni_ctype_st
 53{
 54  uchar  pctype;
 55  uchar  *ctype;
 56} MY_UNI_CTYPE;
 57
 58extern 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_CHARSET_UNDEFINED 0
 91
 92/* Character repertoire flags */
 93#define MY_REPERTOIRE_ASCII      1 /* Pure ASCII            U+0000..U+007F */
 94#define MY_REPERTOIRE_EXTENDED   2 /* Extended characters:  U+0080..U+FFFF */
 95#define MY_REPERTOIRE_UNICODE30  3 /* ASCII | EXTENDED:     U+0000..U+FFFF */
 96
 97
 98typedef struct my_uni_idx_st
 99{
100  uint16 from;
101  uint16 to;
102  uchar  *tab;
103} MY_UNI_IDX;
104
105typedef struct
106{
107  uint beg;
108  uint end;
109  uint mb_len;
110} my_match_t;
111
112enum my_lex_states
113{
114  MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT, 
115  MY_LEX_IDENT_SEP, MY_LEX_IDENT_START,
116  MY_LEX_REAL, MY_LEX_HEX_NUMBER, MY_LEX_BIN_NUMBER,
117  MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END,
118  MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL,
119  MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE, 
120  MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_SEMICOLON, 
121  MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP, 
122  MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR,
123  MY_LEX_IDENT_OR_KEYWORD,
124  MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR,
125  MY_LEX_STRING_OR_DELIMITER
126};
127
128struct charset_info_st;
129
130
131/* See strings/CHARSET_INFO.txt for information about this structure  */
132typedef struct my_collation_handler_st
133{
134  my_bool (*init)(struct charset_info_st *, void *(*alloc)(size_t));
135  /* Collation routines */
136  int     (*strnncoll)(struct charset_info_st *,
137		       const uchar *, size_t, const uchar *, size_t, my_bool);
138  int     (*strnncollsp)(struct charset_info_st *,
139                         const uchar *, size_t, const uchar *, size_t,
140                         my_bool diff_if_only_endspace_difference);
141  size_t     (*strnxfrm)(struct charset_info_st *,
142                         uchar *, size_t, const uchar *, size_t);
143  size_t    (*strnxfrmlen)(struct charset_info_st *, size_t); 
144  my_bool (*like_range)(struct charset_info_st *,
145			const char *s, size_t s_length,
146			pchar w_prefix, pchar w_one, pchar w_many, 
147			size_t res_length,
148			char *min_str, char *max_str,
149			size_t *min_len, size_t *max_len);
150  int     (*wildcmp)(struct charset_info_st *,
151  		     const char *str,const char *str_end,
152                     const char *wildstr,const char *wildend,
153                     int escape,int w_one, int w_many);
154
155  int  (*strcasecmp)(struct charset_info_st *, const char *, const char *);
156  
157  uint (*instr)(struct charset_info_st *,
158                const char *b, size_t b_length,
159                const char *s, size_t s_length,
160                my_match_t *match, uint nmatch);
161  
162  /* Hash calculation */
163  void (*hash_sort)(struct charset_info_st *cs, const uchar *key, size_t len,
164		    ulong *nr1, ulong *nr2); 
165  my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, size_t len);
166} MY_COLLATION_HANDLER;
167
168extern MY_COLLATION_HANDLER my_collation_mb_bin_handler;
169extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler;
170extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler;
171extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler;
172
173/* Some typedef to make it easy for C++ to make function pointers */
174typedef int (*my_charset_conv_mb_wc)(struct charset_info_st *, my_wc_t *,
175                                     const uchar *, const uchar *);
176typedef int (*my_charset_conv_wc_mb)(struct charset_info_st *, my_wc_t,
177                                     uchar *, uchar *);
178typedef size_t (*my_charset_conv_case)(struct charset_info_st *,
179                                       char *, size_t, char *, size_t);
180
181
182/* See strings/CHARSET_INFO.txt about information on this structure  */
183typedef struct my_charset_handler_st
184{
185  my_bool (*init)(struct charset_info_st *, void *(*alloc)(size_t));
186  /* Multibyte routines */
187  uint    (*ismbchar)(struct charset_info_st *, const char *, const char *);
188  uint    (*mbcharlen)(struct charset_info_st *, uint c);
189  size_t  (*numchars)(struct charset_info_st *, const char *b, const char *e);
190  size_t  (*charpos)(struct charset_info_st *, const char *b, const char *e,
191                     size_t pos);
192  size_t  (*well_formed_len)(struct charset_info_st *,
193                             const char *b,const char *e,
194                             size_t nchars, int *error);
195  size_t  (*lengthsp)(struct charset_info_st *, const char *ptr, size_t length);
196  size_t  (*numcells)(struct charset_info_st *, const char *b, const char *e);
197  
198  /* Unicode conversion */
199  my_charset_conv_mb_wc mb_wc;
200  my_charset_conv_wc_mb wc_mb;
201
202  /* CTYPE scanner */
203  int (*ctype)(struct charset_info_st *cs, int *ctype,
204               const uchar *s, const uchar *e);
205  
206  /* Functions for case and sort conversion */
207  size_t  (*caseup_str)(struct charset_info_st *, char *);
208  size_t  (*casedn_str)(struct charset_info_st *, char *);
209
210  my_charset_conv_case caseup;
211  my_charset_conv_case casedn;
212
213  /* Charset dependant snprintf() */
214  size_t (*snprintf)(struct charset_info_st *, char *to, size_t n,
215                     const char *fmt,
216                     ...) ATTRIBUTE_FORMAT_FPTR(printf, 4, 5);
217  size_t (*long10_to_str)(struct charset_info_st *, char *to, size_t n,
218                          int radix, long int val);
219  size_t (*longlong10_to_str)(struct charset_info_st *, char *to, size_t n,
220                              int radix, longlong val);
221  
222  void (*fill)(struct charset_info_st *, char *to, size_t len, int fill);
223  
224  /* String-to-number conversion routines */
225  long        (*strntol)(struct charset_info_st *, const char *s, size_t l,
226			 int base, char **e, int *err);
227  ulong      (*strntoul)(struct charset_info_st *, const char *s, size_t l,
228			 int base, char **e, int *err);
229  longlong   (*strntoll)(struct charset_info_st *, const char *s, size_t l,
230			 int base, char **e, int *err);
231  ulonglong (*strntoull)(struct charset_info_st *, const char *s, size_t l,
232			 int base, char **e, int *err);
233  double      (*strntod)(struct charset_info_st *, char *s, size_t l, char **e,
234			 int *err);
235  longlong    (*strtoll10)(struct charset_info_st *cs,
236                           const char *nptr, char **endptr, int *error);
237  ulonglong   (*strntoull10rnd)(struct charset_info_st *cs,
238                                const char *str, size_t length,
239                                int unsigned_fl,
240                                char **endptr, int *error);
241  size_t        (*scan)(struct charset_info_st *, const char *b, const char *e,
242                        int sq);
243} MY_CHARSET_HANDLER;
244
245extern MY_CHARSET_HANDLER my_charset_8bit_handler;
246extern MY_CHARSET_HANDLER my_charset_ucs2_handler;
247
248
249/* See strings/CHARSET_INFO.txt about information on this structure  */
250typedef struct charset_info_st
251{
252  uint      number;
253  uint      primary_number;
254  uint      binary_number;
255  uint      state;
256  const char *csname;
257  const char *name;
258  const char *comment;
259  const char *tailoring;
260  uchar    *ctype;
261  uchar    *to_lower;
262  uchar    *to_upper;
263  uchar    *sort_order;
264  uint16   *contractions;
265  uint16   **sort_order_big;
266  uint16      *tab_to_uni;
267  MY_UNI_IDX  *tab_from_uni;
268  MY_UNICASE_INFO **caseinfo;
269  uchar     *state_map;
270  uchar     *ident_map;
271  uint      strxfrm_multiply;
272  uchar     caseup_multiply;
273  uchar     casedn_multiply;
274  uint      mbminlen;
275  uint      mbmaxlen;
276  uint16    min_sort_char;
277  uint16    max_sort_char; /* For LIKE optimization */
278  uchar     pad_char;
279  my_bool   escape_with_backslash_is_dangerous;
280  
281  MY_CHARSET_HANDLER *cset;
282  MY_COLLATION_HANDLER *coll;
283  
284} CHARSET_INFO;
285#define ILLEGAL_CHARSET_INFO_NUMBER (~0U)
286
287
288extern CHARSET_INFO my_charset_bin;
289extern CHARSET_INFO my_charset_big5_chinese_ci;
290extern CHARSET_INFO my_charset_big5_bin;
291extern CHARSET_INFO my_charset_cp932_japanese_ci;
292extern CHARSET_INFO my_charset_cp932_bin;
293extern CHARSET_INFO my_charset_eucjpms_japanese_ci;
294extern CHARSET_INFO my_charset_eucjpms_bin;
295extern CHARSET_INFO my_charset_euckr_korean_ci;
296extern CHARSET_INFO my_charset_euckr_bin;
297extern CHARSET_INFO my_charset_gb2312_chinese_ci;
298extern CHARSET_INFO my_charset_gb2312_bin;
299extern CHARSET_INFO my_charset_gbk_chinese_ci;
300extern CHARSET_INFO my_charset_gbk_bin;
301extern CHARSET_INFO my_charset_latin1;
302extern CHARSET_INFO my_charset_latin1_german2_ci;
303extern CHARSET_INFO my_charset_latin1_bin;
304extern CHARSET_INFO my_charset_latin2_czech_ci;
305extern CHARSET_INFO my_charset_sjis_japanese_ci;
306extern CHARSET_INFO my_charset_sjis_bin;
307extern CHARSET_INFO my_charset_tis620_thai_ci;
308extern CHARSET_INFO my_charset_tis620_bin;
309extern CHARSET_INFO my_charset_ucs2_general_ci;
310extern CHARSET_INFO my_charset_ucs2_bin;
311extern CHARSET_INFO my_charset_ucs2_unicode_ci;
312extern CHARSET_INFO my_charset_ujis_japanese_ci;
313extern CHARSET_INFO my_charset_ujis_bin;
314extern CHARSET_INFO my_charset_utf8_general_ci;
315extern CHARSET_INFO my_charset_utf8_unicode_ci;
316extern CHARSET_INFO my_charset_utf8_bin;
317extern CHARSET_INFO my_charset_cp1250_czech_ci;
318extern CHARSET_INFO my_charset_filename;
319
320/* declarations for simple charsets */
321extern size_t my_strnxfrm_simple(CHARSET_INFO *, uchar *, size_t,
322                                 const uchar *, size_t); 
323size_t  my_strnxfrmlen_simple(CHARSET_INFO *, size_t); 
324extern int  my_strnncoll_simple(CHARSET_INFO *, const uchar *, size_t,
325				const uchar *, size_t, my_bool);
326
327extern int  my_strnncollsp_simple(CHARSET_INFO *, const uchar *, size_t,
328                                  const uchar *, size_t,
329                                  my_bool diff_if_only_endspace_difference);
330
331extern void my_hash_sort_simple(CHARSET_INFO *cs,
332				const uchar *key, size_t len,
333				ulong *nr1, ulong *nr2); 
334
335extern size_t my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, size_t length);
336
337extern uint my_instr_simple(struct charset_info_st *,
338                            const char *b, size_t b_length,
339                            const char *s, size_t s_length,
340                            my_match_t *match, uint nmatch);
341
342
343/* Functions for 8bit */
344extern size_t my_caseup_str_8bit(CHARSET_INFO *, char *);
345extern size_t my_casedn_str_8bit(CHARSET_INFO *, char *);
346extern size_t my_caseup_8bit(CHARSET_INFO *, char *src, size_t srclen,
347                             char *dst, size_t dstlen);
348extern size_t my_casedn_8bit(CHARSET_INFO *, char *src, size_t srclen,
349                             char *dst, size_t dstlen);
350
351extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *);
352
353int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, const uchar *s,const uchar *e);
354int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e);
355
356int my_mb_ctype_8bit(CHARSET_INFO *,int *, const uchar *,const uchar *);
357int my_mb_ctype_mb(CHARSET_INFO *,int *, const uchar *,const uchar *);
358
359size_t my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq);
360
361size_t my_snprintf_8bit(struct charset_info_st *, char *to, size_t n,
362                        const char *fmt, ...)
363  ATTRIBUTE_FORMAT(printf, 4, 5);
364
365long       my_strntol_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
366                           char **e, int *err);
367ulong      my_strntoul_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
368			    char **e, int *err);
369longlong   my_strntoll_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
370			    char **e, int *err);
371ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, size_t l, int base,
372			    char **e, int *err);
373double      my_strntod_8bit(CHARSET_INFO *, char *s, size_t l,char **e,
374			    int *err);
375size_t my_long10_to_str_8bit(CHARSET_INFO *, char *to, size_t l, int radix,
376                             long int val);
377size_t my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, size_t l, int radix,
378                                 longlong val);
379
380longlong my_strtoll10_8bit(CHARSET_INFO *cs,
381                           const char *nptr, char **endptr, int *error);
382longlong my_strtoll10_ucs2(CHARSET_INFO *cs, 
383                           const char *nptr, char **endptr, int *error);
384
385ulonglong my_strntoull10rnd_8bit(CHARSET_INFO *cs,
386                                 const char *str, size_t length, int
387                                 unsigned_fl, char **endptr, int *error);
388ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs, 
389                                 const char *str, size_t length,
390                                 int unsigned_fl, char **endptr, int *error);
391
392void my_fill_8bit(CHARSET_INFO *cs, char* to, size_t l, int fill);
393
394my_bool  my_like_range_simple(CHARSET_INFO *cs,
395			      const char *ptr, size_t ptr_length,
396			      pbool escape, pbool w_one, pbool w_many,
397			      size_t res_length,
398			      char *min_str, char *max_str,
399			      size_t *min_length, size_t *max_length);
400
401my_bool  my_like_range_mb(CHARSET_INFO *cs,
402			  const char *ptr, size_t ptr_length,
403			  pbool escape, pbool w_one, pbool w_many,
404			  size_t res_length,
405			  char *min_str, char *max_str,
406			  size_t *min_length, size_t *max_length);
407
408my_bool  my_like_range_ucs2(CHARSET_INFO *cs,
409			    const char *ptr, size_t ptr_length,
410			    pbool escape, pbool w_one, pbool w_many,
411			    size_t res_length,
412			    char *min_str, char *max_str,
413			    size_t *min_length, size_t *max_length);
414
415
416int my_wildcmp_8bit(CHARSET_INFO *,
417		    const char *str,const char *str_end,
418		    const char *wildstr,const char *wildend,
419		    int escape, int w_one, int w_many);
420
421int my_wildcmp_bin(CHARSET_INFO *,
422		   const char *str,const char *str_end,
423		   const char *wildstr,const char *wildend,
424		   int escape, int w_one, int w_many);
425
426size_t my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e);
427size_t my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e);
428size_t my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, size_t pos);
429size_t my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e,
430                             size_t pos, int *error);
431uint my_mbcharlen_8bit(CHARSET_INFO *, uint c);
432
433
434/* Functions for multibyte charsets */
435extern size_t my_caseup_str_mb(CHARSET_INFO *, char *);
436extern size_t my_casedn_str_mb(CHARSET_INFO *, char *);
437extern size_t my_caseup_mb(CHARSET_INFO *, char *src, size_t srclen,
438                                         char *dst, size_t dstlen);
439extern size_t my_casedn_mb(CHARSET_INFO *, char *src, size_t srclen,
440                                         char *dst, size_t dstlen);
441extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *);
442
443int my_wildcmp_mb(CHARSET_INFO *,
444		  const char *str,const char *str_end,
445		  const char *wildstr,const char *wildend,
446		  int escape, int w_one, int w_many);
447size_t my_numchars_mb(CHARSET_INFO *, const char *b, const char *e);
448size_t my_numcells_mb(CHARSET_INFO *, const char *b, const char *e);
449size_t my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, size_t pos);
450size_t my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e,
451                             size_t pos, int *error);
452uint my_instr_mb(struct charset_info_st *,
453                 const char *b, size_t b_length,
454                 const char *s, size_t s_length,
455                 my_match_t *match, uint nmatch);
456
457int my_wildcmp_unicode(CHARSET_INFO *cs,
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                       MY_UNICASE_INFO **weights);
462
463extern my_bool my_parse_charset_xml(const char *bug, size_t len,
464				    int (*add)(CHARSET_INFO *cs));
465extern char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
466                       pchar c);
467
468my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, size_t len);
469my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, size_t len);
470
471
472uint my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong len);
473my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
474my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs);
475uint my_charset_repertoire(CHARSET_INFO *cs);
476
477
478#define	_MY_U	01	/* Upper case */
479#define	_MY_L	02	/* Lower case */
480#define	_MY_NMR	04	/* Numeral (digit) */
481#define	_MY_SPC	010	/* Spacing character */
482#define	_MY_PNT	020	/* Punctuation */
483#define	_MY_CTR	040	/* Control character */
484#define	_MY_B	0100	/* Blank */
485#define	_MY_X	0200	/* heXadecimal digit */
486
487
488#define	my_isascii(c)	(!((c) & ~0177))
489#define	my_toascii(c)	((c) & 0177)
490#define my_tocntrl(c)	((c) & 31)
491#define my_toprint(c)	((c) | 64)
492#define my_toupper(s,c)	(char) ((s)->to_upper[(uchar) (c)])
493#define my_tolower(s,c)	(char) ((s)->to_lower[(uchar) (c)])
494#define	my_isalpha(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L))
495#define	my_isupper(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_U)
496#define	my_islower(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_L)
497#define	my_isdigit(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_NMR)
498#define	my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X)
499#define	my_isalnum(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR))
500#define	my_isspace(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_SPC)
501#define	my_ispunct(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_PNT)
502#define	my_isprint(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B))
503#define	my_isgraph(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR))
504#define	my_iscntrl(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_CTR)
505
506/* Some macros that should be cleaned up a little */
507#define my_isvar(s,c)                 (my_isalnum(s,c) || (c) == '_')
508#define my_isvar_start(s,c)           (my_isalpha(s,c) || (c) == '_')
509
510#define my_binary_compare(s)	      ((s)->state  & MY_CS_BINSORT)
511#define use_strnxfrm(s)               ((s)->state  & MY_CS_STRNXFRM)
512#define my_strnxfrm(s, a, b, c, d)    ((s)->coll->strnxfrm((s), (a), (b), (c), (d)))
513#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
514#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
515   ((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
516#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m)))
517#define my_strcasecmp(s, a, b)        ((s)->coll->strcasecmp((s), (a), (b)))
518#define my_charpos(cs, b, e, num)     (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num))
519
520
521#define use_mb(s)                     ((s)->cset->ismbchar != NULL)
522#define my_ismbchar(s, a, b)          ((s)->cset->ismbchar((s), (a), (b)))
523#ifdef USE_MB
524#define my_mbcharlen(s, a)            ((s)->cset->mbcharlen((s),(a)))
525#else
526#define my_mbcharlen(s, a)            1
527#endif
528
529#define my_caseup_str(s, a)           ((s)->cset->caseup_str((s), (a)))
530#define my_casedn_str(s, a)           ((s)->cset->casedn_str((s), (a)))
531#define my_strntol(s, a, b, c, d, e)  ((s)->cset->strntol((s),(a),(b),(c),(d),(e)))
532#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e)))
533#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e)))
534#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e)))
535#define my_strntod(s, a, b, c, d)     ((s)->cset->strntod((s),(a),(b),(c),(d)))
536
537
538/* XXX: still need to take care of this one */
539#ifdef MY_CHARSET_TIS620
540#error The TIS620 charset is broken at the moment.  Tell tim to fix it.
541#define USE_TIS620
542#include "t_ctype.h"
543#endif
544
545#ifdef	__cplusplus
546}
547#endif
548
549#endif /* _m_ctype_h */