home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / macutils.lzh / MACUTILS / MIXED / macsave.c < prev    next >
C/C++ Source or Header  |  1996-02-02  |  2KB  |  100 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. #ifdef OSK
  64.         (void)fprintf(stderr,"OSK Port by Dean Leiber\n");
  65. #endif
  66.         exit(0);
  67.         }
  68.     }
  69.     }
  70.     if(errflg || optind != argc) {
  71.     usage();
  72.     exit(1);
  73.     }
  74.  
  75.     infp = stdin;
  76.  
  77.     if(info_only || query) {
  78.     list++;
  79.     }
  80.     c = getc(infp);
  81.     (void)ungetc(c, infp);
  82.     switch(c) {
  83.     case 0:
  84.     macbinary();
  85.     break;
  86.     default:
  87.     (void)fprintf(stderr, "Input is not MacBinary\n");
  88.     exit(1);
  89.     }
  90.     exit(0);
  91.     /* NOTREACHED */
  92. }
  93.  
  94. static void usage()
  95. {
  96.     (void)fprintf(stderr, "Usage: macsave [-%s]\n", options);
  97.     (void)fprintf(stderr, "Use \"macsave -H\" for help.\n");
  98. }
  99.  
  100.