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 */
26 #define __USE_GNU /* We want to use stpcpy */
28 #if defined(HAVE_STRINGS_H)
31 #if defined(HAVE_STRING_H)
35 /* need by my_vsnprintf */
38 /* This is needed for the definitions of bzero... on solaris */
39 #if defined(HAVE_STRINGS_H)
43 /* This is needed for the definitions of memcpy... on solaris */
44 #if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
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))
55 # define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
59 #if !defined(HAVE_BFILL)
60 # define bfill(A,B,C) memset((A),(C),(B))
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))
69 #if defined(__cplusplus)
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))
85 extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
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];
97 #define strmov_overlapp(A,B) strmov(A,B)
98 #define strmake_overlapp(A,B,C) strmake(A,B,C)
101 #ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
102 #define memcpy_fixed(A,B,C) bmove((A),(B),(C))
104 #define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
107 #if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
108 #define bmove512(A,B,C) memcpy(A,B,C)
111 /* Prototypes for string functions */
113 #if !defined(bfill) && !defined(HAVE_BFILL)
114 extern void bfill(uchar
*dst
,size_t len
,pchar fill
);
118 extern void bmove512(uchar
*dst
,const uchar
*src
,size_t len
);
121 #if !defined(HAVE_BMOVE) && !defined(bmove)
122 extern void bmove(uuchar
*dst
, const uchar
*src
,size_t len
);
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
,
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
);
140 extern char *strmov(char *dst
,const char *src
);
142 extern char *strmov_overlapp(char *dst
,const char *src
);
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 *);
163 extern size_t strlen(const char *);
167 extern size_t strnlen(const char *s
, size_t n
);
170 #if !defined(__cplusplus)
172 extern char *strpbrk(const char *, const char *);
175 extern char *strstr(const char *, const char *);
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
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
);
196 extern long strtol(const char *str
, char **ptr
, int base
);
197 extern ulong
strtoul(const char *str
, char **ptr
, int base
);
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
,
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))
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
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
);
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)
240 LEX_STRING -- a pair of a C-string and its length.
244 /* This definition must match the one given in mysql/plugin.h */
245 struct st_mysql_lex_string
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))