home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / zoo / stuff2.arc / STUFF.C < prev    next >
C/C++ Source or Header  |  1989-03-21  |  2KB  |  101 lines

  1. /*
  2. Stuff 2.0.
  3.  
  4. Checksum: 1857136836 (verify with "brik")
  5.  
  6. (C) Copyright 1988 Rahul Dhesi.  Permission is granted to copy and
  7. distribute this file in modified or unmodified form, whether for
  8. noncommercial or commercial use, provided (a) this copyright notice
  9. is preserved, (b) no attempt is made to restrict redistribution of
  10. this file, and (c) this file is not distributed as part of any
  11. collection whose redistribution is restricted by a compilation
  12. copyright.
  13. */
  14.  
  15. /*
  16. Main program for "stuff".
  17. */
  18.  
  19. /* make sure there is plenty of stack space */
  20. extern unsigned int _stklen = 10000;
  21.  
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include "stuff.h"
  25.  
  26. FILE *outfile;                         /* where output is going */
  27.  
  28. main (argc, argv)
  29. char **argv;
  30. int argc;
  31. {
  32.    int pathcount;                      /* count of pathnames */
  33.    int i;
  34.  
  35.    outfile = stdout;                   /* may change later */
  36.  
  37.    if (argc < 2) {
  38.       givehelp();
  39.       exit(1);
  40.    }
  41.  
  42.    /* count pathnames */
  43.    for (i = 1;  i < argc && *argv[i] != '-' && *argv[i] != '!'; )
  44.       i++;
  45.    pathcount = i - 1;
  46.    if (pathcount < 1) {
  47.       givehelp();
  48.       exit(1);
  49.    }
  50.  
  51.    for (; i < argc;  i++) {         /* parse options */
  52.       parseopt (argv, &i, argc, NORMAL);
  53.    }
  54.    
  55. #ifdef DEBUG
  56.    dumpopts();
  57. #endif
  58.  
  59.    for (i = 1;  i <= pathcount;  i++) {
  60.       forceslash (argv[i]);
  61.       doarg (argv[i]);
  62.    }
  63. }
  64.  
  65. void bugreport (char *func)
  66. {
  67.    fprintf (stderr, "stuff:  bug in function %s\n", func);
  68.    exit(1);
  69. }
  70.  
  71. extern int last_opt;
  72. extern request_rec *options[];
  73.  
  74. #ifdef DEBUG
  75. void dumpopts (void)
  76. {
  77.    int i;
  78.    request_rec *optr;
  79.    printf ("=== options ===\n");
  80.    for (i = 0;  i <= last_opt;  i++) {
  81.       optr = options[i];
  82.       if (optr->choice == PRINT)
  83.          printf ("%2d: PRINT\n", i);
  84.       else if (optr->choice == NAME)
  85.          printf ("%2d: %sNAME = [%s]\n",
  86.                   i, optr->negate ? "!" : " ", optr->info.name);
  87.       else if (optr->choice == MTIME)
  88.          printf ("%2d: MTIME\n", i);
  89.       else if (optr->choice == OLDER)
  90.          printf ("%2d: OLDER\n", i);
  91.       else if (optr->choice == NEWER)
  92.          printf ("%2d: NEWER\n", i);
  93.       else if (optr->choice == TYPE)
  94.          printf ("%2d: TYPE\n", i);
  95.       else
  96.          printf ("%2d: ????\n", i);
  97.    }
  98.    printf ("===============\n");
  99. }
  100. #endif
  101.