home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / mag&info / cujmay93.zip / 1105108A < prev    next >
Text File  |  1993-03-09  |  1KB  |  50 lines

  1. /* list.c:  List directory */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <ctype.h>
  6.  
  7. int Order = 1,
  8.     Full = 0;
  9.  
  10. static void dir(char *);
  11.  
  12. main(int argc, char **argv)
  13. {
  14.     char *p;
  15.  
  16.     /* Process options */
  17.     while (--argc && **++argv == '-')
  18.     {
  19.         for (p = *argv+1; *p; ++p)
  20.             switch(toupper(*p))
  21.             {
  22.                 case 'L':
  23.                     Full = !Full;
  24.                     break;
  25.                 case 'R':
  26.                     Order = -1;
  27.                     break;
  28.                 default:
  29.                     fprintf(stderr,
  30.                       "list: Invalid flag: %c\n",*p);
  31.                     return EXIT_FAILURE;
  32.             }
  33.     }
  34.  
  35.     /* List all files by default */
  36.     if (argc == 0)
  37.         dir("*.*");
  38.     else
  39.         while (argc--)
  40.             dir(*argv++);
  41. }
  42.  
  43. static void dir(char *template)
  44. {
  45.     /* Replace this stub with working code */
  46.     fprintf(stderr,"Dir: %s (Order = %d, Full = %d)\n",
  47.       template,Order,Full);
  48. }
  49.  
  50.