home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / string.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-09  |  11.7 KB  |  321 lines

  1. // Copyright (C) 1986-2001 by Digital Mars.
  2. // www.digitalmars.com
  3.  
  4. #if __DMC__ || __RCC__
  5. #pragma once
  6. #endif
  7.  
  8. #ifndef __STRING_H
  9. #define __STRING_H 1
  10.  
  11. #if __cplusplus
  12. extern "C" {
  13. #endif
  14.  
  15. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  16. #ifndef _CRTAPI1
  17. #define _CRTAPI1 __cdecl
  18. #endif
  19.  
  20. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  21. #ifndef _CRTAPI2
  22. #define _CRTAPI2 __cdecl
  23. #endif
  24.  
  25. /* Define CRTIMP */
  26. #ifndef _CRTIMP
  27. #if defined(_WIN32) && defined(_DLL)
  28. #define _CRTIMP  __declspec(dllimport)
  29. #else
  30. #define _CRTIMP
  31. #endif
  32. #endif
  33.  
  34. typedef unsigned size_t;
  35.  
  36. #ifndef __STDC__
  37. #if !defined(_WCHAR_T_DEFINED)
  38. typedef unsigned short wchar_t;
  39. #define _WCHAR_T_DEFINED 1
  40. #endif
  41. #endif
  42.  
  43. #define _NLSCMPERROR    2147483647
  44.  
  45. #ifndef NULL
  46. #ifdef __cplusplus
  47. #define NULL 0
  48. #else
  49. #define NULL ((void *)0)
  50. #endif
  51. #endif
  52.  
  53. #if __OS2__ && __INTSIZE == 4
  54. #define __CLIB    __stdcall
  55. #else
  56. #define __CLIB    __cdecl
  57. #endif
  58.  
  59. void *    __CLIB memcpy(void *,const void *,size_t);
  60. void *  __CLIB _inline_memcpy(void *,const void *,size_t);
  61. void *    __CLIB memmove(void *,const void *,size_t);
  62. char *    __CLIB strcpy(char *,const char *);
  63. char *    __CLIB _inline_strcpy(char *,const char *);
  64. char *    __CLIB strncpy(char *,const char *,size_t);
  65. char *    __CLIB strcat(char *,const char *);
  66. char *    __CLIB strncat(char *,const char *,size_t);
  67. int    __CLIB memcmp(const void *,const void *,size_t);
  68. int     __CLIB _inline_memcmp(const void *,const void *,size_t);
  69. int    __CLIB strcmp(const char *,const char *);
  70. int    __CLIB _inline_strcmp(const char *,const char *);
  71. int    __CLIB strcoll(const char *,const char *);
  72. int    __CLIB strncmp(const char *,const char *,size_t);
  73. size_t    __CLIB strxfrm(char *,const char *,size_t);
  74. size_t    __CLIB strcspn(const char *,const char *);
  75. size_t    __CLIB strspn(const char *,const char *);
  76. char *    __CLIB strtok(char *,const char *);
  77. void *    __CLIB memset(void *,int,size_t);
  78. char *    __CLIB strerror(int);
  79. size_t    __CLIB strlen(const char *);
  80. size_t    __CLIB _inline_strlen(const char *);
  81.  
  82. /* Unicode string routines, these are in wchar.h as well */
  83. size_t __CLIB wcslen(const wchar_t *);
  84. _CRTIMP wchar_t * __CLIB wcscpy(wchar_t *, const wchar_t *);
  85. #ifdef __NT__
  86. wchar_t * __CLIB wmemcpy(wchar_t *,const wchar_t *,size_t);
  87. wchar_t * __CLIB wmemmove(wchar_t *,const wchar_t *,size_t);
  88. wchar_t * __CLIB wmemset(wchar_t *,wchar_t,size_t);
  89. wchar_t * __CLIB wcsncpy(wchar_t *, const wchar_t *, size_t);
  90. wchar_t * __CLIB wcscat(wchar_t *, const wchar_t *);
  91. wchar_t * __CLIB wcsncat(wchar_t *, const wchar_t *, size_t);
  92. int __CLIB wcscmp(const wchar_t *, const wchar_t *);
  93. int __CLIB wcsncmp(const wchar_t *, const wchar_t *, size_t);
  94. int __CLIB wcscoll(const wchar_t *, const wchar_t *);
  95. size_t __CLIB wcsxfrm(wchar_t *, const wchar_t *, size_t);
  96. size_t __CLIB wcscspn(const wchar_t *, const wchar_t *);
  97. size_t __CLIB wcsspn(const wchar_t *, const wchar_t *);
  98. wchar_t * __CLIB wcstok(wchar_t *, const wchar_t *);
  99. int __CLIB _wcsicoll(const wchar_t *, const wchar_t *);
  100. int __CLIB _wcsncoll(const wchar_t *, const wchar_t *, size_t);
  101. int __CLIB _wcsnicoll(const wchar_t *, const wchar_t *, size_t);
  102. int __CLIB _wcsicmp(const wchar_t *, const wchar_t *);
  103. _CRTIMP int __CLIB _wcsnicmp(const wchar_t *, const wchar_t *, size_t);
  104. _CRTIMP wchar_t * __CLIB _wcsdup(const wchar_t *);
  105. wchar_t * __CLIB _wcslwr(wchar_t *);
  106. wchar_t * __CLIB _wcsupr(wchar_t *);
  107. wchar_t * __CLIB _wcsnset(wchar_t *, wchar_t, size_t);
  108. wchar_t * __CLIB _wcsrev(wchar_t *);
  109. wchar_t * __CLIB _wcsset(wchar_t *, wchar_t);
  110. #define wcswcs    wcsstr
  111. #define wcsdup    _wcsdup
  112. #define wcsicmp    _wcsicmp
  113. #define wcsnicmp _wcsnicmp
  114. #define wcsnset    _wcsnset
  115. #define wcsrev    _wcsrev
  116. #define wcsset    _wcsset
  117. #define wcslwr    _wcslwr
  118. #define wcsupr    _wcsupr
  119. #define wcsicoll _wcsicoll
  120. #endif
  121.  
  122. int  *    __CLIB _memintset(int *, int, size_t);
  123. int    __CLIB memicmp(const void *,const void *,size_t);
  124. void *  __CLIB memccpy(void *,const void *,int,unsigned int);
  125. char *    __CLIB stpcpy(char *,const char *);
  126. int    __CLIB stricmp(const char *,const char *);
  127. int    __CLIB strcmpl(const char *,const char *); /* obsolete */
  128. int    __CLIB strnicmp(const char *, const char *, size_t);
  129. char *    __CLIB strdup(const char *);
  130. char *    __CLIB strlwr(char *);
  131. char *    __CLIB strupr(char *);
  132. char *    __CLIB strnset(char *,int,size_t);
  133. char *    __CLIB strrev(char *);
  134. char *    __CLIB strset(char *,int);
  135. void    __CLIB swab(char *,char *,size_t);
  136. void    __CLIB movedata(unsigned short srcseg,unsigned srcoff,unsigned short destseg,unsigned destoff,size_t nbytes);
  137. char *    __CLIB _strerror(const char *);
  138. int    __CLIB _stricoll(const char *, const char *);
  139. int    __CLIB _strncoll(const char *, const char *, size_t);
  140. int    __CLIB _strnicoll(const char *, const char *, size_t);
  141.  
  142. #if __INTSIZE == 2
  143. void __far * __CLIB __far fmemccpy(void __far *,const void __far *,int,unsigned int);
  144. void __far * __CLIB __far fmemchr(const void __far *,int,size_t);
  145. int          __CLIB __far fmemcmp(const void __far *,const void __far *,size_t);
  146. int          __CLIB __far _fmemcmp(const void __far *,const void __far *,size_t);
  147. int          __CLIB       _inline_fmemcmp(const void __far *,const void __far *,size_t);
  148. void __far * __CLIB __far fmemcpy(void __far *,const void __far *,size_t);
  149. void __far * __CLIB __far _fmemcpy(void __far *,const void __far *,size_t);
  150. void __far * __CLIB       _inline_fmemcpy(void __far *,const void __far *,size_t);
  151. int          __CLIB __far fmemicmp(const void __far *,const void __far *,size_t);
  152. void __far * __CLIB __far fmemmove(void __far *,const void __far *,size_t);
  153. void __far * __CLIB __far _fmemmove(void __far *,const void __far *,size_t);
  154. void __far * __CLIB __far fmemset(void __far *,int,size_t);
  155. char __far * __CLIB __far fstrcat(char __far *,const char __far*);
  156. char __far * __CLIB __far fstrchr(const char __far *,int);
  157. char __far * __CLIB __far _fstrchr(const char __far *,int);
  158. int         __CLIB __far fstrcmp(const char __far *,const char __far *);
  159. int         __CLIB __far _fstrcmp(const char __far *,const char __far *);
  160. int         __CLIB       _inline_fstrcmp(const char __far *,const char __far *);
  161. char __far * __CLIB __far fstrcpy(char __far *,const char __far *);
  162. char __far * __CLIB __far _fstrcpy(char __far *,const char __far *);
  163. char __far * __CLIB       _inline_fstrcpy(char __far *,const char __far *);
  164. size_t         __CLIB __far fstrcspn(const char __far *,const char __far *);
  165. char __far * __CLIB __far fstrdup(const char __far *);
  166. char __near * __CLIB __far _nstrdup(const char __far *);
  167. int         __CLIB __far fstricmp(const char __far *,const char __far *);
  168. size_t         __CLIB __far fstrlen(const char __far *);
  169. size_t         __CLIB       _inline_fstrlen(const char __far *);
  170. size_t         __CLIB __far _fstrlen(const char __far *);
  171. char __far * __CLIB __far fstrlwr(char __far *);
  172. char __far * __CLIB __far fstrncat(char __far *,const char __far *,size_t);
  173. int         __CLIB __far fstrncmp(const char __far *,const char __far *,size_t);
  174. char __far * __CLIB __far fstrncpy(char __far *,const char __far *,size_t);
  175. int         __CLIB __far fstrnicmp(const char __far *, const char __far *, size_t);
  176. char __far * __CLIB __far fstrnset(char __far *,int,size_t);
  177. char __far * __CLIB __far fstrpbrk(const char __far *,const char __far *);
  178. char __far * __CLIB __far fstrrchr(const char __far *,int);
  179. char __far * __CLIB __far fstrrev(char __far *);
  180. char __far * __CLIB __far fstrset(char __far *,int);
  181. size_t         __CLIB __far fstrspn(const char __far *,const char __far *);
  182. char __far * __CLIB __far fstrstr(const char __far *,const char __far *);
  183. char __far * __CLIB __far fstrtok(char __far *,const char __far *);
  184. char __far * __CLIB __far _fstrtok(char __far *,const char __far *);
  185. char __far * __CLIB __far fstrupr(char __far *);
  186. #endif
  187.  
  188. #ifndef __NT__
  189. #define strcoll         strcmp
  190. #define _stricoll    stricmp
  191. #define _strncoll    strncmp
  192. #define _strnicoll    strnicmp
  193. #endif
  194.  
  195. #define strncmpl        strnicmp
  196.  
  197. #if !__STDC__
  198. #define _stricmp stricmp
  199. #define strcmpi stricmp
  200. #define _strcmpi stricmp
  201. #define movmem(src,dest,len) ((void)memmove(dest,src,len))
  202. #define setmem(dest,len,chr) ((void)memset(dest,chr,len))
  203. #define strncmpi strnicmp
  204. #define _strnicmp strnicmp
  205. #define _movedata movedata
  206. int    __CLIB _memicmp(const void *,const void *,size_t);
  207. #define _memccpy memccpy
  208. char *    __CLIB _strdup(const char *);
  209. #define _strlwr strlwr
  210. #define _strnset strnset
  211. char *    __CLIB _strrev(char *);
  212. #define _strset strset
  213. #define _strupr strupr
  214. #define _swab swab
  215.  
  216. #if __INTSIZE == 2
  217. #define _fmemicmp fmemicmp
  218. #define _fmemccpy fmemccpy
  219. #define _fmemcpy(x,y,n)        _inline_fmemcpy(x,y,n)
  220. #define fmemcpy(x,y,n)        _inline_fmemcpy(x,y,n)
  221. #define _fmemchr fmemchr
  222. #define _fmemset fmemset
  223. #define _fstrcat fstrcat
  224. #define _fstrcat fstrcat
  225. #define _fstrcspn fstrcspn
  226. #define _fstrdup fstrdup
  227. #define _fstricmp fstricmp
  228. #define _fstrcmpl fstricmp
  229. #define _fstrlwr fstrlwr
  230. #define _fstrncat fstrncat
  231. #define _fstrncmp fstrncmp
  232. #define _fstrnicmp fstrnicmp
  233. #define _fstrncpy fstrncpy
  234. #define _fstrnset fstrnset
  235. #define _fstrpbrk fstrpbrk
  236. #define _fstrrchr fstrrchr
  237. #define _fstrrev fstrrev
  238. #define _fstrset fstrset
  239. #define _fstrspn fstrspn
  240. #define _fstrstr fstrstr
  241. #define _fstrupr fstrupr
  242. #define _nmemicmp nmemicmp
  243.  
  244. #if !__LARGE__
  245. #define _fstrcmp(x,y)        _inline_fstrcmp(x,y)
  246. #define fstrcmp(x,y)        _inline_fstrcmp(x,y)
  247. #define _fstrcpy(x,y)        _inline_fstrcpy(x,y)
  248. #define fstrcpy(x,y)        _inline_fstrcpy(x,y)
  249. #define _fstrlen(s)        _inline_fstrlen(s)
  250. #define fstrlen(s)        _inline_fstrlen(s)
  251. #endif
  252.  
  253. #endif
  254. #endif
  255.  
  256. #if !__STDC__
  257. extern int __CLIB sys_nerr;
  258. extern char * __CLIB sys_errlist[];
  259. #endif
  260.  
  261. #if __cplusplus
  262. }
  263. #endif
  264.  
  265. #if 0 && __cplusplus
  266. extern "C" char * __CLIB strchr(char *,int);
  267. inline const char *strchr(const char *s, int n) { return strchr((char *)s, n); }
  268.  
  269. extern "C" char * __CLIB strrchr(char *,int);
  270. inline const char *strrchr(const char *s, int n) { return strrchr((char *)s, n); }
  271.  
  272. extern "C" const char * __CLIB strpbrk(const char *,const char *);
  273. inline char *strpbrk(char *s1,const char *s2) { return (char *) strpbrk((const char *)s1,s2); }
  274.  
  275. extern "C" char * __CLIB strstr(char *,const char *);
  276. inline const char *strstr(const char *s1,const char *s2) { return strstr((char *)s1, s2); }
  277.  
  278. extern "C" void * __CLIB memchr(void *,int,size_t);
  279. inline const void *memchr(const void *s, int c, size_t n) { return memchr((void *)s, c, n); }
  280.  
  281. extern "C" _CRTIMP wchar_t * __CLIB wcschr(wchar_t *,int);
  282. inline const wchar_t *wcschr(const wchar_t *s, int n) { return wcschr((wchar_t *)s, n); }
  283.  
  284. extern "C" wchar_t * __CLIB wcsrchr(wchar_t *,int);
  285. inline const wchar_t *wcsrchr(const wchar_t *s, int n) { return wcsrchr((wchar_t *)s, n); }
  286.  
  287. extern "C" const wchar_t * __CLIB wcspbrk(const wchar_t *,const wchar_t *);
  288. inline wchar_t *wcspbrk(wchar_t *s1,const wchar_t *s2) { return (wchar_t *) wcspbrk((const wchar_t *)s1,s2); }
  289.  
  290. extern "C" wchar_t * __CLIB wcswcs(wchar_t *,const wchar_t *);
  291. inline const wchar_t *wcswcs(const wchar_t *s1,const wchar_t *s2) { return wcswcs((wchar_t *)s1, s2); }
  292.  
  293. extern "C" void * __CLIB wmemchr(void *,wchar_t,size_t);
  294. inline const void *wmemchr(const void *s, wchar_t c, size_t n) { return wmemchr((void *)s, c, n); }
  295.  
  296. #else
  297.  
  298. #if __cplusplus
  299. extern "C" {
  300. #endif
  301.  
  302. char *    __CLIB strchr(const char *,int);
  303. char *    __CLIB strrchr(const char *,int);
  304. char *    __CLIB strpbrk(const char *,const char *);
  305. char *    __CLIB strstr(const char *,const char *);
  306. void *    __CLIB memchr(const void *,int,size_t);
  307.  
  308. _CRTIMP wchar_t * __CLIB wcschr(const wchar_t *, wchar_t);
  309. wchar_t * __CLIB wcsrchr(const wchar_t *, wchar_t);
  310. wchar_t * __CLIB wcspbrk(const wchar_t *, const wchar_t *);
  311. wchar_t * __CLIB wcsstr(const wchar_t *, const wchar_t *);
  312. wchar_t * __CLIB wmemchr(const wchar_t *,wchar_t,size_t);
  313.  
  314. #if __cplusplus
  315. }
  316. #endif
  317.  
  318. #endif
  319.  
  320. #endif
  321.