Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

m_string.h

Go to the documentation of this file.
00001 /* Copyright (C) 2000 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; either version 2 of the License, or
00006    (at your option) any later version.
00007 
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012 
00013    You should have received a copy of the GNU General Public License
00014    along with this program; if not, write to the Free Software
00015    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00016 
00017 /* There may be prolems include all of theese. Try to test in
00018    configure with ones are needed? */
00019 
00020 /*  This is needed for the definitions of strchr... on solaris */
00021 
00022 #ifndef _m_string_h
00023 #define _m_string_h
00024 #ifndef __USE_GNU
00025 #define __USE_GNU                               /* We want to use stpcpy */
00026 #endif
00027 #if defined(HAVE_STRINGS_H)
00028 #include <strings.h>
00029 #endif
00030 #if defined(HAVE_STRING_H)
00031 #include <string.h>
00032 #endif
00033 
00034 /* need by my_vsnprintf */
00035 #include <stdarg.h> 
00036 
00037 /* Correct some things for UNIXWARE7 */
00038 #ifdef HAVE_UNIXWARE7_THREADS
00039 #undef HAVE_STRINGS_H
00040 #undef HAVE_MEMORY_H
00041 #define HAVE_MEMCPY
00042 #ifndef HAVE_MEMMOVE
00043 #define HAVE_MEMMOVE
00044 #endif
00045 #undef HAVE_BCMP
00046 #undef bcopy
00047 #undef bcmp
00048 #undef bzero
00049 #endif /* HAVE_UNIXWARE7_THREADS */
00050 #ifdef _AIX
00051 #undef HAVE_BCMP
00052 #endif
00053 
00054 /*  This is needed for the definitions of bzero... on solaris */
00055 #if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
00056 #include <strings.h>
00057 #endif
00058 
00059 /*  This is needed for the definitions of memcpy... on solaris */
00060 #if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
00061 #include <memory.h>
00062 #endif
00063 
00064 #if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
00065 # define memcpy(d, s, n)        bcopy ((s), (d), (n))
00066 # define memset(A,C,B)          bfill((A),(B),(C))
00067 # define memmove(d, s, n)       bmove ((d), (s), (n))
00068 #elif defined(HAVE_MEMMOVE)
00069 # define bmove(d, s, n)         memmove((d), (s), (n))
00070 #else
00071 # define memmove(d, s, n)       bmove((d), (s), (n)) /* our bmove */
00072 #endif
00073 
00074 /* Unixware 7 */
00075 #if !defined(HAVE_BFILL)
00076 # define bfill(A,B,C)           memset((A),(C),(B))
00077 # define bmove_align(A,B,C)    memcpy((A),(B),(C))
00078 #endif
00079 
00080 #if !defined(HAVE_BCMP)
00081 # define bcopy(s, d, n)         memcpy((d), (s), (n))
00082 # define bcmp(A,B,C)            memcmp((A),(B),(C))
00083 # define bzero(A,B)             memset((A),0,(B))
00084 # define bmove_align(A,B,C)    memcpy((A),(B),(C))
00085 #endif
00086 
00087 #if defined(__cplusplus) && !defined(OS2)
00088 extern "C" {
00089 #endif
00090 
00091 #if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
00092 #define strmov(A,B) stpcpy((A),(B))
00093 #ifndef stpcpy
00094 extern char *stpcpy(char *, const char *);      /* For AIX with gcc 2.95.3 */
00095 #endif
00096 #endif
00097 
00098 /* Declared in int2str() */
00099 extern char NEAR _dig_vec_upper[];
00100 extern char NEAR _dig_vec_lower[];
00101 
00102 #ifdef BAD_STRING_COMPILER
00103 #define strmov(A,B)  (memccpy(A,B,0,INT_MAX)-1)
00104 #else
00105 #define strmov_overlapp(A,B) strmov(A,B)
00106 #define strmake_overlapp(A,B,C) strmake(A,B,C)
00107 #endif
00108 
00109 #ifdef BAD_MEMCPY                       /* Problem with gcc on Alpha */
00110 #define memcpy_fixed(A,B,C) bmove((A),(B),(C))
00111 #else
00112 #define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
00113 #endif
00114 
00115 #ifdef MSDOS
00116 #undef bmove_align
00117 #define bmove512(A,B,C) bmove_align(A,B,C)
00118 extern  void bmove_align(gptr dst,const gptr src,uint len);
00119 #endif
00120 
00121 #if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
00122 #define bmove512(A,B,C) memcpy(A,B,C)
00123 #endif
00124 
00125 #ifdef HAVE_purify
00126 #define memcpy_overlap(A,B,C) \
00127 DBUG_ASSERT((A) <= (B) || ((B)+(C)) <= (A)); \
00128 bmove((byte*) (A),(byte*) (B),(size_t) (C));
00129 #else
00130 #define memcpy_overlap(A,B,C) memcpy((A), (B), (C))
00131 #endif /* HAVE_purify */
00132 
00133 
00134         /* Prototypes for string functions */
00135 
00136 #if !defined(bfill) && !defined(HAVE_BFILL)
00137 extern  void bfill(gptr dst,uint len,pchar fill);
00138 #endif
00139 
00140 #if !defined(bzero) && !defined(HAVE_BZERO)
00141 extern  void bzero(gptr dst,uint len);
00142 #endif
00143 
00144 #if !defined(bcmp) && !defined(HAVE_BCMP)
00145 extern  int bcmp(const char *s1,const char *s2,uint len);
00146 #endif
00147 #ifdef HAVE_purify
00148 extern  int my_bcmp(const char *s1,const char *s2,uint len);
00149 #undef bcmp
00150 #define bcmp(A,B,C) my_bcmp((A),(B),(C))
00151 #endif
00152 
00153 #ifndef bmove512
00154 extern  void bmove512(gptr dst,const gptr src,uint len);
00155 #endif
00156 
00157 #if !defined(HAVE_BMOVE) && !defined(bmove)
00158 extern  void bmove(char *dst, const char *src,uint len);
00159 #endif
00160 
00161 extern  void bmove_upp(char *dst,const char *src,uint len);
00162 extern  void bchange(char *dst,uint old_len,const char *src,
00163                      uint new_len,uint tot_len);
00164 extern  void strappend(char *s,uint len,pchar fill);
00165 extern  char *strend(const char *s);
00166 extern  char *strcend(const char *, pchar);
00167 extern  char *strfield(char *src,int fields,int chars,int blanks,
00168                            int tabch);
00169 extern  char *strfill(my_string s,uint len,pchar fill);
00170 extern  uint strinstr(const char *str,const char *search);
00171 extern  uint r_strinstr(reg1 my_string str,int from, reg4 my_string search);
00172 extern  char *strkey(char *dst,char *head,char *tail,char *flags);
00173 extern  char *strmake(char *dst,const char *src,uint length);
00174 #ifndef strmake_overlapp
00175 extern  char *strmake_overlapp(char *dst,const char *src, uint length);
00176 #endif
00177 
00178 #ifndef strmov
00179 extern  char *strmov(char *dst,const char *src);
00180 #endif
00181 extern  char *strnmov(char *dst,const char *src,uint n);
00182 extern  char *strsuff(const char *src,const char *suffix);
00183 extern  char *strcont(const char *src,const char *set);
00184 extern  char *strxcat _VARARGS((char *dst,const char *src, ...));
00185 extern  char *strxmov _VARARGS((char *dst,const char *src, ...));
00186 extern  char *strxcpy _VARARGS((char *dst,const char *src, ...));
00187 extern  char *strxncat _VARARGS((char *dst,uint len, const char *src, ...));
00188 extern  char *strxnmov _VARARGS((char *dst,uint len, const char *src, ...));
00189 extern  char *strxncpy _VARARGS((char *dst,uint len, const char *src, ...));
00190 
00191 /* Prototypes of normal stringfunctions (with may ours) */
00192 
00193 #ifdef WANT_STRING_PROTOTYPES
00194 extern char *strcat(char *, const char *);
00195 extern char *strchr(const char *, pchar);
00196 extern char *strrchr(const char *, pchar);
00197 extern char *strcpy(char *, const char *);
00198 extern int strcmp(const char *, const char *);
00199 #ifndef __GNUC__
00200 extern size_t strlen(const char *);
00201 #endif
00202 #endif
00203 #ifndef HAVE_STRNLEN
00204 extern uint strnlen(const char *s, uint n);
00205 #endif
00206 
00207 #if !defined(__cplusplus)
00208 #ifndef HAVE_STRPBRK
00209 extern char *strpbrk(const char *, const char *);
00210 #endif
00211 #ifndef HAVE_STRSTR
00212 extern char *strstr(const char *, const char *);
00213 #endif
00214 #endif
00215 extern int is_prefix(const char *, const char *);
00216 
00217 /* Conversion routines */
00218 double my_strtod(const char *str, char **end, int *error);
00219 double my_atof(const char *nptr);
00220 
00221 extern char *llstr(longlong value,char *buff);
00222 #ifndef HAVE_STRTOUL
00223 extern long strtol(const char *str, char **ptr, int base);
00224 extern ulong strtoul(const char *str, char **ptr, int base);
00225 #endif
00226 
00227 extern char *int2str(long val, char *dst, int radix, int upcase);
00228 extern char *int10_to_str(long val,char *dst,int radix);
00229 extern char *str2int(const char *src,int radix,long lower,long upper,
00230                          long *val);
00231 longlong my_strtoll10(const char *nptr, char **endptr, int *error);
00232 #if SIZEOF_LONG == SIZEOF_LONG_LONG
00233 #define longlong2str(A,B,C) int2str((A),(B),(C),1)
00234 #define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
00235 #undef strtoll
00236 #define strtoll(A,B,C) strtol((A),(B),(C))
00237 #define strtoull(A,B,C) strtoul((A),(B),(C))
00238 #ifndef HAVE_STRTOULL
00239 #define HAVE_STRTOULL
00240 #endif
00241 #ifndef HAVE_STRTOLL
00242 #define HAVE_STRTOLL
00243 #endif
00244 #else
00245 #ifdef HAVE_LONG_LONG
00246 extern char *longlong2str(longlong val,char *dst,int radix);
00247 extern char *longlong10_to_str(longlong val,char *dst,int radix);
00248 #if (!defined(HAVE_STRTOULL) || defined(HAVE_mit_thread)) || defined(NO_STRTOLL_PROTO)
00249 extern longlong strtoll(const char *str, char **ptr, int base);
00250 extern ulonglong strtoull(const char *str, char **ptr, int base);
00251 #endif
00252 #endif
00253 #endif
00254 
00255 /* my_vsnprintf.c */
00256 
00257 extern int my_vsnprintf( char *str, size_t n,
00258                                 const char *format, va_list ap );
00259 extern int my_snprintf(char* to, size_t n, const char* fmt, ...);
00260 
00261 #if defined(__cplusplus) && !defined(OS2)
00262 }
00263 #endif
00264 #endif

Generated on Sun May 14 14:51:19 2006 by  doxygen 1.4.2