home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.7z / ftp.whtech.com / emulators / v9t9 / linux / sources / V9t9 / source / OSLib / StringExtras.c < prev    next >
Encoding:
C/C++ Source or Header  |  2006-10-19  |  642 b   |  43 lines

  1. #include "clstandardheaders.h"
  2. #include <ctype.h>
  3. #include "OSLib.h"
  4.  
  5.  
  6. char       *
  7. strcatn(char *d, const char *s, long max)
  8. {
  9.     char       *p = d + strlen(d);
  10.  
  11.     while (*s && p - d + 1 < max)
  12.         *p++ = *s++;
  13.     *p = 0;
  14.     return d;
  15. }
  16.  
  17. char       *
  18. strcpyn(char *d, const char *s, long len, long max)
  19. {
  20.     char       *p = d;
  21.  
  22.     while (len-- && *s && p - d + 1 < max)
  23.         *p++ = *s++;
  24.     *p = 0;
  25.     return d;
  26. }
  27.  
  28. const char *
  29. stristr(const char *hay, const char *nee)
  30. {
  31.     while (*hay) {
  32.         int         idx = 0;
  33.  
  34.         while (hay[idx] && nee[idx]
  35.                && toupper(hay[idx]) == toupper(nee[idx]))
  36.             idx++;
  37.         if (!nee[idx])
  38.             return hay;
  39.         hay++;
  40.     }
  41.     return NULL;
  42. }
  43.