home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / SNIP_STR.H < prev    next >
C/C++ Source or Header  |  1997-07-05  |  4KB  |  104 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  Header file for SNIPPETS string manipulation functions
  5. */
  6.  
  7. #ifndef SNIP_STR__H
  8. #define SNIP_STR__H
  9.  
  10. #include <stddef.h>                       /* For size_t and NULL        */
  11. #include <string.h>                       /* For strncpy() & memmove()  */
  12. #include "sniptype.h"                     /* For LAST_CHAR() & NUL      */
  13. #include "extkword.h"                     /* For FAR                    */
  14.  
  15. /*
  16. **  Macros to print proper plurals by Bob Stout
  17. */
  18.  
  19. #define plural_text(n) &"s"[(1 == (n))]
  20. #define plural_text2(n) &"es"[(1 == (n)) << 1]
  21. #define plural_text3(n) &"y\0ies"[(1 != (n)) << 1]
  22.  
  23. /*
  24. **  Safe string macros by Keiichi Nakasato
  25. */
  26.  
  27. /* strncpy() variants that are guaranteed to append NUL                 */
  28.  
  29. #define strn1cpy(d,s,n) (strncpy(d,s,n),(d)[n]=0,d)
  30. #define strn0cpy(d,s,n) strn1cpy(d,s,(n)-1)
  31.  
  32. /* like strcpy, except guaranteed to work with overlapping strings      */
  33.  
  34. #define strMove(d,s) memmove(d,s,strlen(s)+1)
  35.  
  36.  
  37. /*
  38. **  Prototypes
  39. **
  40. **  Note: If compiling strictly conforming ANSI/ISO standard C code, the
  41. **        function names are modified to be compliant.
  42. */
  43.  
  44. #if defined(__STDC__) && __STDC__
  45.  #define memmem   memMem
  46.  #define strchcat strChcat
  47.  #define strdel   strDel
  48.  #define strdelch strDelch
  49.  #define strdup   strDup
  50.  #define strecpy  strEcpy
  51.  #define stristr  strIstr
  52.  #define strrepl  strRepl
  53.  #define strrev   strRev
  54.  #define strrpbrk strRpbrk
  55.  #define strupr   strUpr
  56.  #define strlwr   strLwr
  57. #endif
  58.  
  59. #if defined(__cplusplus) && __cplusplus
  60.  extern "C" {
  61. #endif
  62.  
  63. void *memmem(const void *buf, const void *pattern,    /* Memmem.C       */
  64.       size_t buflen, size_t len);
  65. char *sstrcpy(char *to, char *from);                  /* Sstrcpy.C      */
  66. char *sstrcat(char *to, char *from);                  /* Sstrcpy.C      */
  67. char *sstrdel(char *s, ...);                          /* Sstrdel.C      */
  68. char *stptok(const char *s, char *tok, size_t toklen,
  69.       char *brk);                                     /* Stptok.C       */
  70. char *strchcat(char *string, int ch, size_t buflen);  /* Strchcat.C     */
  71. char *strdel(char *string, size_t first, size_t len); /* Strdel.C       */
  72. char *strdelch(char *string, const char *lose);       /* Strdelch.C     */
  73. char *strdup(const char *string);                     /* Strdup.C       */
  74. char *strecpy(char *target, const char *src);         /* Strecpy.C/Asm  */
  75. char *stristr(const char *String,                     /* Stristr.C      */
  76.               const char *Pattern);
  77. char *strrepl(char *Str, size_t BufSiz,
  78.       char *OldStr, char *NewStr);                    /* Strrepl.C      */
  79. char *strrev(char *str);                              /* Strrev.C       */
  80. char *strrpbrk(const char *szString,
  81.       const char *szChars);                           /* Strrpbrk.C     */
  82. char *strupr(char *string);                           /* Strupr.C       */
  83. char *strlwr(char *string);                           /* Strupr.C       */
  84. char *translate(char *string);                        /* Translat.C     */
  85. char *xstrcat(char *des, char *src, ...);             /* Xstrcat.C      */
  86. char *rule_line(char * s, unsigned short len,
  87.       short units, char * digits, char filler);       /* Ruleline.C     */
  88. char *rmallws(char *str);                             /* Rmallws.C      */
  89. char *rmlead(char *str);                              /* Rmlead.C       */
  90. char *rmtrail(char *str);                             /* Rmtrail.C      */
  91. char *trim (char *str);                               /* Trim.C         */
  92. void lv1ws(char *str);                                /* Lv1Ws.C        */
  93.  
  94. #if defined(MSDOS) || defined(__MSDOS__)
  95.  void FAR *fmemmem(const void FAR *buf,               /* Fmemmem.C      */
  96.        const void FAR *pattern, long buflen, long len);
  97. #endif
  98.  
  99. #if defined(__cplusplus) && __cplusplus
  100.  }
  101. #endif
  102.  
  103. #endif /*  SNIP_STR__H */
  104.