home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / duucp-1.17 / AU-117b4-src.lha / src / lib / stristr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-22  |  442 b   |  33 lines

  1. #include <ctype.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4.  
  5. #include "config.h"
  6.  
  7. Prototype char *stristr (const char *, const char *);
  8.  
  9. /*
  10. **  stristr
  11. **
  12. **  Just like strstr() except case insensitive
  13. */
  14.  
  15. char *
  16. stristr (const char *s1, const char *s2)
  17. {
  18.     int
  19.         c = tolower (*s2),
  20.         l2 = strlen (s2);
  21.  
  22.     if (l2 == 0)
  23.         return s1;
  24.  
  25.     while (*s1) {
  26.         if (tolower (*s1) == c && strnicmp (s1, s2, l2) == 0)
  27.             return s1;
  28.         s1++;
  29.     }
  30.  
  31.     return NULL;
  32. }
  33.