home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / mntinc16 / string.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-29  |  3.2 KB  |  105 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. #ifndef _SIZE_T
  12. #define _SIZE_T __SIZE_TYPEDEF__
  13. typedef _SIZE_T size_t;
  14. #endif
  15.  
  16. #ifndef NULL
  17. #define NULL __NULL
  18. #endif
  19.  
  20. __EXTERN void *    memcpy    __PROTO((void * dst, const void * src, size_t size));
  21. __EXTERN char *    strcpy    __PROTO((char *dst, const char *src));
  22. __EXTERN char *    strncpy    __PROTO((char *dst, const char *src, size_t size));
  23. __EXTERN char *    strcat    __PROTO((char *dst, const char *src));
  24. __EXTERN char *    strncat    __PROTO((char *dst, const char *src, size_t size));
  25. __EXTERN int     memcmp    __PROTO((const void * s1, const void * s2, size_t size));
  26. __EXTERN int     strcmp    __PROTO((const char *s1, const char *s2));
  27. __EXTERN int     strncmp    __PROTO((const char *s1, const char *s2, size_t size));
  28.      /* strcoll not implemented for now */
  29. __EXTERN size_t    strcoll    __PROTO((char *to, size_t maxsize, const char *from));
  30. __EXTERN void *    memchr    __PROTO((const void * s, int ucharwanted, size_t size));
  31. __EXTERN char *    strchr    __PROTO((const char *s, int charwanted));
  32. __EXTERN size_t strcspn    __PROTO((const char *s, const char *reject));
  33. __EXTERN char *    strpbrk    __PROTO((const char *s, const char *breakat));
  34. __EXTERN char *    strrchr    __PROTO((const char *s, int charwanted));
  35. __EXTERN size_t strspn    __PROTO((const char *s, const char *accept));
  36. __EXTERN char *    strstr    __PROTO((const char *s, const char *wanted));
  37. __EXTERN char *    strtok    __PROTO((char *s, const char *delim));
  38. __EXTERN void *    memset    __PROTO((void *s, int ucharfill, size_t size));
  39. __EXTERN size_t    strlen    __PROTO((const char *s));
  40. __EXTERN char *    strerror __PROTO((int errnum));
  41.  
  42. #ifndef __STRICT_ANSI__
  43. /* 
  44.  * from henry spencers string lib
  45.  *  these dont appear in ansi draft sec 4.11
  46.  */
  47. __EXTERN void *    memccpy    __PROTO((void * dst, const void * src, int ucharstop, size_t size));
  48. __EXTERN char *    strlwr    __PROTO((char *));
  49. __EXTERN char *    strrev    __PROTO((char *));
  50. __EXTERN char *  strdup    __PROTO((const char *s));
  51.  
  52. /*
  53.  * V7 and BSD compatibility.
  54.  */
  55. __EXTERN char *    index    __PROTO((const char *s, int charwanted));
  56. __EXTERN char *    rindex    __PROTO((const char *s, int charwanted));
  57. __EXTERN void   bcopy    __PROTO((const void *src, void *dst, size_t length));
  58. __EXTERN int    bcmp    __PROTO((const void *s1, const void *s2, size_t length));
  59. __EXTERN void    bzero    __PROTO((void *dst, size_t length));
  60. #endif /* __STRICT_ANSI__ */
  61.  
  62. /* some macro versions of functions. these are faster, but less
  63.    forgiving of NULLs and similar nasties. to use the library functions,
  64.    just #undef the appropriate things.
  65. */
  66.  
  67. #ifdef __GNUC_INLINE__
  68.  
  69. static __inline__
  70. char *
  71. __strcat(char *dst, const char *src)
  72. {
  73.     register char *_dscan;
  74.  
  75.     for (_dscan = dst; *_dscan; _dscan++) ;
  76.     while (*_dscan++ = *src++) ;
  77.     return dst;
  78. }
  79.  
  80. static __inline__
  81. char *
  82. __strcpy(char *dst, const char *src)
  83. {
  84.     register char *_dscan = dst;
  85.     while (*_dscan++ = *src++) ;
  86.     return dst;
  87. }
  88.  
  89. static __inline__
  90. size_t
  91. __strlen(const char *scan)
  92. {
  93.     register const char *_start = scan+1;
  94.     while (*scan++) ;
  95.     return (size_t)((long)scan - (long)_start);
  96. }
  97.  
  98. #define strcat     __strcat
  99. #define strcpy     __strcpy
  100. #define strlen     __strlen
  101.  
  102. #endif /* __GNUC_INLINE__ */
  103.  
  104. #endif /* _STRING_H */
  105.