1 /* Copyright (C) 2000 MySQL AB
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.
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.
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 */
16 /* There may be prolems include all of theese. Try to test in
17 configure with ones are needed? */
19 /* This is needed for the definitions of strchr... on solaris */
24 #define __USE_GNU /* We want to use stpcpy */
26 #if defined(HAVE_STRINGS_H)
29 #if defined(HAVE_STRING_H)
33 /* need by my_vsnprintf */
36 /* Correct some things for UNIXWARE7 */
37 #ifdef HAVE_UNIXWARE7_THREADS
48 #endif /* HAVE_UNIXWARE7_THREADS */
53 /* This is needed for the definitions of bzero... on solaris */
54 #if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
58 /* This is needed for the definitions of memcpy... on solaris */
59 #if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
63 #if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
64 # define memcpy(d, s, n) bcopy ((s), (d), (n))
65 # define memset(A,C,B) bfill((A),(B),(C))
66 # define memmove(d, s, n) bmove ((d), (s), (n))
67 #elif defined(HAVE_MEMMOVE)
68 # define bmove(d, s, n) memmove((d), (s), (n))
70 # define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
74 #if !defined(HAVE_BFILL)
75 # define bfill(A,B,C) memset((A),(C),(B))
76 # define bmove_align(A,B,C) memcpy((A),(B),(C))
79 #if !defined(HAVE_BCMP)
80 # define bcopy(s, d, n) memcpy((d), (s), (n))
81 # define bcmp(A,B,C) memcmp((A),(B),(C))
82 # define bzero(A,B) memset((A),0,(B))
83 # define bmove_align(A,B,C) memcpy((A),(B),(C))
86 #if defined(__cplusplus) && !defined(OS2)
91 my_str_malloc() and my_str_free() are assigned to implementations in
92 strings/alloc.c, but can be overridden in the calling program.
94 extern void *(*my_str_malloc
)(size_t);
95 extern void (*my_str_free
)(void *);
97 #if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
98 #define strmov(A,B) stpcpy((A),(B))
100 extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
104 /* Declared in int2str() */
105 extern char NEAR _dig_vec_upper
[];
106 extern char NEAR _dig_vec_lower
[];
108 /* Defined in strtod.c */
109 extern const double log_10
[309];
111 #ifdef BAD_STRING_COMPILER
112 #define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
114 #define strmov_overlapp(A,B) strmov(A,B)
115 #define strmake_overlapp(A,B,C) strmake(A,B,C)
118 #ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
119 #define memcpy_fixed(A,B,C) bmove((A),(B),(C))
121 #define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
126 #define bmove512(A,B,C) bmove_align(A,B,C)
127 extern void bmove_align(gptr dst
,const gptr src
,uint len
);
130 #if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
131 #define bmove512(A,B,C) memcpy(A,B,C)
134 /* Prototypes for string functions */
136 #if !defined(bfill) && !defined(HAVE_BFILL)
137 extern void bfill(gptr dst
,uint len
,pchar fill
);
140 #if !defined(bzero) && !defined(HAVE_BZERO)
141 extern void bzero(gptr dst
,uint len
);
144 #if !defined(bcmp) && !defined(HAVE_BCMP)
145 extern int bcmp(const char *s1
,const char *s2
,uint len
);
148 extern int my_bcmp(const char *s1
,const char *s2
,uint len
);
150 #define bcmp(A,B,C) my_bcmp((A),(B),(C))
154 extern void bmove512(gptr dst
,const gptr src
,uint len
);
157 #if !defined(HAVE_BMOVE) && !defined(bmove)
158 extern void bmove(char *dst
, const char *src
,uint len
);
161 extern void bmove_upp(char *dst
,const char *src
,uint len
);
162 extern void bchange(char *dst
,uint old_len
,const char *src
,
163 uint new_len
,uint tot_len
);
164 extern void strappend(char *s
,uint len
,pchar fill
);
165 extern char *strend(const char *s
);
166 extern char *strcend(const char *, pchar
);
167 extern char *strfield(char *src
,int fields
,int chars
,int blanks
,
169 extern char *strfill(my_string s
,uint len
,pchar fill
);
170 extern uint
strinstr(const char *str
,const char *search
);
171 extern uint
r_strinstr(reg1 my_string str
,int from
, reg4 my_string search
);
172 extern char *strkey(char *dst
,char *head
,char *tail
,char *flags
);
173 extern char *strmake(char *dst
,const char *src
,uint length
);
174 #ifndef strmake_overlapp
175 extern char *strmake_overlapp(char *dst
,const char *src
, uint length
);
179 extern char *strmov(char *dst
,const char *src
);
181 extern char *strnmov(char *dst
,const char *src
,uint n
);
182 extern char *strsuff(const char *src
,const char *suffix
);
183 extern char *strcont(const char *src
,const char *set
);
184 extern char *strxcat
_VARARGS((char *dst
,const char *src
, ...));
185 extern char *strxmov
_VARARGS((char *dst
,const char *src
, ...));
186 extern char *strxcpy
_VARARGS((char *dst
,const char *src
, ...));
187 extern char *strxncat
_VARARGS((char *dst
,uint len
, const char *src
, ...));
188 extern char *strxnmov
_VARARGS((char *dst
,uint len
, const char *src
, ...));
189 extern char *strxncpy
_VARARGS((char *dst
,uint len
, const char *src
, ...));
191 /* Prototypes of normal stringfunctions (with may ours) */
193 #ifdef WANT_STRING_PROTOTYPES
194 extern char *strcat(char *, const char *);
195 extern char *strchr(const char *, pchar
);
196 extern char *strrchr(const char *, pchar
);
197 extern char *strcpy(char *, const char *);
198 extern int strcmp(const char *, const char *);
200 extern size_t strlen(const char *);
204 extern uint
strnlen(const char *s
, uint n
);
207 #if !defined(__cplusplus)
209 extern char *strpbrk(const char *, const char *);
212 extern char *strstr(const char *, const char *);
215 extern int is_prefix(const char *, const char *);
217 /* Conversion routines */
218 double my_strtod(const char *str
, char **end
, int *error
);
219 double my_atof(const char *nptr
);
221 extern char *llstr(longlong value
,char *buff
);
222 extern char *ullstr(longlong value
,char *buff
);
224 extern long strtol(const char *str
, char **ptr
, int base
);
225 extern ulong
strtoul(const char *str
, char **ptr
, int base
);
228 extern char *int2str(long val
, char *dst
, int radix
, int upcase
);
229 extern char *int10_to_str(long val
,char *dst
,int radix
);
230 extern char *str2int(const char *src
,int radix
,long lower
,long upper
,
232 longlong
my_strtoll10(const char *nptr
, char **endptr
, int *error
);
233 #if SIZEOF_LONG == SIZEOF_LONG_LONG
234 #define longlong2str(A,B,C) int2str((A),(B),(C),1)
235 #define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
237 #define strtoll(A,B,C) strtol((A),(B),(C))
238 #define strtoull(A,B,C) strtoul((A),(B),(C))
239 #ifndef HAVE_STRTOULL
240 #define HAVE_STRTOULL
246 #ifdef HAVE_LONG_LONG
247 extern char *longlong2str(longlong val
,char *dst
,int radix
);
248 extern char *longlong10_to_str(longlong val
,char *dst
,int radix
);
249 #if (!defined(HAVE_STRTOULL) || defined(HAVE_mit_thread)) || defined(NO_STRTOLL_PROTO)
250 extern longlong
strtoll(const char *str
, char **ptr
, int base
);
251 extern ulonglong
strtoull(const char *str
, char **ptr
, int base
);
258 extern int my_vsnprintf( char *str
, size_t n
,
259 const char *format
, va_list ap
);
260 extern int my_snprintf(char *to
, size_t n
, const char *fmt
, ...)
261 ATTRIBUTE_FORMAT(printf
, 3, 4);
263 #if defined(__cplusplus) && !defined(OS2)