home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / _str.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  15.8 KB  |  409 lines

  1. /*  _str.h internal version of "C" string.h functions
  2.  
  3.     Definitions for string functions.
  4.  
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 10.0
  9.  *
  10.  *      Copyright (c) 1987, 2000 by Inprise Corporation
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14.  
  15. /* $Revision:   9.0  $ */
  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 _strnicmp(s1,s2,s3) strnicmp(s1,s2,s3)
  173. #define _stricmp(s1,s2)     stricmp(s1,s2)
  174. #define _strdup(s1)         strdup(s1)
  175. #define _strupr(s1)         strupr(s1)
  176. #define _strlwr(s1)         strlwr(s1)
  177. #define _strrev(s1)         strrev(s1)
  178. #endif  /* __MSC */
  179.  
  180. #if defined(__MFC_COMPAT__)
  181. __inline char _FAR * _RTLENTRY  _strrev(char _FAR *__s) { return strrev(__s); }
  182.  
  183. __inline char _FAR * _RTLENTRY  _strset(char _FAR *__s, int __ch)
  184.                               { return strset(__s, __ch); }
  185. __inline char _FAR * _RTLENTRY  _strnset(char _FAR *__s, int __ch, _SIZE_T __n)
  186.                               { return strnset(__s, __ch, __n); }
  187. __inline char _FAR * _RTLENTRYF _strupr(char _FAR *__s) { return strupr(__s); }
  188.  
  189. __inline char _FAR * _RTLENTRYF _strlwr(char _FAR *__s) { return strlwr(__s); }
  190.  
  191. __inline char _FAR * _RTLENTRY  _strdup(const char _FAR *__s)
  192.                               { return strdup(__s); }
  193. __inline int         _RTLENTRYF _strcmpi(const char _FAR *__s1, const char _FAR *__s2)
  194.                               { return stricmp (__s1, __s2); }
  195. __inline int         _RTLENTRYF _stricmp(const char _FAR *__s1, const char _FAR *__s2)
  196.                               { return stricmp (__s1, __s2); }
  197. __inline int         _RTLENTRYF _strcmp(const char _FAR *__s1, const char _FAR *__s2)
  198.                               { return strcmp (__s1, __s2); }
  199. __inline int         _RTLENTRYF _strnicmp(const char _FAR *__s1, const char _FAR *__s2, _SIZE_T __maxlen)
  200.                               { return strnicmp (__s1, __s2, __maxlen); }
  201. #endif
  202.  
  203. int    _RTLENTRY  _EXPFUNC _lstrcoll(const char * __s1, const char * __s2);
  204. int    _RTLENTRY  _EXPFUNC _lstricoll(const char * __s1, const char * __s2);
  205. int    _RTLENTRY  _EXPFUNC _lstrncoll(const char * __s1, const char * __s2, const int __len);
  206. int    _RTLENTRY  _EXPFUNC _lstrnicoll(const char * __s1, const char * __s2, int __len);
  207. _SIZE_T _RTLENTRY  _EXPFUNC _lstrxfrm(char * __s1, const char * __s2,_SIZE_T __n );
  208. int    _RTLENTRY  _EXPFUNC strcoll(const char * __s1, const char * __s2);
  209. int    _RTLENTRY  _EXPFUNC _stricoll(const char * __s1, const char * __s2);
  210. int    _RTLENTRY  _EXPFUNC _strncoll(const char * __s1, const char * __s2, _SIZE_T __n);
  211. int    _RTLENTRY  _EXPFUNC _strnicoll(const char * __s1, const char * __s2, int __len);
  212. _SIZE_T _RTLENTRY  _EXPFUNC strxfrm(char * __s1, const char * __s2,_SIZE_T __n );
  213.  
  214. int    _RTLENTRY  _EXPFUNC _lwcscoll(const wchar_t * __s1, const wchar_t * __s2);
  215. int    _RTLENTRY  _EXPFUNC _lwcsicoll(const wchar_t * __s1, const wchar_t * __s2);
  216. int    _RTLENTRY  _EXPFUNC _lwcsncoll(const wchar_t * __s1, const wchar_t * __s2, const int __len);
  217. int    _RTLENTRY  _EXPFUNC _lwcsnicoll(const wchar_t * __s1, const wchar_t * __s2, int __len);
  218. _SIZE_T _RTLENTRY  _EXPFUNC _lwcsxfrm(wchar_t * __s1, const wchar_t * __s2,_SIZE_T __n );
  219. int    _RTLENTRY  _EXPFUNC wcscoll(const wchar_t * __s1, const wchar_t * __s2);
  220. int    _RTLENTRY  _EXPFUNC _wcsicoll(const wchar_t * __s1, const wchar_t * __s2);
  221. int    _RTLENTRY  _EXPFUNC _wcsncoll(const wchar_t * __s1, const wchar_t * __s2, _SIZE_T __n);
  222. int    _RTLENTRY  _EXPFUNC _wcsnicoll(const wchar_t * __s1, const wchar_t * __s2, int __len);
  223. _SIZE_T _RTLENTRY  _EXPFUNC wcsxfrm(wchar_t * __s1, const wchar_t * __s2, _SIZE_T __n );
  224.  
  225.  
  226. #if !defined(__STDC__) /* NON_ANSI  */
  227. #define _fstrcat   strcat
  228. #define _fstrchr   strchr
  229. #define _fstrcmp   strcmp
  230. #define _fstrcpy   strcpy
  231. #define _fstrcspn  strcspn
  232. #define _fstrdup   strdup
  233. #define _fstricmp  stricmp
  234. #define _fstrlen   strlen
  235. #define _fstrlwr   strlwr
  236. #define _fstrncat  strncat
  237. #define _fstrncmp  strncmp
  238. #define _fstrncpy  strncpy
  239. #define _fstrnicmp strnicmp
  240. #define _fstrnset  strnset
  241. #define _fstrpbrk  strpbrk
  242. #define _fstrrchr  strrchr
  243. #define _fstrrev   strrev
  244. #define _fstrset   strset
  245. #define _fstrspn   strspn
  246. #define _fstrstr   strstr
  247. #define _fstrtok   strtok
  248. #define _fstrupr   strupr
  249. #endif /* __STDC__  */
  250.  
  251. #if defined(__USELOCALES__)
  252. #define  strupr     _lstrupr
  253. #define  strlwr     _lstrlwr
  254. #define  strcoll    _lstrcoll
  255. #define  stricoll   _lstricoll
  256. #define  strncoll   _lstrncoll
  257. #define  strnicoll  _lstrnicoll
  258. #define  strxfrm    _lstrxfrm
  259. #endif  /* __USELOCALES__ */
  260.  
  261. #if !defined(RC_INVOKED)
  262.  
  263. #if defined(__STDC__)
  264. #pragma warn .nak
  265. #endif
  266.  
  267. #endif  /* !RC_INVOKED */
  268.  
  269. #ifdef __cplusplus
  270. } // std
  271. #endif /* __cplusplus */
  272.  
  273. #ifdef __cplusplus
  274. }
  275. #endif
  276.  
  277. #endif  /* __STRING_H */
  278.  
  279. #if defined(__cplusplus) && !defined(__USING_CNAME__) && !defined(__STRING_H_USING_LIST)
  280. #define __STRING_H_USING_LIST
  281. #if !defined(__STDC__)
  282.      using std::_lstrlwr;
  283.      using std::_lstrupr;
  284.      using std::_stpcpy;
  285.      using std::strdup;
  286.      using std::stricmp;
  287.      using std::strlwr;
  288.      using std::strnicmp;
  289.      using std::strrev;
  290.      using std::strupr;
  291. #endif
  292. #if defined(__MFC_COMPAT__)
  293.  
  294.      using std::_strrev;
  295.      using std::_strset;
  296.      using std::_strnset;
  297.      using std::_strupr;
  298.      using std::_strdup;
  299.      using std::_strlwr;
  300.      using std::_strcmpi;
  301.      using std::_stricmp;
  302.      using std::_strcmp;
  303.      using std::_strnicmp;
  304. #endif
  305.      using std::_lstrcoll;
  306.      using std::_lstricoll;
  307.      using std::_lstrncoll;
  308.      using std::_lstrnicoll;
  309.      using std::_lstrxfrm;
  310.      using std::_lwcscoll;
  311.      using std::_lwcsicoll;
  312.      using std::_lwcslwr;
  313.      using std::_lwcsncoll;
  314.      using std::_lwcsnicoll;
  315.      using std::_lwcsupr;
  316.      using std::_lwcsxfrm;
  317.      using std::_strerror;
  318.      using std::_stricoll;
  319.      using std::_strncoll;
  320.      using std::_strnicoll;
  321.      using std::_wcsdup;
  322.      using std::_wcsicmp;
  323.      using std::_wcsicoll;
  324.      using std::_wcslwr;
  325.      using std::_wcsncoll;
  326.      using std::_wcsnicmp;
  327.      using std::_wcsnicoll;
  328.      using std::_wcsnset;
  329.      using std::_wcspcpy;
  330.      using std::_wcsrev;
  331.      using std::_wcsset;
  332.      using std::_wcsupr;
  333.  
  334. /*
  335.    Handle intrinsics specially.  If intrinsics are on, the compiler creates
  336.    a macro of the normal function mapping to the __ intrinsic version, ie:
  337.      #define strcpy __strcpy__
  338.    Thus, we can test the normal name as a macro to see if it's defined, and
  339.    only preform a using statement if it's not an intrinsic
  340. */
  341.  
  342. #if !defined(__STDC__)
  343. #    ifndef strnset
  344.     using std::strnset;
  345. #    endif // ifndef strnset
  346. #    ifndef stpcpy
  347.     using std::stpcpy;
  348. #    endif // ifndef stpcpy
  349. #    ifndef strset
  350.     using std::strset;
  351. #    endif // ifndef strset
  352. #endif // __STDC__
  353.  
  354. #    ifndef strcat
  355.     using std::strcat;
  356. #    endif // ifndef strcat
  357. #    ifndef strchr
  358.     using std::strchr;
  359. #    endif // ifndef strchr
  360. #    ifndef strcmp
  361.     using std::strcmp;
  362. #    endif // ifndef strcmp
  363. #    ifndef strcpy
  364.     using std::strcpy;
  365. #    endif // ifndef strcpy
  366. #    ifndef strlen
  367.     using std::strlen;
  368. #    endif // ifndef strlen
  369. #    ifndef strncat
  370.     using std::strncat;
  371. #    endif // ifndef strncat
  372. #    ifndef strncmp
  373.     using std::strncmp;
  374. #    endif // ifndef strncmp
  375. #    ifndef strncpy
  376.     using std::strncpy;
  377. #    endif // ifndef strncpy
  378. #    ifndef strrchr
  379.     using std::strrchr;
  380. #    endif // ifndef strrchr
  381.  
  382.      using std::strcspn;
  383.      using std::strerror;
  384.      using std::strpbrk;
  385.      using std::strspn;
  386.      using std::strstr;
  387.      using std::strtok;
  388.      using std::strxfrm;
  389.      using std::strcoll;
  390.  
  391.      using std::wcscat;
  392.      using std::wcschr;
  393.      using std::wcscmp;
  394.      using std::wcscoll;
  395.      using std::wcscpy;
  396.      using std::wcscspn;
  397.      using std::wcslen;
  398.      using std::wcsncat;
  399.      using std::wcsncmp;
  400.      using std::wcsncpy;
  401.      using std::wcspbrk;
  402.      using std::wcspcpy;
  403.      using std::wcsrchr;
  404.      using std::wcsspn;
  405.      using std::wcsstr;
  406.      using std::wcstok;
  407.      using std::wcsxfrm;
  408. #endif /* __USING_CNAME__ */
  409.