Eneboo - Documentación para desarrolladores
src/libmysql_std/include/m_string.h
Ir a la documentación de este archivo.
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; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00015 
00016 /* There may be prolems include all of theese. Try to test in
00017    configure with ones are needed? */
00018 
00019 /*  This is needed for the definitions of strchr... on solaris */
00020 
00021 #ifndef _m_string_h
00022 #define _m_string_h
00023 #ifndef __USE_GNU
00024 #define __USE_GNU                               /* We want to use stpcpy */
00025 #endif
00026 #if defined(HAVE_STRINGS_H)
00027 #include <strings.h>
00028 #endif
00029 #if defined(HAVE_STRING_H)
00030 #include <string.h>
00031 #endif
00032 
00033 /* need by my_vsnprintf */
00034 #include <stdarg.h> 
00035 
00036 /* Correct some things for UNIXWARE7 */
00037 #ifdef HAVE_UNIXWARE7_THREADS
00038 #undef HAVE_STRINGS_H
00039 #undef HAVE_MEMORY_H
00040 #define HAVE_MEMCPY
00041 #ifndef HAVE_MEMMOVE
00042 #define HAVE_MEMMOVE
00043 #endif
00044 #undef HAVE_BCMP
00045 #undef bcopy
00046 #undef bcmp
00047 #undef bzero
00048 #endif /* HAVE_UNIXWARE7_THREADS */
00049 #ifdef _AIX
00050 #undef HAVE_BCMP
00051 #endif
00052 
00053 /*  This is needed for the definitions of bzero... on solaris */
00054 #if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
00055 #include <strings.h>
00056 #endif
00057 
00058 /*  This is needed for the definitions of memcpy... on solaris */
00059 #if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
00060 #include <memory.h>
00061 #endif
00062 
00063 #if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
00064 # define memcpy(d, s, n)        bcopy ((s), (d), (n))
00065 # define memset(A,C,B)          bfill((A),(B),(C))
00066 # define memmove(d, s, n)       bmove ((d), (s), (n))
00067 #elif defined(HAVE_MEMMOVE)
00068 # define bmove(d, s, n)         memmove((d), (s), (n))
00069 #else
00070 # define memmove(d, s, n)       bmove((d), (s), (n)) /* our bmove */
00071 #endif
00072 
00073 /* Unixware 7 */
00074 #if !defined(HAVE_BFILL)
00075 # define bfill(A,B,C)           memset((A),(C),(B))
00076 # define bmove_align(A,B,C)    memcpy((A),(B),(C))
00077 #endif
00078 
00079 #if !defined(HAVE_BCMP)
00080 # define bcopy(s, d, n)         memcpy((d), (s), (n))
00081 # define bcmp(A,B,C)            memcmp((A),(B),(C))
00082 # define bzero(A,B)             memset((A),0,(B))
00083 # define bmove_align(A,B,C)    memcpy((A),(B),(C))
00084 #endif
00085 
00086 #if defined(__cplusplus) && !defined(OS2)
00087 extern "C" {
00088 #endif
00089 
00090 /*
00091   my_str_malloc() and my_str_free() are assigned to implementations in
00092   strings/alloc.c, but can be overridden in the calling program.
00093  */
00094 extern void *(*my_str_malloc)(size_t);
00095 extern void (*my_str_free)(void *);
00096 
00097 #if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
00098 #define strmov(A,B) stpcpy((A),(B))
00099 #ifndef stpcpy
00100 extern char *stpcpy(char *, const char *);      /* For AIX with gcc 2.95.3 */
00101 #endif
00102 #endif
00103 
00104 /* Declared in int2str() */
00105 extern char NEAR _dig_vec_upper[];
00106 extern char NEAR _dig_vec_lower[];
00107 
00108 /* Defined in strtod.c */
00109 extern const double log_10[309];
00110 
00111 #ifdef BAD_STRING_COMPILER
00112 #define strmov(A,B)  (memccpy(A,B,0,INT_MAX)-1)
00113 #else
00114 #define strmov_overlapp(A,B) strmov(A,B)
00115 #define strmake_overlapp(A,B,C) strmake(A,B,C)
00116 #endif
00117 
00118 #ifdef BAD_MEMCPY                       /* Problem with gcc on Alpha */
00119 #define memcpy_fixed(A,B,C) bmove((A),(B),(C))
00120 #else
00121 #define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
00122 #endif
00123 
00124 #ifdef MSDOS
00125 #undef bmove_align
00126 #define bmove512(A,B,C) bmove_align(A,B,C)
00127 extern  void bmove_align(gptr dst,const gptr src,uint len);
00128 #endif
00129 
00130 #if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
00131 #define bmove512(A,B,C) memcpy(A,B,C)
00132 #endif
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   ATTRIBUTE_FORMAT(printf, 3, 4);
00261 
00262 #if defined(__cplusplus) && !defined(OS2)
00263 }
00264 #endif
00265 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'