sz.c File Reference

#include <sys/types.h>
#include <signal.h>
#include <setjmp.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <utime.h>
#include <stdio.h>
#include "rbsb.c"
#include "crctab.c"
#include "zm.c"

Include dependency graph for sz.c:

Go to the source code of this file.

Defines

#define VERSION   "sz 2.12 05-29-88"
#define PUBDIR   "/usr/spool/uucppublic"
#define SS_NORMAL   0
#define LOGFILE   "/tmp/szlog"
#define sendline(c)   putchar((c) & 0377)
#define xsendline(c)   putchar(c)
#define PATHLEN   256
#define OK   0
#define FALSE   0
#define TRUE   1
#define ERROR   (-1)
#define ENQ   005
#define CAN   ('X'&037)
#define XOFF   ('s'&037)
#define XON   ('q'&037)
#define SOH   1
#define STX   2
#define EOT   4
#define ACK   6
#define NAK   025
#define CPMEOF   032
#define WANTCRC   0103
#define WANTG   0107
#define TIMEOUT   (-2)
#define RCDO   (-3)
#define RETRYMAX   10
#define HOWMANY   2

Functions

 _PROTOTYPE (void onintr,(int sig))
 _PROTOTYPE (int main,(int argc, char *argv[]))
 _PROTOTYPE (int wcsend,(int argc, char *argp[]))
 _PROTOTYPE (int wcs,(char *oname))
 _PROTOTYPE (int wctxpn,(char *name))
 _PROTOTYPE (int getnak,(void))
 _PROTOTYPE (int wctx,(long flen))
 _PROTOTYPE (int wcputsec,(char *buf, int sectnum, int cseclen))
 _PROTOTYPE (int filbuf,(char *buf, int count))
 _PROTOTYPE (int fooseek,(FILE *fptr, long pos, int whence))
 _PROTOTYPE (int readline,(int timeout))
 _PROTOTYPE (void flushmo,(void))
void zperr ()
 _PROTOTYPE (char *substr,(char *s, char *t))
 _PROTOTYPE (int zsendfile,(char *buf, int blen))
 _PROTOTYPE (int getinsync,(int flag))
 _PROTOTYPE (void bttyout,(int c))
 _PROTOTYPE (void chkinvok,(char *s))
 _PROTOTYPE (void countem,(int argc, char **argv))
 _PROTOTYPE (void chartest,(int m))
void bibi (int n)
void onintr (int sig)
int main (int argc, argv)
int wcsend (int argc, argp)
int wcs (char *oname)
int wctxpn (char *name)
int getnak ()
int wctx (long flen)
int wcputsec (char *buf, int sectnum, int cseclen)
int filbuf (char *buf, int count)
int zfilbuf ()
void vfile (char *f, char *a, char *b, char *c)
void alrm (int sig)
int readline (int timeout)
void flushmo ()
void purgeline ()
void canit ()
void zperr (char *s, char *p, char *u)
char * substr (char *s, char *t)
int usage ()
int getzrxinit ()
int sendzsinit ()
int zsendfile (char *buf, int blen)
int zsendfdata ()
int getinsync (int flag)
void saybibi ()
void bttyout (int c)
int zsendcmd (char *buf, int blen)
void chkinvok (char *s)
void countem (int argc, char **argv)
void chartest (int m)

Variables

int Zmodem = 0
unsigned Baudrate = 2400
unsigned Txwindow
unsigned Txwspac
unsigned Txwcnt
long Lrxpos
int errors
int Filesleft
long Totalleft
char Myattn [] = { 03, 0336, 0 }
FILEin
int Canseek = 1
char txbuf [1024]
long vpos = 0
char Lastrx
char Crcflg
int Verbose = 0
int Modem2 = 0
int Restricted = 0
int Quiet = 0
int Ascii = 0
int Fullname = 0
int Unlinkafter = 0
int Dottoslash = 0
int firstsec
int errcnt = 0
int blklen = 128
int Optiong
int Eofseen
int BEofseen
int Totsecs
int Filcnt = 0
int Lfseen = 0
unsigned Rxbuflen = 16384
int Tframlen = 0
int blkopt = 0
int Rxflags = 0
long bytcnt
int Wantfcs32 = TRUE
char Lzconv
char Lzmanag
int Lskipnocor
char Lztrans
char zconv
char zmanag
char ztrans
int Command
char * Cmdstr
int Cmdtries = 11
int Cmdack1
int Exitcode = 0
int Test
char * qbf = "The quick brown fox jumped over the lazy dog's back 1234567890\r\n"
long Lastsync
int Beenhereb4
jmp_buf tohere
jmp_buf intrjmp
int Zctlesc
int Nozmodem = 0
char * Progname = "sz"
int Zrwindow = 1400
char * babble []


Define Documentation

#define ACK   6
 

Definition at line 113 of file sz.c.

#define CAN   ('X'&037)
 

Definition at line 107 of file sz.c.

#define CPMEOF   032
 

Definition at line 115 of file sz.c.

#define ENQ   005
 

Definition at line 106 of file sz.c.

#define EOT   4
 

Definition at line 112 of file sz.c.

#define ERROR   (-1)
 

Definition at line 104 of file sz.c.

#define FALSE   0
 

Definition at line 101 of file sz.c.

#define HOWMANY   2
 

Definition at line 123 of file sz.c.

#define LOGFILE   "/tmp/szlog"
 

Definition at line 81 of file sz.c.

#define NAK   025
 

Definition at line 114 of file sz.c.

#define OK   0
 

Definition at line 100 of file sz.c.

#define PATHLEN   256
 

Definition at line 99 of file sz.c.

#define PUBDIR   "/usr/spool/uucppublic"
 

Definition at line 2 of file sz.c.

#define RCDO   (-3)
 

Definition at line 119 of file sz.c.

#define RETRYMAX   10
 

Definition at line 120 of file sz.c.

#define sendline c   )     putchar((c) & 0377)
 

Definition at line 83 of file sz.c.

Referenced by chartest(), rzfile(), saybibi(), wcputsec(), wcrx(), wcrxpn(), zmputs(), zputhex(), and zshhdr().

#define SOH   1
 

Definition at line 110 of file sz.c.

#define SS_NORMAL   0
 

Definition at line 80 of file sz.c.

#define STX   2
 

Definition at line 111 of file sz.c.

#define TIMEOUT   (-2)
 

Definition at line 118 of file sz.c.

#define TRUE   1
 

Definition at line 102 of file sz.c.

#define VERSION   "sz 2.12 05-29-88"
 

Definition at line 1 of file sz.c.

#define WANTCRC   0103
 

Definition at line 116 of file sz.c.

#define WANTG   0107
 

Definition at line 117 of file sz.c.

Referenced by getnak(), and wctx().

#define XOFF   ('s'&037)
 

Definition at line 108 of file sz.c.

#define XON   ('q'&037)
 

Definition at line 109 of file sz.c.

#define xsendline c   )     putchar(c)
 

Definition at line 84 of file sz.c.


Function Documentation

_PROTOTYPE void  chartest,
(int m
 

_PROTOTYPE void  countem,
(int argc, char **argv) 
 

_PROTOTYPE void  chkinvok,
(char *s
 

_PROTOTYPE void  bttyout,
(int c
 

_PROTOTYPE int  getinsync,
(int flag
 

_PROTOTYPE int  zsendfile,
(char *buf, int blen) 
 

_PROTOTYPE char *  substr,
(char *s, char *t
 

_PROTOTYPE void  flushmo,
(void) 
 

_PROTOTYPE int  readline,
(int timeout) 
 

_PROTOTYPE int  fooseek,
(FILE *fptr, long pos, int whence
 

_PROTOTYPE int  filbuf,
(char *buf, int count) 
 

_PROTOTYPE int  wcputsec,
(char *buf, int sectnum, int cseclen) 
 

_PROTOTYPE int  wctx,
(long flen) 
 

_PROTOTYPE int  getnak,
(void) 
 

_PROTOTYPE int  wctxpn,
(char *name
 

_PROTOTYPE int  wcs,
(char *oname) 
 

_PROTOTYPE int  wcsend,
(int argc, char *argp[]) 
 

_PROTOTYPE int  main,
(int argc, char *argv[]) 
 

_PROTOTYPE void  onintr,
(int sig
 

void alrm int  sig  ) 
 

Definition at line 962 of file sz.c.

References tohere.

void bibi int  n  ) 
 

Definition at line 255 of file sz.c.

References abort(), canit(), cucheck(), exit(), fflush(), fprintf(), mode, SIGQUIT, stderr, and stdout.

void bttyout int  c  ) 
 

Definition at line 1602 of file sz.c.

References putc, stderr, and Verbose.

void canit  ) 
 

Definition at line 1018 of file sz.c.

References fflush(), printf, purgeline(), stdout, and strlen().

void chartest int  m  ) 
 

Definition at line 1720 of file sz.c.

References fflush(), flushmo(), mode, printf, readline(), sendline, and stdout.

Referenced by main().

void chkinvok char *  s  ) 
 

Definition at line 1666 of file sz.c.

References blklen, Modem2, p, TRUE, and Verbose.

void countem int  argc,
char **  argv
 

Definition at line 1693 of file sz.c.

References c, f, fflush(), Filesleft, fprintf(), if(), stderr, Totalleft, and Verbose.

Referenced by main().

int filbuf char *  buf,
int  count
 

Definition at line 825 of file sz.c.

References Ascii, c, CPMEOF, EOF, fileno(), getc, in, Lfseen, m, read, and TRUE.

Referenced by wctx().

void flushmo  ) 
 

Definition at line 1001 of file sz.c.

References fflush(), and stdout.

int getinsync int  flag  ) 
 

Definition at line 1533 of file sz.c.

References c, printf, Rxpos, Test, and ZRPOS.

Referenced by zsendfdata().

int getnak  ) 
 

Definition at line 662 of file sz.c.

References Ascii, blklen, CAN, Crcflg, ERROR, FALSE, firstch(), getzrxinit(), Lastrx, mode, NAK, Optiong, readline(), TIMEOUT, TRUE, WANTCRC, WANTG, ZPAD, and zperr().

Referenced by wctxpn().

int getzrxinit  ) 
 

Definition at line 1134 of file sz.c.

References Baudrate, blklen, blkopt, CANFC32, CANFDX, Command, ERROR, f, fileno(), Fromcu, fstat, in, iofd, L, mode, Rxbuflen, Rxflags, Rxhdr, Rxpos, S_IFCHR, S_IFMT, S_IFREG, sendzsinit(), SIG_IGN, SIGINT, signal(), stohdr(), TESCCTL, Tframlen, TIMEOUT, Txfcs32, Txhdr, Txwindow, Txwspac, vfile(), Wantfcs32, ZACK, ZCAN, ZCHALLENGE, ZCOMMAND, ZF0, zgethdr(), ZNAK, ZP0, ZP1, ZRINIT, ZRQINIT, and zshhdr().

Referenced by getnak(), and main().

int main int  argc,
argv 
 

Definition at line 282 of file sz.c.

References Ascii, atoi, bibi(), blklen, blkopt, BUFSIZ, canit(), chartest(), chkinvok(), Cmdack1, Cmdstr, Cmdtries, Command, countem(), cp, cucheck(), Dottoslash, errcnt, ERROR, exit(), Exitcode, FALSE, fflush(), freopen(), from_cu(), Fromcu, Fullname, getenv(), getzrxinit(), iofd, L, LOGFILE, Lskipnocor, Lzconv, Lzmanag, mode, Modem2, NULL, OS, printf, putc, Quiet, Restricted, Rxtimeout, setbuf(), SIG_IGN, SIGINT, SIGKILL, signal(), SIGQUIT, SIGTERM, SS_NORMAL, stderr, stdout, stohdr(), strcmp, strlen(), substr(), Test, Tframlen, toupper, TRUE, Twostop, Txhdr, Txwindow, Txwspac, Unlinkafter, usage, Verbose, VERSION, vfile(), Wantfcs32, wcsend(), ZCACK1, ZCBIN, ZCNL, ZCOMMAND, ZCRESUM, ZF0, ZMAPND, ZMCLOB, ZMNEW, ZMNEWL, ZMPROT, Znulls, ZRQINIT, zsendcmd(), and zshhdr().

void onintr int  sig  ) 
 

Definition at line 268 of file sz.c.

References intrjmp, SIG_IGN, SIGINT, and signal().

void purgeline  ) 
 

Definition at line 1007 of file sz.c.

References ioctl, iofd, L, lseek, and TCFLSH.

int readline int  timeout  ) 
 

Definition at line 974 of file sz.c.

References alarm, c, fflush(), fprintf(), iofd, read, setjmp, SIGALRM, signal(), stderr, stdout, TIMEOUT, tohere, Verbose, and zperr().

void saybibi  ) 
 

Definition at line 1586 of file sz.c.

References flushmo(), L, Rxhdr, sendline, stohdr(), TIMEOUT, Txhdr, ZCAN, ZFIN, zgethdr(), and zshhdr().

Referenced by zsendcmd().

int sendzsinit  ) 
 

Definition at line 1239 of file sz.c.

References c, errors, L, Myattn, OK, Rxflags, stohdr(), TESCCTL, Txhdr, ZF0, zshhdr(), and ZSINIT.

Referenced by getzrxinit().

char* substr char *  s,
char*  t
 

Definition at line 1053 of file sz.c.

int usage void   ) 
 

Definition at line 1118 of file sz.c.

References cucheck(), exit(), fprintf(), OS, SS_NORMAL, stderr, and VERSION.

void vfile char *  f,
char*  a,
char*  b,
char*  c
 

Definition at line 952 of file sz.c.

References fprintf(), stderr, and Verbose.

int wcputsec char *  buf,
int  sectnum,
int  cseclen
 

Definition at line 746 of file sz.c.

References checksum(), cp, firstch(), fprintf(), Lastrx, RETRYMAX, sendline, SOH, stderr, STX, Totsecs, updcrc, and Verbose.

Referenced by wctx().

int wcs char *  oname  ) 
 

Definition at line 533 of file sz.c.

References BEofseen, c, canit(), Eofseen, errcnt, ERROR, f, fclose(), Filcnt, fileno(), fopen(), fprintf(), fstat, getenv(), getpid, in, NULL, OK, p, PATHLEN, PUBDIR, Restricted, S_IFBLK, S_IFDIR, S_IFMT, sprintf(), stderr, stdin, strcmp, strcpy(), strlen(), strncmp(), substr(), unlink, Unlinkafter, vpos, wctx(), wctxpn(), Zmodem, and ZSKIP.

Referenced by wcsend().

int wcsend int  argc,
argp 
 

Definition at line 493 of file sz.c.

References bytcnt, Crcflg, ERROR, FALSE, firstsec, n, Totsecs, TRUE, and wcs().

Referenced by main().

int wctx long  flen  ) 
 

Definition at line 698 of file sz.c.

References blklen, CAN, Crcflg, ERROR, filbuf(), firstch(), firstsec, L, NAK, readline(), Rxtimeout, TIMEOUT, TRUE, vfile(), WANTCRC, WANTG, wcputsec(), and zperr().

Referenced by wcs().

int wctxpn char *  name  ) 
 

Definition at line 596 of file sz.c.

References Dottoslash, ERROR, f, fileno(), fprintf(), fstat, getnak(), in, Modem2, name2, OK, p, PATHLEN, stderr, stdin, strcpy(), strlen(), Zmodem, and zperr().

Referenced by wcs().

int zfilbuf  ) 
 

Definition at line 863 of file sz.c.

References BEofseen, blklen, bytcnt, Eofseen, fread(), in, n, and vpos.

Referenced by zsendfdata().

void zperr char *  s,
char *  p,
char *  u
 

Definition at line 1038 of file sz.c.

References errors, fprintf(), stderr, and Verbose.

void zperr  ) 
 

int zsendcmd char *  buf,
int  blen
 

Definition at line 1610 of file sz.c.

References c, Cmdack1, Cmdtries, ERROR, errors, Exitcode, getpid, listen, OK, Rxhdr, Rxpos, Rxtimeout, saybibi(), stohdr(), system(), TIMEOUT, Txhdr, vfile(), ZABORT, ZCAN, ZCOMMAND, ZCOMPL, ZCRCW, ZF0, ZFIN, zgethdr(), ZRINIT, ZRPOS, ZRQINIT, zsbhdr(), zsdata(), and ZSKIP.

Referenced by main().

int zsendfdata  ) 
 

Definition at line 1329 of file sz.c.

References Beenhereb4, bytcnt, c, CAN, canit(), Crc32t, e, Eofseen, ERROR, exit(), FALSE, fclose(), fflush(), fprintf(), Fromcu, getinsync(), in, intrjmp, ioctl, iofd, Lastsync, Lrxpos, mode, OK, printf, purgeline(), qbf, readline(), Rxbuflen, setjmp, SIG_IGN, SIGINT, signal(), sleep, SS_NORMAL, stderr, stdout, stohdr(), strlen(), TCFLSH, Test, Txhdr, Txpos, Txwcnt, Txwindow, Txwspac, Verbose, vfile(), XOFF, ZACK, ZCAN, ZCRCE, ZCRCG, ZCRCQ, ZCRCW, ZDATA, ZEOF, zfilbuf(), ZPAD, ZRINIT, ZRPOS, zsbhdr(), zsdata(), and ZSKIP.

Referenced by zsendfile().

int zsendfile char *  buf,
int  blen
 

Definition at line 1269 of file sz.c.

References bytcnt, c, clearerr, crc(), EOF, ERROR, fclose(), fseek(), getc, in, L, Lastsync, Lskipnocor, Lzconv, Lzmanag, Lztrans, readline(), Rxhdr, Rxpos, stohdr(), TIMEOUT, Txhdr, Txpos, UPDC32, ZABORT, ZCAN, ZCRC, ZCRCW, ZF0, ZF1, ZF2, ZF3, ZFILE, ZFIN, zgethdr(), ZMSKNOLOC, ZPAD, ZRINIT, ZRPOS, zsbhdr(), zsdata(), zsendfdata(), and ZSKIP.


Variable Documentation

int Ascii = 0
 

Definition at line 183 of file sz.c.

Referenced by filbuf(), getnak(), and main().

char* babble[]
 

Definition at line 1070 of file sz.c.

unsigned Baudrate = 2400
 

Definition at line 125 of file sz.c.

int Beenhereb4
 

Definition at line 218 of file sz.c.

Referenced by zsendfdata().

int BEofseen
 

Definition at line 192 of file sz.c.

Referenced by wcs(), and zfilbuf().

int blklen = 128
 

Definition at line 189 of file sz.c.

Referenced by chkinvok(), getnak(), getzrxinit(), main(), wctx(), and zfilbuf().

int blkopt = 0
 

Definition at line 198 of file sz.c.

Referenced by getzrxinit(), and main().

long bytcnt
 

Definition at line 200 of file sz.c.

Referenced by wcsend(), zfilbuf(), zsendfdata(), and zsendfile().

int Canseek = 1
 

Definition at line 165 of file sz.c.

int Cmdack1
 

Definition at line 212 of file sz.c.

Referenced by main(), and zsendcmd().

char* Cmdstr
 

Definition at line 210 of file sz.c.

Referenced by main().

int Cmdtries = 11
 

Definition at line 211 of file sz.c.

Referenced by main(), and zsendcmd().

int Command
 

Definition at line 209 of file sz.c.

char Crcflg
 

Definition at line 178 of file sz.c.

int Dottoslash = 0
 

Definition at line 186 of file sz.c.

Referenced by main(), and wctxpn().

int Eofseen
 

Definition at line 191 of file sz.c.

int errcnt = 0
 

Definition at line 188 of file sz.c.

Referenced by main(), rd_sync(), and wcs().

int errors
 

Definition at line 130 of file sz.c.

int Exitcode = 0
 

Definition at line 213 of file sz.c.

Referenced by main(), and zsendcmd().

int Filcnt = 0
 

Definition at line 194 of file sz.c.

Referenced by wcs().

int Filesleft
 

Definition at line 139 of file sz.c.

Referenced by countem().

int firstsec
 

Definition at line 187 of file sz.c.

Referenced by wcsend(), and wctx().

int Fullname = 0
 

Definition at line 184 of file sz.c.

Referenced by main().

FILE* in
 

Definition at line 157 of file sz.c.

jmp_buf intrjmp
 

Definition at line 221 of file sz.c.

Referenced by onintr(), and zsendfdata().

char Lastrx
 

Definition at line 177 of file sz.c.

long Lastsync
 

Definition at line 217 of file sz.c.

Referenced by zsendfdata(), and zsendfile().

int Lfseen = 0
 

Definition at line 195 of file sz.c.

Referenced by filbuf().

long Lrxpos
 

Definition at line 129 of file sz.c.

Referenced by zsendfdata().

int Lskipnocor
 

Definition at line 204 of file sz.c.

Referenced by main(), and zsendfile().

char Lzconv
 

Definition at line 202 of file sz.c.

Referenced by main(), and zsendfile().

char Lzmanag
 

Definition at line 203 of file sz.c.

char Lztrans
 

Definition at line 205 of file sz.c.

Referenced by zsendfile().

int Modem2 = 0
 

Definition at line 180 of file sz.c.

Referenced by chkinvok(), main(), and wctxpn().

char Myattn[] = { 03, 0336, 0 }
 

Definition at line 151 of file sz.c.

Referenced by sendzsinit().

int Nozmodem = 0
 

Definition at line 276 of file sz.c.

int Optiong
 

Definition at line 190 of file sz.c.

Referenced by getnak().

char* Progname = "sz"
 

Definition at line 277 of file sz.c.

char* qbf = "The quick brown fox jumped over the lazy dog's back 1234567890\r\n"
 

Definition at line 216 of file sz.c.

Referenced by zsendfdata().

int Quiet = 0
 

Definition at line 182 of file sz.c.

int Restricted = 0
 

Definition at line 181 of file sz.c.

unsigned Rxbuflen = 16384
 

Definition at line 196 of file sz.c.

Referenced by getzrxinit(), and zsendfdata().

int Rxflags = 0
 

Definition at line 199 of file sz.c.

Referenced by getzrxinit(), and sendzsinit().

int Test
 

Definition at line 214 of file sz.c.

Referenced by getinsync(), main(), and zsendfdata().

int Tframlen = 0
 

Definition at line 197 of file sz.c.

Referenced by getzrxinit(), and main().

jmp_buf tohere
 

Definition at line 220 of file sz.c.

long Totalleft
 

Definition at line 140 of file sz.c.

Referenced by countem().

int Totsecs
 

Definition at line 193 of file sz.c.

Referenced by wcputsec(), and wcsend().

char txbuf[1024]
 

Definition at line 173 of file sz.c.

unsigned Txwcnt
 

Definition at line 128 of file sz.c.

Referenced by zsendfdata().

unsigned Txwindow
 

Definition at line 126 of file sz.c.

Referenced by getzrxinit(), main(), and zsendfdata().

unsigned Txwspac
 

Definition at line 127 of file sz.c.

Referenced by getzrxinit(), main(), and zsendfdata().

int Unlinkafter = 0
 

Definition at line 185 of file sz.c.

Referenced by main(), and wcs().

int Verbose = 0
 

Definition at line 179 of file sz.c.

long vpos = 0
 

Definition at line 175 of file sz.c.

Referenced by wcs(), and zfilbuf().

int Wantfcs32 = TRUE
 

Definition at line 201 of file sz.c.

Referenced by getzrxinit(), and main().

char zconv
 

Definition at line 206 of file sz.c.

int Zctlesc
 

Definition at line 275 of file sz.c.

char zmanag
 

Definition at line 207 of file sz.c.

int Zmodem = 0
 

Definition at line 124 of file sz.c.

int Zrwindow = 1400
 

Definition at line 278 of file sz.c.

char ztrans
 

Definition at line 208 of file sz.c.


Generated on Fri Apr 14 23:08:34 2006 for minix by  doxygen 1.4.6