From: Melon Date: Mon, 27 Jan 2014 17:13:42 +0000 (+0100) Subject: zmodem: K&R -> ANSI C function declaration X-Git-Tag: v3.3.0~645 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/index.css?a=commitdiff_plain;h=refs%2Fchanges%2F08%2F1208%2F4;p=minix.git zmodem: K&R -> ANSI C function declaration Change-Id: Id3dbd2e39563cb399da9ad86bdd0024676f9d728 --- diff --git a/commands/zmodem/crctab.c b/commands/zmodem/crctab.c index 6811b3daf..71863b218 100644 --- a/commands/zmodem/crctab.c +++ b/commands/zmodem/crctab.c @@ -126,8 +126,7 @@ static long cr3tab[] = { /* CRC polynomial 0xedb88320 */ #ifdef NFGM long -UPDC32(b, c) -long c; +UPDC32(int b, long c) { return (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF)); } diff --git a/commands/zmodem/rbsb.c b/commands/zmodem/rbsb.c index 6c93bdd82..c8f6fbcd0 100644 --- a/commands/zmodem/rbsb.c +++ b/commands/zmodem/rbsb.c @@ -107,7 +107,7 @@ int Twostop; /* Use two stop bits */ /* * Return non 0 iff something to read from io descriptor f */ -int rdchk(f) +int rdchk(int f) { static long lf; @@ -138,8 +138,7 @@ int rdchk(f) static unsigned -getspeed(code) -int code; +getspeed(int code) { register int n; diff --git a/commands/zmodem/rz.c b/commands/zmodem/rz.c index 9acbf6c39..e137c7bf9 100644 --- a/commands/zmodem/rz.c +++ b/commands/zmodem/rz.c @@ -84,6 +84,7 @@ extern int errno; #include #include #include +#include #define OK 0 #define FALSE 0 @@ -125,6 +126,10 @@ void ackbibi(void); void bttyout(int c ); int sys2(char *s ); void exec2(char *s ); +/* + * Debugging information output interface routine + */ +void vfile(const char *s, ...); /* * Max value for HOWMANY is 255. @@ -242,8 +247,7 @@ int sig; } /* called by signal interrupt or terminate to clean things up */ -void bibi(n) -int n; +void bibi(int n) { if (Zmodem) zmputs(Attn); @@ -253,9 +257,7 @@ int n; exit(128+n); } -int main(argc, argv) -int argc; -char *argv[]; +int main(int argc, char *argv[]) { register char *cp; register int npats; @@ -394,16 +396,14 @@ int usage() fprintf(stderr, "\t\t\042The High Reliability Software\042\n"); exit(SS_NORMAL); } -/* - * Debugging information output interface routine - */ -/* VARARGS1 */ -void vfile(f, a, b, c) -register char *f,*a,*b,*c; +void vfile(const char *string, ...) { if (Verbose > 2) { - fprintf(stderr, f, a, b, c); + va_list args; + va_start(args, string); + vfprintf(stderr, string, args); + va_end(args); fprintf(stderr, "\n"); } } @@ -415,9 +415,7 @@ register char *f,*a,*b,*c; char *rbmsg = "%s ready. To begin transfer, type \"%s file ...\" to your modem program\r\n\n"; -int wcreceive(argc, argp) -int argc; -char **argp; +int wcreceive(int argc, char **argp) { register int c; @@ -479,9 +477,10 @@ fubar: * Fetch a pathname from the other end as a C ctyle ASCIZ string. * Length is indeterminate as long as less than Blklen * A null string represents no more files (YMODEM) + * + * Parameter rpn is for receiving a pathname */ -int wcrxpn(rpn) -char *rpn; /* receive a pathname */ +int wcrxpn(char *rpn) { register int c; @@ -567,9 +566,7 @@ int wcrx() * (Caller must do that when he is good and ready to get next sector) */ -int wcgetsec(rxbuf, maxtime) -char *rxbuf; -int maxtime; +int wcgetsec(char *rxbuf, int maxtime) { register int checksum, wcj, firstch; register unsigned short oldcrc; @@ -668,8 +665,7 @@ humbug: * * timeout is in tenths of seconds */ -int readline(timeout) -int timeout; +int readline(int timeout) { register int n; static char *cdq; /* pointer for removing chars from linbuf */ @@ -730,8 +726,7 @@ void purgeline() /* * Process incoming file information header */ -int procheader(name) -char *name; +int procheader(char *name) { register char *openmode, *p; @@ -846,8 +841,7 @@ char *name; * it's because some required directory was not present, and if * so, create all required dirs. */ -int make_dirs(pathname) -register char *pathname; +int make_dirs(char *pathname) { register char *p; /* Points into path */ int madeone = 0; /* Did we do anything yet? */ @@ -890,9 +884,7 @@ register char *pathname; /* * Make a directory. Compatible with the mkdir() system call on 4.2BSD. */ -int makedir(dpath, dmode) -char *dpath; -int dmode; +int makedir(char *dpath, int dmode) { int cpid, status; struct stat statbuf; @@ -941,9 +933,7 @@ int dmode; * If not in binary mode, carriage returns, and all characters * starting with CPMEOF are discarded. */ -int putsec(buf, n) -char *buf; -register int n; +int putsec(char *buf, int n) { register char *p; @@ -972,8 +962,7 @@ register int n; /* * Send a character to modem. Small is beautiful. */ -void sendline(c) -int c; +void sendline(int c) { char d; @@ -991,8 +980,7 @@ void flushmo() {} /* make string s lower case */ -void uncaps(s) -register char *s; +void uncaps(char *s) { for ( ; *s; ++s) if (isupper(*s)) @@ -1001,8 +989,7 @@ register char *s; /* * IsAnyLower returns TRUE if string s has lower case letters. */ -int IsAnyLower(s) -register char *s; +int IsAnyLower(char *s) { for ( ; *s; ++s) if (islower(*s)) @@ -1015,8 +1002,7 @@ register char *s; * returns pointer to token within string if found, NULL otherwise */ char * -substr(s, t) -register char *s,*t; +substr(char *s, char *t) { register char *ss,*tt; /* search for first char of token */ @@ -1036,8 +1022,7 @@ register char *s,*t; * Log an error */ /*VARARGS1*/ -void zperr(s,p,u) -char *s, *p, *u; +void zperr(char *s, char *p, char *u) { if (Verbose <= 0) return; @@ -1064,8 +1049,7 @@ void canit() } -void report(sct) -int sct; +void report(int sct) { if (Verbose>1) fprintf(stderr,"%03d%c",sct,sct%10? ' ' : '\r'); @@ -1077,8 +1061,7 @@ int sct; * If called as [-][dir/../]rzCOMMAND set the pipe flag * If called as rb use YMODEM protocol */ -void chkinvok(s) -char *s; +void chkinvok(char *s) { register char *p; @@ -1106,8 +1089,7 @@ char *s; /* * Totalitarian Communist pathname processing */ -void checkpath(name) -char *name; +void checkpath(char *name) { if (Restricted) { if (fopen(name, "r") != NULL) { @@ -1436,8 +1418,7 @@ moredata: * Send a string to the modem, processing for \336 (sleep 1 sec) * and \335 (break signal) */ -void zmputs(s) -char *s; +void zmputs(char *s) { register int c; @@ -1516,8 +1497,7 @@ void ackbibi() /* * Local console output simulation */ -void bttyout(c) -int c; +void bttyout(int c) { if (Verbose || Fromcu) putc(c, stderr); @@ -1527,8 +1507,7 @@ int c; /* * Strip leading ! if present, do shell escape. */ -int sys2(s) -register char *s; +int sys2(char *s) { if (*s == '!') ++s; @@ -1537,8 +1516,7 @@ register char *s; /* * Strip leading ! if present, do exec. */ -void exec2(s) -register char *s; +void exec2(char *s) { if (*s == '!') ++s; diff --git a/commands/zmodem/sz.c b/commands/zmodem/sz.c index 167244ac9..2724388ab 100644 --- a/commands/zmodem/sz.c +++ b/commands/zmodem/sz.c @@ -95,6 +95,7 @@ extern int errno; #include #include #include +#include #define PATHLEN 256 #define OK 0 @@ -252,8 +253,7 @@ void countem(int argc , char **argv ); void chartest(int m ); /* called by signal interrupt or terminate to clean things up */ -void bibi(n) -int n; +void bibi(int n) { canit(); fflush(stdout); mode(0); fprintf(stderr, "sz: caught signal %d; exiting\n", n); @@ -265,8 +265,7 @@ int n; exit(128+n); } /* Called when ZMODEM gets an interrupt (^X) */ -void onintr(sig) -int sig; +void onintr(int sig) { signal(SIGINT, SIG_IGN); longjmp(intrjmp, -1); @@ -279,9 +278,7 @@ int Zrwindow = 1400; /* RX window size (controls garbage count) */ #include "zm.c" -int main(argc, argv) -int argc; -char *argv[]; +int main(int argc, char *argv[]) { register char *cp; register int npats; @@ -490,9 +487,7 @@ char *argv[]; /*NOTREACHED*/ } -int wcsend(argc, argp) -int argc; -char *argp[]; +int wcsend(int argc, char *argp[]) { register int n; @@ -530,8 +525,7 @@ char *argp[]; return OK; } -int wcs(oname) -char *oname; +int wcs(char *oname) { register int c; register char *p; @@ -593,8 +587,7 @@ char *oname; * as provided by the Unix fstat call. * N.B.: modifies the passed name, may extend it! */ -int wctxpn(name) -char *name; +int wctxpn(char *name) { register char *p, *q; char name2[PATHLEN]; @@ -695,8 +688,7 @@ int getnak() } -int wctx(flen) -long flen; +int wctx(long flen) { register int thisblklen; register int sectnum, attempts, firstch; @@ -742,11 +734,10 @@ long flen; else return OK; } - -int wcputsec(buf, sectnum, cseclen) -char *buf; -int sectnum; -int cseclen; /* data length of this sector to send */ +/** + * @param cseclen :data length of this sector to send + */ +int wcputsec(char *buf, int sectnum, int cseclen) { register int checksum, wcj; register char *cp; @@ -822,9 +813,7 @@ cancan: } /* fill buf with count chars padding with ^Z for CPM */ -int filbuf(buf, count) -register char *buf; -int count; +int filbuf(char *buf, int count) { register int c, m; @@ -888,9 +877,7 @@ int zfilbuf() } #ifdef TXBSIZE -int fooseek(fptr, pos, whence) -FILE *fptr; -long pos; +int fooseek(FILE *fptr, long pos, int whence) { int m, n; @@ -947,20 +934,19 @@ long pos; #define fseek fooseek #endif - -/* VARARGS1 */ -void vfile(f, a, b, c) -register char *f,*a,*b,*c; +void vfile(const char *string, ...) { if (Verbose > 2) { - fprintf(stderr, f, a, b, c); + va_list args; + va_start(args, string); + vfprintf(stderr, string, args); + va_end(args); fprintf(stderr, "\n"); } } -void alrm(sig) -int sig; +void alrm(int sig) { longjmp(tohere, -1); } @@ -971,8 +957,7 @@ int sig; * readline(timeout) reads character(s) from file descriptor 0 * timeout is in tenths of seconds */ -int readline(timeout) -int timeout; +int readline(int timeout) { register int c; static char byt[1]; @@ -1035,8 +1020,7 @@ void canit() * Log an error */ /*VARARGS1*/ -void zperr(s,p,u) -char *s, *p, *u; +void zperr(char *s, char *p, char *u) { if (Verbose <= 0) return; @@ -1050,8 +1034,7 @@ char *s, *p, *u; * returns pointer to token within string if found, NULL otherwise */ char * -substr(s, t) -register char *s,*t; +substr(char *s, char *t) { register char *ss,*tt; /* search for first char of token */ @@ -1266,9 +1249,7 @@ int sendzsinit() } /* Send file name and related info */ -int zsendfile(buf, blen) -char *buf; -int blen; +int zsendfile(char *buf, int blen) { register int c; register UNSL long crc; @@ -1530,8 +1511,7 @@ gotack: /* * Respond to receiver's complaint, get back in sync with receiver */ -int getinsync(flag) -int flag; +int getinsync(int flag) { register int c; @@ -1599,17 +1579,14 @@ void saybibi() } /* Local screen character display function */ -void bttyout(c) -int c; +void bttyout(int c) { if (Verbose) putc(c, stderr); } /* Send command and related info */ -int zsendcmd(buf, blen) -char *buf; -int blen; +int zsendcmd(char *buf, int blen) { register int c; long cmdnum; @@ -1663,8 +1640,7 @@ listen: /* * If called as sb use YMODEM protocol */ -void chkinvok(s) -char *s; +void chkinvok(char *s) { #ifdef vax11c Progname = "sz"; @@ -1690,9 +1666,7 @@ char *s; #endif } -void countem(argc, argv) -int argc; -register char **argv; +void countem(int argc, char **argv) { register int c; struct stat f; @@ -1717,8 +1691,7 @@ register char **argv; Filesleft, Totalleft); } -void chartest(m) -int m; +void chartest(int m) { register int n; diff --git a/commands/zmodem/zm.c b/commands/zmodem/zm.c index 797e237eb..56ced1a65 100644 --- a/commands/zmodem/zm.c +++ b/commands/zmodem/zm.c @@ -73,9 +73,7 @@ static char *frametypes[] = { static char badcrc[] = "Bad CRC"; /* Send ZMODEM binary header hdr of type type */ -void zsbhdr(type, hdr) -int type; -register char *hdr; +void zsbhdr(int type, char *hdr) { register int n; register unsigned short crc; @@ -106,9 +104,7 @@ register char *hdr; /* Send ZMODEM binary header hdr of type type */ -void zsbh32(hdr, type) -register char *hdr; -int type; +void zsbh32(char *hdr, int type) { register int n; register UNSL long crc; @@ -128,9 +124,7 @@ int type; } /* Send ZMODEM HEX header hdr of type type */ -void zshhdr(type, hdr) -int type; -register char *hdr; +void zshhdr(int type, char *hdr) { register int n; register unsigned short crc; @@ -162,10 +156,7 @@ register char *hdr; */ static char *Zendnames[] = { "ZCRCE", "ZCRCG", "ZCRCQ", "ZCRCW"}; -void zsdata(buf, length, frameend) -register char *buf; -int length; -int frameend; +void zsdata(char *buf, int length, int frameend) { register unsigned short crc; @@ -188,10 +179,7 @@ int frameend; } } -void zsda32(buf, length, frameend) -register char *buf; -int length; -int frameend; +void zsda32(char *buf, int length, int frameend) { register int c; register UNSL long crc; @@ -219,9 +207,7 @@ int frameend; * and CRC. Returns the ending character or error code. * NB: On errors may store length+1 bytes! */ -int zrdata(buf, length) -register char *buf; -int length; +int zrdata(char *buf, int length) { register int c; register unsigned short crc; @@ -273,9 +259,7 @@ crcfoo: return ERROR; } -int zrdat32(buf, length) -register char *buf; -int length; +int zrdat32(char *buf, int length) { register int c; register UNSL long crc; @@ -342,9 +326,7 @@ crcfoo: * Otherwise return negative on error. * Return ERROR instantly if ZCRCW sequence, for fast error recovery. */ -int zgethdr(hdr, eflag) -char *hdr; -int eflag; +int zgethdr(char *hdr, int eflag) { register int c, n, cancount; @@ -461,8 +443,7 @@ fifi: } /* Receive a binary style header (type and position) */ -int zrbhdr(hdr) -register char *hdr; +int zrbhdr(char *hdr) { register int c, n; register unsigned short crc; @@ -496,8 +477,7 @@ register char *hdr; } /* Receive a binary style header (type and position) with 32 bit FCS */ -int zrbhdr32(hdr) -register char *hdr; +int zrbhdr32(char *hdr) { register int c, n; register UNSL long crc; @@ -540,8 +520,7 @@ register char *hdr; /* Receive a hex style header (type and position) */ -int zrhhdr(hdr) -char *hdr; +int zrhhdr(char *hdr) { register int c; register unsigned short crc; @@ -585,8 +564,7 @@ char *hdr; } /* Send a byte as two hex digits */ -void zputhex(c) -register int c; +void zputhex(int c) { static char digits[] = "0123456789abcdef"; @@ -600,8 +578,7 @@ register int c; * Send character c with ZMODEM escape sequence encoding. * Escape XON, XOFF. Escape CR following @ (Telenet net escape) */ -void zsendline(c) -int c; +void zsendline(int c) { /* Quick check for non control characters */ @@ -763,8 +740,7 @@ int noxrd7() } /* Store long integer pos in Txhdr */ -void stohdr(pos) -long pos; +void stohdr(long pos) { Txhdr[ZP0] = pos; Txhdr[ZP1] = pos>>8; @@ -774,8 +750,7 @@ long pos; /* Recover a long integer from a header */ long -rclhdr(hdr) -register char *hdr; +rclhdr(char *hdr) { register long l; diff --git a/commands/zmodem/zmodem.h b/commands/zmodem/zmodem.h index 35005fedc..e35708246 100644 --- a/commands/zmodem/zmodem.h +++ b/commands/zmodem/zmodem.h @@ -155,7 +155,7 @@ long rclhdr(char *hdr ); /* rz.c sz.c */ -void vfile(); +void vfile(const char *s, ...); void bibi(int n ); /* End of ZMODEM.H */