home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / rzsz_3_36_3_src.lzh / sz.c < prev    next >
Text File  |  1996-01-09  |  42KB  |  1,932 lines

  1.  
  2. #define VERSION "3.36 04-23-94"
  3. #ifdef OS9
  4. #define PUBDIR "/dd/spool/uucppublic"
  5. #else /* !OS9 */
  6. #define PUBDIR "/usr/spool/uucppublic"
  7. #endif /* !OS9 */
  8.  
  9. /*
  10.  **************************************************************************
  11.  *
  12.  * sz.c By Chuck Forsberg,  Omen Technology INC
  13.  *    Copyright 1994 Omen Technology Inc All Rights Reserved
  14.  * 
  15.  *********************************************************************
  16.  *********************************************************************
  17.  * 
  18.  *
  19.  *    This version implements numerous enhancements including ZMODEM
  20.  *    Run Length Encoding and variable length headers.  These
  21.  *    features were not funded by the original Telenet development
  22.  *    contract.
  23.  * 
  24.  * 
  25.  * This software may be freely used for educational (didactic
  26.  * only) purposes.  "Didactic" means it is used as a study item
  27.  * in a course teaching the workings of computer protocols.
  28.  * 
  29.  * This software may also be freely used to support file transfer
  30.  * operations to or from duly licensed Omen Technology products.
  31.  * This includes DSZ, GSZ, ZCOMM, Professional-YAM and PowerCom.
  32.  * Institutions desiring to use rz/sz this way should add the
  33.  * following to the sz compile line:    -DCOMPL
  34.  * Programs based on stolen or public domain ZMODEM materials are
  35.  * not included.  Use with other commercial or shareware programs
  36.  * (Crosstalk, Procomm, etc.) REQUIRES REGISTRATION.
  37.  * 
  38.  *
  39.  *  Any programs which incorporate part or all of this code must be
  40.  *  provided in source form with this notice intact except by
  41.  *  prior written permission from Omen Technology Incorporated.
  42.  *  This includes compiled executables of this program.
  43.  *
  44.  *   The .doc files and the file "mailer.rz" must also be included.
  45.  * 
  46.  * Use of this software for commercial or administrative purposes
  47.  * except when exclusively limited to interfacing Omen Technology
  48.  * products requires license payment of $20.00 US per user
  49.  * (less in quantity, see mailer.rz).  Use of this code by
  50.  * inclusion, decompilation, reverse engineering or any other means
  51.  * constitutes agreement to these conditions and acceptance of
  52.  * liability to license the materials and payment of reasonable
  53.  * legal costs necessary to enforce this license agreement.
  54.  *
  55.  *
  56.  *  Omen Technology Inc
  57.  *  Post Office Box 4681
  58.  *  Portland OR 97208
  59.  *
  60.  *    This code is made available in the hope it will be useful,
  61.  *    BUT WITHOUT ANY WARRANTY OF ANY KIND OR LIABILITY FOR ANY
  62.  *    DAMAGES OF ANY KIND.
  63.  *
  64.  *  USG UNIX (3.0) ioctl conventions courtesy Jeff Martin
  65.  */
  66.  
  67. char *Copyrsz = "Copyright 1994 Omen Technology Inc All Rights Reserved";
  68.  
  69. char *substr();
  70.  
  71. #ifdef OS9
  72. #define LOGFILE "/dd/tmp/szlog"
  73. #else /* !OS9 */
  74. #define LOGFILE "/tmp/szlog"
  75. #endif /* !OS9 */
  76.  
  77. #define LOGFILE2 "szlog"
  78. #include <stdio.h>
  79. #include <signal.h>
  80. #include <ctype.h>
  81. #include <errno.h>
  82. extern int errno;
  83. #define STATIC
  84.  
  85. #ifdef OS9
  86. #include "os9.h"
  87. #include <direct.h>
  88. #include <modes.h>
  89. #include <setjmp.h>
  90. #include <sgstat.h>
  91. #include <strings.h>
  92. struct sgbuf stty;
  93. struct sgbuf sttyold;
  94. long outime();
  95. int getuid();
  96. #ifdef m6809
  97. pflinit();
  98. #else /* !m6809 */
  99. char *ltoc4();
  100. long c4tol();
  101. char *getenv();
  102. #endif /* !m6809 */
  103. #endif /* OS9 */
  104.  
  105. #ifndef OS9
  106. #define PATHLEN 256
  107. #define OK 0
  108. #define FALSE 0
  109. #ifdef TRUE
  110. #undef TRUE
  111. #endif /* TRUE */
  112. #define TRUE 1
  113. #define ERROR (-1)
  114. /* Ward Christensen / CP/M parameters - Don't change these! */
  115. #define ENQ 005
  116. #define CAN ('X'&037)
  117. #define XOFF ('s'&037)
  118. #define XON ('q'&037)
  119. #define SOH 1
  120. #define STX 2
  121. #define EOT 4
  122. #define ACK 6
  123. #define NAK 025
  124. #define CPMEOF 032
  125. #define WANTCRC 0103    /* send C not NAK to get crc not checksum */
  126. #define WANTG 0107    /* Send G not NAK to get nonstop batch xmsn */
  127. #define TIMEOUT (-2)
  128. #define RCDO (-3)
  129. #define GCOUNT (-4)
  130. #define RETRYMAX 10
  131. #define HOWMANY 2
  132. #endif /* !OS9 */
  133.  
  134. STATIC int Zmodem=0;        /* ZMODEM protocol requested by receiver */
  135. unsigned Baudrate = 9600;        /* Default, set by first mode() call */
  136. STATIC unsigned Effbaud = 9600;
  137. STATIC unsigned Txwindow;    /* Control the size of the transmitted window */
  138. STATIC unsigned Txwspac;    /* Spacing between zcrcq requests */
  139. STATIC unsigned Txwcnt;    /* Counter used to space ack requests */
  140. STATIC long Lrxpos;    /* Receiver's last reported offset */
  141. STATIC int errors;
  142. char endmsg[80] = {0};    /* Possible message to display on exit */
  143.  
  144. #ifdef OS9
  145. extern int did0;
  146. extern int Tty;
  147. extern FILE *Ttystream;
  148. extern int Verbose;
  149. extern char Nametty[32]; /* was defined as char array[32] in rbsb.c */
  150. long UPDC32();
  151. #ifdef m6809
  152. unsigned updcrc();
  153. #else /* !m6809 */
  154. unsigned long updcrc();
  155. #endif /* !m6809 */
  156. #else /* !OS9 */
  157. #include "rbsb.c"    /* most of the system dependent stuff here */
  158. #include "crctab.c"
  159. #endif /* !OS9 */
  160.  
  161. STATIC int Filesleft;
  162. STATIC long Totalleft;
  163.  
  164. /*
  165.  * Attention string to be executed by receiver to interrupt streaming data
  166.  *  when an error is detected.  A pause (0336) may be needed before the
  167.  *  ^C (03) or after it.
  168.  */
  169. #ifdef READCHECK
  170. STATIC char Myattn[] = { 0 };
  171. #else
  172. #ifdef USG
  173. STATIC char Myattn[] = { 03, 0336, 0 };
  174. #endif
  175. #endif
  176.  
  177. FILE *in;
  178.  
  179. STATIC int Canseek = 1;    /* 1: Can seek 0: only rewind -1: neither (pipe) */
  180.  
  181. #ifdef TXBSIZE
  182. #define TXBMASK (TXBSIZE-1)
  183. STATIC char Txb[TXBSIZE];        /* Circular buffer for file reads */
  184. STATIC char *txbuf = Txb;        /* Pointer to current file segment */
  185. #else
  186. STATIC char txbuf[1024];
  187. #endif
  188. STATIC long vpos = 0;        /* Number of bytes read from file */
  189.  
  190. STATIC char Lastrx;
  191. STATIC char Crcflg;
  192. STATIC int Modem2=0;        /* XMODEM Protocol - don't send pathnames */
  193. STATIC int Restricted=0;    /* restricted; no /.. or ../ in filenames */
  194. STATIC int Fullname=0;        /* transmit full pathname */
  195. STATIC int Unlinkafter=0;    /* Unlink file after it is sent */
  196. STATIC int Dottoslash=0;    /* Change foo.bar.baz to foo/bar/baz */
  197. STATIC int firstsec;
  198. STATIC int errcnt=0;        /* number of files unreadable */
  199. STATIC int blklen=128;        /* length of transmitted records */
  200. STATIC int Optiong;        /* Let it rip no wait for sector ACK's */
  201. STATIC int Eofseen;        /* EOF seen on input set by zfilbuf */
  202. STATIC int BEofseen;        /* EOF seen on input set by fooseek */
  203. STATIC int Totsecs;        /* total number of sectors this file */
  204. STATIC int Filcnt=0;        /* count of number of files opened */
  205. STATIC unsigned Rxbuflen=16384;    /* Receiver's max buffer length */
  206. STATIC long Tframlen = 0;    /* Override for tx frame length */
  207. STATIC int blkopt=0;        /* Override value for zmodem blklen */
  208. STATIC int Rxflags = 0;
  209. STATIC long bytcnt;
  210. STATIC int Wantfcs32 = TRUE;    /* want to send 32 bit FCS */
  211. STATIC char Lzconv;    /* Local ZMODEM file conversion request */
  212. STATIC char Lzmanag;    /* Local ZMODEM file management request */
  213. STATIC int Lskipnocor;
  214. STATIC char Lztrans;
  215. STATIC int Command;        /* Send a command, then exit. */
  216. STATIC char *Cmdstr;        /* Pointer to the command string */
  217. STATIC int Cmdack1;        /* Rx ACKs command, then do it */
  218. STATIC int Exitcode;
  219. STATIC int Test;        /* 1= Force receiver to send Attn, etc with qbf. */
  220.             /* 2= Character transparency test */
  221. STATIC char *qbf=
  222.  "The quick brown fox jumped over the lazy dog's back 1234567890\r\n";
  223. STATIC long Lastsync;    /* Last offset to which we got a ZRPOS */
  224. STATIC int Beenhereb4;        /* How many times we've been ZRPOS'd here */
  225. STATIC int Ksendstr;        /* 1= Send esc-?-3-4-l to remote kermit */
  226. STATIC char *ksendbuf = "\033[?34l";
  227.  
  228. /* STATIC jmp_buf tohere;         For the interrupt on RX timeout */
  229. STATIC jmp_buf intrjmp;    /* For the interrupt on RX CAN */
  230.  
  231.  
  232. /* called by signal interrupt or terminate to clean things up */
  233. void
  234. bibi(n)
  235. {
  236.     canit(); fflush(Ttystream); mode(0);
  237.     fprintf(stderr, "sz: caught signal %d; exiting\n", n);
  238. #ifdef OS9
  239.     if ((n == SIGQUIT) || (n == SIGINT))
  240. #else
  241.     if (n == SIGQUIT)
  242. #endif
  243.         abort();
  244.     if (n == 99)
  245.         fprintf(stderr, "mode(2) in rbsb.c not implemented!!\n");
  246. #ifdef OS9
  247.     if (Verbose < 3)
  248.         _ss_opt(fileno(stderr), &sttyold);
  249. #endif
  250.     exit(3);
  251. }
  252.  
  253. /* Called when ZMODEM gets an interrupt (^X) */
  254. void
  255. onintr(c)
  256. {
  257.     signal(SIGINT, SIG_IGN);
  258.     longjmp(intrjmp, -1);
  259. }
  260.  
  261. STATIC int Zctlesc;    /* Encode control characters */
  262. STATIC int Nozmodem = 0;    /* If invoked as "sb" */
  263. STATIC char *Progname = "sz";
  264. STATIC int Zrwindow = 1400;    /* RX window size (controls garbage count) */
  265.  
  266. /*
  267.  * Log an error
  268.  */
  269. /*VARARGS1*/
  270. void
  271. zperr(s,p,u)
  272. char *s, *p, *u;
  273. {
  274.     if (Verbose <= 0)
  275.         return;
  276.     fprintf(stderr, "Retry %d: ", errors);
  277.     fprintf(stderr, s, p, u);
  278.     fprintf(stderr, "\n");
  279. }
  280.  
  281. #ifdef OS9
  282. #include "zmodem.h"
  283. #define FTOFFSET 4
  284. extern char *frametypes[];
  285. extern char Rxhdr[];
  286. extern char Txhdr[];
  287. extern int Usevhdrs;
  288. int zgethdr();
  289. int zsdata();
  290. #else /* !OS9 */
  291. #include "zm.c"
  292. #include "zmr.c"
  293. #endif /* !OS9 */
  294.  
  295. char logfile[256];
  296.  
  297. main(argc, argv)
  298. char *argv[];
  299. {
  300.     register char *cp;
  301.     register npats;
  302.     char **patts;
  303.  
  304. #ifdef OS9
  305.     _gs_opt(fileno(stderr), &sttyold);
  306. #ifdef m6809
  307.     _strass(&stty, &sttyold, sizeof(struct sgbuf));
  308.     Restricted = getuid()? TRUE : FALSE;
  309. #else /* !m6809 */
  310.     stty = sttyold;
  311.     if ((cp = getenv("ZNULLS")) && *cp)
  312.         Znulls = atoi(cp);
  313.     if (getuid() && 
  314.         !(cp=getenv("SHELL")) && (substr(cp, "shell") || substr(cp, "ksh")))
  315.         Restricted=TRUE;
  316. #endif /* !m6809 */
  317. #else /* !OS9 */
  318.     if ((cp = getenv("ZNULLS")) && *cp)
  319.         Znulls = atoi(cp);
  320.     if ((cp=getenv("SHELL")) && (substr(cp, "rsh") || substr(cp, "rksh")))
  321.         Restricted=TRUE;
  322. #endif /* !OS9 */
  323.     inittty();
  324.     chkinvok(argv[0]);
  325.  
  326.     Rxtimeout = 600;
  327.     npats=0;
  328.     if (argc<2)
  329.         usage();
  330.     while (--argc) {
  331.         cp = *++argv;
  332.         if (*cp++ == '-' && *cp) {
  333.             while ( *cp) {
  334.                 if (isdigit(*cp)) {
  335.                     ++cp;  continue;
  336.                 }
  337.                 switch(*cp++) {
  338.                 case '\\':
  339.                      *cp = toupper(*cp);  continue;
  340.                 case '+':
  341.                     Lzmanag = ZMAPND; break;
  342.                 case 'a':
  343.                     if (Nozmodem || Modem2)
  344.                         usage();
  345.                     Lzconv = ZCNL;  break;
  346.                 case 'b':
  347.                     Lzconv = ZCBIN; break;
  348.                 case 'c':
  349.                     Lzmanag = ZMCHNG;  break;
  350.                 case 'd':
  351.                     ++Dottoslash;
  352.                     /* **** FALL THROUGH TO **** */
  353.                 case 'f':
  354.                     Fullname=TRUE; break;
  355.                         case 'g' :
  356.                     Ksendstr = TRUE; break;
  357.                 case 'e':
  358.                     Zctlesc = 1; break;
  359.                 case 'k':
  360.                     blklen=1024; break;
  361.                 case 'L':
  362.                     if (isdigit(*cp))
  363.  
  364.                         blkopt = atoi(cp);
  365.                     else {
  366.                         if (--argc < 1)
  367.                             usage();
  368.                         blkopt = atoi(*++argv);
  369.                     }
  370.                     if (blkopt<24 || blkopt>1024)
  371.                         usage();
  372.                     break;
  373.                 case 'l':
  374.                     if (isdigit(*cp))
  375.                         Tframlen = atol(cp);
  376.                     else {
  377.                         if (--argc < 1)
  378.                             usage();
  379.                         Tframlen = atol(*++argv);
  380.                     }
  381.                     if (Tframlen<32 || Tframlen>65535L)
  382.                         usage();
  383.                     break;
  384.                 case 'N':
  385.                     Lzmanag = ZMNEWL;  break;
  386.                 case 'n':
  387.                     Lzmanag = ZMNEW;  break;
  388.                 case 'o':
  389.                     Wantfcs32 = FALSE; break;
  390.                 case 'p':
  391.                     Lzmanag = ZMPROT;  break;
  392.                 case 'r':
  393.                     if (Lzconv == ZCRESUM)
  394.                         Lzmanag = (Lzmanag & ZMMASK) | ZMCRC;
  395.                     Lzconv = ZCRESUM; break;
  396.                 case 'T':
  397.                     chartest(1); chartest(2);
  398.                     mode(0);  exit(0);
  399.                 case 'u':
  400.                     ++Unlinkafter; break;
  401.                 case 'v':
  402.                     ++Verbose; break;
  403.                 case 'w':
  404.                     if (isdigit(*cp))
  405.                         Txwindow = atoi(cp);
  406.                     else {
  407.                         if (--argc < 1)
  408.                             usage();
  409.                         Txwindow = atoi(*++argv);
  410.                     }
  411.                     if (Txwindow < 256)
  412.                         Txwindow = 256;
  413.                     Txwindow = (Txwindow/64) * 64;
  414.                     Txwspac = Txwindow/4;
  415.                     if (blkopt > Txwspac
  416.                      || (!blkopt && Txwspac < 1024))
  417.                         blkopt = Txwspac;
  418.                     break;
  419.                 case 'Y':
  420.                     Lskipnocor = TRUE;
  421.                     /* **** FALLL THROUGH TO **** */
  422.                 case 'y':
  423.                     Lzmanag = ZMCLOB; break;
  424.                 case 'Z':
  425.                 case 'z':
  426.                     Lztrans = ZTRLE;  break;
  427.                 default:
  428.                     usage();
  429.                 }
  430.             }
  431.         }
  432.         else if (Command)
  433.         {
  434.             if (argc != 1)
  435.             {
  436.                 usage();
  437.             }
  438.             Cmdstr = *argv;
  439.         }
  440.         else if ( !npats && argc>0)
  441.         {
  442.             if (argv[0][0])
  443.             {
  444.                 npats=argc;
  445.                  patts=argv;
  446.             }
  447.         }
  448.     }
  449.     if (npats < 1 && !Command && !Test) 
  450.         usage();
  451. #ifdef OS9
  452.     if (Verbose > 2)
  453.     {
  454.         sprintf(logfile,"%s.%d", LOGFILE, getuid());
  455. #else
  456.     if (Verbose)
  457.     {
  458.         sprintf(logfile,"%s.%s", LOGFILE, getlogin());
  459. #endif
  460.         if (freopen(logfile, "a", stderr)==NULL)
  461.             if (freopen(LOGFILE2, "a", stderr)==NULL)
  462.             {
  463. #ifdef OS9
  464.                 fprintf(stderr,"Can't open log file!");
  465.                 exit(2);
  466.             }
  467. #else
  468.                 fprintf(Ttystream,"Can't open log file!");
  469.                 exit(2);
  470.             }
  471. #endif   /* exit(2)'s , } were moved to balance the braces for cntx -GH- */
  472.         setbuf(stderr, NULL);
  473.     }
  474. #ifdef OS9
  475.     else
  476.     {
  477.         stty.sg_pause = 0;
  478.         _ss_opt(fileno(stderr), &stty);
  479.     }
  480. #endif /* OS9 */
  481.     vfile("%s %s for %s tty=%.3s", Progname, VERSION, OS, Nametty);
  482.  
  483.     mode(3);
  484.  
  485.     if (signal(SIGINT, bibi) == SIG_IGN) {
  486.         signal(SIGINT, SIG_IGN); signal(SIGKILL, SIG_IGN);
  487.     } else {
  488.         signal(SIGINT, bibi); signal(SIGKILL, bibi);
  489.     }
  490. #ifdef SIGQUIT
  491.     signal(SIGQUIT, SIG_IGN);
  492. #endif
  493. #ifdef SIGTERM
  494.     signal(SIGTERM, bibi);
  495. #endif
  496.  
  497.     countem(npats, patts);
  498.  
  499.     if (!Modem2 && !Nozmodem) {
  500.         if (Ksendstr)
  501.             fprintf(Ttystream,ksendbuf);
  502. #ifdef OS9
  503.         fprintf(Ttystream,"rz\r\lrz\l\r");  fflush(Ttystream);
  504. #else
  505.         fprintf(Ttystream,"rz\r");  fflush(Ttystream);
  506. #endif
  507.         stohdr(0L);
  508.         if (Command)
  509.             Txhdr[ZF0] = ZCOMMAND;
  510.         zshhdr(4, ZRQINIT, Txhdr);
  511.     }
  512.     fflush(Ttystream);
  513.  
  514.  
  515.     if (Command) {
  516.         if (getzrxinit()) {
  517.             Exitcode=1; canit();
  518.         }
  519.         else if (zsendcmd(Cmdstr, 1+strlen(Cmdstr))) {
  520.             Exitcode=1; canit();
  521.         }
  522.     } else if (wcsend(npats, patts)==ERROR) {
  523.         Exitcode=1;
  524.         canit();
  525.     }
  526.     if (endmsg[0])
  527.     {
  528. #ifdef OS9
  529.         fprintf(stderr,"\r\l%s: %s\r\l", Progname, endmsg);
  530.         if (Verbose)
  531.             fprintf(stderr, "%s\r\l", endmsg);
  532. #else
  533.         fprintf(Ttystream,"\r\n%s: %s\r\n", Progname, endmsg);
  534.         if (Verbose)
  535.             fprintf(stderr, "%s\r\n", endmsg);
  536. #endif
  537.     }
  538. #ifdef OS9
  539.     fprintf(stderr,"\n\n%s %s finished.\r\l", Progname, VERSION);
  540.     fflush(stderr);
  541. #else
  542.     fprintf(Ttystream,"%s %s finished.\r\n", Progname, VERSION);
  543.     fflush(Ttystream);
  544. #endif
  545.     mode(0);
  546. #ifdef OS9
  547.     if (Verbose < 3) /* doing this to a file locks machine up GH */
  548.         _ss_opt(fileno(stderr), &sttyold);
  549. #endif
  550.     if(errcnt || Exitcode)
  551.         exit(1);
  552.  
  553. #ifndef REGISTERED
  554.     /* Removing or disabling this code without registering is theft */
  555.     if (!Usevhdrs)  {
  556. #ifdef OS9
  557.         fprintf(stderr,"\n\n\nPlease read the License Agreement in sz.doc\n");
  558.         fflush(stderr);
  559.         sleep(1);
  560. #else /* !OS9 */
  561.         fprintf(Ttystream,"\n\n\nPlease read the License Agreement in sz.doc\n");
  562.         fflush(Ttystream);
  563.         sleep(1);
  564. #endif /* !OS9 */
  565.     }
  566. #endif
  567.     exit(0);
  568.     /*NOTREACHED*/
  569. }
  570.  
  571. /* Say "bibi" to the receiver, try to do it cleanly */
  572. void
  573. saybibi()
  574. {
  575.     for (;;) {
  576.         stohdr(0L);        /* CAF Was zsbhdr - minor change */
  577.         zshhdr(4, ZFIN, Txhdr);    /*  to make debugging easier */
  578.         switch (zgethdr(Rxhdr)) {
  579.         case ZFIN:
  580.             sendline('O'); sendline('O'); flushmo();
  581.         case ZCAN:
  582.         case TIMEOUT:
  583.             return;
  584.         }
  585.     }
  586. }
  587.  
  588. wcsend(argc, argp)
  589. char *argp[];
  590. {
  591.     register n;
  592.  
  593.     Crcflg=FALSE;
  594.     firstsec=TRUE;
  595.     bytcnt = -1;
  596.     if (Nozmodem) {
  597.         fprintf(Ttystream,"Start your local YMODEM receive.     ");
  598.         fflush(Ttystream);
  599.     }
  600.     for (n=0; n<argc; ++n) {
  601.         Totsecs = 0;
  602.         if (wcs(argp[n])==ERROR)
  603.             return ERROR;
  604.     }
  605.     Totsecs = 0;
  606.     if (Filcnt==0) {    /* bitch if we couldn't open ANY files */
  607.         if (!Nozmodem && !Modem2) {
  608.             Command = TRUE;
  609.             Cmdstr = "echo \"sz: Can't open any requested files\"";
  610.             if (getnak()) {
  611.                 Exitcode=1; canit();
  612.             }
  613.             if (!Zmodem)
  614.                 canit();
  615.             else if (zsendcmd(Cmdstr, 1+strlen(Cmdstr))) {
  616.                 Exitcode=1; canit();
  617.             }
  618.             Exitcode = 1; return OK;
  619.         }
  620.         canit();
  621.         sprintf(endmsg, "Can't open any requested files");
  622.         return ERROR;
  623.     }
  624.     if (Zmodem)
  625.         saybibi();
  626.     else if ( !Modem2)
  627.         wctxpn("");
  628.     return OK;
  629. }
  630.  
  631. wcs(oname)
  632. char *oname;
  633. {
  634.     register c;
  635. #ifdef OS9
  636.     struct fildes f;
  637. #else
  638.     struct stat f;
  639. #endif
  640.     char name[PATHLEN];
  641.  
  642.     strcpy(name, oname);
  643.  
  644.     if (Restricted) {
  645.         /* restrict pathnames to current tree or uucppublic */
  646.         if ( substr(name, "../")
  647.          || (name[0]== '/' && strncmp(name, PUBDIR, strlen(PUBDIR))) ) {
  648.             canit();  sprintf(endmsg,"Security Violation");
  649.             return ERROR;
  650.         }
  651.     }
  652.  
  653.     in=fopen(oname, "r");
  654.  
  655.     if (in==NULL) {
  656.         ++errcnt;
  657.         return OK;    /* pass over it, there may be others */
  658.     }
  659.     BEofseen = Eofseen = 0;  vpos = 0;
  660.  
  661.     /* Check for directory */
  662. #ifdef OS9
  663.     _gs_gfd(fileno(in), &f, sizeof(struct fildes));
  664. #ifdef m6809
  665.     c = f.fd_attr & S_IFMT;
  666. #else /* !m6809 */
  667.     c = f.fd_att & S_IFMT;
  668. #endif /* !m6809 */
  669.     if (c == S_IFDIR)
  670. #else /* !OS9 */
  671.     fstat(fileno(in), &f);
  672. #ifdef POSIX
  673.     if (S_ISDIR(f.st_mode))
  674. #else
  675.     c = f.st_mode & S_IFMT;
  676.     if (c == S_IFDIR || c == S_IFBLK)
  677. #endif
  678. #endif /* !OS9 */
  679.     {
  680.         fclose(in);
  681.         return OK;
  682.     }
  683.  
  684.     ++Filcnt;
  685.     switch (wctxpn(name)) {
  686.     case ZSKIP:
  687.     case ZFERR:
  688.         return OK;
  689.     case OK:
  690.         break;
  691.     default:
  692.         return ERROR;
  693.     }
  694. #ifdef OS9
  695. #ifdef m6809
  696.     if (!Zmodem && wctx(f.fd_fsize))
  697. #else /* !m6809 */
  698.     if (!Zmodem && wctx(c4tol(f.fd_fsize)))
  699. #endif /* !m6809 */
  700. #else /* !OS9 */
  701.     if (!Zmodem && wctx(f.st_size))
  702. #endif /* !OS9 */
  703.         return ERROR;
  704.  
  705.     if (Unlinkafter)
  706.         unlink(oname);
  707.  
  708.     return 0;
  709. }
  710.  
  711. /*
  712.  * generate and transmit pathname block consisting of
  713.  *  pathname (null terminated),
  714.  *  file length, mode time and file mode in octal
  715.  *  as provided by the Unix fstat call.
  716.  *  N.B.: modifies the passed name, may extend it!
  717.  */
  718. wctxpn(name)
  719. char *name;
  720. {
  721.     register char *p, *q;
  722.     char name2[PATHLEN];
  723. #ifdef OS9
  724.     struct fildes f;
  725. #else
  726.     struct stat f;
  727. #endif
  728.  
  729.     if (Modem2) {
  730. #ifdef OS9
  731.         if (*name && _gs_gfd(fileno(in), &f, sizeof(f))!= -1) {
  732. #ifdef m6809
  733.  
  734.             fprintf(stderr, "Sending %s, %ld XMODEM blocks. ",
  735.               name, (127+f.fd_fsize)>>7);
  736. #else /* !m6809 */
  737.             fprintf(stderr, "Sending %s, %ld XMODEM blocks. ",
  738.               name, (127+c4tol(f.fd_fsize))>>7);
  739. #endif /* !m6809 */
  740.         }
  741. #else /* !OS9 */
  742.         if (*name && fstat(fileno(in), &f)!= -1) {
  743.             fprintf(stderr, "Sending %s, %ld XMODEM blocks. ",
  744.               name, (127+f.st_size)>>7);
  745.         }
  746. #endif /* !OS9 */
  747.         fprintf(Ttystream,"Start your local XMODEM receive.     ");
  748.         fflush(Ttystream);
  749.         return OK;
  750.     }
  751.     zperr("\n\nAwaiting pathname nak for %s", *name?name:"<END>");
  752.     if ( !Zmodem)
  753.         if (getnak())
  754.             return ERROR;
  755.  
  756. #ifdef OS9
  757.     if (*name && (_gs_gfd(fileno(in), &f, sizeof(struct fildes))!= -1) &&
  758.         Verbose && !Modem2) {
  759. #ifdef m6809
  760.     fprintf(stderr, " - Sending %ld bytes.\n", f.fd_fsize);
  761. #else /* !m6809 */
  762.     fprintf(stderr, " - Sending %ld bytes.\n", c4tol(f.fd_fsize));
  763. #endif /* !m6809 */
  764.     }
  765. #endif /* OS9 */
  766.  
  767.      q = (char *) 0;
  768.     if (Dottoslash)
  769.     {        /* change . to . */
  770.         for (p=name; *p; ++p)
  771.         {
  772.             if (*p == '/')
  773.                 q = p;
  774.             else if (*p == '.')
  775.                 *(q=p) = '/';
  776.         }
  777.         if (q && strlen(++q) > 8) {    /* If name>8 chars */
  778.             q += 8;            /*   make it .ext */
  779.             strcpy(name2, q);    /* save excess of name */
  780.             *q = '.';
  781.             strcpy(++q, name2);    /* add it back */
  782.         }
  783.     }
  784.  
  785.     for (p=name, q=txbuf ; *p; )
  786.         if ((*q++ = *p++) == '/' && !Fullname)
  787.             q = txbuf;
  788.     *q++ = 0;
  789.     p=q;
  790.     while (q < (txbuf + 1024))
  791.         *q++ = 0;
  792.     if (*name) {
  793. #ifdef OS9
  794.         if (_gs_gfd(fileno(in), &f, sizeof(struct fildes)) != -1)
  795. #ifdef m6809
  796.             sprintf(p, "%ld %lo %o 0 %d %ld\n", f.fd_fsize, outime(f.fd_date),
  797.               o2uattr(f.fd_attr), Filesleft, Totalleft);
  798.         Totalleft -= f.fd_fsize;
  799. #else /* !m6809 */
  800.             sprintf(p, "%lu %lo %o 0 %d %ld\n", c4tol(f.fd_fsize), outime(f.fd_date),
  801.               o2uattr(f.fd_att), Filesleft, Totalleft);
  802.         Totalleft -= c4tol(f.fd_fsize);
  803. #endif /* !m6809 */
  804. #else /* !OS9 */
  805.         if (fstat(fileno(in), &f)!= -1)
  806.             sprintf(p, "%lu %lo %o 0 %d %ld", f.st_size, f.st_mtime,
  807.               f.st_mode, Filesleft, Totalleft);
  808.         Totalleft -= f.st_size;
  809. #endif /* !OS9 */
  810.     }
  811.  
  812.     if (--Filesleft <= 0)
  813.         Filesleft = Totalleft = 0;
  814.     if (Totalleft < 0)
  815.         Totalleft = 0;
  816.  
  817.     /* force 1k blocks if name won't fit in 128 byte block */
  818.     if (txbuf[125])
  819.         blklen=1024;
  820.     else {        /* A little goodie for IMP/KMD */
  821. #ifdef OS9
  822. #ifdef m6809
  823.         txbuf[127] = (f.fd_fsize + 127) >>7;
  824.         txbuf[126] = (f.fd_fsize + 127) >>15;
  825. #else /* !m6809 */
  826.         txbuf[127] = (c4tol(f.fd_fsize) + 127) >>7;
  827.         txbuf[126] = (c4tol(f.fd_fsize) + 127) >>15;
  828. #endif /* !m6809 */
  829. #else /* !OS9 */
  830.         txbuf[127] = (f.st_size + 127) >>7;
  831.         txbuf[126] = (f.st_size + 127) >>15;
  832. #endif /* !OS9 */
  833.     }
  834.     if (Zmodem)
  835.         return zsendfile(txbuf, 1+strlen(p)+(p-txbuf));
  836.     if (wcputsec(txbuf, 0, 128)==ERROR)
  837.         return ERROR;
  838.     return OK;
  839. }
  840.  
  841. getnak()
  842. {
  843.     register firstch;
  844.  
  845.     Lastrx = 0;
  846.     for (;;) {
  847.         switch (firstch = readline(800)) {
  848.         case ZPAD:
  849.             if (getzrxinit())
  850.                 return ERROR;
  851.             return FALSE;
  852.         case TIMEOUT:
  853.             sprintf(endmsg, "Timeout waiting for ZRINIT");
  854.             return TRUE;
  855.         case WANTG:
  856. #ifdef MODE2OK
  857.             mode(2);    /* Set cbreak, XON/XOFF, etc. */
  858. #endif
  859.             Optiong = TRUE;
  860.             blklen=1024;
  861.         case WANTCRC:
  862.             Crcflg = TRUE;
  863.         case NAK:
  864.             return FALSE;
  865.         case CAN:
  866.             if ((firstch = readline(20)) == CAN && Lastrx == CAN) {
  867.                 sprintf(endmsg, "Got CAN waiting to send file");
  868.                 return TRUE;
  869.             }
  870.         default:
  871.             break;
  872.         }
  873.         Lastrx = firstch;
  874.     }
  875. }
  876.  
  877.  
  878. wctx(flen)
  879. long flen;
  880. {
  881.     register int thisblklen;
  882.     register int sectnum, attempts, firstch;
  883.     long charssent;
  884.  
  885.     charssent = 0;  firstsec=TRUE;  thisblklen = blklen;
  886.     vfile("wctx:file length=%ld", flen);
  887.  
  888.     while ((firstch=readline(Rxtimeout))!=NAK && firstch != WANTCRC
  889.       && firstch != WANTG && firstch!=TIMEOUT && firstch!=CAN)
  890.         ;
  891.     if (firstch==CAN) {
  892.         zperr("Receiver CANcelled");
  893.         return ERROR;
  894.     }
  895.     if (firstch==WANTCRC)
  896.         Crcflg=TRUE;
  897.     if (firstch==WANTG)
  898.         Crcflg=TRUE;
  899.     sectnum=0;
  900.     for (;;) {
  901.         if (flen <= (charssent + 896L))
  902.             thisblklen = 128;
  903.         if ( !filbuf(txbuf, thisblklen))
  904.             break;
  905.         if (wcputsec(txbuf, ++sectnum, thisblklen)==ERROR)
  906.             return ERROR;
  907.         charssent += thisblklen;
  908.     }
  909.     fclose(in);
  910.     attempts=0;
  911.     do {
  912.         purgeline();
  913.         sendline(EOT);
  914.         flushmo();
  915.         ++attempts;
  916.     }
  917.         while ((firstch=(readline(Rxtimeout)) != ACK) && attempts < RETRYMAX);
  918.     if (attempts == RETRYMAX) {
  919.         zperr("No ACK on EOT");
  920.         return ERROR;
  921.     }
  922.     else
  923.         return OK;
  924. }
  925.  
  926. wcputsec(buf, sectnum, cseclen)
  927. char *buf;
  928. int sectnum;
  929. int cseclen;    /* data length of this sector to send */
  930. {
  931.     register checksum, wcj;
  932.     register char *cp;
  933.     unsigned oldcrc;
  934.     int firstch;
  935.     int attempts;
  936.  
  937.     firstch=0;    /* part of logic to detect CAN CAN */
  938.  
  939.     if (Verbose>2)
  940.         fprintf(stderr, "Sector %3d %2dk\n", Totsecs, Totsecs/8 );
  941.     else if (Verbose>1)
  942.         fprintf(stderr, "\rSector %3d %2dk ", Totsecs, Totsecs/8 );
  943.     for (attempts=0; attempts <= RETRYMAX; attempts++) {
  944.         Lastrx= firstch;
  945.         sendline(cseclen==1024?STX:SOH);
  946.         sendline(sectnum);
  947.         sendline(-sectnum -1);
  948.         oldcrc=checksum=0;
  949.         for (wcj=cseclen,cp=buf; --wcj>=0; ) {
  950.             sendline(*cp);
  951.             oldcrc=updcrc((0377& *cp), oldcrc);
  952.             checksum += *cp++;
  953.         }
  954.         if (Crcflg) {
  955.             oldcrc=updcrc(0,updcrc(0,oldcrc));
  956.             sendline((int)oldcrc>>8);
  957.             sendline((int)oldcrc);
  958.         }
  959.         else
  960.             sendline(checksum);
  961.         flushmo();
  962.  
  963.         if (Optiong) {
  964.             firstsec = FALSE; return OK;
  965.         }
  966.         firstch = readline(Rxtimeout);
  967. gotnak:
  968.         switch (firstch) {
  969.         case CAN:
  970.             if(Lastrx == CAN) {
  971. cancan:
  972.                 zperr("Cancelled");  return ERROR;
  973.             }
  974.             break;
  975.         case TIMEOUT:
  976.             zperr("Timeout on sector ACK"); continue;
  977.         case WANTCRC:
  978.             if (firstsec)
  979.                 Crcflg = TRUE;
  980.         case NAK:
  981.             zperr("NAK on sector"); continue;
  982.         case ACK: 
  983.             firstsec=FALSE;
  984.             Totsecs += (cseclen>>7);
  985.             return OK;
  986.         case ERROR:
  987.             zperr("Got burst for sector ACK"); break;
  988.         default:
  989.             zperr("Got %02x for sector ACK", firstch); break;
  990.         }
  991.         for (;;) {
  992.             Lastrx = firstch;
  993.             if ((firstch = readline(Rxtimeout)) == TIMEOUT)
  994.                 break;
  995.             if (firstch == NAK || firstch == WANTCRC)
  996.                 goto gotnak;
  997.             if (firstch == CAN && Lastrx == CAN)
  998.                 goto cancan;
  999.         }
  1000.     }
  1001.     zperr("Retry Count Exceeded");
  1002.     return ERROR;
  1003. }
  1004.  
  1005. /* fill buf with count chars padding with ^Z for CPM */
  1006. filbuf(buf, count)
  1007. register char *buf;
  1008. {
  1009.     register m;
  1010.  
  1011.     m = read(fileno(in), buf, count);
  1012.     if (m <= 0)
  1013.         return 0;
  1014.     while (m < count)
  1015.         buf[m++] = 032;
  1016.     return count;
  1017. }
  1018.  
  1019. /* Fill buffer with blklen chars */
  1020. zfilbuf()
  1021. {
  1022.     int n;
  1023.  
  1024. #ifdef TXBSIZE
  1025. #ifdef m6809
  1026.     vfile("zfilbuf: bytcnt =%ld vpos=%ld blklen=%d", bytcnt, vpos, blklen);
  1027. #else /* !m6809 */
  1028.     vfile("zfilbuf: bytcnt =%lu vpos=%lu blklen=%d", bytcnt, vpos, blklen);
  1029. #endif /* !m6809 */
  1030.     /* We assume request is within buffer, or just beyond */
  1031.     txbuf = Txb + (bytcnt & TXBMASK);
  1032.     if (vpos <= bytcnt) {
  1033.         n = fread(txbuf, 1, blklen, in);
  1034.  
  1035.         vpos += n;
  1036.         if (n < blklen)
  1037.             Eofseen = 1;
  1038. #ifdef m6809
  1039.         vfile("zfilbuf: n=%d vpos=%ld Eofseen=%d", n, vpos, Eofseen);
  1040. #else /* !m6809 */
  1041.         vfile("zfilbuf: n=%d vpos=%lu Eofseen=%d", n, vpos, Eofseen);
  1042. #endif /* !m6809 */
  1043.         return n;
  1044.     }
  1045.     if (vpos >= (bytcnt+blklen))
  1046.         return blklen;
  1047.     /* May be a short block if crash recovery etc. */
  1048.     Eofseen = BEofseen;
  1049.     return (vpos - bytcnt);
  1050. #else
  1051.     n = fread(txbuf, 1, blklen, in);
  1052.     if (n < blklen) {
  1053.         Eofseen = 1;
  1054. #ifdef m6809
  1055.         vfile("zfilbuf: n=%d vpos=%ld Eofseen=%d", n, vpos, Eofseen);
  1056. #else /* !m6809 */
  1057.         vfile("zfilbuf: n=%d vpos=%lu Eofseen=%d", n, vpos, Eofseen);
  1058. #endif /* !m6809 */
  1059.     }
  1060.     return n;
  1061. #endif
  1062. }
  1063.  
  1064. #ifdef TXBSIZE
  1065. /* Replacement for brain damaged fseek function.  Returns 0==success */
  1066. fooseek(fptr, pos, whence)
  1067. FILE *fptr;
  1068. long pos;
  1069. {
  1070. #ifdef m6809
  1071.     int m,n;
  1072. #else
  1073.     long m, n;
  1074. #endif
  1075.  
  1076. #ifdef m6809
  1077.     vfile("fooseek: pos =%ld vpos=%ld Canseek=%d", pos, vpos, Canseek);
  1078. #else /* !m6809 */
  1079.     vfile("fooseek: pos =%lu vpos=%lu Canseek=%d", pos, vpos, Canseek);
  1080. #endif /* !m6809 */
  1081.     /* Seek offset < current buffer */
  1082.     if (pos < (vpos -TXBSIZE +1024)) {
  1083.         BEofseen = 0;
  1084.         if (Canseek > 0) {
  1085.             vpos = pos & ~TXBMASK;
  1086.             if (vpos >= pos)
  1087.                 vpos -= TXBSIZE;
  1088.             if (fseek(fptr, vpos, 0))
  1089.                 return 1;
  1090.         }
  1091.         else if (Canseek == 0) {
  1092.             if (fseek(fptr, vpos = 0L, 0))
  1093.                 return 1;
  1094.         } else
  1095.             return 1;
  1096.         while (vpos < pos) {
  1097.             n = fread(Txb, 1, TXBSIZE, fptr);
  1098.             vpos += n;
  1099.             vfile("n=%d vpos=%ld", n, vpos);
  1100.             if (n < TXBSIZE) {
  1101.                 BEofseen = 1;
  1102.                 break;
  1103.             }
  1104.         }
  1105.         vfile("vpos=%ld", vpos);
  1106.         return 0;
  1107.     }
  1108.     /* Seek offset > current buffer (Crash Recovery, etc.) */
  1109.     if (pos > vpos) {
  1110.         if (Canseek)
  1111.             if (fseek(fptr, vpos = (pos & ~TXBMASK), 0))
  1112.                 return 1;
  1113.         while (vpos <= pos) {
  1114.             txbuf = Txb + (vpos & TXBMASK);
  1115.             m = TXBSIZE - (vpos & TXBMASK);
  1116. #ifdef m6809
  1117.             vfile("m=%d vpos=%ld", m,vpos);
  1118. #else
  1119.             vfile("m=%ld vpos=%ld", m,vpos);
  1120. #endif
  1121.             n = fread(txbuf, 1, m, fptr);
  1122. #ifdef m6809
  1123.             vfile("n=%d vpos=%ld", n,vpos);
  1124. #else
  1125.             vfile("n=%ld vpos=%ld", n,vpos);
  1126. #endif
  1127.             vpos += n;
  1128. #ifdef m6809
  1129.             vfile("bo=%d m=%d vpos=%ld", txbuf-Txb,m,vpos);
  1130. #else
  1131.             vfile("bo=%d m=%ld vpos=%ld", txbuf-Txb,m,vpos);
  1132. #endif
  1133.             if (n < m) {
  1134.                 BEofseen = 1;
  1135.                 break;
  1136.             }
  1137.         }
  1138.         return 0;
  1139.     }
  1140.     /* Seek offset is within current buffer */
  1141.     vfile("within buffer: vpos=%ld", vpos);
  1142.     return 0;
  1143. }
  1144. #define fseek fooseek
  1145. #endif
  1146.  
  1147.  
  1148. /*
  1149.  * substr(string, token) searches for token in string s
  1150.  * returns pointer to token within string if found, NULL otherwise
  1151.  */
  1152. char *
  1153. substr(s, t)
  1154. register char *s,*t;
  1155. {
  1156.     register char *ss,*tt;
  1157.     /* search for first char of token */
  1158.     for (ss=s; *s; s++)
  1159.         if (*s == *t)
  1160.             /* compare token with substring */
  1161.             for (ss=s,tt=t; ;) {
  1162.                 if (*tt == 0)
  1163.                     return s;
  1164.                 if (*ss++ != *tt++)
  1165.                     break;
  1166.             }
  1167.     return NULL;
  1168. }
  1169.  
  1170. char *usinfo[] = {
  1171.     "Send Files and Commands with ZMODEM/YMODEM/XMODEM Protocol\n",
  1172.     "Usage:    sz [-+abcdefgklLnNuvwyYZ] [-] file ...",
  1173. #ifdef m6809
  1174.     "       zcommand [-egv] COMMAND",
  1175.     "       zcommandi [-egv] COMMAND",
  1176.     "       sb [-adfkuv] [-] file ...",
  1177.     "       sx [-akuv] [-] file",
  1178. #else /* !m6809 */
  1179.     "\tzcommand [-egv] COMMAND",
  1180.     "\tzcommandi [-egv] COMMAND",
  1181.     "\tsb [-adfkuv] [-] file ...",
  1182.     "\tsx [-akuv] [-] file",
  1183. #endif
  1184.     ""
  1185. };
  1186.  
  1187. usage()
  1188. {
  1189.     char **pp;
  1190.  
  1191.     fprintf(stderr, "\n%s %s for %s by Chuck Forsberg, Omen Technology INC\n",
  1192.      Progname, VERSION, OS);
  1193. #ifdef m6809
  1194.     fprintf(stderr, "                \042The High Reliability Software\042\n");
  1195. #else
  1196.     fprintf(stderr, "\t\t\042The High Reliability Software\042\n");
  1197. #endif
  1198.     for (pp=usinfo; **pp; ++pp)
  1199.         fprintf(stderr, "%s\n", *pp);
  1200.     fprintf(stderr,"\nCopyright (c) 1994 Omen Technology INC All Rights Reserved\n");
  1201.     fprintf(stderr,
  1202.      "See sz.doc for option descriptions and licensing information.\n\n");
  1203.     fprintf(stderr,
  1204.     "This program is designed to talk to terminal programs,\nnot to be called by one.\n");
  1205.     fprintf(stderr,
  1206.     "\nTechnical support hotline: 900-737-7836 (1-900-737-RTFM) $4.69/min.\n\n");
  1207.     exit(3);
  1208. }
  1209.  
  1210. /*
  1211.  * Get the receiver's init parameters
  1212.  */
  1213. getzrxinit()
  1214. {
  1215.     register n;
  1216. #ifdef OS9
  1217.     struct fildes f;
  1218. #else
  1219.     struct stat f;
  1220. #endif
  1221.  
  1222.     for (n=10; --n>=0; ) {
  1223.         
  1224.         switch (zgethdr(Rxhdr)) {
  1225.         case ZCHALLENGE:    /* Echo receiver's challenge numbr */
  1226.             stohdr(Rxpos);
  1227.             zshhdr(4, ZACK, Txhdr);
  1228.             continue;
  1229.         case ZCOMMAND:        /* They didn't see out ZRQINIT */
  1230.             stohdr(0L);
  1231.             zshhdr(4, ZRQINIT, Txhdr);
  1232.             continue;
  1233.         case ZRINIT:
  1234.             Rxflags = 0377 & Rxhdr[ZF0];
  1235. #ifdef COMPL
  1236.             Usevhdrs = 1;
  1237. #else
  1238.             Usevhdrs = Rxhdr[ZF1] & CANVHDR;
  1239. #endif
  1240.             Txfcs32 = (Wantfcs32 && (Rxflags & CANFC32));
  1241.             Zctlesc |= Rxflags & TESCCTL;
  1242.             Rxbuflen = (0377 & Rxhdr[ZP0])+((0377 & Rxhdr[ZP1])<<8);
  1243.             if ( !(Rxflags & CANFDX))
  1244.                 Txwindow = 0;
  1245.             vfile("Rxbuflen=%d Tframlen=%ld", Rxbuflen, Tframlen);
  1246.             signal(SIGINT, SIG_IGN);
  1247. #ifdef MODE2OK
  1248.             mode(2);    /* Set cbreak, XON/XOFF, etc. */
  1249. #endif
  1250.  
  1251. #ifndef READCHECK
  1252. #ifndef USG
  1253.             /* Use 1024 byte frames if no sample/interrupt */
  1254.             if (Rxbuflen < 32 || Rxbuflen > 1024) {
  1255.                 Rxbuflen = 1024;
  1256.                 vfile("Rxbuflen=%d", Rxbuflen);
  1257.             }
  1258. #endif
  1259. #endif
  1260.  
  1261.             /* Override to force shorter frame length */
  1262.             if (Rxbuflen && (Rxbuflen>Tframlen) && (Tframlen>=32))
  1263.                 Rxbuflen = Tframlen;
  1264.             if ( !Rxbuflen && (Tframlen>=32) && (Tframlen<=1024))
  1265.                 Rxbuflen = Tframlen;
  1266.             vfile("Rxbuflen=%d", Rxbuflen);
  1267.  
  1268.  
  1269.             /*
  1270.              * If input is not a regular file, force ACK's to
  1271.              *  prevent running beyond the buffer limits
  1272.              */
  1273. #ifndef OS9
  1274.             if ( !Command) {
  1275.                 fstat(fileno(in), &f);
  1276.                 if (
  1277. #ifdef POSIX
  1278.                     !S_ISREG(f.st_mode)
  1279. #else
  1280.                     (f.st_mode & S_IFMT) != S_IFREG
  1281. #endif
  1282.                     ) {
  1283.                     Canseek = -1;
  1284. #ifdef TXBSIZE
  1285.                     Txwindow = TXBSIZE - 1024;
  1286.                     Txwspac = TXBSIZE/4;
  1287. #else
  1288.                     return ERROR;
  1289. #endif
  1290.                 }
  1291.             }
  1292. #endif /* !OS9 */
  1293.  
  1294.             /* Set initial subpacket length */
  1295.             if (blklen < 1024) {    /* Command line override? */
  1296.                 if (Effbaud > 300)
  1297.                     blklen = 256;
  1298.                 if (Effbaud > 1200)
  1299.                     blklen = 512;
  1300.                 if (Effbaud > 2400)
  1301.                     blklen = 1024;
  1302.             }
  1303.             if (Rxbuflen && blklen>Rxbuflen)
  1304.                 blklen = Rxbuflen;
  1305.             if (blkopt && blklen > blkopt)
  1306.                 blklen = blkopt;
  1307.             vfile("Rxbuflen=%d blklen=%d", Rxbuflen, blklen);
  1308.             vfile("Txwindow = %u Txwspac = %d", Txwindow, Txwspac);
  1309.  
  1310.  
  1311.             if (Lztrans == ZTRLE && (Rxflags & CANRLE))
  1312.                 Txfcs32 = 2;
  1313.             else
  1314.                 Lztrans = 0;
  1315.  
  1316.             return (sendzsinit());
  1317.         case ZCAN:
  1318.         case TIMEOUT:
  1319.             return ERROR;
  1320.         case ZRQINIT:
  1321.             if (Rxhdr[ZF0] == ZCOMMAND)
  1322.                 continue;
  1323.         default:
  1324.             zshhdr(4, ZNAK, Txhdr);
  1325.             continue;
  1326.         }
  1327.     }
  1328.     return ERROR;
  1329. }
  1330.  
  1331. /* Send send-init information */
  1332. sendzsinit()
  1333. {
  1334.     register c;
  1335.  
  1336.     if (Myattn[0] == '\0' && (!Zctlesc || (Rxflags & TESCCTL)))
  1337.         return OK;
  1338.     errors = 0;
  1339.     for (;;) {
  1340.         stohdr(0L);
  1341. #ifdef ALTCANOFF
  1342.         Txhdr[ALTCOFF] = ALTCANOFF;
  1343. #endif
  1344.         if (Zctlesc) {
  1345.             Txhdr[ZF0] |= TESCCTL; zshhdr(4, ZSINIT, Txhdr);
  1346.         }
  1347.         else
  1348.             zsbhdr(4, ZSINIT, Txhdr);
  1349.         zsdata(Myattn, ZATTNLEN, ZCRCW);
  1350.         c = zgethdr(Rxhdr);
  1351.         switch (c) {
  1352.         case ZCAN:
  1353.             return ERROR;
  1354.         case ZACK:
  1355.             return OK;
  1356.         default:
  1357.             if (++errors > 19)
  1358.                 return ERROR;
  1359.             continue;
  1360.         }
  1361.     }
  1362. }
  1363.  
  1364. /* Send file name and related info */
  1365. zsendfile(buf, blen)
  1366. char *buf;
  1367. {
  1368.     register c;
  1369. #ifdef m6809
  1370.     long crc;
  1371. #else
  1372.     register unsigned long crc;
  1373. #endif
  1374.     long lastcrcrq = -1;
  1375.  
  1376.     for (errors=0; ++errors<11;) {
  1377.         Txhdr[ZF0] = Lzconv;    /* file conversion request */
  1378.         Txhdr[ZF1] = Lzmanag;    /* file management request */
  1379.         if (Lskipnocor)
  1380.             Txhdr[ZF1] |= ZMSKNOLOC;
  1381.         Txhdr[ZF2] = Lztrans;    /* file transport request */
  1382.         Txhdr[ZF3] = 0;
  1383.         zsbhdr(4, ZFILE, Txhdr);
  1384.         zsdata(buf, blen, ZCRCW);
  1385. again:
  1386.         c = zgethdr(Rxhdr);
  1387.         switch (c) {
  1388.         case ZRINIT:
  1389.             while ((c = readline(50)) > 0)
  1390.                 if (c == ZPAD) {
  1391.                     goto again;
  1392.                 }
  1393.             continue;
  1394.         case ZCAN:
  1395.         case TIMEOUT:
  1396.         case ZABORT:
  1397.         case ZFIN:
  1398.             sprintf(endmsg, "Got %s on pathname", frametypes[c+FTOFFSET]);
  1399.             return ERROR;
  1400.         default:
  1401.             sprintf(endmsg, "Got %d frame type on pathname", c);
  1402.             continue;
  1403.         case ERROR:
  1404.         case ZNAK:
  1405.             continue;
  1406.         case ZCRC:
  1407.             if (Rxpos != lastcrcrq) {
  1408.                 lastcrcrq = Rxpos;
  1409.                 crc = 0xFFFFFFFFL;
  1410.                 if (Canseek >= 0) {
  1411.                     fseek(in, 0L, 0);
  1412.                     while (((c = getc(in)) != EOF) && --lastcrcrq)
  1413.                         crc = UPDC32(c, crc);
  1414.                     crc = ~crc;
  1415.                     clearerr(in);    /* Clear possible EOF */
  1416.                     lastcrcrq = Rxpos;
  1417.                 }
  1418.             }
  1419.             stohdr(crc);
  1420.             zsbhdr(4, ZCRC, Txhdr);
  1421.             goto again;
  1422.         case ZFERR:
  1423.         case ZSKIP:
  1424.             sprintf(endmsg, "File skipped by receiver request");
  1425.             fclose(in); return c;
  1426.         case ZRPOS:
  1427.             /*
  1428.              * Suppress zcrcw request otherwise triggered by
  1429.              * lastyunc==bytcnt
  1430.              */
  1431.             if (fseek(in, Rxpos, 0))
  1432.                 return ERROR;
  1433.             Lastsync = (bytcnt = Txpos = Lrxpos = Rxpos) -1;
  1434.             return zsendfdata();
  1435.         }
  1436.     }
  1437.     fclose(in); return ERROR;
  1438. }
  1439.  
  1440. /* Send the data in the file */
  1441. zsendfdata()
  1442. {
  1443. #ifdef m6809
  1444.     int
  1445. #else
  1446.     register
  1447. #endif
  1448.          c, e, n;
  1449. #ifdef m6809
  1450.     int
  1451. #else
  1452.     register
  1453. #endif
  1454.          newcnt;
  1455. #ifdef m6809
  1456.     long
  1457. #else
  1458.     register long
  1459. #endif
  1460.          tcount = 0;
  1461.     int junkcount;        /* Counts garbage chars received by TX */
  1462.     static int tleft = 6;    /* Counter for test mode */
  1463.  
  1464.     junkcount = 0;
  1465.     Beenhereb4 = FALSE; /* clear the error counter */
  1466. somemore:
  1467.     if (setjmp(intrjmp)) {
  1468. waitack:
  1469.         junkcount = 0;
  1470.         c = getinsync(0);
  1471. gotack:
  1472.         switch (c) {
  1473.         default:
  1474.         case ZCAN:
  1475.             fclose(in);
  1476.             return ERROR;
  1477.         case ZRINIT:
  1478.             fclose(in);
  1479.             return ZSKIP;
  1480.         case ZSKIP:
  1481.             fclose(in);
  1482.             return c;
  1483.         case ZACK:
  1484.         case ZRPOS:
  1485.             break;
  1486.         }
  1487. #ifdef READCHECK
  1488.         /*
  1489.          * If the reverse channel can be tested for data,
  1490.          *  this logic may be used to detect error packets
  1491.          *  sent by the receiver, in place of setjmp/longjmp
  1492.          *  rdchk(Tty) returns non 0 if a character is available
  1493.          */
  1494.         while (rdchk(Tty)) {
  1495. #ifdef EATSIT
  1496.             switch (checked)
  1497. #else
  1498.             switch (readline(1))
  1499. #endif
  1500.             {
  1501.             case CAN:
  1502.             case ZPAD:
  1503.                 c = getinsync(1);
  1504.                 goto gotack;
  1505.             case XOFF:        /* Wait a while for an XON */
  1506.                 readline(100);
  1507.             }
  1508.         }
  1509. #endif /* READCHECK */
  1510.     }
  1511.  
  1512.     signal(SIGINT, onintr);
  1513.     newcnt = Rxbuflen;
  1514.     Txwcnt = 0;
  1515.     stohdr(Txpos);
  1516.     zsbhdr(4, ZDATA, Txhdr);
  1517.  
  1518.     /*
  1519.      * Special testing mode.  This should force receiver to Attn,ZRPOS
  1520.      *  many times.  Each time the signal should be caught, causing the
  1521.      *  file to be started over from the beginning.
  1522.      */
  1523.     if (Test) {
  1524.         if ( --tleft)
  1525.             while (tcount < 20000) {
  1526.                 fprintf(Ttystream,qbf); fflush(Ttystream);
  1527.                 tcount += strlen(qbf);
  1528. #ifdef READCHECK
  1529.                 while (rdchk(Tty)) {
  1530. #ifdef EATSIT
  1531.                     switch (checked)
  1532. #else
  1533.                     switch (readline(1))
  1534. #endif
  1535.                     {
  1536.                     case CAN:
  1537.                     case ZPAD:
  1538.                         goto waitack;
  1539.                     case XOFF:    /* Wait for XON */
  1540.                         readline(100);
  1541.                     }
  1542.                 }
  1543. #endif /* READCHECK */
  1544.             }
  1545.         signal(SIGINT, SIG_IGN); canit();
  1546.         sleep(3); purgeline(); mode(0);
  1547. #ifdef OS9
  1548.         fprintf(stderr,"\nsz: Tcount = %ld\n", tcount);
  1549.         if (tleft) {
  1550.             fprintf(stderr,"ERROR: Interrupts Not Caught\n");
  1551.             if(Verbose < 3)
  1552.                 _ss_opt(fileno(stderr), &sttyold);
  1553. #else
  1554.         fprintf(Ttystream,"\nsz: Tcount = %ld\n", tcount);
  1555.         if (tleft) {
  1556.             fprintf(Ttystream,"ERROR: Interrupts Not Caught\n");
  1557. #endif
  1558.             exit(1);
  1559.         }
  1560. #ifdef OS9
  1561.         if(Verbose < 3)
  1562.             _ss_opt(fileno(stderr), &sttyold);
  1563.         exit(0);
  1564.     }
  1565. #else
  1566.         exit(0);
  1567.     }
  1568. #endif
  1569.  
  1570.     do {
  1571.         n = zfilbuf();
  1572.         if (Eofseen)
  1573.             e = ZCRCE;
  1574.             else if (junkcount > 3)
  1575.             e = ZCRCW;
  1576.         else if (bytcnt == Lastsync)
  1577.             e = ZCRCW;
  1578.         else if (Rxbuflen && (newcnt -= n) <= 0)
  1579.             e = ZCRCW;
  1580.         else if (Txwindow && (Txwcnt += n) >= Txwspac) {
  1581.             Txwcnt = 0;  e = ZCRCQ;
  1582.         } else
  1583.             e = ZCRCG;
  1584.         if (Verbose>1)
  1585. #ifdef OS9
  1586. #ifdef m6809
  1587.     fprintf(stderr, "\r\t%7ld ZMODEM%s    ", Txpos, Crc32t?" CRC-32":"");
  1588. #else /* !m6809 */
  1589.     fprintf(stderr, "\r\x1b\x5b A%7ld ZMODEM%s    ", Txpos, Crc32t?" CRC-32":"");
  1590. #endif /* !m6809 */
  1591. #else /* !OS9 */ 
  1592.     fprintf(stderr, "\r%7ld ZMODEM%s    ", Txpos, Crc32t?" CRC-32":"");
  1593. #endif /* !OS9 */
  1594.         zsdata(txbuf, n, e);
  1595.         bytcnt = Txpos += n;
  1596.         if (e == ZCRCW)
  1597.             goto waitack;
  1598. #ifdef READCHECK
  1599.         /*
  1600.          * If the reverse channel can be tested for data,
  1601.          *  this logic may be used to detect error packets
  1602.          *  sent by the receiver, in place of setjmp/longjmp
  1603.          *  rdchk(Tty) returns non 0 if a character is available
  1604.          */
  1605.         fflush(Ttystream);
  1606.         while (rdchk(Tty)) {
  1607. #ifdef EATSIT
  1608.             switch (checked)
  1609. #else
  1610.             switch (readline(1))
  1611. #endif
  1612.             {
  1613.             case CAN:
  1614.             case ZPAD:
  1615.                 c = getinsync(1);
  1616.                 if (c == ZACK)
  1617.                     break;
  1618.                 /* zcrce - dinna wanna starta ping-pong game */
  1619.                 zsdata(txbuf, 0, ZCRCE);
  1620.                 goto gotack;
  1621.             case XOFF:        /* Wait a while for an XON */
  1622.                 readline(100);
  1623.             default:
  1624.                 ++junkcount;
  1625.             }
  1626.         }
  1627. #endif    /* READCHECK */
  1628.         if (Txwindow) {
  1629.             while ((tcount = (Txpos - Lrxpos)) >= Txwindow) {
  1630.                 vfile("zsendfdata: %ld window >= %u", tcount, Txwindow);
  1631.                 if (e != ZCRCQ)
  1632.                     zsdata(txbuf, 0, e = ZCRCQ);
  1633.                 c = getinsync(1);
  1634.                 if (c != ZACK) {
  1635.                     zsdata(txbuf, 0, ZCRCE);
  1636.                     goto gotack;
  1637.                 }
  1638.             }
  1639.             vfile("window = %ld", tcount);
  1640.         }
  1641.     } while (!Eofseen);
  1642.     signal(SIGINT, SIG_IGN);
  1643.  
  1644.     for (;;) {
  1645.         stohdr(Txpos);
  1646.         zsbhdr(4, ZEOF, Txhdr);
  1647. egotack:
  1648.         switch (getinsync(0)) {
  1649.         case ZACK:
  1650.             goto egotack;
  1651.         case ZNAK:
  1652.             continue;
  1653.         case ZRPOS:
  1654.             goto somemore;
  1655.         case ZRINIT:
  1656.             fclose(in);
  1657.             return OK;
  1658.         case ZSKIP:
  1659.             fclose(in);
  1660.             sprintf(endmsg, "File skipped by receiver request");
  1661.             return c;
  1662.         default:
  1663.             sprintf(endmsg, "Got %d trying to send end of file", c);
  1664.         case ERROR:
  1665.             fclose(in);
  1666.             return ERROR;
  1667.         }
  1668.     }
  1669. }
  1670.  
  1671. /*
  1672.  * Respond to receiver's complaint, get back in sync with receiver
  1673.  */
  1674. getinsync(flag)
  1675. {
  1676.     register c;
  1677.  
  1678.     for (;;) {
  1679.         if (Test) {
  1680. #ifdef OS9
  1681.             fprintf(stderr,"\r\l\l\l***** Signal Caught *****\r\l");
  1682. #else
  1683.             fprintf(Ttystream,"\r\n\n\n***** Signal Caught *****\r\n");
  1684. #endif
  1685.             Rxpos = 0; c = ZRPOS;
  1686.         } else
  1687.             c = zgethdr(Rxhdr);
  1688.         switch (c) {
  1689.         case ZCAN:
  1690.         case ZABORT:
  1691.         case ZFIN:
  1692.         case TIMEOUT:
  1693.             sprintf(endmsg, "Got %s sending data", frametypes[c+FTOFFSET]);
  1694.             return ERROR;
  1695.         case ZRPOS:
  1696.             if (Rxpos > bytcnt) {
  1697.                 sprintf(endmsg, "Nonstandard Protocol");
  1698.                 return ZRPOS;
  1699.             }
  1700.             /* ************************************* */
  1701.             /*  If sending to a buffered modem, you  */
  1702.             /*   might send a break at this point to */
  1703.             /*   dump the modem's buffer.         */
  1704.             clearerr(in);    /* In case file EOF seen */
  1705.             if (fseek(in, Rxpos, 0)) {
  1706.                 sprintf(endmsg, "Bad Seek");
  1707.                 return ERROR;
  1708.             }
  1709.             Eofseen = 0;
  1710.             bytcnt = Lrxpos = Txpos = Rxpos;
  1711.             if (Lastsync == Rxpos) {
  1712.                 if (++Beenhereb4 > 12) {
  1713.                     sprintf(endmsg, "Can't send block");
  1714.                     return ERROR;
  1715.                 }
  1716.                 if (Beenhereb4 > 4)
  1717.                     if (blklen > 32)
  1718.                         blklen /= 2;
  1719.             }
  1720.             Lastsync = Rxpos;
  1721.             return c;
  1722.         case ZACK:
  1723.             Lrxpos = Rxpos;
  1724.             if (flag || Txpos == Rxpos)
  1725.                 return ZACK;
  1726.             continue;
  1727.         case ZRINIT:
  1728.             return c;
  1729.         case ZSKIP:
  1730.             sprintf(endmsg, "File skipped by receiver request");
  1731.             return c;
  1732.         case ERROR:
  1733.         default:
  1734.             zsbhdr(4, ZNAK, Txhdr);
  1735.             continue;
  1736.         }
  1737.     }
  1738. }
  1739.  
  1740.  
  1741. /* Send command and related info */
  1742. zsendcmd(buf, blen)
  1743. char *buf;
  1744. {
  1745.     register c;
  1746.     long cmdnum;
  1747.  
  1748.     cmdnum = getpid();
  1749.     errors = 0;
  1750.     for (;;) {
  1751.         stohdr(cmdnum);
  1752.         Txhdr[ZF0] = Cmdack1;
  1753.         zsbhdr(4, ZCOMMAND, Txhdr);
  1754.         zsdata(buf, blen, ZCRCW);
  1755. listen:
  1756.         Rxtimeout = 100;        /* Ten second wait for resp. */
  1757.         Usevhdrs = 0;        /* Allow rx to send fixed len headers */
  1758.         c = zgethdr(Rxhdr);
  1759.  
  1760.         switch (c) {
  1761.         case ZRINIT:
  1762.             goto listen;    /* CAF 8-21-87 */
  1763.         case ERROR:
  1764.         case GCOUNT:
  1765.         case TIMEOUT:
  1766.             if (++errors > 11)
  1767.                 return ERROR;
  1768.             continue;
  1769.         case ZCAN:
  1770.         case ZABORT:
  1771.         case ZFIN:
  1772.         case ZSKIP:
  1773.         case ZRPOS:
  1774.             return ERROR;
  1775.         default:
  1776.             if (++errors > 20)
  1777.                 return ERROR;
  1778.             continue;
  1779.         case ZCOMPL:
  1780.             Exitcode = Rxpos;
  1781.             saybibi();
  1782.             return OK;
  1783.         case ZRQINIT:
  1784.             vfile("******** RZ *******");
  1785.             system("rz");
  1786.             vfile("******** SZ *******");
  1787.             goto listen;
  1788.         }
  1789.     }
  1790. }
  1791.  
  1792. /*
  1793.  * If called as sb use YMODEM protocol
  1794.  */
  1795. chkinvok(s)
  1796. char *s;
  1797. {
  1798.     register char *p;
  1799.  
  1800.     p = s;
  1801.     while (*p == '-')
  1802.         s = ++p;
  1803.     while (*p)
  1804.         if (*p++ == '/')
  1805.             s = p;
  1806.     if (*s == 'v') {
  1807.         Verbose=1; ++s;
  1808.     }
  1809.     Progname = s;
  1810.     if (s[0]=='z' && s[1] == 'c') {
  1811.         Command = TRUE;
  1812.         if (s[8] == 'i')
  1813.             Cmdack1 = ZCACK1;
  1814.     }
  1815.     if (s[0]=='s' && s[1]=='b') {
  1816.         Nozmodem = TRUE; blklen=1024;
  1817.     }
  1818.     if (s[0]=='s' && s[1]=='x') {
  1819.         Modem2 = TRUE;
  1820.     }
  1821. }
  1822.  
  1823. countem(argc, argv)
  1824. register char **argv;
  1825. {
  1826. #ifdef OS9
  1827.     struct fildes f;
  1828. #else
  1829.     struct stat f;
  1830. #endif
  1831.  
  1832.     for (Totalleft = 0, Filesleft = 0; --argc >=0; ++argv) {
  1833. #ifndef OS9
  1834.         f.st_size = -1;
  1835. #endif
  1836.         if (Verbose>2) {
  1837.             fprintf(stderr, "\nCountem: %03d %s ", argc, *argv);
  1838.             fflush(stderr);
  1839.         }
  1840. #ifdef OS9
  1841.         if ((in = fopen(*argv, "r")) != NULL) {
  1842.             _gs_gfd(fileno(in), &f, sizeof(f));
  1843. #ifdef m6809
  1844.             ++Filesleft;  Totalleft += f.fd_fsize;
  1845. #else /* !m6809 */
  1846.             ++Filesleft;  Totalleft += c4tol(f.fd_fsize);
  1847. #endif /* !m6809 */
  1848.             fclose(in);
  1849.             if (Verbose > 2)
  1850. #ifdef m6809
  1851.                 fprintf(stderr, " %ld", f.fd_fsize);
  1852. #else /* !m6809 */
  1853.                 fprintf(stderr, " %ld", c4tol(f.fd_fsize));
  1854. #endif /* !m6809 */
  1855.         }
  1856. #else /* !OS9 */
  1857.         if (access(*argv, 04) >= 0 && stat(*argv, &f) >= 0) {
  1858.             ++Filesleft;  Totalleft += f.st_size;
  1859.             if (Verbose>2)
  1860.                 fprintf(stderr, " %ld", f.st_size);
  1861.         }
  1862. #endif /* !OS9 */
  1863.     }
  1864.     if (Verbose>2)
  1865.         fprintf(stderr, "\ncountem: Total %d %ld\n",
  1866.           Filesleft, Totalleft);
  1867. }
  1868.  
  1869. chartest(m)
  1870. {
  1871.     register n;
  1872.  
  1873.     mode(m);
  1874. #ifdef OS9
  1875.     printf("\r\l\lCharacter Transparency Test Mode %d\r\l", m);
  1876.     printf("If Pro-YAM/ZCOMM is not displaying ^M hit ALT-V NOW.\r\l");
  1877. #else
  1878.     printf("\r\n\nCharacter Transparency Test Mode %d\r\n", m);
  1879.     printf("If Pro-YAM/ZCOMM is not displaying ^M hit ALT-V NOW.\r\n");
  1880. #endif
  1881.     printf("Hit Enter.\021");  fflush(stdout);
  1882.     readline(500);
  1883.  
  1884.     for (n = 0; n < 256; ++n) {
  1885.         if (!(n%8))
  1886. #ifdef OS9
  1887.             printf("\r\l");
  1888. #else
  1889.             printf("\r\n");
  1890. #endif
  1891.         printf("%02x ", n);  fflush(stdout);
  1892.         sendline(n);    flushmo();
  1893.         printf("  ");  fflush(stdout);
  1894.         if (n == 127) {
  1895.             printf("Hit Enter.\021");  fflush(stdout);
  1896.             readline(500);
  1897. #ifdef OS9
  1898.             printf("\r\l");  fflush(stdout);
  1899. #else
  1900.             printf("\r\n");  fflush(stdout);
  1901. #endif
  1902.         }
  1903.     }
  1904. #ifdef OS9
  1905.     printf("\021\r\lEnter Characters, echo is in hex.\r\l");
  1906.     printf("Hit SPACE or pause 40 seconds for exit.\r\l");
  1907. #else
  1908.     printf("\021\r\nEnter Characters, echo is in hex.\r\n");
  1909.     printf("Hit SPACE or pause 40 seconds for exit.\r\n");
  1910. #endif
  1911.  
  1912.     while (n != TIMEOUT && n != ' ') {
  1913.         n = readline(400);
  1914. #ifdef OS9
  1915.         printf("%02x\r\l", n);
  1916. #else
  1917.         printf("%02x\r\n", n);
  1918. #endif
  1919.         fflush(stdout);
  1920.     }
  1921. #ifdef OS9
  1922.     printf("\r\lMode %d character transparency test ends.\r\l", m);
  1923. #else
  1924.     printf("\r\nMode %d character transparency test ends.\r\n", m);
  1925. #endif
  1926.     fflush(stdout);
  1927. }
  1928.  
  1929. /* End of sz.c */
  1930.  
  1931.  
  1932.