Update stty, sysctl, test, uname, xargs, zmodem.

This commit is contained in:
Serge
2022-06-12 21:53:58 -07:00
parent 6794c38ff4
commit 2f2d84e6a0
17 changed files with 314 additions and 152 deletions

View File

@@ -69,6 +69,7 @@ FILE *fopen (const char *, const char *);
FILE *fdopen (int, const char *); FILE *fdopen (int, const char *);
FILE *freopen (const char *, const char *, FILE *); FILE *freopen (const char *, const char *, FILE *);
FILE *popen (const char *, const char *); FILE *popen (const char *, const char *);
int pclose(FILE *stream);
FILE *tmpfile (void); FILE *tmpfile (void);
int fclose (FILE *); int fclose (FILE *);
long ftell (FILE *); long ftell (FILE *);

View File

@@ -4,7 +4,7 @@
TOPSRC = $(shell cd ../../..; pwd) TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk include $(TOPSRC)/target.mk
CFLAGS = -O -Werror -g CFLAGS = -O -Werror -g -Wno-string-plus-int
SRCS = stty.c SRCS = stty.c
OBJS = stty.o OBJS = stty.o

View File

@@ -160,6 +160,11 @@ struct special {
char *arg; char *arg;
char *Nfmt = "%-8s"; char *Nfmt = "%-8s";
static void prmodes(int all);
static void pit(struct special *sp);
static int eq(char *string);
int
main(argc, argv) main(argc, argv)
int argc; int argc;
register char **argv; register char **argv;
@@ -328,6 +333,7 @@ done:
} }
} }
int
eq(string) eq(string)
char *string; char *string;
{ {
@@ -344,10 +350,11 @@ char *string;
fprintf(stderr, str + ((lmode & what) != 0)); any++; \ fprintf(stderr, str + ((lmode & what) != 0)); any++; \
} }
void
prmodes(all) prmodes(all)
int all; /* 0 for short display, !0 for long display */ int all; /* 0 for short display, !0 for long display */
{ {
register m; int m;
int any, i; int any, i;
register struct special *sp; register struct special *sp;
@@ -455,6 +462,7 @@ prmodes(all)
} }
} }
void
pit(sp) pit(sp)
struct special *sp; struct special *sp;
{ {

View File

@@ -51,6 +51,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h>
struct ctlname topname[] = CTL_NAMES; struct ctlname topname[] = CTL_NAMES;
struct ctlname kernname[] = CTL_KERN_NAMES; struct ctlname kernname[] = CTL_KERN_NAMES;
@@ -97,6 +98,12 @@ extern int optind, errno;
#define BOOTTIME 0x0002 #define BOOTTIME 0x0002
#define CONSDEV 0x0004 #define CONSDEV 0x0004
static void usage(void);
static void debuginit(void);
static void listall(char *prefix, struct list *lp);
static void parse(char *string, int flags);
static int findname(char *string, char *level, char **bufp, struct list *namelist);
int int
main(argc, argv) main(argc, argv)
int argc; int argc;
@@ -146,6 +153,7 @@ main(argc, argv)
/* /*
* List all variables known to the system. * List all variables known to the system.
*/ */
void
listall(prefix, lp) listall(prefix, lp)
char *prefix; char *prefix;
struct list *lp; struct list *lp;
@@ -171,11 +179,13 @@ listall(prefix, lp)
* Lookup and print out the MIB entry if it exists. * Lookup and print out the MIB entry if it exists.
* Set a new value if requested. * Set a new value if requested.
*/ */
void
parse(string, flags) parse(string, flags)
char *string; char *string;
int flags; int flags;
{ {
int indx, type, state, size, len; int indx, type, state, len;
size_t size;
int special = 0; int special = 0;
void *newval = (void *)0; void *newval = (void *)0;
int intval, newsize = 0; int intval, newsize = 0;
@@ -430,9 +440,11 @@ doit:
/* /*
* Initialize the set of debugging names * Initialize the set of debugging names
*/ */
void
debuginit() debuginit()
{ {
int mib[3], size, loc, i; int mib[3], loc, i;
size_t size;
if (secondlevel[CTL_DEBUG].list != 0) if (secondlevel[CTL_DEBUG].list != 0)
return; return;
@@ -480,6 +492,7 @@ struct list inetvars[] = {
/* /*
* handle internet requests * handle internet requests
*/ */
int
sysctl_inet(string, bufpp, mib, flags, typep) sysctl_inet(string, bufpp, mib, flags, typep)
char *string; char *string;
char **bufpp; char **bufpp;
@@ -521,6 +534,7 @@ sysctl_inet(string, bufpp, mib, flags, typep)
/* /*
* Scan a list of names searching for a particular name. * Scan a list of names searching for a particular name.
*/ */
int
findname(string, level, bufp, namelist) findname(string, level, bufp, namelist)
char *string; char *string;
char *level; char *level;
@@ -546,9 +560,9 @@ findname(string, level, bufp, namelist)
return (i); return (i);
} }
void
usage() usage()
{ {
(void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n", (void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n",
"sysctl [-n] variable ...", "sysctl [-n] -w variable=value ...", "sysctl [-n] variable ...", "sysctl [-n] -w variable=value ...",
"sysctl [-n] -a", "sysctl [-n] -A"); "sysctl [-n] -a", "sysctl [-n] -A");

View File

@@ -42,6 +42,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include "operators.h" #include "operators.h"
@@ -84,7 +85,11 @@ extern char binary_op[][4];
extern char andor_op[][4]; extern char andor_op[][4];
extern int op_priority[]; extern int op_priority[];
extern int op_argflag[]; extern int op_argflag[];
extern long atol();
static int expr_is_false(struct value *val);
static int posix_unary_op(char **argv);
static int posix_binary_op(char **argv);
static int lookup_op(char *name, char table[][4]);
/* /*
* Execute an operator. Op is the operator. Sp is the stack pointer; * Execute an operator. Op is the operator. Sp is the stack pointer;
@@ -279,6 +284,7 @@ overflow()
err(2, "expression is too complex"); err(2, "expression is too complex");
} }
int
main(argc, argv) main(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
@@ -423,7 +429,7 @@ main(argc, argv)
valsp->u.num); valsp->u.num);
#else #else
(void)sprintf(p, (void)sprintf(p,
"%d", valsp->u.num); "%ld", valsp->u.num);
#endif #endif
valsp->u.string = p; valsp->u.string = p;
} else if (valsp->type == BOOLEAN) { } else if (valsp->type == BOOLEAN) {
@@ -492,18 +498,16 @@ expr_is_false(val)
int int
lookup_op(name, table) lookup_op(name, table)
char *name; char *name;
char *table; char table[][4];
{ {
char *tp;
char c; char c;
int i; int i;
c = name[1]; c = name[1];
tp = table; for (i = 0; strcmp(table[i], "ZZZ"); i++) {
for(i = 0; strcmp((char *)(tp + i),"ZZZ") ; i=i+4){ if (table[i][1] == c && strcmp(table[i], name) == 0)
if ((char)(tp + i)[1] == c && !strcmp((char *)(tp + i), name)) return i;
return (i/4); }
}
return (-1); return (-1);
} }

View File

@@ -34,6 +34,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <unistd.h>
extern int optind; extern int optind;

View File

@@ -134,6 +134,7 @@ usage()
exit(1); exit(1);
} }
int
main(argc, argv) main(argc, argv)
int argc; int argc;
char **argv; char **argv;

View File

@@ -9,19 +9,19 @@ CFLAGS += -Werror -DV7 -DMD=2 -DTXBSIZE=4096 -DNFGVMIN -DSEGMENTS=2
SRCS = rz.c sz.c SRCS = rz.c sz.c
OBJS = rz.o sz.o OBJS = rz.o sz.o
MAN = rz.0 sz.0 MAN = rz.0 sz.0
MANSRC = rz.1 sz.1 MANSRC = rz.1 sz.1
all: rz sz $(MAN) all: rz sz $(MAN)
rz: rz.o rz: rz.o
$(CC) $(LDFLAGS) -o rz.elf $< $(LIBS) $(LD) $(LDFLAGS) -o rz.elf $< $(LIBS)
$(OBJDUMP) -S rz.elf > rz.dis $(OBJDUMP) -S rz.elf > rz.dis
$(SIZE) rz.elf $(SIZE) rz.elf
$(ELF2AOUT) rz.elf $@ && rm rz.elf $(ELF2AOUT) rz.elf $@ && rm rz.elf
sz: sz.o sz: sz.o
$(CC) $(LDFLAGS) -o sz.elf $< $(LIBS) $(LD) $(LDFLAGS) -o sz.elf $< $(LIBS)
$(OBJDUMP) -S sz.elf > sz.dis $(OBJDUMP) -S sz.elf > sz.dis
$(SIZE) sz.elf $(SIZE) sz.elf
$(ELF2AOUT) sz.elf $@ && rm sz.elf $(ELF2AOUT) sz.elf $@ && rm sz.elf

18
src/cmd/zmodem/decl.h Normal file
View File

@@ -0,0 +1,18 @@
void bibi (int);
void vfile(char *f, ...);
void flushmo(void);
void zsendline(int c);
void zsdar32(char *buf, int length, int frameend);
int zrdatr32(char *buf, int length);
int zdlread(void);
void zperr(char *s, ...);
int readline(unsigned timeout);
void bttyout(int c);
char *substr(char *s, char *t);
void chkinvok(char *s);
void usage(void);
int wcrxpn(char *rpn);
int procheader(char *name);
int wcrx(void);
int wcgetsec(char *rxbuf, int maxtime);
int putsec(char *buf, int n);

View File

@@ -52,7 +52,7 @@ int Locbit = LLITOUT|LDECCTQ; /* Bit SUPPOSED to disable output
Howmany must be 255 or less Howmany must be 255 or less
#endif #endif
extern void bibi (int); #include "decl.h"
/* /*
* return 1 iff stdout and stderr are different devices * return 1 iff stdout and stderr are different devices
@@ -60,21 +60,21 @@ extern void bibi (int);
* different line * different line
*/ */
int Fromcu; /* Were called from cu or yam */ int Fromcu; /* Were called from cu or yam */
from_cu()
void from_cu()
{ {
struct stat a, b; struct stat a, b;
fstat(1, &a); fstat(2, &b); fstat(1, &a); fstat(2, &b);
Fromcu = a.st_rdev != b.st_rdev; Fromcu = a.st_rdev != b.st_rdev;
return;
} }
cucheck()
void cucheck()
{ {
if (Fromcu) if (Fromcu)
fprintf(stderr,"Please read the manual page BUGS chapter!\r\n"); fprintf(stderr,"Please read the manual page BUGS chapter!\r\n");
} }
struct { struct {
unsigned baudr; unsigned baudr;
int speedcode; int speedcode;
@@ -111,7 +111,7 @@ int Twostop; /* Use two stop bits */
/* /*
* Return non 0 iff something to read from io descriptor f * Return non 0 iff something to read from io descriptor f
*/ */
rdchk(f) int rdchk(f)
{ {
static long lf; static long lf;
@@ -126,13 +126,15 @@ rdchk(f)
#include <fcntl.h> #include <fcntl.h>
int checked = 0; int checked = 0;
/* /*
* Nonblocking I/O is a bit different in System V, Release 2 * Nonblocking I/O is a bit different in System V, Release 2
* Note: this rdchk vsn throws away a byte, OK for ZMODEM * Note: this rdchk vsn throws away a byte, OK for ZMODEM
* sender because protocol design anticipates this problem. * sender because protocol design anticipates this problem.
*/ */
#define EATSIT #define EATSIT
rdchk(f)
int rdchk(f)
{ {
int lf, savestat; int lf, savestat;
static char bchecked; static char bchecked;
@@ -148,11 +150,10 @@ rdchk(f)
#endif #endif
#endif #endif
static unsigned static unsigned
getspeed(code) getspeed(code)
{ {
register n; int n;
for (n=0; speeds[n].baudr; ++n) for (n=0; speeds[n].baudr; ++n)
if (speeds[n].speedcode == code) if (speeds[n].speedcode == code)
@@ -160,8 +161,6 @@ getspeed(code)
return 38400; /* Assume fifo if ioctl failed */ return 38400; /* Assume fifo if ioctl failed */
} }
#ifdef ICANON #ifdef ICANON
struct termio oldtty, tty; struct termio oldtty, tty;
#else #else
@@ -176,9 +175,9 @@ struct tchars oldtch, tch;
* 1: save old tty stat, set raw mode * 1: save old tty stat, set raw mode
* 0: restore original tty mode * 0: restore original tty mode
*/ */
mode(n) int mode(n)
{ {
static did0 = FALSE; static int did0 = FALSE;
vfile("mode:%d", n); vfile("mode:%d", n);
switch(n) { switch(n) {
@@ -320,7 +319,7 @@ mode(n)
} }
} }
sendbrk() void sendbrk()
{ {
#ifdef V7 #ifdef V7
#ifdef TIOCSBRK #ifdef TIOCSBRK

View File

@@ -102,6 +102,7 @@
#include <setjmp.h> #include <setjmp.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <stdarg.h>
#define OK 0 #define OK 0
#define FALSE 0 #define FALSE 0
@@ -117,7 +118,7 @@
#define HOWMANY 133 #define HOWMANY 133
#endif #endif
// PITO: // PITO:
#define readline_timeout 1 #define readline_timeout 1
/* Ward Christensen / CP/M parameters - Don't change these! */ /* Ward Christensen / CP/M parameters - Don't change these! */
@@ -152,7 +153,6 @@ unsigned Effbaud = 2400;
#endif #endif
#include "crctab.c" #include "crctab.c"
char *substr();
FILE *fout; FILE *fout;
/* /*
@@ -206,7 +206,6 @@ char secbuf[1025];
char linbuf[HOWMANY]; char linbuf[HOWMANY];
int Lleft=0; /* number of characters in linbuf */ int Lleft=0; /* number of characters in linbuf */
time_t timep[2];
char Lzmanag; /* Local file management request */ char Lzmanag; /* Local file management request */
char zconv; /* ZMODEM file conversion request */ char zconv; /* ZMODEM file conversion request */
char zmanag; /* ZMODEM file management request */ char zmanag; /* ZMODEM file management request */
@@ -217,6 +216,23 @@ int Zrwindow = 1400; /* RX window size (controls garbage count) */
jmp_buf tohere; /* For the interrupt on RX timeout */ jmp_buf tohere; /* For the interrupt on RX timeout */
static void zmputs(char *s);
static void canit(void);
static int wcreceive(int argc, char **argp);
static int tryz(void);
static int rzfiles(void);
static void checkpath(char *name);
static void report(int sct);
static int closeit(void);
static int IsAnyLower(char *s);
static void uncaps(char *s);
static int make_dirs(char *pathname);
static int sys2(char *s);
static void ackbibi(void);
static void exec2(char *s);
static int rzfile(void);
static void sendline(int c);
#define xsendline(c) sendline(c) #define xsendline(c) sendline(c)
#include "zm.c" #include "zm.c"
@@ -243,13 +259,13 @@ bibi(n)
exit(128+n); exit(128+n);
} }
int
main(argc, argv) main(argc, argv)
char *argv[]; char *argv[];
{ {
register char *cp; register char *cp;
register npats; int npats;
char *virgin, **patts; char *virgin, **patts;
char *getenv();
int exitcode; int exitcode;
Rxtimeout = 100; Rxtimeout = 100;
@@ -358,7 +374,7 @@ char *argv[];
exit(exitcode ? exitcode:SS_NORMAL); exit(exitcode ? exitcode:SS_NORMAL);
} }
void
usage() usage()
{ {
cucheck(); cucheck();
@@ -371,30 +387,32 @@ usage()
#ifndef vax11c #ifndef vax11c
fprintf(stderr," -c Use 16 bit CRC (XMODEM)\n"); fprintf(stderr," -c Use 16 bit CRC (XMODEM)\n");
#endif #endif
fprintf(stderr," -D Output file to /dev/null\n"); fprintf(stderr," -D Output file to /dev/null\n");
fprintf(stderr," -e Escape control characters (ZMODEM)\n"); fprintf(stderr," -e Escape control characters (ZMODEM)\n");
fprintf(stderr," -p Skip file if destination exists\n"); fprintf(stderr," -p Skip file if destination exists\n");
fprintf(stderr," -q Quiet suppresses verbosity\n"); fprintf(stderr," -q Quiet suppresses verbosity\n");
fprintf(stderr," -t tim Change Rxtimeout to tim tenths of seconds (10-1000)\n"); fprintf(stderr," -t tim Change Rxtimeout to tim tenths of seconds (10-1000)\n");
fprintf(stderr," -u Do not make file pathnames lower case \n"); fprintf(stderr," -u Do not make file pathnames lower case \n");
fprintf(stderr," -w n Rx window size to n bytes (ZMODEM)\n"); fprintf(stderr," -w n Rx window size to n bytes (ZMODEM)\n");
fprintf(stderr," -v Verbose more v's give more info\n"); fprintf(stderr," -v Verbose more v's give more info\n");
fprintf(stderr," -y Yes, clobber existing file if any\n"); fprintf(stderr," -y Yes, clobber existing file if any\n");
fprintf(stderr,"%s %s for %s by Chuck Forsberg, Omen Technology INC\n", fprintf(stderr,"%s %s for %s by Chuck Forsberg, Omen Technology INC\n",
Progname, VERSION, OS); Progname, VERSION, OS);
fprintf(stderr, "\t\t\042The High Reliability Software\042\n"); fprintf(stderr, "\t\t\042The High Reliability Software\042\n");
exit(SS_NORMAL); exit(SS_NORMAL);
} }
/* /*
* Debugging information output interface routine * Debugging information output interface routine
*/ */
/* VARARGS1 */ /* VARARGS1 */
vfile(f, a, b, c, d) void
char *f; vfile(char *f, ...)
long a, b, c, d;
{ {
if (Verbose > 2) { if (Verbose > 2) {
fprintf(stderr, f, a, b, c, d); va_list args;
va_start(args, f);
vfprintf(stderr, f, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
} }
@@ -406,16 +424,17 @@ long a, b, c, d;
char *rbmsg = char *rbmsg =
"%s ready. To begin transfer, type \"%s file ...\" to your modem program\r\n\n"; "%s ready. To begin transfer, type \"%s file ...\" to your modem program\r\n\n";
int
wcreceive(argc, argp) wcreceive(argc, argp)
char **argp; char **argp;
{ {
register c; int c;
if (Batch || argc==0) { if (Batch || argc==0) {
Crcflg=1; Crcflg=1;
if ( !Quiet) if ( !Quiet)
fprintf(stderr, rbmsg, Progname, Nozmodem?"sb":"sz"); fprintf(stderr, rbmsg, Progname, Nozmodem?"sb":"sz");
if (c=tryz()) { if ((c = tryz())) {
if (c == ZCOMPL) if (c == ZCOMPL)
return OK; return OK;
if (c == ERROR) if (c == ERROR)
@@ -471,10 +490,11 @@ fubar:
* Length is indeterminate as long as less than Blklen * Length is indeterminate as long as less than Blklen
* A null string represents no more files (YMODEM) * A null string represents no more files (YMODEM)
*/ */
int
wcrxpn(rpn) wcrxpn(rpn)
char *rpn; /* receive a pathname */ char *rpn; /* receive a pathname */
{ {
register c; int c;
#ifdef NFGVMIN #ifdef NFGVMIN
readline(readline_timeout); readline(readline_timeout);
@@ -504,7 +524,7 @@ et_tu:
* Adapted from CMODEM13.C, written by * Adapted from CMODEM13.C, written by
* Jack M. Wierda and Roderick W. Hart * Jack M. Wierda and Roderick W. Hart
*/ */
int
wcrx() wcrx()
{ {
register int sectnum, sectcurr; register int sectnum, sectcurr;
@@ -518,14 +538,14 @@ wcrx()
for (;;) { for (;;) {
sendline(sendchar); /* send it now, we're ready! */ sendline(sendchar); /* send it now, we're ready! */
Lleft=0; /* Do read next time ... */ Lleft=0; /* Do read next time ... */
sectcurr=wcgetsec(secbuf, (sectnum&0177)?50:130); sectcurr=wcgetsec(secbuf, (sectnum&0177)?50:130);
report(sectcurr); report(sectcurr);
if (sectcurr==(sectnum+1 &0377)) { if (sectcurr==(sectnum+1 &0377)) {
sectnum++; sectnum++;
cblklen = Bytesleft>Blklen ? Blklen:Bytesleft; cblklen = Bytesleft>Blklen ? Blklen:Bytesleft;
if (putsec(secbuf, cblklen)==ERROR) if (putsec(secbuf, cblklen)==ERROR)
return ERROR; return ERROR;
if ((Bytesleft-=cblklen) < 0) if ((Bytesleft -= cblklen) < 0)
Bytesleft = 0; Bytesleft = 0;
sendchar=ACK; sendchar=ACK;
} }
@@ -558,12 +578,12 @@ wcrx()
***************** NO ACK IS SENT IF SECTOR IS RECEIVED OK ************** ***************** NO ACK IS SENT IF SECTOR IS RECEIVED OK **************
* (Caller must do that when he is good and ready to get next sector) * (Caller must do that when he is good and ready to get next sector)
*/ */
int
wcgetsec(rxbuf, maxtime) wcgetsec(rxbuf, maxtime)
char *rxbuf; char *rxbuf;
int maxtime; int maxtime;
{ {
register checksum, wcj, firstch; int checksum, wcj, firstch;
register unsigned short oldcrc; register unsigned short oldcrc;
register char *p; register char *p;
int sectcurr; int sectcurr;
@@ -643,7 +663,7 @@ humbug:
sendline(Crcflg?WANTCRC:NAK); sendline(Crcflg?WANTCRC:NAK);
Lleft=0; /* Do read next time ... */ Lleft=0; /* Do read next time ... */
} else { } else {
maxtime=40; sendline(NAK); maxtime=40; sendline(NAK);
Lleft=0; /* Do read next time ... */ Lleft=0; /* Do read next time ... */
} }
} }
@@ -660,13 +680,14 @@ humbug:
* *
* timeout is in tenths of seconds * timeout is in tenths of seconds
*/ */
int
readline(timeout) readline(timeout)
unsigned int timeout; unsigned int timeout;
{ {
unsigned int n; unsigned int n;
register char *p; register char *p;
static char *cdq; /* pointer for removing chars from linbuf */ static char *cdq; /* pointer for removing chars from linbuf */
int c; int c;
if (--Lleft >= 0) { if (--Lleft >= 0) {
if (Verbose > 8) { if (Verbose > 8) {
@@ -719,11 +740,10 @@ unsigned int timeout;
return (*cdq++ & 0377); return (*cdq++ & 0377);
} }
/* /*
* Purge the modem input queue of all characters * Purge the modem input queue of all characters
*/ */
void
purgeline() purgeline()
{ {
Lleft = 0; Lleft = 0;
@@ -735,10 +755,10 @@ purgeline()
} }
#endif #endif
/* /*
* Process incoming file information header * Process incoming file information header
*/ */
int
procheader(name) procheader(name)
char *name; char *name;
{ {
@@ -853,6 +873,7 @@ char *name;
* it's because some required directory was not present, and if * it's because some required directory was not present, and if
* so, create all required dirs. * so, create all required dirs.
*/ */
int
make_dirs(pathname) make_dirs(pathname)
register char *pathname; register char *pathname;
{ {
@@ -948,9 +969,10 @@ int dmode;
* If not in binary mode, carriage returns, and all characters * If not in binary mode, carriage returns, and all characters
* starting with CPMEOF are discarded. * starting with CPMEOF are discarded.
*/ */
int
putsec(buf, n) putsec(buf, n)
char *buf; char *buf;
register n; int n;
{ {
register char *p; register char *p;
@@ -979,6 +1001,7 @@ register n;
/* /*
* Send a character to modem. Small is beautiful. * Send a character to modem. Small is beautiful.
*/ */
void
sendline(c) sendline(c)
{ {
char d; char d;
@@ -989,14 +1012,11 @@ sendline(c)
write(1, &d, 1); write(1, &d, 1);
} }
flushmo() {} void flushmo() {}
#endif #endif
/* make string s lower case */ /* make string s lower case */
void
uncaps(s) uncaps(s)
register char *s; register char *s;
{ {
@@ -1004,9 +1024,11 @@ register char *s;
if (isupper(*s)) if (isupper(*s))
*s = tolower(*s); *s = tolower(*s);
} }
/* /*
* IsAnyLower returns TRUE if string s has lower case letters. * IsAnyLower returns TRUE if string s has lower case letters.
*/ */
int
IsAnyLower(s) IsAnyLower(s)
register char *s; register char *s;
{ {
@@ -1042,17 +1064,20 @@ register char *s,*t;
* Log an error * Log an error
*/ */
/*VARARGS1*/ /*VARARGS1*/
zperr(s,p,u) void zperr(char *s, ...)
char *s, *p, *u;
{ {
if (Verbose <= 0) if (Verbose <= 0)
return; return;
va_list args;
va_start(args, s);
fprintf(stderr, "Retry %d: ", errors); fprintf(stderr, "Retry %d: ", errors);
fprintf(stderr, s, p, u); vfprintf(stderr, s, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
/* send cancel string to get the other end to shut up */ /* send cancel string to get the other end to shut up */
void
canit() canit()
{ {
static char canistr[] = { static char canistr[] = {
@@ -1063,13 +1088,13 @@ canit()
raw_wbuf(strlen(canistr), canistr); raw_wbuf(strlen(canistr), canistr);
purgeline(); purgeline();
#else #else
printf(canistr); fputs(canistr, stdout);
Lleft=0; /* Do read next time ... */ Lleft=0; /* Do read next time ... */
fflush(stdout); fflush(stdout);
#endif #endif
} }
void
report(sct) report(sct)
int sct; int sct;
{ {
@@ -1082,6 +1107,7 @@ int sct;
* If called as [-][dir/../]rzCOMMAND set the pipe flag * If called as [-][dir/../]rzCOMMAND set the pipe flag
* If called as rb use YMODEM protocol * If called as rb use YMODEM protocol
*/ */
void
chkinvok(s) chkinvok(s)
char *s; char *s;
{ {
@@ -1110,6 +1136,7 @@ char *s;
/* /*
* Totalitarian Communist pathname processing * Totalitarian Communist pathname processing
*/ */
void
checkpath(name) checkpath(name)
char *name; char *name;
{ {
@@ -1135,10 +1162,11 @@ char *name;
* Return ZFILE if Zmodem filename received, -1 on error, * Return ZFILE if Zmodem filename received, -1 on error,
* ZCOMPL if transaction finished, else 0 * ZCOMPL if transaction finished, else 0
*/ */
int
tryz() tryz()
{ {
register c, n; int c, n;
register cmdzack1flg; int cmdzack1flg;
if (Nozmodem) /* Check for "rb" program name */ if (Nozmodem) /* Check for "rb" program name */
return 0; return 0;
@@ -1238,9 +1266,10 @@ again:
/* /*
* Receive 1 or more files with ZMODEM protocol * Receive 1 or more files with ZMODEM protocol
*/ */
int
rzfiles() rzfiles()
{ {
register c; int c;
for (;;) { for (;;) {
switch (c = rzfile()) { switch (c = rzfile()) {
@@ -1265,11 +1294,12 @@ rzfiles()
/* /*
* Receive a file with ZMODEM protocol * Receive a file with ZMODEM protocol
* Assumes file name frame is in secbuf * Assumes file name frame is in secbuf
*/ */
int
rzfile() rzfile()
{ {
register c, n; int c, n;
long rxbytes; long rxbytes;
Eofseen=FALSE; Eofseen=FALSE;
@@ -1448,10 +1478,11 @@ moredata:
* Send a string to the modem, processing for \336 (sleep 1 sec) * Send a string to the modem, processing for \336 (sleep 1 sec)
* and \335 (break signal) * and \335 (break signal)
*/ */
void
zmputs(s) zmputs(s)
char *s; char *s;
{ {
register c; int c;
while (*s) { while (*s) {
switch (c = *s++) { switch (c = *s++) {
@@ -1468,10 +1499,9 @@ char *s;
/* /*
* Close the receive dataset, return OK or ERROR * Close the receive dataset, return OK or ERROR
*/ */
int
closeit() closeit()
{ {
time_t time();
#ifndef vax11c #ifndef vax11c
if (Topipe) { if (Topipe) {
if (pclose(fout)) { if (pclose(fout)) {
@@ -1486,9 +1516,14 @@ closeit()
} }
#ifndef vax11c #ifndef vax11c
if (Modtime) { if (Modtime) {
timep[0] = time(NULL); struct timeval tv[2];
timep[1] = Modtime;
utime(Pathname, timep); tv[0].tv_sec = time(NULL);
tv[0].tv_usec = 0;
tv[1].tv_sec = Modtime;
tv[1].tv_usec = 0;
utimes(Pathname, tv);
} }
#endif #endif
if ((Filemode&S_IFMT) == S_IFREG) if ((Filemode&S_IFMT) == S_IFREG)
@@ -1499,9 +1534,10 @@ closeit()
/* /*
* Ack a ZFIN packet, let byegones be byegones * Ack a ZFIN packet, let byegones be byegones
*/ */
void
ackbibi() ackbibi()
{ {
register n; int n;
vfile("ackbibi:"); vfile("ackbibi:");
Readnum = 1; Readnum = 1;
@@ -1523,11 +1559,10 @@ ackbibi()
} }
} }
/* /*
* Local console output simulation * Local console output simulation
*/ */
void
bttyout(c) bttyout(c)
{ {
if (Verbose || Fromcu) if (Verbose || Fromcu)
@@ -1538,6 +1573,7 @@ bttyout(c)
/* /*
* Strip leading ! if present, do shell escape. * Strip leading ! if present, do shell escape.
*/ */
int
sys2(s) sys2(s)
register char *s; register char *s;
{ {
@@ -1545,9 +1581,11 @@ register char *s;
++s; ++s;
return system(s); return system(s);
} }
/* /*
* Strip leading ! if present, do exec. * Strip leading ! if present, do exec.
*/ */
void
exec2(s) exec2(s)
register char *s; register char *s;
{ {

View File

@@ -1,7 +1,7 @@
#define VERSION "sz 3.07 2-02-90" #define VERSION "sz 3.07 2-02-90"
#define PUBDIR "/usr/spool/uucppublic" #define PUBDIR "/usr/spool/uucppublic"
/*% cc -compat -M2 -Ox -K -i -DTXBSIZE=16384 -DNFGVMIN -DREADCHECK sz.c -lx -o sz; size sz // % cc -compat -M2 -Ox -K -i -DTXBSIZE=16384 -DNFGVMIN -DREADCHECK sz.c -lx -o sz; size sz
/*% cc -Zi -DXX -DNFGVMIN -DREADCHECK sz.c -lx -o xsz; size xsz /*% cc -Zi -DXX -DNFGVMIN -DREADCHECK sz.c -lx -o xsz; size xsz
<-xtx-*> cc -Osal -DTXBSIZE=32768 -DSV sz.c -lx -o $B/sz; size $B/sz <-xtx-*> cc -Osal -DTXBSIZE=32768 -DSV sz.c -lx -o $B/sz; size $B/sz
@@ -94,8 +94,6 @@
long Thisflen; long Thisflen;
#endif #endif
char *substr(), *getenv();
#define LOGFILE "/tmp/szlog" #define LOGFILE "/tmp/szlog"
#define SS_NORMAL 0 #define SS_NORMAL 0
#include <stdio.h> #include <stdio.h>
@@ -106,10 +104,11 @@ char *substr(), *getenv();
#include <setjmp.h> #include <setjmp.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
extern int errno; #include <stdarg.h>
#define STATIC #define STATIC
#define sendline(c) putchar(c & 0377) #define sendline(c) putchar((unsigned char)(c))
#define xsendline(c) putchar(c) #define xsendline(c) putchar(c)
#define PATHLEN 256 #define PATHLEN 256
@@ -248,6 +247,25 @@ STATIC int Beenhereb4; /* How many times we've been ZRPOS'd same place */
STATIC jmp_buf tohere; /* For the interrupt on RX timeout */ STATIC jmp_buf tohere; /* For the interrupt on RX timeout */
STATIC jmp_buf intrjmp; /* For the interrupt on RX CAN */ STATIC jmp_buf intrjmp; /* For the interrupt on RX CAN */
static void canit(void);
static void chartest(int m);
static void countem(int argc, char **argv);
static int getzrxinit(void);
static int zsendcmd(char *buf, int blen);
static int wcsend(int argc, char *argp[]);
static int wcs(char *oname);
static int getnak(void);
static void saybibi(void);
static int wctxpn(char *name);
static int wctx(long flen);
static int zsendfile(char *buf, int blen);
static int wcputsec(char *buf, int sectnum, int cseclen);
static int filbuf(char *buf, int count);
static void purgeline(void);
static int sendzsinit(void);
static int zsendfdata(void);
static int getinsync(int flag);
#ifdef XARGSFILE #ifdef XARGSFILE
char * char *
mystrsave(s) mystrsave(s)
@@ -314,11 +332,12 @@ STATIC int Zrwindow = 1400; /* RX window size (controls garbage count) */
char *xargv[XARGSMAX+1]; char *xargv[XARGSMAX+1];
#endif #endif
int
main(argc, argv) main(argc, argv)
char *argv[]; char *argv[];
{ {
register char *cp; register char *cp;
register npats; int npats;
int dm; int dm;
char **patts; char **patts;
static char xXbuf[BUFSIZ]; static char xXbuf[BUFSIZ];
@@ -555,10 +574,11 @@ char *argv[];
/*NOTREACHED*/ /*NOTREACHED*/
} }
int
wcsend(argc, argp) wcsend(argc, argp)
char *argp[]; char *argp[];
{ {
register n; int n;
Crcflg=FALSE; Crcflg=FALSE;
firstsec=TRUE; firstsec=TRUE;
@@ -597,10 +617,11 @@ char *argp[];
return OK; return OK;
} }
int
wcs(oname) wcs(oname)
char *oname; char *oname;
{ {
register c; int c;
register char *p, *q; register char *p, *q;
#ifdef STAT #ifdef STAT
struct stat f; struct stat f;
@@ -706,6 +727,7 @@ char *oname;
* as provided by the Unix fstat call. * as provided by the Unix fstat call.
* N.B.: modifies the passed name, may extend it! * N.B.: modifies the passed name, may extend it!
*/ */
int
wctxpn(name) wctxpn(name)
char *name; char *name;
{ {
@@ -800,9 +822,10 @@ char *name;
return OK; return OK;
} }
int
getnak() getnak()
{ {
register firstch; int firstch;
Lastrx = 0; Lastrx = 0;
for (;;) { for (;;) {
@@ -835,7 +858,7 @@ getnak()
} }
} }
int
wctx(flen) wctx(flen)
long flen; long flen;
{ {
@@ -861,7 +884,7 @@ long flen;
for (;;) { for (;;) {
if (flen <= (charssent + 896L)) if (flen <= (charssent + 896L))
thisblklen = 128; thisblklen = 128;
if ( !filbuf(txbuf, thisblklen)) if (!filbuf(txbuf, thisblklen))
break; break;
if (wcputsec(txbuf, ++sectnum, thisblklen)==ERROR) if (wcputsec(txbuf, ++sectnum, thisblklen)==ERROR)
return ERROR; return ERROR;
@@ -884,12 +907,13 @@ long flen;
return OK; return OK;
} }
int
wcputsec(buf, sectnum, cseclen) wcputsec(buf, sectnum, cseclen)
char *buf; char *buf;
int sectnum; int sectnum;
int cseclen; /* data length of this sector to send */ int cseclen; /* data length of this sector to send */
{ {
register checksum, wcj; int checksum, wcj;
register char *cp; register char *cp;
unsigned oldcrc; unsigned oldcrc;
int firstch; int firstch;
@@ -964,10 +988,11 @@ cancan:
} }
/* fill buf with count chars padding with ^Z for CPM */ /* fill buf with count chars padding with ^Z for CPM */
int
filbuf(buf, count) filbuf(buf, count)
register char *buf; register char *buf;
{ {
register c, m; int c, m;
if ( !Ascii) { if ( !Ascii) {
m = read(fileno(in), buf, count); m = read(fileno(in), buf, count);
@@ -1001,6 +1026,7 @@ register char *buf;
} }
/* Fill buffer with blklen chars */ /* Fill buffer with blklen chars */
int
zfilbuf() zfilbuf()
{ {
int n; int n;
@@ -1044,6 +1070,7 @@ zfilbuf()
#ifdef TXBSIZE #ifdef TXBSIZE
/* Replacement for brain damaged fseek function. Returns 0==success */ /* Replacement for brain damaged fseek function. Returns 0==success */
int
fooseek(fptr, pos, whence) fooseek(fptr, pos, whence)
FILE *fptr; FILE *fptr;
long pos; long pos;
@@ -1134,14 +1161,14 @@ long pos;
#define fseek fooseek #define fseek fooseek
#endif #endif
/* VARARGS1 */ /* VARARGS1 */
vfile(f, a, b, c, d) void
char *f; vfile(char *f, ...)
long a, b, c, d;
{ {
if (Verbose > 2) { if (Verbose > 2) {
fprintf(stderr, f, a, b, c, d); va_list args;
va_start(args, f);
vfprintf(stderr, f, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
} }
@@ -1158,7 +1185,9 @@ alrm(sig)
* readline(timeout) reads character(s) from file descriptor 0 * readline(timeout) reads character(s) from file descriptor 0
* timeout is in tenths of seconds * timeout is in tenths of seconds
*/ */
int
readline(timeout) readline(timeout)
unsigned timeout;
{ {
register int c; register int c;
static char byt[1]; static char byt[1];
@@ -1184,12 +1213,13 @@ readline(timeout)
return (byt[0]&0377); return (byt[0]&0377);
} }
void
flushmo() flushmo()
{ {
fflush(stdout); fflush(stdout);
} }
void
purgeline() purgeline()
{ {
#ifdef USG #ifdef USG
@@ -1202,6 +1232,7 @@ purgeline()
#endif #endif
/* send cancel string to get the other end to shut up */ /* send cancel string to get the other end to shut up */
void
canit() canit()
{ {
static char canistr[] = { static char canistr[] = {
@@ -1212,7 +1243,7 @@ canit()
raw_wbuf(strlen(canistr), canistr); raw_wbuf(strlen(canistr), canistr);
purgeline(); purgeline();
#else #else
printf(canistr); fputs(canistr, stdout);
fflush(stdout); fflush(stdout);
#endif #endif
} }
@@ -1222,13 +1253,16 @@ canit()
* Log an error * Log an error
*/ */
/*VARARGS1*/ /*VARARGS1*/
zperr(s,p,u) void
char *s, *p, *u; zperr(char *s, ...)
{ {
if (Verbose <= 0) if (Verbose <= 0)
return; return;
va_list args;
va_start(args, s);
fprintf(stderr, "Retry %d: ", errors); fprintf(stderr, "Retry %d: ", errors);
fprintf(stderr, s, p, u); fprintf(stderr, s, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
@@ -1307,6 +1341,7 @@ char *babble[] = {
"" ""
}; };
void
usage() usage()
{ {
char **pp; char **pp;
@@ -1323,9 +1358,10 @@ usage()
/* /*
* Get the receiver's init parameters * Get the receiver's init parameters
*/ */
int
getzrxinit() getzrxinit()
{ {
register n; int n;
#ifdef STAT #ifdef STAT
struct stat f; struct stat f;
#endif #endif
@@ -1462,9 +1498,10 @@ getzrxinit()
} }
/* Send send-init information */ /* Send send-init information */
int
sendzsinit() sendzsinit()
{ {
register c; int c;
if (Myattn[0] == '\0' && (!Zctlesc || (Rxflags & TESCCTL))) if (Myattn[0] == '\0' && (!Zctlesc || (Rxflags & TESCCTL)))
return OK; return OK;
@@ -1495,10 +1532,11 @@ sendzsinit()
} }
/* Send file name and related info */ /* Send file name and related info */
int
zsendfile(buf, blen) zsendfile(buf, blen)
char *buf; char *buf;
{ {
register c; int c;
register UNSL long crc; register UNSL long crc;
long lastcrcrq = -1; long lastcrcrq = -1;
char *p; char *p;
@@ -1585,10 +1623,11 @@ again:
} }
/* Send the data in the file */ /* Send the data in the file */
int
zsendfdata() zsendfdata()
{ {
register c, e, n; int c, e, n;
register newcnt; int newcnt;
register long tcount = 0; register long tcount = 0;
int junkcount; /* Counts garbage chars received by TX */ int junkcount; /* Counts garbage chars received by TX */
static int tleft = 6; /* Counter for test mode */ static int tleft = 6; /* Counter for test mode */
@@ -1656,7 +1695,7 @@ gotack:
if (Test) { if (Test) {
if ( --tleft) if ( --tleft)
while (tcount < 20000) { while (tcount < 20000) {
printf(qbf); fflush(stdout); fputs(qbf, stdout); fflush(stdout);
tcount += strlen(qbf); tcount += strlen(qbf);
#ifdef READCHECK #ifdef READCHECK
while (rdchk(0)) { while (rdchk(0)) {
@@ -1787,9 +1826,10 @@ gotack:
/* /*
* Respond to receiver's complaint, get back in sync with receiver * Respond to receiver's complaint, get back in sync with receiver
*/ */
int
getinsync(flag) getinsync(flag)
{ {
register c; int c;
for (;;) { for (;;) {
if (Test) { if (Test) {
@@ -1839,8 +1879,8 @@ getinsync(flag)
} }
} }
/* Say "bibi" to the receiver, try to do it cleanly */ /* Say "bibi" to the receiver, try to do it cleanly */
void
saybibi() saybibi()
{ {
for (;;) { for (;;) {
@@ -1857,6 +1897,7 @@ saybibi()
} }
/* Local screen character display function */ /* Local screen character display function */
void
bttyout(c) bttyout(c)
{ {
if (Verbose) if (Verbose)
@@ -1864,10 +1905,11 @@ bttyout(c)
} }
/* Send command and related info */ /* Send command and related info */
int
zsendcmd(buf, blen) zsendcmd(buf, blen)
char *buf; char *buf;
{ {
register c; int c;
long cmdnum; long cmdnum;
#ifdef GENIE #ifdef GENIE
@@ -1925,6 +1967,7 @@ listen:
/* /*
* If called as sb use YMODEM protocol * If called as sb use YMODEM protocol
*/ */
void
chkinvok(s) chkinvok(s)
char *s; char *s;
{ {
@@ -1949,10 +1992,11 @@ char *s;
} }
#ifdef STAT #ifdef STAT
void
countem(argc, argv) countem(argc, argv)
register char **argv; register char **argv;
{ {
register c; int c;
struct stat f; struct stat f;
for (Totalleft = 0, Filesleft = 0; --argc >=0; ++argv) { for (Totalleft = 0, Filesleft = 0; --argc >=0; ++argv) {
@@ -1975,10 +2019,11 @@ register char **argv;
Filesleft, Totalleft); Filesleft, Totalleft);
} }
#else #else
void
countem(argc, argv) countem(argc, argv)
register char **argv; register char **argv;
{ {
register c; int c;
register char *p; register char *p;
long size; long size;
@@ -2015,9 +2060,10 @@ register char **argv;
} }
#endif #endif
void
chartest(m) chartest(m)
{ {
register n; int n;
mode(m); mode(m);
printf("\r\n\nCharacter Transparency Test Mode %d\r\n", m); printf("\r\n\nCharacter Transparency Test Mode %d\r\n", m);

View File

@@ -129,7 +129,7 @@ char *Rxcdq = Rxlbuf; /* pointer for removing chars from Rxlbuf */
* *
* timeout is in tenths of seconds * timeout is in tenths of seconds
*/ */
int
readline(timeout) readline(timeout)
int timeout; int timeout;
{ {
@@ -224,7 +224,7 @@ flushmoc()
/* /*
* Wait for the modem line outbuffer to drain * Wait for the modem line outbuffer to drain
*/ */
flushmo() void flushmo()
{ {
fflush(stdout); fflush(stdout);
flushmoc(); flushmoc();

View File

@@ -11,13 +11,13 @@
* zrdata(buf, len) receive data * zrdata(buf, len) receive data
* stohdr(pos) store position data in Txhdr * stohdr(pos) store position data in Txhdr
* long rclhdr(hdr) recover position offset from header * long rclhdr(hdr) recover position offset from header
* *
* *
* This version implements numerous enhancements including ZMODEM * This version implements numerous enhancements including ZMODEM
* Run Length Encoding and variable length headers. These * Run Length Encoding and variable length headers. These
* features were not funded by the original Telenet development * features were not funded by the original Telenet development
* contract. * contract.
* *
* This software may be freely used for non commercial and * This software may be freely used for non commercial and
* educational (didactic only) purposes. This software may also * educational (didactic only) purposes. This software may also
* be freely used to support file transfer operations to or from * be freely used to support file transfer operations to or from
@@ -25,7 +25,7 @@
* part or all of this software must be provided in source form * part or all of this software must be provided in source form
* with this notice intact except by written permission from Omen * with this notice intact except by written permission from Omen
* Technology Incorporated. * Technology Incorporated.
* *
* Use of this software for commercial or administrative purposes * Use of this software for commercial or administrative purposes
* except when exclusively limited to interfacing Omen Technology * except when exclusively limited to interfacing Omen Technology
* products requires a per port license payment of $20.00 US per * products requires a per port license payment of $20.00 US per
@@ -75,8 +75,8 @@ int Znulls; /* Number of nulls to send at beginning of ZDATA hdr */
char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */ char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */
char *Altcan; /* Alternate canit string */ char *Altcan; /* Alternate canit string */
static lastsent; /* Last char we sent */ static int lastsent; /* Last char we sent */
static Not8bit; /* Seven bits seen on header */ static int Not8bit; /* Seven bits seen on header */
static char *frametypes[] = { static char *frametypes[] = {
"No Response to Error Correction Request", /* -4 */ "No Response to Error Correction Request", /* -4 */
@@ -111,7 +111,20 @@ static char *frametypes[] = {
static char badcrc[] = "Bad CRC"; static char badcrc[] = "Bad CRC";
static void zsbh32(int len, char *hdr, int type, int flavour);
static void zputhex(int c);
static void zsda32(char *buf, int length, int frameend);
static int zrdat32(char *buf, int length);
static void garbitch(void);
static int noxrd7(void);
static int zrbhd32(char *hdr);
static int zrbhdr(char *hdr);
static int zgethex(void);
static int zrhhdr(char *hdr);
static int zgeth1(void);
/* Send ZMODEM binary header hdr of type type */ /* Send ZMODEM binary header hdr of type type */
void
zsbhdr(len, type, hdr) zsbhdr(len, type, hdr)
register char *hdr; register char *hdr;
{ {
@@ -156,16 +169,16 @@ register char *hdr;
flushmo(); flushmo();
} }
/* Send ZMODEM binary header hdr of type type */ /* Send ZMODEM binary header hdr of type type */
void
zsbh32(len, hdr, type, flavour) zsbh32(len, hdr, type, flavour)
register char *hdr; register char *hdr;
{ {
register int n; register int n;
register UNSL long crc; register UNSL long crc;
xsendline(flavour); xsendline(flavour);
if (Usevhdrs) if (Usevhdrs)
zsendline(len); zsendline(len);
zsendline(type); zsendline(type);
crc = 0xFFFFFFFFL; crc = UPDC32(type, crc); crc = 0xFFFFFFFFL; crc = UPDC32(type, crc);
@@ -182,6 +195,7 @@ register char *hdr;
} }
/* Send ZMODEM HEX header hdr of type type */ /* Send ZMODEM HEX header hdr of type type */
void
zshhdr(len, type, hdr) zshhdr(len, type, hdr)
register char *hdr; register char *hdr;
{ {
@@ -223,6 +237,8 @@ register char *hdr;
* Send binary array buf of length length, with ending ZDLE sequence frameend * Send binary array buf of length length, with ending ZDLE sequence frameend
*/ */
static char *Zendnames[] = { "ZCRCE", "ZCRCG", "ZCRCQ", "ZCRCW"}; static char *Zendnames[] = { "ZCRCE", "ZCRCG", "ZCRCQ", "ZCRCW"};
void
zsdata(buf, length, frameend) zsdata(buf, length, frameend)
register char *buf; register char *buf;
{ {
@@ -252,6 +268,7 @@ register char *buf;
} }
} }
void
zsda32(buf, length, frameend) zsda32(buf, length, frameend)
register char *buf; register char *buf;
{ {
@@ -281,6 +298,7 @@ register char *buf;
* and CRC. Returns the ending character or error code. * and CRC. Returns the ending character or error code.
* NB: On errors may store length+1 bytes! * NB: On errors may store length+1 bytes!
*/ */
int
zrdata(buf, length) zrdata(buf, length)
register char *buf; register char *buf;
{ {
@@ -336,13 +354,14 @@ crcfoo:
crc = updcrc(c, crc); crc = updcrc(c, crc);
} }
#ifdef DSZ #ifdef DSZ
garbitch(); garbitch();
#else #else
zperr("Data subpacket too long"); zperr("Data subpacket too long");
#endif #endif
return ERROR; return ERROR;
} }
int
zrdat32(buf, length) zrdat32(buf, length)
register char *buf; register char *buf;
{ {
@@ -401,6 +420,7 @@ crcfoo:
return ERROR; return ERROR;
} }
void
garbitch() garbitch()
{ {
zperr("Garbled data subpacket"); zperr("Garbled data subpacket");
@@ -418,6 +438,7 @@ garbitch()
* Otherwise return negative on error. * Otherwise return negative on error.
* Return ERROR instantly if ZCRCW sequence, for fast error recovery. * Return ERROR instantly if ZCRCW sequence, for fast error recovery.
*/ */
int
zgethdr(hdr, eflag) zgethdr(hdr, eflag)
char *hdr; char *hdr;
{ {
@@ -583,6 +604,7 @@ fifi:
} }
/* Receive a binary style header (type and position) */ /* Receive a binary style header (type and position) */
int
zrbhdr(hdr) zrbhdr(hdr)
register char *hdr; register char *hdr;
{ {
@@ -618,6 +640,7 @@ register char *hdr;
} }
/* Receive a binary style header (type and position) with 32 bit FCS */ /* Receive a binary style header (type and position) with 32 bit FCS */
int
zrbhd32(hdr) zrbhd32(hdr)
register char *hdr; register char *hdr;
{ {
@@ -660,8 +683,8 @@ register char *hdr;
return Rxtype; return Rxtype;
} }
/* Receive a hex style header (type and position) */ /* Receive a hex style header (type and position) */
int
zrhhdr(hdr) zrhhdr(hdr)
char *hdr; char *hdr;
{ {
@@ -694,7 +717,7 @@ char *hdr;
Not8bit = c; Not8bit = c;
/* **** FALL THRU TO **** */ /* **** FALL THRU TO **** */
case 015: case 015:
/* Throw away possible cr/lf */ /* Throw away possible cr/lf */
switch (c = readline(2)) { switch (c = readline(2)) {
case 012: case 012:
Not8bit |= c; Not8bit |= c;
@@ -710,6 +733,7 @@ char *hdr;
} }
/* Send a byte as two hex digits */ /* Send a byte as two hex digits */
void
zputhex(c) zputhex(c)
register int c; register int c;
{ {
@@ -727,6 +751,7 @@ register int c;
* Send character c with ZMODEM escape sequence encoding. * Send character c with ZMODEM escape sequence encoding.
* Escape XON, XOFF. Escape CR following @ (Telenet net escape) * Escape XON, XOFF. Escape CR following @ (Telenet net escape)
*/ */
void
zsendline(c) zsendline(c)
{ {
@@ -766,6 +791,7 @@ zsendline(c)
} }
/* Decode two lower case hex digits into an 8 bit byte value */ /* Decode two lower case hex digits into an 8 bit byte value */
int
zgethex() zgethex()
{ {
register int c; register int c;
@@ -777,6 +803,8 @@ zgethex()
#endif #endif
return c; return c;
} }
int
zgeth1() zgeth1()
{ {
register int c, n; register int c, n;
@@ -803,6 +831,7 @@ zgeth1()
* Read a byte, checking for ZMODEM escape encoding * Read a byte, checking for ZMODEM escape encoding
* including CAN*5 which represents a quick abort * including CAN*5 which represents a quick abort
*/ */
int
zdlread() zdlread()
{ {
register int c; register int c;
@@ -868,6 +897,7 @@ again2:
* Read a character from the modem line with timeout. * Read a character from the modem line with timeout.
* Eat parity, XON and XOFF characters. * Eat parity, XON and XOFF characters.
*/ */
int
noxrd7() noxrd7()
{ {
register int c; register int c;
@@ -891,6 +921,7 @@ noxrd7()
} }
/* Store long integer pos in Txhdr */ /* Store long integer pos in Txhdr */
void
stohdr(pos) stohdr(pos)
long pos; long pos;
{ {

View File

@@ -119,17 +119,17 @@
long rclhdr(); long rclhdr();
/* Globals used by ZMODEM functions */ /* Globals used by ZMODEM functions */
extern Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */ extern int Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */
extern Rxtype; /* Type of header received */ extern int Rxtype; /* Type of header received */
extern Rxcount; /* Count of data bytes received */ extern int Rxcount; /* Count of data bytes received */
extern Rxtimeout; /* Tenths of seconds to wait for something */ extern int Rxtimeout; /* Tenths of seconds to wait for something */
extern long Rxpos; /* Received file position */ extern long Rxpos; /* Received file position */
extern long Txpos; /* Transmitted file position */ extern long Txpos; /* Transmitted file position */
extern Txfcs32; /* TURE means send binary frames with 32 bit FCS */ extern int Txfcs32; /* TURE means send binary frames with 32 bit FCS */
extern Crc32t; /* Display flag indicating 32 bit CRC being sent */ extern int Crc32t; /* Display flag indicating 32 bit CRC being sent */
extern Crc32; /* Display flag indicating 32 bit CRC being received */ extern int Crc32; /* Display flag indicating 32 bit CRC being received */
extern Znulls; /* Number of nulls to send at beginning of ZDATA hdr */ extern int Znulls; /* Number of nulls to send at beginning of ZDATA hdr */
extern char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */ extern char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */
extern char *Altcan; /* Alternate canit string */ extern char *Altcan; /* Alternate canit string */
/* End of ZMODEM.H */ /* End of ZMODEM.H */

View File

@@ -3,11 +3,11 @@
* Copyright 1988, 1989 Omen Technology Inc All Rights Reserved * Copyright 1988, 1989 Omen Technology Inc All Rights Reserved
* *
* *
* *
* This module implements ZMODEM Run Length Encoding, an * This module implements ZMODEM Run Length Encoding, an
* extension that was not funded by the original Telenet * extension that was not funded by the original Telenet
* development contract. * development contract.
* *
* This software may be freely used for non commercial and * This software may be freely used for non commercial and
* educational (didactic only) purposes. This software may also * educational (didactic only) purposes. This software may also
* be freely used to support file transfer operations to or from * be freely used to support file transfer operations to or from
@@ -15,7 +15,7 @@
* part or all of this software must be provided in source form * part or all of this software must be provided in source form
* with this notice intact except by written permission from Omen * with this notice intact except by written permission from Omen
* Technology Incorporated. * Technology Incorporated.
* *
* Use of this software for commercial or administrative purposes * Use of this software for commercial or administrative purposes
* except when exclusively limited to interfacing Omen Technology * except when exclusively limited to interfacing Omen Technology
* products requires a per port license payment of $20.00 US per * products requires a per port license payment of $20.00 US per
@@ -38,6 +38,7 @@
*/ */
/* Send data subpacket RLE encoded with 32 bit FCS */ /* Send data subpacket RLE encoded with 32 bit FCS */
void
zsdar32(buf, length, frameend) zsdar32(buf, length, frameend)
char *buf; char *buf;
{ {
@@ -95,8 +96,8 @@ char *buf;
} }
} }
/* Receive data subpacket RLE encoded with 32 bit FCS */ /* Receive data subpacket RLE encoded with 32 bit FCS */
int
zrdatr32(buf, length) zrdatr32(buf, length)
register char *buf; register char *buf;
{ {
@@ -182,4 +183,3 @@ badpkt:
zperr("Data subpacket too long"); zperr("Data subpacket too long");
return ERROR; return ERROR;
} }

View File

@@ -96,9 +96,10 @@ struct stat
#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE) #define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
#else #else
int chmod (const char *path, mode_t mode); int chmod(const char *path, mode_t mode);
int fchmod (int fd, mode_t mode); int fchmod(int fd, mode_t mode);
mode_t umask (mode_t cmask); mode_t umask(mode_t cmask);
int mkdir(const char *path, mode_t mode);
#endif #endif