1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
3
This library is free software; you can redistribute it and/or
4
modify it under the terms of the GNU Library General Public
5
License as published by the Free Software Foundation; either
6
version 2 of the License, or (at your option) any later version.
8
This library 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 GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public
14
License along with this library; if not, write to the Free
15
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
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
/* Correct some things for UNIXWARE7 */
36
#ifdef HAVE_UNIXWARE7_THREADS
47
#endif /* HAVE_UNIXWARE7_THREADS */
52
/* This is needed for the definitions of bzero... on solaris */
53
#if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
57
/* This is needed for the definitions of memcpy... on solaris */
58
#if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
62
#if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
63
# define memcpy(d, s, n) bcopy ((s), (d), (n))
64
# define memset(A,C,B) bfill((A),(B),(C))
65
# define memmove(d, s, n) bmove ((d), (s), (n))
66
#elif defined(HAVE_MEMMOVE)
67
# define bmove(d, s, n) memmove((d), (s), (n))
69
# define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
73
#if !defined(HAVE_BFILL)
74
# define bfill(A,B,C) memset((A),(C),(B))
75
# define bmove_allign(A,B,C) memcpy((A),(B),(C))
78
#if !defined(HAVE_BCMP)
79
# define bcopy(s, d, n) memcpy((d), (s), (n))
80
# define bcmp(A,B,C) memcmp((A),(B),(C))
81
# define bzero(A,B) memset((A),0,(B))
82
# define bmove_allign(A,B,C) memcpy((A),(B),(C))
85
#if defined(__cplusplus) && !defined(OS2)
89
#if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
90
#define strmov(A,B) stpcpy((A),(B))
92
extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
96
extern char NEAR _dig_vec[]; /* Declared in int2str() */
98
#ifdef BAD_STRING_COMPILER
99
#define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
101
#define strmov_overlapp(A,B) strmov(A,B)
102
#define strmake_overlapp(A,B,C) strmake(A,B,C)
105
#ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
106
#define memcpy_fixed(A,B,C) bmove((A),(B),(C))
108
#define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
113
#define bmove512(A,B,C) bmove_allign(A,B,C)
114
#define my_itoa(A,B,C) itoa(A,B,C)
115
#define my_ltoa(A,B,C) ltoa(A,B,C)
116
extern void bmove_allign(gptr dst,const gptr src,uint len);
119
#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
120
#define bmove512(A,B,C) memcpy(A,B,C)
123
/* Prototypes for string functions */
125
#if !defined(bfill) && !defined(HAVE_BFILL)
126
extern void bfill(gptr dst,uint len,pchar fill);
129
#if !defined(bzero) && !defined(HAVE_BZERO)
130
extern void bzero(gptr dst,uint len);
133
#if !defined(bcmp) && !defined(HAVE_BCMP)
134
extern int bcmp(const char *s1,const char *s2,uint len);
136
extern int my_bcmp(const char *s1,const char *s2,uint len);
137
#define bcmp(A,B,C) my_bcmp((A),(B),(C))
142
extern void bmove512(gptr dst,const gptr src,uint len);
145
#if !defined(HAVE_BMOVE) && !defined(bmove)
146
extern void bmove(char *dst, const char *src,uint len);
149
extern void bmove_upp(char *dst,const char *src,uint len);
150
extern void bchange(char *dst,uint old_len,const char *src,
151
uint new_len,uint tot_len);
152
extern void strappend(char *s,uint len,pchar fill);
153
extern char *strend(const char *s);
154
extern char *strcend(const char *, pchar);
155
extern char *strfield(char *src,int fields,int chars,int blanks,
157
extern char *strfill(my_string s,uint len,pchar fill);
158
extern uint strinstr(const char *str,const char *search);
159
extern uint r_strinstr(reg1 my_string str,int from, reg4 my_string search);
160
extern char *strkey(char *dst,char *head,char *tail,char *flags);
161
extern char *strmake(char *dst,const char *src,uint length);
162
#ifndef strmake_overlapp
163
extern char *strmake_overlapp(char *dst,const char *src, uint length);
167
extern char *strmov(char *dst,const char *src);
169
extern char *strnmov(char *dst,const char *src,uint n);
170
extern char *strsuff(const char *src,const char *suffix);
171
extern char *strcont(const char *src,const char *set);
172
extern char *strxcat _VARARGS((char *dst,const char *src, ...));
173
extern char *strxmov _VARARGS((char *dst,const char *src, ...));
174
extern char *strxcpy _VARARGS((char *dst,const char *src, ...));
175
extern char *strxncat _VARARGS((char *dst,uint len, const char *src, ...));
176
extern char *strxnmov _VARARGS((char *dst,uint len, const char *src, ...));
177
extern char *strxncpy _VARARGS((char *dst,uint len, const char *src, ...));
179
/* Prototypes of normal stringfunctions (with may ours) */
181
#ifdef WANT_STRING_PROTOTYPES
182
extern char *strcat(char *, const char *);
183
extern char *strchr(const char *, pchar);
184
extern char *strrchr(const char *, pchar);
185
extern char *strcpy(char *, const char *);
186
extern int strcmp(const char *, const char *);
188
extern size_t strlen(const char *);
192
extern uint strnlen(const char *s, uint n);
195
#if !defined(__cplusplus)
197
extern char *strpbrk(const char *, const char *);
200
extern char *strstr(const char *, const char *);
203
extern int is_prefix(const char *, const char *);
205
/* Conversion rutins */
208
extern char *my_itoa(int val,char *dst,int radix);
209
extern char *my_ltoa(long val,char *dst,int radix);
212
extern char *llstr(longlong value,char *buff);
214
extern long strtol(const char *str, char **ptr, int base);
215
extern ulong strtoul(const char *str, char **ptr, int base);
218
extern char *int2str(long val,char *dst,int radix);
219
extern char *int10_to_str(long val,char *dst,int radix);
220
extern char *str2int(const char *src,int radix,long lower,long upper,
222
#if SIZEOF_LONG == SIZEOF_LONG_LONG
223
#define longlong2str(A,B,C) int2str((A),(B),(C))
224
#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
225
#define strtoll(A,B,C) strtol((A),(B),(C))
226
#define strtoull(A,B,C) strtoul((A),(B),(C))
227
#ifndef HAVE_STRTOULL
228
#define HAVE_STRTOULL
231
#ifdef HAVE_LONG_LONG
232
extern char *longlong2str(longlong val,char *dst,int radix);
233
extern char *longlong10_to_str(longlong val,char *dst,int radix);
234
#if (!defined(HAVE_STRTOULL) || defined(HAVE_mit_thread)) || defined(NO_STRTOLL_PROTO)
235
extern longlong strtoll(const char *str, char **ptr, int base);
236
extern ulonglong strtoull(const char *str, char **ptr, int base);
241
#if defined(__cplusplus) && !defined(OS2)