home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / STRING.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  15.8 KB  |  411 lines

  1. /*  string.h
  2.  
  3.     Definitions for string functions.
  4.  
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 9.5
  9.  *
  10.  *      Copyright (c) 1987, 1999 by Inprise Corporation
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14.  
  15. /* $Revision:   9.5  $ */
  16.  
  17. #ifndef __STRING_H
  18. #define __STRING_H
  19. #define _INC_STRING  /* MSC Guard name */
  20.  
  21. #ifndef ___STDDEF_H
  22. #include <_stddef.h>
  23. #endif
  24.  
  25. #if !defined(__STDC__) && defined(__USELOCALES__)
  26. #if !defined(__LOCALE_H)
  27. #include <locale.h>
  28. #endif
  29. #endif  /* !__STDC__ && __USELOCALES__ */
  30.  
  31. #if !defined(RC_INVOKED)
  32.  
  33. #ifndef __MEM_H
  34. #include <mem.h>  /* All mem... functions have now been moved to MEM.H */
  35. #endif
  36.  
  37. #if defined(__STDC__)
  38. #pragma warn -nak
  39. #endif
  40.  
  41. #endif  /* !RC_INVOKED */
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. #ifdef __cplusplus
  48. namespace std {
  49. #endif /* __cplusplus */
  50.  
  51. #define wcscmpi(s1,s2)      _wcsicmp(s1,s2)
  52. #define _wcscmpi(s1,s2)     _wcsicmp(s1,s2)
  53. #define wcsncmpi(s1,s2,n)   _wcsnicmp(s1,s2,n)
  54. #define _wcsncmpi(s1,s2,n)  _wcsnicmp(s1,s2,n)
  55.  
  56. _SIZE_T          _RTLENTRY  _EXPFUNC wcslen(const wchar_t *__s);
  57. wchar_t *       _RTLENTRY  _EXPFUNC wcscpy(wchar_t *__dst, const wchar_t *__src);
  58. wchar_t *       _RTLENTRY  _EXPFUNC wcscat(wchar_t *__dest, const wchar_t *__src);
  59. wchar_t *       _RTLENTRY  _EXPFUNC wcschr(const wchar_t *__s, int __c);
  60. int             _RTLENTRY  _EXPFUNC wcscmp(const wchar_t *__s1, const wchar_t *__s2);
  61. int             _RTLENTRY  _EXPFUNC wcscoll(const wchar_t * __s1, const wchar_t * __s2);
  62. _SIZE_T          _RTLENTRY  _EXPFUNC wcscspn(const wchar_t *__s1, const wchar_t *__s2);
  63. wchar_t *       _RTLENTRY  _EXPFUNC _wcsdup(const wchar_t *__s);
  64. int             _RTLENTRY  _EXPFUNC wcsncmp(const wchar_t *__s1, const wchar_t *__s2, _SIZE_T __maxlen);
  65. wchar_t *       _RTLENTRY  _EXPFUNC wcsncpy(wchar_t *__dest, const wchar_t *__src, _SIZE_T __maxlen);
  66. wchar_t *       _RTLENTRY  _EXPFUNC _wcsnset(wchar_t *__s, wchar_t __ch, _SIZE_T __n);
  67. wchar_t *       _RTLENTRY  _EXPFUNC wcspbrk(const wchar_t *__s1, const wchar_t *__s2);
  68. wchar_t *       _RTLENTRY  _EXPFUNC wcsrchr(const wchar_t *__s, wchar_t __c);
  69. wchar_t *       _RTLENTRY  _EXPFUNC _wcsrev(wchar_t *__s);
  70. wchar_t *       _RTLENTRY  _EXPFUNC _wcsset(wchar_t*__s, wchar_t __ch);
  71. _SIZE_T          _RTLENTRY  _EXPFUNC wcsspn(const wchar_t *__s1, const wchar_t *__s2);
  72. wchar_t *       _RTLENTRY  _EXPFUNC wcsstr(const wchar_t *__s1, const wchar_t *__s2);
  73. wchar_t *       _RTLENTRY  _EXPFUNC wcstok(wchar_t *__s1, const wchar_t *__s2);
  74. wchar_t *       _RTLENTRY  _EXPFUNC wcsncat(wchar_t *__dest, const wchar_t *__src, _SIZE_T __maxlen);
  75. wchar_t *       _RTLENTRY  _EXPFUNC wcspcpy(wchar_t *__dest, const wchar_t *__src);
  76. wchar_t *       _RTLENTRY  _EXPFUNC _wcspcpy(wchar_t *__dest, const wchar_t *__src);
  77. int             _RTLENTRY  _EXPFUNC _wcsicmp(const wchar_t *__s1, const wchar_t *__s2);
  78. int             _RTLENTRY  _EXPFUNC _wcsnicmp(const wchar_t *__s1, const wchar_t *__s2, _SIZE_T __maxlen);
  79. wchar_t *       _RTLENTRYF _EXPFUNC _wcslwr(wchar_t *__s);
  80. wchar_t *       _RTLENTRYF _EXPFUNC _wcsupr(wchar_t *__s);
  81. wchar_t *       _RTLENTRYF _EXPFUNC _lwcslwr(wchar_t *__s);
  82. wchar_t *       _RTLENTRYF _EXPFUNC _lwcsupr(wchar_t *__s);
  83.  
  84. char _FAR * _RTLENTRYF _EXPFUNC strcat(char _FAR *__dest, const char _FAR *__src);
  85. int         _RTLENTRYF _EXPFUNC strcmp(const char _FAR *__s1, const char _FAR *__s2);
  86. char _FAR * _RTLENTRYF _EXPFUNC strcpy(char _FAR *__dest, const char _FAR *__src);
  87. _SIZE_T      _RTLENTRY  _EXPFUNC strcspn(const char _FAR *__s1, const char _FAR *__s2);
  88. char _FAR * _RTLENTRY  _EXPFUNC strerror(int __errnum);
  89. _SIZE_T      _RTLENTRYF _EXPFUNC strlen(const char _FAR *__s);
  90. char _FAR * _RTLENTRYF _EXPFUNC strncat(char _FAR *__dest, const char _FAR *__src,
  91.                                         _SIZE_T __maxlen);
  92. int         _RTLENTRYF _EXPFUNC strncmp(const char _FAR *__s1, const char _FAR *__s2,
  93.                                         _SIZE_T __maxlen);
  94. char _FAR * _RTLENTRYF _EXPFUNC strncpy(char _FAR *__dest, const char _FAR *__src,
  95.                                         _SIZE_T __maxlen);
  96. _SIZE_T      _RTLENTRY  _EXPFUNC strspn(const char _FAR *__s1, const char _FAR *__s2);
  97. char _FAR * _RTLENTRYF _EXPFUNC strtok(char _FAR *__s1, const char _FAR *__s2);
  98. char _FAR * _RTLENTRY  _EXPFUNC _strerror(const char _FAR *__s);
  99.  
  100.  
  101. #if !defined(__STDC__)
  102. /* compatibility with other compilers */
  103. #define strcmpi(s1,s2)      stricmp(s1,s2)
  104. #define strncmpi(s1,s2,n)   strnicmp(s1,s2,n)
  105.  
  106. char _FAR * _RTLENTRYF _EXPFUNC   _lstrlwr(char _FAR *__s);
  107. char _FAR * _RTLENTRYF _EXPFUNC   _lstrupr(char _FAR *__s);
  108. char _FAR * _RTLENTRYF _EXPFUNC32 stpcpy(char _FAR *__dest, const char _FAR *__src);
  109. char _FAR * _RTLENTRY  _EXPFUNC32 _stpcpy(char _FAR *__dest, const char _FAR *__src);
  110. char _FAR * _RTLENTRY  _EXPFUNC   strdup(const char _FAR *__s);
  111. int         _RTLENTRYF _EXPFUNC   stricmp(const char _FAR *__s1, const char _FAR *__s2);
  112. char _FAR * _RTLENTRYF _EXPFUNC   strlwr(char _FAR *__s);
  113. int         _RTLENTRYF _EXPFUNC   strnicmp(const char _FAR *__s1, const char _FAR *__s2,
  114.                                            _SIZE_T __maxlen);
  115. char _FAR * _RTLENTRY  _EXPFUNC   strnset(char _FAR *__s, int __ch, _SIZE_T __n);
  116. char _FAR * _RTLENTRY  _EXPFUNC   strrev(char _FAR *__s);
  117. char _FAR * _RTLENTRY  _EXPFUNC   strset(char _FAR *__s, int __ch);
  118. char _FAR * _RTLENTRYF _EXPFUNC   strupr(char _FAR *__s);
  119. #endif  /* !__STDC__ */
  120.  
  121.  
  122. #if defined(__cplusplus)
  123. extern "C++"
  124. {
  125.           char _FAR * _RTLENTRYF _EXPFUNC   strchr(char _FAR * __s, int __c);
  126.     const char _FAR * _RTLENTRYF _EXPFUNC   strchr(const char _FAR * __s, int __c);
  127.           char _FAR * _RTLENTRYF _EXPFUNC   strrchr(char _FAR *__s, int __c);
  128.     const char _FAR * _RTLENTRYF _EXPFUNC   strrchr(const char _FAR *__s, int __c);
  129.           char _FAR * _RTLENTRYF _EXPFUNC   strpbrk(char _FAR *__s1, const char _FAR *__s2);
  130.     const char _FAR * _RTLENTRYF _EXPFUNC   strpbrk(const char _FAR *__s1, const char _FAR *__s2);
  131.           char _FAR * _RTLENTRY  _EXPFUNC   strstr(char _FAR *__s1, const char _FAR *__s2);
  132.     const char _FAR * _RTLENTRY  _EXPFUNC   strstr(const char _FAR *__s1, const char _FAR *__s2);
  133. }
  134. #else
  135.           char _FAR * _RTLENTRYF _EXPFUNC   strchr(const char _FAR * __s, int __c);
  136.           char _FAR * _RTLENTRYF _EXPFUNC   strrchr(const char _FAR *__s, int __c);
  137.           char _FAR * _RTLENTRYF _EXPFUNC   strpbrk(const char _FAR *__s1, const char _FAR *__s2);
  138.           char _FAR * _RTLENTRY  _EXPFUNC   strstr(const char _FAR *__s1, const char _FAR *__s2);
  139. #endif
  140.  
  141.  
  142. /* Intrinsic functions */
  143.  
  144. /* Intrinsics must be prototyped outside of any namespace */
  145. #ifdef __cplusplus
  146. } // std
  147. #endif /* __cplusplus */
  148.  
  149. char _FAR * _RTLENTRY             __stpcpy__(char _FAR *__dest, const char _FAR *__src);
  150. char _FAR * _RTLENTRYF _EXPFUNC16 __strcat__(char _FAR *__dest, const char _FAR *__src);
  151. char _FAR * _RTLENTRY  _EXPFUNC16 __strchr__(const char _FAR *__s, int __c);
  152. int         _RTLENTRYF _EXPFUNC16 __strcmp__(const char _FAR *__s1, const char _FAR *__s2);
  153. char _FAR * _RTLENTRYF _EXPFUNC16 __strcpy__(char _FAR *__dest, const char _FAR *__src);
  154. _SIZE_T     _RTLENTRYF _EXPFUNC16 __strlen__(const char _FAR *__s);
  155. char _FAR * _RTLENTRY  _EXPFUNC16 __strncat__(char _FAR *__dest, const char _FAR *__src,
  156.                                               _SIZE_T __maxlen);
  157. int         _RTLENTRY  _EXPFUNC16 __strncmp__(const char _FAR *__s1, const char _FAR *__s2,
  158.                                               _SIZE_T __maxlen);
  159. char _FAR * _RTLENTRYF _EXPFUNC16 __strncpy__(char _FAR *__dest, const char _FAR *__src,
  160.                                               _SIZE_T __maxlen);
  161. char _FAR * _RTLENTRY  _EXPFUNC16 __strnset__(char _FAR *__s, int __ch, _SIZE_T __n);
  162. char _FAR * _RTLENTRYF _EXPFUNC16 __strrchr__(const char _FAR *__s, int __c);
  163. char _FAR * _RTLENTRY  _EXPFUNC16 __strset__(char _FAR *__s, int __ch);
  164.  
  165. /* Now that the intrinsics are finished, turn the namespace back on */
  166. #ifdef __cplusplus
  167. namespace std {
  168. #endif /* __cplusplus */
  169.  
  170.  
  171. #if defined(__MSC) && !defined(__MFC_COMPAT__)
  172. #define _stricmp(s1,s2) stricmp(s1,s2)
  173. #define _strdup(s1)     strdup(s1)
  174. #define _strupr(s1)     strupr(s1)
  175. #define _strlwr(s1)     strlwr(s1)
  176. #define _strrev(s1)     strrev(s1)
  177. #endif  /* __MSC */
  178.  
  179. #if defined(__MFC_COMPAT__)
  180. inline char _FAR * _RTLENTRY  _strrev(char _FAR *__s) { return strrev(__s); }
  181.  
  182. inline char _FAR * _RTLENTRY  _strset(char _FAR *__s, int __ch)
  183.                               { return strset(__s, __ch); }
  184. inline char _FAR * _RTLENTRY  _strnset(char _FAR *__s, int __ch, _SIZE_T __n)
  185.                               { return strnset(__s, __ch, __n); }
  186. inline char _FAR * _RTLENTRYF _strupr(char _FAR *__s) { return strupr(__s); }
  187.  
  188. inline char _FAR * _RTLENTRYF _strlwr(char _FAR *__s) { return strlwr(__s); }
  189.  
  190. inline char _FAR * _RTLENTRY  _strdup(const char _FAR *__s)
  191.                               { return strdup(__s); }
  192. inline int         _RTLENTRYF _strcmpi(const char _FAR *__s1, const char _FAR *__s2)
  193.                               { return stricmp (__s1, __s2); }
  194. inline int         _RTLENTRYF _stricmp(const char _FAR *__s1, const char _FAR *__s2)
  195.                               { return stricmp (__s1, __s2); }
  196. inline int         _RTLENTRYF _strcmp(const char _FAR *__s1, const char _FAR *__s2)
  197.                               { return strcmp (__s1, __s2); }
  198. inline int         _RTLENTRYF _strnicmp(const char _FAR *__s1, const char _FAR *__s2, _SIZE_T __maxlen)
  199.                               { return strnicmp (__s1, __s2, __maxlen); }
  200. #endif
  201.  
  202. int    _RTLENTRY  _EXPFUNC _lstrcoll(const char * __s1, const char * __s2);
  203. int    _RTLENTRY  _EXPFUNC _lstricoll(const char * __s1, const char * __s2);
  204. int    _RTLENTRY  _EXPFUNC _lstrncoll(const char * __s1, const char * __s2, const int __len);
  205. int    _RTLENTRY  _EXPFUNC _lstrnicoll(const char * __s1, const char * __s2, int __len);
  206. _SIZE_T _RTLENTRY  _EXPFUNC _lstrxfrm(char * __s1, const char * __s2,_SIZE_T __n );
  207. int    _RTLENTRY  _EXPFUNC strcoll(const char * __s1, const char * __s2);
  208. int    _RTLENTRY  _EXPFUNC _stricoll(const char * __s1, const char * __s2);
  209. int    _RTLENTRY  _EXPFUNC _strncoll(const char * __s1, const char * __s2, _SIZE_T __n);
  210. int    _RTLENTRY  _EXPFUNC _strnicoll(const char * __s1, const char * __s2, int __len);
  211. _SIZE_T _RTLENTRY  _EXPFUNC strxfrm(char * __s1, const char * __s2,_SIZE_T __n );
  212.  
  213. int    _RTLENTRY  _EXPFUNC _lwcscoll(const wchar_t * __s1, const wchar_t * __s2);
  214. int    _RTLENTRY  _EXPFUNC _lwcsicoll(const wchar_t * __s1, const wchar_t * __s2);
  215. int    _RTLENTRY  _EXPFUNC _lwcsncoll(const wchar_t * __s1, const wchar_t * __s2, const int __len);
  216. int    _RTLENTRY  _EXPFUNC _lwcsnicoll(const wchar_t * __s1, const wchar_t * __s2, int __len);
  217. _SIZE_T _RTLENTRY  _EXPFUNC _lwcsxfrm(wchar_t * __s1, const wchar_t * __s2,_SIZE_T __n );
  218. int    _RTLENTRY  _EXPFUNC wcscoll(const wchar_t * __s1, const wchar_t * __s2);
  219. int    _RTLENTRY  _EXPFUNC _wcsicoll(const wchar_t * __s1, const wchar_t * __s2);
  220. int    _RTLENTRY  _EXPFUNC _wcsncoll(const wchar_t * __s1, const wchar_t * __s2, _SIZE_T __n);
  221. int    _RTLENTRY  _EXPFUNC _wcsnicoll(const wchar_t * __s1, const wchar_t * __s2, int __len);
  222. _SIZE_T _RTLENTRY  _EXPFUNC wcsxfrm(wchar_t * __s1, const wchar_t * __s2, _SIZE_T __n );
  223.  
  224.  
  225. #if !defined(__STDC__) /* NON_ANSI  */
  226. #define _fstrcat   strcat
  227. #define _fstrchr   strchr
  228. #define _fstrcmp   strcmp
  229. #define _fstrcpy   strcpy
  230. #define _fstrcspn  strcspn
  231. #define _fstrdup   strdup
  232. #define _fstricmp  stricmp
  233. #define _fstrlen   strlen
  234. #define _fstrlwr   strlwr
  235. #define _fstrncat  strncat
  236. #define _fstrncmp  strncmp
  237. #define _fstrncpy  strncpy
  238. #define _fstrnicmp strnicmp
  239. #define _fstrnset  strnset
  240. #define _fstrpbrk  strpbrk
  241. #define _fstrrchr  strrchr
  242. #define _fstrrev   strrev
  243. #define _fstrset   strset
  244. #define _fstrspn   strspn
  245. #define _fstrstr   strstr
  246. #define _fstrtok   strtok
  247. #define _fstrupr   strupr
  248. #endif /* __STDC__  */
  249.  
  250. #if defined(__USELOCALES__)
  251. #define  strupr     _lstrupr
  252. #define  strlwr     _lstrlwr
  253. #define  strcoll    _lstrcoll
  254. #define  stricoll   _lstricoll
  255. #define  strncoll   _lstrncoll
  256. #define  strnicoll  _lstrnicoll
  257. #define  strxfrm    _lstrxfrm
  258. #endif  /* __USELOCALES__ */
  259.  
  260. #if !defined(RC_INVOKED)
  261.  
  262. #if defined(__STDC__)
  263. #pragma warn .nak
  264. #endif
  265.  
  266. #endif  /* !RC_INVOKED */
  267.  
  268. #ifdef __cplusplus
  269. } // std
  270. #endif /* __cplusplus */
  271.  
  272. #ifdef __cplusplus
  273. }
  274. #endif
  275.  
  276. #endif  /* __STRING_H */
  277.  
  278. #if defined(__cplusplus) && !defined(__USING_CNAME__) && !defined(__STRING_H_USING_LIST)
  279. #define __STRING_H_USING_LIST
  280. #if !defined(__STDC__)
  281.      using std::_lstrlwr;
  282.      using std::_lstrupr;
  283.      using std::_stpcpy;
  284.      using std::strdup;
  285.      using std::stricmp;
  286.      using std::strlwr;
  287.      using std::strnicmp;
  288.      using std::strrev;
  289.      using std::strupr;
  290. #endif
  291. #if defined(__MFC_COMPAT__)
  292.  
  293.      using std::_strrev;
  294.      using std::_strset;
  295.      using std::_strnset;
  296.      using std::_strupr;
  297.      using std::_strdup;
  298.      using std::_strlwr;
  299.      using std::_strcmpi;
  300.      using std::_stricmp;
  301.      using std::_strcmp;
  302.      using std::_strnicmp;
  303. #endif
  304.      using std::_lstrcoll;
  305.      using std::_lstricoll;
  306.      using std::_lstrncoll;
  307.      using std::_lstrnicoll;
  308.      using std::_lstrxfrm;
  309.      using std::_lwcscoll;
  310.      using std::_lwcsicoll;
  311.      using std::_lwcslwr;
  312.      using std::_lwcsncoll;
  313.      using std::_lwcsnicoll;
  314.      using std::_lwcsupr;
  315.      using std::_lwcsxfrm;
  316.      using std::_strerror;
  317.      using std::_stricoll;
  318.      using std::_strncoll;
  319.      using std::_strnicoll;
  320.      using std::_wcsdup;
  321.      using std::_wcsicmp;
  322.      using std::_wcsicoll;
  323.      using std::_wcslwr;
  324.      using std::_wcsncoll;
  325.      using std::_wcsnicmp;
  326.      using std::_wcsnicoll;
  327.      using std::_wcsnset;
  328.      using std::_wcspcpy;
  329.      using std::_wcsrev;
  330.      using std::_wcsset;
  331.      using std::_wcsupr;
  332.  
  333. /*
  334.    Handle intrinsics specially.  If intrinsics are on, the compiler creates
  335.    a macro of the normal function mapping to the __ intrinsic version, ie:
  336.      #define strcpy __strcpy__
  337.    Thus, we can test the normal name as a macro to see if it's defined, and
  338.    only preform a using statement if it's not an intrinsic
  339. */
  340.  
  341. #if !defined(__STDC__)
  342. #    ifndef strnset
  343.     using std::strnset;
  344. #    endif // ifndef strnset
  345. #    ifndef stpcpy
  346.     using std::stpcpy;
  347. #    endif // ifndef stpcpy
  348. #    ifndef strset
  349.     using std::strset;
  350. #    endif // ifndef strset
  351. #endif // __STDC__
  352.  
  353. #    ifndef strcat
  354.     using std::strcat;
  355. #    endif // ifndef strcat
  356. #    ifndef strchr
  357.     using std::strchr;
  358. #    endif // ifndef strchr
  359. #    ifndef strcmp
  360.     using std::strcmp;
  361. #    endif // ifndef strcmp
  362. #    ifndef strcpy
  363.     using std::strcpy;
  364. #    endif // ifndef strcpy
  365. #    ifndef strlen
  366.     using std::strlen;
  367. #    endif // ifndef strlen
  368. #    ifndef strncat
  369.     using std::strncat;
  370. #    endif // ifndef strncat
  371. #    ifndef strncmp
  372.     using std::strncmp;
  373. #    endif // ifndef strncmp
  374. #    ifndef strncpy
  375.     using std::strncpy;
  376. #    endif // ifndef strncpy
  377. #    ifndef strrchr
  378.     using std::strrchr;
  379. #    endif // ifndef strrchr
  380.  
  381.      using std::strcspn;
  382.      using std::strerror;
  383.      using std::strpbrk;
  384.      using std::strspn;
  385.      using std::strstr;
  386.      using std::strtok;
  387.      using std::strxfrm;
  388.      using std::strcoll;
  389.  
  390.      using std::wcscat;
  391.      using std::wcschr;
  392.      using std::wcscmp;
  393.      using std::wcscoll;
  394.      using std::wcscpy;
  395.      using std::wcscspn;
  396.      using std::wcslen;
  397.      using std::wcsncat;
  398.      using std::wcsncmp;
  399.      using std::wcsncpy;
  400.      using std::wcspbrk;
  401.      using std::wcspcpy;
  402.      using std::wcsrchr;
  403.      using std::wcsspn;
  404.      using std::wcsstr;
  405.      using std::wcstok;
  406.      using std::wcsxfrm;
  407. #endif /* __USING_CNAME__ */
  408.  
  409. #if defined(__USING_STD_NAMES__) && !defined(__STD_STRING)
  410. #  include <string.stl>
  411. #endif  /* __USING_STD_NAMES__ */