home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / util / unix / macutil2.sha / macutil / mixed / macsave.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-05  |  1.9 KB  |  97 lines

  1. #include "globals.h"
  2. #include "../util/patchlevel.h"
  3. #include "../fileio/wrfile.h"
  4. #include "../fileio/wrfileopt.h"
  5. #include "../util/util.h"
  6.  
  7. #define LOCALOPT    "ilqVH"
  8.  
  9. extern char *strcat();
  10. void macbinary();
  11.  
  12. static void usage();
  13.  
  14. static char options[128];
  15.  
  16. int main(argc, argv)
  17. int argc;
  18. char *argv[];
  19. {
  20.     int c;
  21.     extern int optind;
  22.     extern char *optarg;
  23.     int errflg;
  24.  
  25.     set_wrfileopt(0);
  26.     set_s_wrfileopt(1);
  27.     (void)strcat(options, get_wrfileopt());
  28.     (void)strcat(options, LOCALOPT);
  29.     errflg = 0;
  30.  
  31.     while((c = getopt(argc, argv, options)) != EOF) {
  32.     if(!wrfileopt((char)c)) {
  33.         switch(c) {
  34.         case 'l':
  35.         list++;
  36.         break;
  37.         case 'q':
  38.         query++;
  39.         break;
  40.         case 'i':
  41.         info_only++;
  42.         break;
  43.         case '?':
  44.         errflg++;
  45.         break;
  46.         case 'H':
  47.         give_wrfileopt();
  48.         (void)fprintf(stderr, "Macsave specific options:\n");
  49.         (void)fprintf(stderr,
  50.             "-i:\tgive information only, do not save\n");
  51.         (void)fprintf(stderr, "-l:\tgive listing\n");
  52.         (void)fprintf(stderr,
  53.             "-q:\tquery for every file/folder before saving\n");
  54.         (void)fprintf(stderr,
  55.             "-V:\tgive information about this version\n");
  56.         (void)fprintf(stderr, "-H:\tthis message\n");
  57.         (void)fprintf(stderr, "Default is silent saving\n");
  58.         exit(0);
  59.         case 'V':
  60.         (void)fprintf(stderr, "Version %s, ", VERSION);
  61.         (void)fprintf(stderr, "patchlevel %d", PATCHLEVEL);
  62.         (void)fprintf(stderr, "%s.\n", get_mina());
  63.         exit(0);
  64.         }
  65.     }
  66.     }
  67.     if(errflg || optind != argc) {
  68.     usage();
  69.     exit(1);
  70.     }
  71.  
  72.     infp = stdin;
  73.  
  74.     if(info_only || query) {
  75.     list++;
  76.     }
  77.     c = getc(infp);
  78.     (void)ungetc(c, infp);
  79.     switch(c) {
  80.     case 0:
  81.     macbinary();
  82.     break;
  83.     default:
  84.     (void)fprintf(stderr, "Input is not MacBinary\n");
  85.     exit(1);
  86.     }
  87.     exit(0);
  88.     /* NOTREACHED */
  89. }
  90.  
  91. static void usage()
  92. {
  93.     (void)fprintf(stderr, "Usage: macsave [-%s]\n", options);
  94.     (void)fprintf(stderr, "Use \"macsave -H\" for help.\n");
  95. }
  96.  
  97.