home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / macutils.lzh / MACUTILS / COMM / frommac.c < prev    next >
C/C++ Source or Header  |  1995-09-18  |  4KB  |  168 lines

  1. #include <stdio.h>
  2. #include "comm.h"
  3. #include "../util/patchlevel.h"
  4. #include "../fileio/machdr.h"
  5. #include "globals.h"
  6. #include "../fileio/fileglob.h"
  7. #include "../fileio/wrfile.h"
  8.  
  9. #define LOCALOPT    "lmxyzoTVH"
  10.  
  11. extern void exit();
  12. extern void setup_tty();
  13. extern void reset_tty();
  14.  
  15. extern char info[];
  16.  
  17. static void usage();
  18.  
  19. static char options[128];
  20. static int multi_file = 0;
  21. static int listmode = 0;
  22.  
  23. int main(argc, argv)
  24. int argc;
  25. char **argv;
  26. {
  27.     extern int optind;
  28.     extern char *optarg;
  29.     int errflg;
  30.     int c;
  31.     char tname[64];
  32.     char fauth[5];
  33.     char ftype[5];
  34.  
  35.     set_wrfileopt(0);
  36.     (void)strcat(options, get_wrfileopt());
  37.     (void)strcat(options, LOCALOPT);
  38.     errflg = 0;
  39.  
  40.     while((c = getopt(argc, argv, options)) != EOF) {
  41.     if(!wrfileopt((char)c)) {
  42.         switch(c) {
  43.         case 'l':
  44.         listmode++;
  45.         break;
  46.         case 'm':
  47.         multi_file++;
  48.         break;
  49.         case 'x':
  50.         xfertype = XMODEM;
  51. #ifndef XM
  52.         (void)fprintf(stderr, "XMODEM not supported\n");
  53.         exit(1);
  54. #else /* XM */
  55.         break;
  56. #endif /* XM */
  57.         case 'y':
  58.         xfertype = YMODEM;
  59. #ifndef YM
  60.         (void)fprintf(stderr, "YMODEM not supported\n");
  61.         exit(1);
  62. #else /* YM */
  63.         break;
  64. #endif /* YM */
  65.         case 'z':
  66.         xfertype = ZMODEM;
  67. #ifndef ZM
  68.         (void)fprintf(stderr, "ZMODEM not supported\n");
  69.         exit(1);
  70. #else /* ZM */
  71.         break;
  72. #endif /* ZM */
  73.         case 'o':
  74.         pre_beta++;
  75.         break;
  76.         case 'T':
  77.         time_out++;
  78.         break;
  79.         case '?':
  80.         errflg++;
  81.         break;
  82.         case 'H':
  83.         give_wrfileopt();
  84.         (void)fprintf(stderr, "Frommac specific options:\n");
  85.         (void)fprintf(stderr, "-l:\tgive listing\n");
  86.         (void)fprintf(stderr, "-m:\tmulti-file transfer\n");
  87. #ifdef XM
  88.         (void)fprintf(stderr, "-x:\tuse XMODEM protocol\n");
  89. #endif /* XM */
  90. #ifdef YM
  91.         (void)fprintf(stderr, "-y:\tuse YMODEM protocol\n");
  92. #endif /* YM */
  93. #ifdef ZM
  94.         (void)fprintf(stderr, "-z:\tuse ZMODEM protocol\n");
  95. #endif /* ZM */
  96.         (void)fprintf(stderr, "-o:\tuse pre-beta protocol\n");
  97.         (void)fprintf(stderr, "-T:\tdetect time-outs\n");
  98.         (void)fprintf(stderr,
  99.             "-V:\tgive information about this version\n");
  100.         (void)fprintf(stderr, "-H:\tthis message\n");
  101.         (void)fprintf(stderr,
  102.           "Default is silent receival of a single file using XMODEM\n");
  103.         exit(0);
  104.         case 'V':
  105.         (void)fprintf(stderr, "Version %s, ", VERSION);
  106.         (void)fprintf(stderr, "patchlevel %d", PATCHLEVEL);
  107.         (void)fprintf(stderr, "%s.\n", get_mina());
  108.         (void)fprintf(stderr, "Supported protocols:\n");
  109. #ifdef XM
  110.         (void)fprintf(stderr, "\tXMODEM\n");
  111. #endif /* XM */
  112. #ifdef YM
  113.         (void)fprintf(stderr, "\tYMODEM\n");
  114. #endif /* YM */
  115. #ifdef ZM
  116.         (void)fprintf(stderr, "\tZMODEM\n");
  117. #endif /* ZM */
  118.         exit(0);
  119.         }
  120.     }
  121.     }
  122.     if(errflg) {
  123.     usage();
  124.     exit(1);
  125.     }
  126.  
  127.     do {
  128.     setup_tty();
  129.     switch(xfertype) {
  130.     case XMODEM:
  131. #ifdef XM
  132.         xm_from();
  133.         break;
  134. #endif /* XM */
  135. #ifdef YM
  136.     case YMODEM:
  137.         ym_from();
  138.         break;
  139. #endif /* YM */
  140. #ifdef ZM
  141.     case ZMODEM:
  142.         zm_from();
  143.         break;
  144. #endif /* ZM */
  145.     }
  146.     reset_tty();
  147.     if(listmode) {
  148.         transname(info + I_NAMEOFF + 1, tname, info[I_NAMEOFF]);
  149.         transname(info + I_AUTHOFF, fauth, 4);
  150.         transname(info + I_TYPEOFF, ftype, 4);
  151.         (void)fprintf(stderr,
  152.             "name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld",
  153.             tname, ftype, fauth,
  154.             get4(info + I_DLENOFF), get4(info + I_RLENOFF));
  155.         (void)fprintf(stderr, "\n");
  156.     }
  157.     } while(multi_file);
  158.     exit(0);
  159.     /* NOTREACHED */
  160. }
  161.  
  162. static void usage()
  163. {
  164.     (void)fprintf(stderr, "Usage: frommac [-%s]\n", options);
  165.     (void)fprintf(stderr, "Use \"frommac -H\" for help.\n");
  166. }
  167.  
  168.