home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 July & August / PCWorld_2003-07-08_cd.bin / Software / Vyzkuste / mysql / data1.cab / Development / include / m_string.h < prev    next >
C/C++ Source or Header  |  2003-05-17  |  8KB  |  245 lines

  1. /* Copyright (C) 2000 MySQL AB
  2.  
  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; either version 2 of the License, or
  6.    (at your option) any later version.
  7.  
  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.
  12.  
  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  16.  
  17. /* There may be prolems include all of theese. Try to test in
  18.    configure with ones are needed? */
  19.  
  20. /*  This is needed for the definitions of strchr... on solaris */
  21.  
  22. #ifndef _m_string_h
  23. #define _m_string_h
  24. #ifndef __USE_GNU
  25. #define __USE_GNU                /* We want to use stpcpy */
  26. #endif
  27. #if defined(HAVE_STRINGS_H)
  28. #include <strings.h>
  29. #endif
  30. #if defined(HAVE_STRING_H)
  31. #include <string.h>
  32. #endif
  33.  
  34. /* Correct some things for UNIXWARE7 */
  35. #ifdef HAVE_UNIXWARE7_THREADS
  36. #undef HAVE_STRINGS_H
  37. #undef HAVE_MEMORY_H
  38. #define HAVE_MEMCPY
  39. #ifndef HAVE_MEMMOVE
  40. #define HAVE_MEMMOVE
  41. #endif
  42. #undef HAVE_BCMP
  43. #undef bcopy
  44. #undef bcmp
  45. #undef bzero
  46. #endif /* HAVE_UNIXWARE7_THREADS */
  47. #ifdef _AIX
  48. #undef HAVE_BCMP
  49. #endif
  50.  
  51. /*  This is needed for the definitions of bzero... on solaris */
  52. #if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
  53. #include <strings.h>
  54. #endif
  55.  
  56. /*  This is needed for the definitions of memcpy... on solaris */
  57. #if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
  58. #include <memory.h>
  59. #endif
  60.  
  61. #if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
  62. # define memcpy(d, s, n)    bcopy ((s), (d), (n))
  63. # define memset(A,C,B)        bfill((A),(B),(C))
  64. # define memmove(d, s, n)    bmove ((d), (s), (n))
  65. #elif defined(HAVE_MEMMOVE)
  66. # define bmove(d, s, n)        memmove((d), (s), (n))
  67. #else
  68. # define memmove(d, s, n)    bmove((d), (s), (n)) /* our bmove */
  69. #endif
  70.  
  71. /* Unixware 7 */
  72. #if !defined(HAVE_BFILL)
  73. # define bfill(A,B,C)           memset((A),(C),(B))
  74. # define bmove_allign(A,B,C)    memcpy((A),(B),(C))
  75. #endif
  76.  
  77. #if !defined(HAVE_BCMP)
  78. # define bcopy(s, d, n)        memcpy((d), (s), (n))
  79. # define bcmp(A,B,C)        memcmp((A),(B),(C))
  80. # define bzero(A,B)        memset((A),0,(B))
  81. # define bmove_allign(A,B,C)    memcpy((A),(B),(C))
  82. #endif
  83.  
  84. #if defined(__cplusplus) && !defined(OS2)
  85. extern "C" {
  86. #endif
  87.  
  88. #if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
  89. #define strmov(A,B) stpcpy((A),(B))
  90. #ifndef stpcpy
  91. extern char *stpcpy(char *, const char *);    /* For AIX with gcc 2.95.3 */
  92. #endif
  93. #endif
  94.  
  95. extern char NEAR _dig_vec[];        /* Declared in int2str() */
  96.  
  97. #ifdef BAD_STRING_COMPILER
  98. #define strmov(A,B)  (memccpy(A,B,0,INT_MAX)-1)
  99. #else
  100. #define strmov_overlapp(A,B) strmov(A,B)
  101. #define strmake_overlapp(A,B,C) strmake(A,B,C)
  102. #endif
  103.  
  104. #ifdef BAD_MEMCPY            /* Problem with gcc on Alpha */
  105. #define memcpy_fixed(A,B,C) bmove((A),(B),(C))
  106. #else
  107. #define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
  108. #endif
  109.  
  110. #ifdef MSDOS
  111. #undef bmove_allign
  112. #define bmove512(A,B,C) bmove_allign(A,B,C)
  113. #define my_itoa(A,B,C) itoa(A,B,C)
  114. #define my_ltoa(A,B,C) ltoa(A,B,C)
  115. extern    void bmove_allign(gptr dst,const gptr src,uint len);
  116. #endif
  117.  
  118. #if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
  119. #define bmove512(A,B,C) memcpy(A,B,C)
  120. #endif
  121.  
  122.     /* Prototypes for string functions */
  123.  
  124. #if !defined(bfill) && !defined(HAVE_BFILL)
  125. extern    void bfill(gptr dst,uint len,pchar fill);
  126. #endif
  127.  
  128. #if !defined(bzero) && !defined(HAVE_BZERO)
  129. extern    void bzero(gptr dst,uint len);
  130. #endif
  131.  
  132. #if !defined(bcmp) && !defined(HAVE_BCMP)
  133. extern    int bcmp(const char *s1,const char *s2,uint len);
  134. #endif
  135. #ifdef HAVE_purify
  136. extern    int my_bcmp(const char *s1,const char *s2,uint len);
  137. #undef bcmp
  138. #define bcmp(A,B,C) my_bcmp((A),(B),(C))
  139. #endif
  140.  
  141. #ifndef bmove512
  142. extern    void bmove512(gptr dst,const gptr src,uint len);
  143. #endif
  144.  
  145. #if !defined(HAVE_BMOVE) && !defined(bmove)
  146. extern    void bmove(char *dst, const char *src,uint len);
  147. #endif
  148.  
  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,
  156.                int tabch);
  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);
  164. #endif
  165.  
  166. #ifndef strmov
  167. extern    char *strmov(char *dst,const char *src);
  168. #endif
  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, ...));
  178.  
  179. /* Prototypes of normal stringfunctions (with may ours) */
  180.  
  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 *);
  187. #ifndef __GNUC__
  188. extern size_t strlen(const char *);
  189. #endif
  190. #endif
  191. #ifndef HAVE_STRNLEN 
  192. extern uint strnlen(const char *s, uint n);
  193. #endif
  194.  
  195. #if !defined(__cplusplus)
  196. #ifndef HAVE_STRPBRK
  197. extern char *strpbrk(const char *, const char *);
  198. #endif
  199. #ifndef HAVE_STRSTR
  200. extern char *strstr(const char *, const char *);
  201. #endif
  202. #endif
  203. extern int is_prefix(const char *, const char *);
  204.  
  205. /* Conversion rutins */
  206.  
  207. #ifdef USE_MY_ITOA
  208. extern char *my_itoa(int val,char *dst,int radix);
  209. extern char *my_ltoa(long val,char *dst,int radix);
  210. #endif
  211.  
  212. extern char *llstr(longlong value,char *buff);
  213. #ifndef HAVE_STRTOUL
  214. extern long strtol(const char *str, char **ptr, int base);
  215. extern ulong strtoul(const char *str, char **ptr, int base);
  216. #endif
  217.  
  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,
  221.              long *val);
  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
  229. #endif
  230. #else
  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);
  237. #endif
  238. #endif
  239. #endif
  240.  
  241. #if defined(__cplusplus) && !defined(OS2)
  242. }
  243. #endif
  244. #endif
  245.