home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / duucp-1.17 / AU-117b4-src.lha / src / lib / namemunge.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-24  |  972 b   |  59 lines

  1. /*
  2.  *  NAMEMUNGE.C
  3.  */
  4.  
  5. #include <string.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include "config.h"
  9.  
  10. Prototype void mungecase_filename (char *, char *);
  11.  
  12. /*
  13.  *  Convert case-sensitive file name into case-insensitive file name.  Only
  14.  *  handles local files (i.e. no associated path) and then only files that
  15.  *  begin with <somechar><period>, where <somechar> is never modified.
  16.  */
  17.  
  18. void
  19. mungecase_filename (char *s, char *d)
  20. {
  21.     char
  22.         *ptr;
  23.     short
  24.         c;
  25.     static char
  26.         tmp [128];
  27.  
  28.     if (strchr (s, ':') || strchr (s, '/') || s [0] == 0 || s [1] != '.') {
  29.         strcpy (d, s);
  30.         return;
  31.     }
  32.     ptr = GetConfig (MUNGECASE, "Y");
  33.     if (ptr [0] == 'n' || ptr [0] == 'N' || ptr [0] == '0') {
  34.         strcpy (d, s);
  35.         return;
  36.     }
  37.  
  38.     ptr = tmp;
  39.     *ptr++ = *s++;    /*  <char>  */
  40.     *ptr++ = *s++;    /*  <dot>   */
  41.  
  42.     while (c = *s) {
  43.         if (c >= 'A' && c <= 'Z') {
  44.             c = c - 'A' + 'a';
  45.             *ptr++ = c;
  46.             *ptr++ = c;
  47.         }
  48.         else {
  49.             *ptr++ = c;
  50.         }
  51.         ++s;
  52.     }
  53.     *ptr = 0;
  54.  
  55.     strcpy (d, tmp);
  56.  
  57.     return;
  58. }
  59.