mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / include / m_string.h
blob08738c9e48229fa9e282dfc509d2a95562de6859
1 /*
2 Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 /* There may be prolems include all of theese. Try to test in
19 configure with ones are needed? */
21 /* This is needed for the definitions of strchr... on solaris */
23 #ifndef _m_string_h
24 #define _m_string_h
25 #ifndef __USE_GNU
26 #define __USE_GNU /* We want to use stpcpy */
27 #endif
28 #if defined(HAVE_STRINGS_H)
29 #include <strings.h>
30 #endif
31 #if defined(HAVE_STRING_H)
32 #include <string.h>
33 #endif
35 /* need by my_vsnprintf */
36 #include <stdarg.h>
38 /* This is needed for the definitions of bzero... on solaris */
39 #if defined(HAVE_STRINGS_H)
40 #include <strings.h>
41 #endif
43 /* This is needed for the definitions of memcpy... on solaris */
44 #if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
45 #include <memory.h>
46 #endif
48 #if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
49 # define memcpy(d, s, n) bcopy ((s), (d), (n))
50 # define memset(A,C,B) bfill((A),(B),(C))
51 # define memmove(d, s, n) bmove ((d), (s), (n))
52 #elif defined(HAVE_MEMMOVE)
53 # define bmove(d, s, n) memmove((d), (s), (n))
54 #else
55 # define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
56 #endif
58 /* Unixware 7 */
59 #if !defined(HAVE_BFILL)
60 # define bfill(A,B,C) memset((A),(C),(B))
61 #endif
63 #if !defined(bzero) && (!defined(HAVE_BZERO) || !HAVE_DECL_BZERO || defined(_AIX))
64 /* See autoconf doku: "HAVE_DECL_symbol" will be defined after configure, to 0 or 1 */
65 /* AIX has bzero() as a function, but the declaration prototype is strangely hidden */
66 # define bzero(A,B) memset((A),0,(B))
67 #endif
69 #if defined(__cplusplus)
70 extern "C" {
71 #endif
74 my_str_malloc() and my_str_free() are assigned to implementations in
75 strings/alloc.c, but can be overridden in the calling program.
77 extern void *(*my_str_malloc)(size_t);
78 extern void (*my_str_free)(void *);
80 #if defined(HAVE_STPCPY) && MY_GNUC_PREREQ(3, 4) && !defined(__INTEL_COMPILER)
81 #define strmov(A,B) __builtin_stpcpy((A),(B))
82 #elif defined(HAVE_STPCPY)
83 #define strmov(A,B) stpcpy((A),(B))
84 #ifndef stpcpy
85 extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
86 #endif
87 #endif
89 /* Declared in int2str() */
90 extern char NEAR _dig_vec_upper[];
91 extern char NEAR _dig_vec_lower[];
93 /* Defined in strtod.c */
94 extern const double log_10[309];
96 #ifndef strmov
97 #define strmov_overlapp(A,B) strmov(A,B)
98 #define strmake_overlapp(A,B,C) strmake(A,B,C)
99 #endif
101 #ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
102 #define memcpy_fixed(A,B,C) bmove((A),(B),(C))
103 #else
104 #define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
105 #endif
107 #if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
108 #define bmove512(A,B,C) memcpy(A,B,C)
109 #endif
111 /* Prototypes for string functions */
113 #if !defined(bfill) && !defined(HAVE_BFILL)
114 extern void bfill(uchar *dst,size_t len,pchar fill);
115 #endif
117 #ifndef bmove512
118 extern void bmove512(uchar *dst,const uchar *src,size_t len);
119 #endif
121 #if !defined(HAVE_BMOVE) && !defined(bmove)
122 extern void bmove(uuchar *dst, const uchar *src,size_t len);
123 #endif
125 extern void bmove_upp(uchar *dst,const uchar *src,size_t len);
126 extern void bchange(uchar *dst,size_t old_len,const uchar *src,
127 size_t new_len,size_t tot_len);
128 extern void strappend(char *s,size_t len,pchar fill);
129 extern char *strend(const char *s);
130 extern char *strcend(const char *, pchar);
131 extern char *strfield(char *src,int fields,int chars,int blanks,
132 int tabch);
133 extern char *strfill(char * s,size_t len,pchar fill);
134 extern size_t strinstr(const char *str,const char *search);
135 extern size_t r_strinstr(const char *str, size_t from, const char *search);
136 extern char *strkey(char *dst,char *head,char *tail,char *flags);
137 extern char *strmake(char *dst,const char *src,size_t length);
139 #ifndef strmov
140 extern char *strmov(char *dst,const char *src);
141 #else
142 extern char *strmov_overlapp(char *dst,const char *src);
143 #endif
144 extern char *strnmov(char *dst,const char *src,size_t n);
145 extern char *strsuff(const char *src,const char *suffix);
146 extern char *strcont(const char *src,const char *set);
147 extern char *strxcat _VARARGS((char *dst,const char *src, ...));
148 extern char *strxmov _VARARGS((char *dst,const char *src, ...));
149 extern char *strxcpy _VARARGS((char *dst,const char *src, ...));
150 extern char *strxncat _VARARGS((char *dst,size_t len, const char *src, ...));
151 extern char *strxnmov _VARARGS((char *dst,size_t len, const char *src, ...));
152 extern char *strxncpy _VARARGS((char *dst,size_t len, const char *src, ...));
154 /* Prototypes of normal stringfunctions (with may ours) */
156 #ifdef WANT_STRING_PROTOTYPES
157 extern char *strcat(char *, const char *);
158 extern char *strchr(const char *, pchar);
159 extern char *strrchr(const char *, pchar);
160 extern char *strcpy(char *, const char *);
161 extern int strcmp(const char *, const char *);
162 #ifndef __GNUC__
163 extern size_t strlen(const char *);
164 #endif
165 #endif
166 #ifndef HAVE_STRNLEN
167 extern size_t strnlen(const char *s, size_t n);
168 #endif
170 #if !defined(__cplusplus)
171 #ifndef HAVE_STRPBRK
172 extern char *strpbrk(const char *, const char *);
173 #endif
174 #ifndef HAVE_STRSTR
175 extern char *strstr(const char *, const char *);
176 #endif
177 #endif
178 extern int is_prefix(const char *, const char *);
180 /* Conversion routines */
181 double my_strtod(const char *str, char **end, int *error);
182 double my_atof(const char *nptr);
184 #ifndef NOT_FIXED_DEC
185 #define NOT_FIXED_DEC 31
186 #endif
189 Max length of a floating point number.
191 #define FLOATING_POINT_BUFFER (311 + NOT_FIXED_DEC)
193 extern char *llstr(longlong value,char *buff);
194 extern char *ullstr(longlong value,char *buff);
195 #ifndef HAVE_STRTOUL
196 extern long strtol(const char *str, char **ptr, int base);
197 extern ulong strtoul(const char *str, char **ptr, int base);
198 #endif
200 extern char *int2str(long val, char *dst, int radix, int upcase);
201 extern char *int10_to_str(long val,char *dst,int radix);
202 extern char *str2int(const char *src,int radix,long lower,long upper,
203 long *val);
204 longlong my_strtoll10(const char *nptr, char **endptr, int *error);
205 #if SIZEOF_LONG == SIZEOF_LONG_LONG
206 #define longlong2str(A,B,C) int2str((A),(B),(C),1)
207 #define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
208 #undef strtoll
209 #define strtoll(A,B,C) strtol((A),(B),(C))
210 #define strtoull(A,B,C) strtoul((A),(B),(C))
211 #ifndef HAVE_STRTOULL
212 #define HAVE_STRTOULL
213 #endif
214 #ifndef HAVE_STRTOLL
215 #define HAVE_STRTOLL
216 #endif
217 #else
218 #ifdef HAVE_LONG_LONG
219 extern char *longlong2str(longlong val,char *dst,int radix);
220 extern char *longlong10_to_str(longlong val,char *dst,int radix);
221 #if (!defined(HAVE_STRTOULL) || defined(NO_STRTOLL_PROTO))
222 extern longlong strtoll(const char *str, char **ptr, int base);
223 extern ulonglong strtoull(const char *str, char **ptr, int base);
224 #endif
225 #endif
226 #endif
228 /* my_vsnprintf.c */
230 extern size_t my_vsnprintf(char *str, size_t n,
231 const char *format, va_list ap);
232 extern size_t my_snprintf(char *to, size_t n, const char *fmt, ...)
233 ATTRIBUTE_FORMAT(printf, 3, 4);
235 #if defined(__cplusplus)
237 #endif
240 LEX_STRING -- a pair of a C-string and its length.
243 #ifndef _my_plugin_h
244 /* This definition must match the one given in mysql/plugin.h */
245 struct st_mysql_lex_string
247 char *str;
248 size_t length;
250 #endif
251 typedef struct st_mysql_lex_string LEX_STRING;
253 #define STRING_WITH_LEN(X) (X), ((size_t) (sizeof(X) - 1))
254 #define USTRING_WITH_LEN(X) ((uchar*) X), ((size_t) (sizeof(X) - 1))
255 #define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
257 #endif