home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntinc25.zoo / string.h < prev    next >
C/C++ Source or Header  |  1992-08-26  |  4KB  |  131 lines

  1. /*
  2.  * String functions.
  3.  */
  4. #ifndef _STRING_H
  5. #define _STRING_H
  6.  
  7. #ifndef _COMPILER_H
  8. #include <compiler.h>
  9. #endif
  10.  
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14.  
  15.  
  16. #ifndef _SIZE_T
  17. #define _SIZE_T __SIZE_TYPEDEF__
  18. typedef _SIZE_T size_t;
  19. #endif
  20.  
  21. #ifndef NULL
  22. #define NULL __NULL
  23. #endif
  24.  
  25. __EXTERN void *memcpy __PROTO((void *dst, const void *src, size_t size));
  26. __EXTERN void *memmove __PROTO((void *dst, const void *src, size_t size));
  27. __EXTERN int memcmp __PROTO((const void *s1, const void *s2, size_t size));
  28. __EXTERN void *memchr __PROTO((const void *s, int ucharwanted, size_t size));
  29. __EXTERN void *memset __PROTO((void *s, int ucharfill, size_t size));
  30.  
  31. __EXTERN char *strcpy __PROTO((char *dst, const char *src));
  32. __EXTERN char *strncpy __PROTO((char *dst, const char *src, size_t n));
  33. __EXTERN char *strcat __PROTO((char *dst, const char *src));
  34. __EXTERN char *strncat __PROTO((char *dst, const char *src, size_t n));
  35. __EXTERN int strcmp __PROTO((const char *scan1, const char *scan2));
  36. __EXTERN int strncmp __PROTO((const char *scan1, const char *scan2, size_t n));
  37. __EXTERN int strcoll __PROTO((const char *scan1, const char *scan2));
  38. __EXTERN size_t    strxfrm __PROTO((char *to, const char *from, size_t maxsize));
  39. __EXTERN char *strchr __PROTO((const char *s, int charwanted));
  40. __EXTERN size_t strcspn __PROTO((const char *s, const char *reject));
  41. __EXTERN char *strpbrk __PROTO((const char *s, const char *breakat));
  42. __EXTERN char *strrchr __PROTO((const char *s, int charwanted));
  43. __EXTERN size_t strspn __PROTO((const char *s, const char *accept));
  44. __EXTERN char *strstr __PROTO((const char *s, const char *wanted));
  45. __EXTERN char *strtok __PROTO((char *s, const char *delim));
  46. __EXTERN size_t strlen __PROTO((const char *scan));
  47. __EXTERN char *strerror __PROTO((int errnum));
  48.  
  49. #ifndef __STRICT_ANSI__
  50. /* 
  51.  * from henry spencers string lib
  52.  *  these dont appear in ansi draft sec 4.11
  53.  */
  54. __EXTERN void *memccpy __PROTO((void *dst, const void *src, int ucharstop, size_t size));
  55. __EXTERN char *strlwr __PROTO((char *string));
  56. /* CAUTION: there are assumptions elsewhere in the code that strrev()
  57.    reverses in-place
  58.  */
  59. __EXTERN char *strrev __PROTO((char *string));
  60. __EXTERN char *strdup __PROTO((const char *s));
  61.  
  62. /*
  63.  * V7 and BSD compatibility.
  64.  */
  65. __EXTERN char *index __PROTO((const char *s, int charwanted));
  66. __EXTERN char *rindex __PROTO((const char *s, int charwanted));
  67. __EXTERN void bcopy __PROTO((const void *src, void *dst, size_t length));
  68. __EXTERN int bcmp __PROTO((const void *src, const void *dst, size_t n));
  69. __EXTERN void bzero __PROTO((void *b, size_t n));
  70.  
  71. __EXTERN void _bcopy __PROTO((const void *src, void *dst, unsigned long length));
  72. __EXTERN int  _bcmp __PROTO((const void *s1, const void *s2, unsigned long length));
  73. __EXTERN void _bzero __PROTO((void *dst, unsigned long length));
  74.  
  75. __EXTERN int stricmp __PROTO(( const char *, const char * ));
  76. __EXTERN int strnicmp __PROTO(( const char *, const char *, size_t ));
  77. __EXTERN int strcmpi __PROTO(( const char *, const char * ));
  78. __EXTERN int strncmpi __PROTO(( const char *, const char *, size_t ));
  79.  
  80. #endif /* __STRICT_ANSI__ */
  81.  
  82. /* some macro versions of functions. these are faster, but less
  83.    forgiving of NULLs and similar nasties. to use the library functions,
  84.    just #undef the appropriate things.
  85. */
  86.  
  87. #ifdef __GNUC_INLINE__
  88. # ifndef __cplusplus
  89.  
  90. static __inline__
  91. char *
  92. __strcat(char *dst, const char *src)
  93. {
  94.     register char *_dscan;
  95.  
  96.     for (_dscan = dst; *_dscan; _dscan++) ;
  97.     while (*_dscan++ = *src++) ;
  98.     return dst;
  99. }
  100.  
  101. static __inline__ 
  102. char *
  103. __strcpy(char *dst, const char *src)
  104. {
  105.     register char *_dscan = dst;
  106.     while (*_dscan++ = *src++) ;
  107.     return dst;
  108. }
  109.  
  110. static __inline__
  111. size_t
  112. __strlen(const char *scan)
  113. {
  114.     register const char *_start = scan+1;
  115.     while (*scan++) ;
  116.     return (size_t)((long)scan - (long)_start);
  117. }
  118.  
  119. #define strcat     __strcat
  120. #define strcpy     __strcpy
  121. #define strlen     __strlen
  122.  
  123. # endif /* !__cplusplus */
  124. #endif /* __GNUC_INLINE__ */
  125.  
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129.  
  130. #endif /* _STRING_H */
  131.