home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 497a.lha / ComSMUS_v2.2 / iffar.src / misc.c < prev    next >
C/C++ Source or Header  |  1991-04-07  |  1KB  |  61 lines

  1. /* iffar - IFF CAT archiver miscellaneous functions
  2.  
  3.    By Karl Lehenbauer, version 1.2, release date 5/9/88.
  4.    This code is released to the public domain.
  5.    See the README file for more information.
  6.  
  7. */
  8.  
  9. #include <ctype.h>
  10.  
  11. /* strnicmp - case-insensitive strncmp, not provided by manx, this one
  12.  * is like lattice's */
  13. int strnicmp(s1, s2, len)
  14. char *s1, *s2;
  15. int len;
  16. {
  17.     char c1, c2;
  18.  
  19.     c1 = *s1;
  20.     c2 = *s2;
  21.     while (len-->0 && *s1) 
  22.     {
  23.         if (isupper(*s1))
  24.             c1 = tolower(*s1);
  25.         else
  26.             c1 = *s1;
  27.         s1++;
  28.         if (isupper(*s2))
  29.             c2 = tolower(*s2);
  30.         else
  31.             c2 = *s2;
  32.         s2++;
  33.         if (c1 != c2)
  34.             break;
  35.     }
  36.     return (c1 - c2);
  37. }
  38.  
  39. /* return the base portion of a file name - needs to be hacked in C style BWTF*/
  40.  
  41. char *basename(fname)
  42. char *fname;
  43. {
  44.     char *basename_ptr;
  45.     int i;
  46.     int fnamelen = strlen(fname);
  47.  
  48.     basename_ptr = fname;
  49.     for (i = fnamelen - 1; i > 0; i--)
  50.     {
  51.         if (fname[i] == '/' || fname[i] == ':')
  52.         {
  53.             basename_ptr = &fname[i+1];
  54.             break;
  55.         }
  56.     }
  57.     return(basename_ptr);
  58. }
  59.  
  60. /* end of misc.c */
  61.