home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / networking / uucp / amigauucpsrc / lib / string.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-29  |  765 b   |  51 lines

  1.  
  2. /*
  3.  *  STRING.C
  4.  *
  5.  *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include "config.h"
  10.  
  11. Prototype int strcmpi(const char *, const char *);
  12. Prototype int strncmpi(const char *, const char *, int);
  13.  
  14. int
  15. strcmpi(s, d)
  16. const char *s;
  17. const char *d;
  18. {
  19.     short c1, c2;
  20.     for (;;) {
  21.     c1 = *s++;
  22.     c2 = *d++;
  23.  
  24.     if (c1 == 0 || c2 == 0)
  25.         return(c1 || c2);   /*  0= both are 0   */
  26.     if (((c1 ^ c2) | 0x20) != 0x20)
  27.         return(1);
  28.     }
  29.     return(0);
  30. }
  31.  
  32. int
  33. strncmpi(s, d, n)
  34. const char *s;
  35. const char *d;
  36. int n;
  37. {
  38.     short c1, c2;
  39.     while (n--) {
  40.     c1 = *s++;
  41.     c2 = *d++;
  42.  
  43.     if (c1 == 0 || c2 == 0)
  44.         return(c1 || c2);   /*  0= both are 0   */
  45.     if (((c1 ^ c2) | 0x20) != 0x20)
  46.         return(1);
  47.     }
  48.     return(0);
  49. }
  50.  
  51.