home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / NLS / FNLWR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  1.3 KB  |  63 lines

  1. /* fnlwr.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <sys/nls.h>
  5. #include <stdlib.h>
  6. #include <ctype.h>
  7.  
  8. static char cache_curdrive = 0;
  9. static char cache_filesys[26] =
  10.     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  11.  
  12. void _fnlwr (char *name)
  13. {
  14.   char c, dr[3], fs[16];
  15.   int i;
  16.  
  17.   c = _fngetdrive (name);
  18.   if (c == 0)
  19.     {
  20.       if (cache_curdrive == 0)
  21.         cache_curdrive = _getdrive ();
  22.       c = cache_curdrive;
  23.     }
  24.   else
  25.     name[0] = (char)(c - 'A' + 'a');
  26.   i = c - 'A';
  27.   if (cache_filesys[i] == 0)
  28.     {
  29.       dr[0] = c;
  30.       dr[1] = ':';
  31.       dr[2] = 0;
  32.       if (_filesys (dr, fs, sizeof (fs)) != 0)
  33.         return;
  34.       if (strcmp (fs, "HPFS") == 0 || strcmp (fs, "NFS") == 0)
  35.         cache_filesys[i] = 'p';     /* case-preserving */
  36.       else
  37.         cache_filesys[i] = 'u';     /* upper-casing */
  38.     }
  39.   if (cache_filesys[i] == 'u')
  40.     {
  41.       if (!_nls_init_flag) _nls_init();
  42.       _nls_strlwr (name);
  43.     }
  44. }
  45.  
  46.  
  47. void _rfnlwr (void)
  48. {
  49.   int i;
  50.  
  51.   for (i = 0; i < 26; ++i)
  52.     cache_filesys[i] = 0;
  53.   cache_curdrive = 0;
  54. }
  55.  
  56.  
  57. void _sfnlwr (const char *name)
  58. {
  59.   cache_curdrive = _fngetdrive (name);
  60.   if (cache_curdrive == 0)
  61.     cache_curdrive = _getdrive ();
  62. }
  63.