diff --git a/bin/pax/Makefile b/bin/pax/Makefile index 59d389fdd393..6b9514593bc6 100644 --- a/bin/pax/Makefile +++ b/bin/pax/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.10 2000/09/26 16:49:23 phil Exp $ +# $NetBSD: Makefile,v 1.11 2001/10/25 05:33:32 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 # To install on versions prior to BSD 4.4 the following may have to be @@ -8,8 +8,8 @@ # stat structure is easily determined by looking at the # basic type of an off_t (often defined in the file: # /usr/include/sys/types.h). If off_t is a long (and is -# NOT A quad) then you must define NET2_STAT. -# This define is important, as if you do have a quad_t +# NOT A longlong_t) then you must define NET2_STAT. +# This define is important, as if you do have a longlong_t # off_t and define NET2_STAT, pax will compile but will # NOT RUN PROPERLY. # diff --git a/bin/pax/ar_io.c b/bin/pax/ar_io.c index dc50650cefa2..7fc46661df28 100644 --- a/bin/pax/ar_io.c +++ b/bin/pax/ar_io.c @@ -1,4 +1,4 @@ -/* $NetBSD: ar_io.c,v 1.19 2001/09/16 16:34:23 wiz Exp $ */ +/* $NetBSD: ar_io.c,v 1.20 2001/10/25 05:33:32 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)ar_io.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: ar_io.c,v 1.19 2001/09/16 16:34:23 wiz Exp $"); +__RCSID("$NetBSD: ar_io.c,v 1.20 2001/10/25 05:33:32 lukem Exp $"); #endif #endif /* not lint */ @@ -92,11 +92,11 @@ int minusCfd = -1; /* active -C directory */ int curdirfd = -1; /* original current directory */ int force_one_volume; /* 1 if we ignore volume changes */ -static int get_phys __P((void)); +static int get_phys(void); extern sigset_t s_mask; -static void ar_start_gzip __P((int)); -static const char *timefmt __P((char *, size_t, off_t, time_t)); -static const char *sizefmt __P((char *, size_t, off_t)); +static void ar_start_gzip(int); +static const char *timefmt(char *, size_t, off_t, time_t); +static const char *sizefmt(char *, size_t, off_t); /* * ar_open() @@ -107,14 +107,8 @@ static const char *sizefmt __P((char *, size_t, off_t)); * -1 on failure, 0 otherwise */ -#if __STDC__ int ar_open(const char *name) -#else -int -ar_open(name) - const char *name; -#endif { struct mtget mb; @@ -324,13 +318,8 @@ ar_open(name) * ar_close() * closes archive device, increments volume number, and prints i/o summary */ -#if __STDC__ void ar_close(void) -#else -void -ar_close() -#endif { FILE *outf; @@ -417,13 +406,8 @@ ar_close() * other side of the pipe from getting a SIGPIPE (pax will stop * reading an archive once a format dependent trailer is detected). */ -#if __STDC__ void ar_drain(void) -#else -void -ar_drain() -#endif { int res; char drbuf[MAXBLK]; @@ -454,13 +438,8 @@ ar_drain() * 0 if all ready to write, -1 otherwise */ -#if __STDC__ int ar_set_wr(void) -#else -int -ar_set_wr() -#endif { off_t cpos; @@ -497,13 +476,8 @@ ar_set_wr() * 0 if we can append, -1 otherwise. */ -#if __STDC__ int ar_app_ok(void) -#else -int -ar_app_ok() -#endif { if (artyp == ISPIPE) { tty_warn(1, @@ -528,16 +502,8 @@ ar_app_ok() * Number of bytes written. -1 indicates an error. */ -#if __STDC__ int read_with_restart(int fd, void *buf, int bsz) -#else -int -read_with_restart(fd, buf, bsz) - int fd; - void *buf; - int bsz; -#endif { int r; @@ -556,16 +522,8 @@ read_with_restart(fd, buf, bsz) * Number of bytes read. 0 for end of file, -1 for an error. */ -#if __STDC__ int xread(int fd, void *buf, int bsz) -#else -int -xread(fd, buf, bsz) - int fd; - void *buf; - int bsz; -#endif { char *b = buf; int nread = 0; @@ -591,16 +549,8 @@ xread(fd, buf, bsz) * Number of bytes written. -1 indicates an error. */ -#if __STDC__ int write_with_restart(int fd, void *buf, int bsz) -#else -int -write_with_restart(fd, buf, bsz) - int fd; - void *buf; - int bsz; -#endif { int r; @@ -619,16 +569,8 @@ write_with_restart(fd, buf, bsz) * Number of bytes written. -1 indicates an error. */ -#if __STDC__ int xwrite(int fd, void *buf, int bsz) -#else -int -xwrite(fd, buf, bsz) - int fd; - void *buf; - int bsz; -#endif { char *b = buf; int written = 0; @@ -654,15 +596,8 @@ xwrite(fd, buf, bsz) * Number of bytes in buffer. 0 for end of file, -1 for a read error. */ -#if __STDC__ int ar_read(char *buf, int cnt) -#else -int -ar_read(buf, cnt) - char *buf; - int cnt; -#endif { int res = 0; @@ -744,15 +679,8 @@ ar_read(buf, cnt) * error in the archive occurred. */ -#if __STDC__ int ar_write(char *buf, int bsz) -#else -int -ar_write(buf, bsz) - char *buf; - int bsz; -#endif { int res; off_t cpos; @@ -872,13 +800,8 @@ ar_write(buf, bsz) * 0 when ok to try i/o again, -1 otherwise. */ -#if __STDC__ int ar_rdsync(void) -#else -int -ar_rdsync() -#endif { long fsbz; off_t cpos; @@ -963,15 +886,8 @@ ar_rdsync() * partial move (the amount moved is in skipped) */ -#if __STDC__ int ar_fow(off_t sksz, off_t *skipped) -#else -int -ar_fow(sksz, skipped) - off_t sksz; - off_t *skipped; -#endif { off_t cpos; off_t mpos; @@ -1032,14 +948,8 @@ ar_fow(sksz, skipped) * 0 if moved the requested distance, -1 on complete failure */ -#if __STDC__ int ar_rev(off_t sksz) -#else -int -ar_rev(sksz) - off_t sksz; -#endif { off_t cpos; struct mtop mb; @@ -1171,13 +1081,8 @@ ar_rev(sksz) * physical block size if ok (ok > 0), -1 otherwise */ -#if __STDC__ static int get_phys(void) -#else -static int -get_phys() -#endif { int padsz = 0; int res; @@ -1289,13 +1194,8 @@ get_phys() * 0 when ready to continue, -1 when all done */ -#if __STDC__ int ar_next(void) -#else -int -ar_next() -#endif { char buf[PAXPATHLEN+2]; static int freeit = 0; @@ -1441,16 +1341,11 @@ ar_next() * to keep the fd the same in the calling function (parent). */ void -#ifdef __STDC__ ar_start_gzip(int fd) -#else -ar_start_gzip(fd) - int fd; -#endif { pid_t pid; int fds[2]; - char *gzip_flags; + const char *gzip_flags; if (pipe(fds) < 0) err(1, "could not pipe"); @@ -1504,13 +1399,8 @@ timefmt(buf, size, sz, tm) off_t sz; time_t tm; { -#ifdef NET2_STAT - (void)snprintf(buf, size, "%lu secs (%lu bytes/sec)", - (unsigned long)tm, (unsigned long)(sz / tm)); -#else - (void)snprintf(buf, size, "%lu secs (%llu bytes/sec)", - (unsigned long)tm, (unsigned long long)(sz / tm)); -#endif + (void)snprintf(buf, size, "%lu secs (" OFFT_F " bytes/sec)", + (unsigned long)tm, (OFFT_T)(sz / tm)); return buf; } @@ -1520,22 +1410,12 @@ sizefmt(buf, size, sz) size_t size; off_t sz; { -#ifdef NET2_STAT - (void)snprintf(buf, size, "%lu bytes", (unsigned long)sz); -#else - (void)snprintf(buf, size, "%llu bytes", (unsigned long long)sz); -#endif + (void)snprintf(buf, size, OFFT_F " bytes", (OFFT_T)sz); return buf; } -#if __STDC__ void ar_summary(int n) -#else -void -ar_summary(n) - int n; -#endif { time_t secs; int len; @@ -1614,14 +1494,8 @@ ar_summary(n) * Returns 0 if all went well, else -1. */ -#ifdef __STDC__ int ar_dochdir(char *name) -#else -int -ar_dochdir(name) - char *name; -#endif { if (curdirfd == -1) { /* first time. remember where we came from */ diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c index f8984962de85..2c501da079c1 100644 --- a/bin/pax/ar_subs.c +++ b/bin/pax/ar_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: ar_subs.c,v 1.14 2000/02/17 03:12:23 itohy Exp $ */ +/* $NetBSD: ar_subs.c,v 1.15 2001/10/25 05:33:32 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: ar_subs.c,v 1.14 2000/02/17 03:12:23 itohy Exp $"); +__RCSID("$NetBSD: ar_subs.c,v 1.15 2001/10/25 05:33:32 lukem Exp $"); #endif #endif /* not lint */ @@ -62,9 +62,9 @@ __RCSID("$NetBSD: ar_subs.c,v 1.14 2000/02/17 03:12:23 itohy Exp $"); #include "pax.h" #include "extern.h" -static void wr_archive __P((ARCHD *, int is_app)); -static int get_arc __P((void)); -static int next_head __P((ARCHD *)); +static void wr_archive(ARCHD *, int is_app); +static int get_arc(void); +static int next_head(ARCHD *); extern sigset_t s_mask; /* @@ -82,13 +82,8 @@ ARCHD archd; * (no pattern matches all). */ -#if __STDC__ void list(void) -#else -void -list() -#endif { ARCHD *arcn; int res; @@ -163,13 +158,8 @@ list() * pattern(s) (no patterns extracts all members) */ -#if __STDC__ void extract(void) -#else -void -extract() -#endif { ARCHD *arcn; int res; @@ -364,21 +354,14 @@ extract() * previously written archive. */ -#if __STDC__ static void wr_archive(ARCHD *arcn, int is_app) -#else -static void -wr_archive(arcn, is_app) - ARCHD *arcn; - int is_app; -#endif { int res; int hlk; int wr_one; off_t cnt; - int (*wrf) __P((ARCHD *)); + int (*wrf)(ARCHD *); int fd = -1; /* @@ -570,13 +553,8 @@ wr_archive(arcn, is_app) * over write existing files that it creates. */ -#if __STDC__ void append(void) -#else -void -append() -#endif { ARCHD *arcn; int res; @@ -710,13 +688,8 @@ append() * write a new archive */ -#if __STDC__ void archive(void) -#else -void -archive() -#endif { /* @@ -740,13 +713,8 @@ archive() * (except the files are forced to be under the destination directory). */ -#if __STDC__ void copy(void) -#else -void -copy() -#endif { ARCHD *arcn; int res; @@ -991,14 +959,8 @@ copy() * the specs for rd_wrbuf() for more details) */ -#if __STDC__ static int next_head(ARCHD *arcn) -#else -static int -next_head(arcn) - ARCHD *arcn; -#endif { int ret; char *hdend; @@ -1142,13 +1104,8 @@ next_head(arcn) * 0 if archive found -1 otherwise */ -#if __STDC__ static int get_arc(void) -#else -static int -get_arc() -#endif { int i; int hdsz = 0; diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c index 4a3923346784..f5030394ab01 100644 --- a/bin/pax/buf_subs.c +++ b/bin/pax/buf_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: buf_subs.c,v 1.15 2001/10/07 16:28:39 wiz Exp $ */ +/* $NetBSD: buf_subs.c,v 1.16 2001/10/25 05:33:32 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)buf_subs.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: buf_subs.c,v 1.15 2001/10/07 16:28:39 wiz Exp $"); +__RCSID("$NetBSD: buf_subs.c,v 1.16 2001/10/25 05:33:32 lukem Exp $"); #endif #endif /* not lint */ @@ -90,13 +90,8 @@ off_t rdcnt; /* # of bytes read on current vol */ * 0 if ok, -1 if the user specified write block size violates pax spec */ -#if __STDC__ int wr_start(void) -#else -int -wr_start() -#endif { buf = &(bufmem[BLKMULT]); /* @@ -138,13 +133,8 @@ wr_start() * 0 if ok, -1 otherwise */ -#if __STDC__ int rd_start(void) -#else -int -rd_start() -#endif { /* * leave space for the header pushback (see get_arc()). If we are @@ -183,13 +173,8 @@ rd_start() * set up buffer system for copying within the file system */ -#if __STDC__ void cp_start(void) -#else -void -cp_start() -#endif { buf = &(bufmem[BLKMULT]); rdblksz = blksz = MAXBLK; @@ -227,14 +212,8 @@ cp_start() * 0 for success, -1 for failure */ -#if __STDC__ int appnd_start(off_t skcnt) -#else -int -appnd_start(skcnt) - off_t skcnt; -#endif { int res; off_t cnt; @@ -332,13 +311,8 @@ appnd_start(skcnt) * 0 on success, and -1 on failure */ -#if __STDC__ int rd_sync(void) -#else -int -rd_sync() -#endif { int errcnt = 0; int res; @@ -407,15 +381,8 @@ rd_sync() * pback space is increased. */ -#if __STDC__ void pback(char *pt, int cnt) -#else -void -pback(pt, cnt) - char *pt; - int cnt; -#endif { bufpt -= cnt; memcpy(bufpt, pt, cnt); @@ -430,14 +397,8 @@ pback(pt, cnt) * 0 if ok, -1 failure, and 1 when EOF on the archive volume was detected. */ -#if __STDC__ int rd_skip(off_t skcnt) -#else -int -rd_skip(skcnt) - off_t skcnt; -#endif { off_t res; off_t cnt; @@ -505,13 +466,8 @@ rd_skip(skcnt) * BE a requirement.... */ -#if __STDC__ void wr_fin(void) -#else -void -wr_fin() -#endif { if (bufpt > buf) { memset(bufpt, 0, bufend - bufpt); @@ -531,15 +487,8 @@ wr_fin() * 0 if buffer was filled ok, -1 o.w. (buffer flush failure) */ -#if __STDC__ int wr_rdbuf(char *out, int outcnt) -#else -int -wr_rdbuf(out, outcnt) - char *out; - int outcnt; -#endif { int cnt; @@ -574,15 +523,8 @@ wr_rdbuf(out, outcnt) * -1 is a read error */ -#if __STDC__ int rd_wrbuf(char *in, int cpcnt) -#else -int -rd_wrbuf(in, cpcnt) - char *in; - int cpcnt; -#endif { int res; int cnt; @@ -629,14 +571,8 @@ rd_wrbuf(in, cpcnt) * 0 if ok, -1 if there was a buf_flush failure */ -#if __STDC__ int wr_skip(off_t skcnt) -#else -int -wr_skip(skcnt) - off_t skcnt; -#endif { int cnt; @@ -673,16 +609,8 @@ wr_skip(skcnt) * 0, but "left" is set to be greater than zero. */ -#if __STDC__ int wr_rdfile(ARCHD *arcn, int ifd, off_t *left) -#else -int -wr_rdfile(arcn, ifd, left) - ARCHD *arcn; - int ifd; - off_t *left; -#endif { int cnt; int res = 0; @@ -742,16 +670,8 @@ wr_rdfile(arcn, ifd, left) * we return a 0 but "left" is set to be the amount unwritten */ -#if __STDC__ int rd_wrfile(ARCHD *arcn, int ofd, off_t *left) -#else -int -rd_wrfile(arcn, ofd, left) - ARCHD *arcn; - int ofd; - off_t *left; -#endif { int cnt = 0; off_t size = arcn->sb.st_size; @@ -841,16 +761,8 @@ rd_wrfile(arcn, ofd, left) * destination file so we can properly copy files with holes. */ -#if __STDC__ void cp_file(ARCHD *arcn, int fd1, int fd2) -#else -void -cp_file(arcn, fd1, fd2) - ARCHD *arcn; - int fd1; - int fd2; -#endif { int cnt; off_t cpcnt = 0L; @@ -930,13 +842,8 @@ cp_file(arcn, fd1, fd2) * 0 when finished (user specified termination in ar_next()). */ -#if __STDC__ int buf_fill(void) -#else -int -buf_fill() -#endif { int cnt; static int fini = 0; @@ -980,14 +887,8 @@ buf_fill() * 0 if all is ok, -1 when a write error occurs. */ -#if __STDC__ int buf_flush(int bufcnt) -#else -int -buf_flush(bufcnt) - int bufcnt; -#endif { int cnt; int push = 0; diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c index 36307e99277f..1f95186105d9 100644 --- a/bin/pax/cpio.c +++ b/bin/pax/cpio.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpio.c,v 1.10 2001/01/04 15:39:51 lukem Exp $ */ +/* $NetBSD: cpio.c,v 1.11 2001/10/25 05:33:32 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)cpio.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: cpio.c,v 1.10 2001/01/04 15:39:51 lukem Exp $"); +__RCSID("$NetBSD: cpio.c,v 1.11 2001/10/25 05:33:32 lukem Exp $"); #endif #endif /* not lint */ @@ -59,9 +59,9 @@ __RCSID("$NetBSD: cpio.c,v 1.10 2001/01/04 15:39:51 lukem Exp $"); #include "cpio.h" #include "extern.h" -static int rd_nm __P((ARCHD *, int)); -static int rd_ln_nm __P((ARCHD *)); -static int com_rd __P((ARCHD *)); +static int rd_nm(ARCHD *, int); +static int rd_ln_nm(ARCHD *); +static int com_rd(ARCHD *); /* * Routines which support the different cpio versions @@ -80,13 +80,8 @@ int cpio_swp_head; /* binary cpio header byte swap */ * 0 if ok -1 otherwise (the return values of lnk_start()) */ -#if __STDC__ int cpio_strd(void) -#else -int -cpio_strd() -#endif { return(lnk_start()); } @@ -101,14 +96,8 @@ cpio_strd() * 0 if a valid trailer, -1 if not a valid trailer, */ -#if __STDC__ int cpio_subtrail(ARCHD *arcn) -#else -int -cpio_subtrail(arcn) - ARCHD *arcn; -#endif { /* * look for trailer id in file we are about to process @@ -125,14 +114,8 @@ cpio_subtrail(arcn) * 0 */ -#if __STDC__ static int com_rd(ARCHD *arcn) -#else -static int -com_rd(arcn) - ARCHD *arcn; -#endif { arcn->skip = 0; arcn->pat = NULL; @@ -180,13 +163,8 @@ com_rd(arcn) * result of the write of the trailer from the cpio specific write func */ -#if __STDC__ int cpio_endwr(void) -#else -int -cpio_endwr() -#endif { ARCHD last; @@ -208,15 +186,8 @@ cpio_endwr() * 0 if ok, -1 otherwise */ -#if __STDC__ static int rd_nm(ARCHD *arcn, int nsz) -#else -static int -rd_nm(arcn, nsz) - ARCHD *arcn; - int nsz; -#endif { /* * do not even try bogus values @@ -245,27 +216,16 @@ rd_nm(arcn, nsz) * 0 if ok, -1 otherwise */ -#if __STDC__ static int rd_ln_nm(ARCHD *arcn) -#else -static int -rd_ln_nm(arcn) - ARCHD *arcn; -#endif { /* * check the length specified for bogus values */ if ((arcn->sb.st_size == 0) || (arcn->sb.st_size >= sizeof(arcn->ln_name))) { -# ifdef NET2_STAT - tty_warn(1, "Cpio link name length is invalid: %lu", - arcn->sb.st_size); -# else - tty_warn(1, "Cpio link name length is invalid: %llu", - (unsigned long long) arcn->sb.st_size); -# endif + tty_warn(1, "Cpio link name length is invalid: " OFFT_F, + (OFFT_T) arcn->sb.st_size); return(-1); } @@ -302,15 +262,8 @@ rd_ln_nm(arcn) * 0 if a valid header, -1 otherwise */ -#if __STDC__ int cpio_id(char *blk, int size) -#else -int -cpio_id(blk, size) - char *blk; - int size; -#endif { if ((size < sizeof(HD_CPIO)) || (strncmp(blk, AMAGIC, sizeof(AMAGIC) - 1) != 0)) @@ -326,15 +279,8 @@ cpio_id(blk, size) * 0 if a valid header, -1 otherwise. */ -#if __STDC__ int cpio_rd(ARCHD *arcn, char *buf) -#else -int -cpio_rd(arcn, buf) - ARCHD *arcn; - char *buf; -#endif { int nsz; HD_CPIO *hd; @@ -362,13 +308,8 @@ cpio_rd(arcn, buf) arcn->sb.st_mtime = (time_t)asc_ul(hd->c_mtime, sizeof(hd->c_mtime), OCT); arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime; -# ifdef NET2_STAT - arcn->sb.st_size = (off_t)asc_ul(hd->c_filesize,sizeof(hd->c_filesize), - OCT); -# else - arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize,sizeof(hd->c_filesize), - OCT); -# endif + arcn->sb.st_size = (off_t)ASC_OFFT(hd->c_filesize, + sizeof(hd->c_filesize), OCT); /* * check name size and if valid, read in the name of this entry (name @@ -409,13 +350,8 @@ cpio_rd(arcn, buf) * size of trailer header in this format */ -#if __STDC__ off_t cpio_endrd(void) -#else -off_t -cpio_endrd() -#endif { return((off_t)(sizeof(HD_CPIO) + sizeof(TRAILER))); } @@ -427,13 +363,8 @@ cpio_endrd() * 0 if ok, -1 otherwise (what dev_start() returns) */ -#if __STDC__ int cpio_stwr(void) -#else -int -cpio_stwr() -#endif { return(dev_start()); } @@ -447,14 +378,8 @@ cpio_stwr() * data to write after the header, -1 if archive write failed */ -#if __STDC__ int cpio_wr(ARCHD *arcn) -#else -int -cpio_wr(arcn) - ARCHD *arcn; -#endif { HD_CPIO *hd; int nsz; @@ -479,13 +404,8 @@ cpio_wr(arcn) /* * set data size for file data */ -# ifdef NET2_STAT - if (ul_asc((u_long)arcn->sb.st_size, hd->c_filesize, + if (OFFT_ASC(arcn->sb.st_size, hd->c_filesize, sizeof(hd->c_filesize), OCT)) { -# else - if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize, - sizeof(hd->c_filesize), OCT)) { -# endif tty_warn(1,"File is too large for cpio format %s", arcn->org_name); return(1); @@ -585,15 +505,8 @@ cpio_wr(arcn) * 0 if a valid header, -1 otherwise */ -#if __STDC__ int vcpio_id(char *blk, int size) -#else -int -vcpio_id(blk, size) - char *blk; - int size; -#endif { if ((size < sizeof(HD_VCPIO)) || (strncmp(blk, AVMAGIC, sizeof(AVMAGIC) - 1) != 0)) @@ -609,15 +522,8 @@ vcpio_id(blk, size) * 0 if a valid header, -1 otherwise */ -#if __STDC__ int crc_id(char *blk, int size) -#else -int -crc_id(blk, size) - char *blk; - int size; -#endif { if ((size < sizeof(HD_VCPIO)) || (strncmp(blk, AVCMAGIC, sizeof(AVCMAGIC) - 1) != 0)) @@ -632,13 +538,8 @@ crc_id(blk, size) * 0 if ok -1 otherwise (the return values of lnk_start()) */ -#if __STDC__ int crc_strd(void) -#else -int -crc_strd() -#endif { docrc = 1; return(lnk_start()); @@ -652,15 +553,8 @@ crc_strd() * 0 if a valid header, -1 otherwise. */ -#if __STDC__ int vcpio_rd(ARCHD *arcn, char *buf) -#else -int -vcpio_rd(arcn, buf) - ARCHD *arcn; - char *buf; -#endif { HD_VCPIO *hd; dev_t devminor; @@ -691,13 +585,8 @@ vcpio_rd(arcn, buf) arcn->sb.st_gid = (gid_t)asc_ul(hd->c_gid, sizeof(hd->c_gid), HEX); arcn->sb.st_mtime = (time_t)asc_ul(hd->c_mtime,sizeof(hd->c_mtime),HEX); arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime; -# ifdef NET2_STAT - arcn->sb.st_size = (off_t)asc_ul(hd->c_filesize, + arcn->sb.st_size = (off_t)ASC_OFFT(hd->c_filesize, sizeof(hd->c_filesize), HEX); -# else - arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize, - sizeof(hd->c_filesize), HEX); -# endif arcn->sb.st_nlink = (nlink_t)asc_ul(hd->c_nlink, sizeof(hd->c_nlink), HEX); devmajor = (dev_t)asc_ul(hd->c_maj, sizeof(hd->c_maj), HEX); @@ -758,13 +647,8 @@ vcpio_rd(arcn, buf) * size of trailer header in this format */ -#if __STDC__ off_t vcpio_endrd(void) -#else -off_t -vcpio_endrd() -#endif { return((off_t)(sizeof(HD_VCPIO) + sizeof(TRAILER) + (VCPIO_PAD(sizeof(HD_VCPIO) + sizeof(TRAILER))))); @@ -777,13 +661,8 @@ vcpio_endrd() * 0 if ok, -1 otherwise (what dev_start() returns) */ -#if __STDC__ int crc_stwr(void) -#else -int -crc_stwr() -#endif { docrc = 1; return(dev_start()); @@ -798,14 +677,8 @@ crc_stwr() * NO data to write after the header, -1 if archive write failed */ -#if __STDC__ int vcpio_wr(ARCHD *arcn) -#else -int -vcpio_wr(arcn) - ARCHD *arcn; -#endif { HD_VCPIO *hd; unsigned int nsz; @@ -848,13 +721,8 @@ vcpio_wr(arcn) * much to pad. */ arcn->pad = VCPIO_PAD(arcn->sb.st_size); -# ifdef NET2_STAT - if (ul_asc((u_long)arcn->sb.st_size, hd->c_filesize, + if (OFFT_ASC(arcn->sb.st_size, hd->c_filesize, sizeof(hd->c_filesize), HEX)) { -# else - if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize, - sizeof(hd->c_filesize), HEX)) { -# endif tty_warn(1,"File is too large for sv4cpio format %s", arcn->org_name); return(1); @@ -963,15 +831,8 @@ vcpio_wr(arcn) * 0 if a valid header, -1 otherwise */ -#if __STDC__ int bcpio_id(char *blk, int size) -#else -int -bcpio_id(blk, size) - char *blk; - int size; -#endif { if (size < sizeof(HD_BCPIO)) return(-1); @@ -998,15 +859,8 @@ bcpio_id(blk, size) * 0 if a valid header, -1 otherwise. */ -#if __STDC__ int bcpio_rd(ARCHD *arcn, char *buf) -#else -int -bcpio_rd(arcn, buf) - ARCHD *arcn; - char *buf; -#endif { HD_BCPIO *hd; int nsz; @@ -1102,13 +956,8 @@ bcpio_rd(arcn, buf) * size of trailer header in this format */ -#if __STDC__ off_t bcpio_endrd(void) -#else -off_t -bcpio_endrd() -#endif { return((off_t)(sizeof(HD_BCPIO) + sizeof(TRAILER) + (BCPIO_PAD(sizeof(HD_BCPIO) + sizeof(TRAILER))))); @@ -1125,14 +974,8 @@ bcpio_endrd() * data to write after the header, -1 if archive write failed */ -#if __STDC__ int bcpio_wr(ARCHD *arcn) -#else -int -bcpio_wr(arcn) - ARCHD *arcn; -#endif { HD_BCPIO *hd; int nsz; diff --git a/bin/pax/extern.h b/bin/pax/extern.h index 94f62671312c..92b193a1e280 100644 --- a/bin/pax/extern.h +++ b/bin/pax/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.25 2000/10/22 15:41:31 kleink Exp $ */ +/* $NetBSD: extern.h,v 1.26 2001/10/25 05:33:32 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -53,39 +53,39 @@ extern int curdirfd; extern const char *gzip_program; extern time_t starttime; extern int force_one_volume; -int ar_open __P((const char *)); -void ar_close __P((void)); -void ar_drain __P((void)); -int ar_set_wr __P((void)); -int ar_app_ok __P((void)); +int ar_open(const char *); +void ar_close(void); +void ar_drain(void); +int ar_set_wr(void); +int ar_app_ok(void); #ifdef SYS_NO_RESTART -int read_with_restart __P((int, void *, int)); -int write_with_restart __P((int, void *, int)); +int read_with_restart(int, void *, int); +int write_with_restart(int, void *, int); #else #define read_with_restart read #define write_with_restart write #endif -int xread __P((int, void *, int)); -int xwrite __P((int, void *, int)); -int ar_read __P((char *, int)); -int ar_write __P((char *, int)); -int ar_rdsync __P((void)); -int ar_fow __P((off_t, off_t *)); -int ar_rev __P((off_t )); -int ar_next __P((void)); -void ar_summary __P((int)); -int ar_dochdir __P((char *)); +int xread(int, void *, int); +int xwrite(int, void *, int); +int ar_read(char *, int); +int ar_write(char *, int); +int ar_rdsync(void); +int ar_fow(off_t, off_t *); +int ar_rev(off_t ); +int ar_next(void); +void ar_summary(int); +int ar_dochdir(char *); /* * ar_subs.c */ extern u_long flcnt; extern ARCHD archd; -void list __P((void)); -void extract __P((void)); -void append __P((void)); -void archive __P((void)); -void copy __P((void)); +void list(void); +void extract(void); +void append(void); +void archive(void); +void copy(void); /* * buf_subs.c @@ -97,97 +97,97 @@ extern int rdblksz; extern off_t wrlimit; extern off_t rdcnt; extern off_t wrcnt; -int wr_start __P((void)); -int rd_start __P((void)); -void cp_start __P((void)); -int appnd_start __P((off_t)); -int rd_sync __P((void)); -void pback __P((char *, int)); -int rd_skip __P((off_t)); -void wr_fin __P((void)); -int wr_rdbuf __P((char *, int)); -int rd_wrbuf __P((char *, int)); -int wr_skip __P((off_t)); -int wr_rdfile __P((ARCHD *, int, off_t *)); -int rd_wrfile __P((ARCHD *, int, off_t *)); -void cp_file __P((ARCHD *, int, int)); -int buf_fill __P((void)); -int buf_flush __P((int)); +int wr_start(void); +int rd_start(void); +void cp_start(void); +int appnd_start(off_t); +int rd_sync(void); +void pback(char *, int); +int rd_skip(off_t); +void wr_fin(void); +int wr_rdbuf(char *, int); +int rd_wrbuf(char *, int); +int wr_skip(off_t); +int wr_rdfile(ARCHD *, int, off_t *); +int rd_wrfile(ARCHD *, int, off_t *); +void cp_file(ARCHD *, int, int); +int buf_fill(void); +int buf_flush(int); /* * cpio.c */ extern int cpio_swp_head; -int cpio_strd __P((void)); -int cpio_subtrail __P((ARCHD *)); -int cpio_endwr __P((void)); -int cpio_id __P((char *, int)); -int cpio_rd __P((ARCHD *, char *)); -off_t cpio_endrd __P((void)); -int cpio_stwr __P((void)); -int cpio_wr __P((ARCHD *)); -int vcpio_id __P((char *, int)); -int crc_id __P((char *, int)); -int crc_strd __P((void)); -int vcpio_rd __P((ARCHD *, char *)); -off_t vcpio_endrd __P((void)); -int crc_stwr __P((void)); -int vcpio_wr __P((ARCHD *)); -int bcpio_id __P((char *, int)); -int bcpio_rd __P((ARCHD *, char *)); -off_t bcpio_endrd __P((void)); -int bcpio_wr __P((ARCHD *)); +int cpio_strd(void); +int cpio_subtrail(ARCHD *); +int cpio_endwr(void); +int cpio_id(char *, int); +int cpio_rd(ARCHD *, char *); +off_t cpio_endrd(void); +int cpio_stwr(void); +int cpio_wr(ARCHD *); +int vcpio_id(char *, int); +int crc_id(char *, int); +int crc_strd(void); +int vcpio_rd(ARCHD *, char *); +off_t vcpio_endrd(void); +int crc_stwr(void); +int vcpio_wr(ARCHD *); +int bcpio_id(char *, int); +int bcpio_rd(ARCHD *, char *); +off_t bcpio_endrd(void); +int bcpio_wr(ARCHD *); /* * file_subs.c */ extern char *gnu_hack_string; -int file_creat __P((ARCHD *)); -void file_close __P((ARCHD *, int)); -int lnk_creat __P((ARCHD *)); -int cross_lnk __P((ARCHD *)); -int chk_same __P((ARCHD *)); -int node_creat __P((ARCHD *)); -int unlnk_exist __P((char *, int)); -int chk_path __P((char *, uid_t, gid_t)); -void set_ftime __P((char *fnm, time_t mtime, time_t atime, int frc)); -int set_ids __P((char *, uid_t, gid_t)); -void set_pmode __P((char *, mode_t)); -void set_chflags __P((char *fnm, u_int32_t flags)); -int file_write __P((int, char *, int, int *, int *, int, char *)); -void file_flush __P((int, char *, int)); -void rdfile_close __P((ARCHD *, int *)); -int set_crc __P((ARCHD *, int)); +int file_creat(ARCHD *); +void file_close(ARCHD *, int); +int lnk_creat(ARCHD *); +int cross_lnk(ARCHD *); +int chk_same(ARCHD *); +int node_creat(ARCHD *); +int unlnk_exist(char *, int); +int chk_path(char *, uid_t, gid_t); +void set_ftime(char *fnm, time_t mtime, time_t atime, int frc); +int set_ids(char *, uid_t, gid_t); +void set_pmode(char *, mode_t); +void set_chflags(char *fnm, u_int32_t flags); +int file_write(int, char *, int, int *, int *, int, char *); +void file_flush(int, char *, int); +void rdfile_close(ARCHD *, int *); +int set_crc(ARCHD *, int); /* * ftree.c */ -int ftree_start __P((void)); -int ftree_add __P((char *, int)); -void ftree_sel __P((ARCHD *)); -void ftree_chk __P((void)); -int next_file __P((ARCHD *)); +int ftree_start(void); +int ftree_add(char *, int); +void ftree_sel(ARCHD *); +void ftree_chk(void); +int next_file(ARCHD *); /* * gen_subs.c */ -void ls_list __P((ARCHD *, time_t)); -void ls_tty __P((ARCHD *)); -void zf_strncpy __P((char *, const char *, int)); -int l_strncpy __P((char *, const char *, int)); -u_long asc_ul __P((char *, int, int)); -int ul_asc __P((u_long, char *, int, int)); +void ls_list(ARCHD *, time_t); +void ls_tty(ARCHD *); +void zf_strncpy(char *, const char *, int); +int l_strncpy(char *, const char *, int); +u_long asc_ul(char *, int, int); +int ul_asc(u_long, char *, int, int); #ifndef NET2_STAT -u_quad_t asc_uqd __P((char *, int, int)); -int uqd_asc __P((u_quad_t, char *, int, int)); +u_longlong_t asc_ull(char *, int, int); +int ull_asc(u_longlong_t, char *, int, int); #endif -int check_Aflag __P((void)); +int check_Aflag(void); /* * getoldopt.c */ struct option; -int getoldopt __P((int, char **, const char *, struct option *, int *)); +int getoldopt(int, char **, const char *, struct option *, int *); /* * options.c @@ -195,22 +195,22 @@ int getoldopt __P((int, char **, const char *, struct option *, int *)); extern FSUB fsub[]; extern int ford[]; extern int cpio_mode; -void options __P((int, char **)); -OPLIST * opt_next __P((void)); -int opt_add __P((const char *)); -int opt_chdir __P((char *)); -int bad_opt __P((void)); +void options(int, char **); +OPLIST * opt_next(void); +int opt_add(const char *); +int opt_chdir(char *); +int bad_opt(void); /* * pat_rep.c */ -int rep_add __P((char *)); -int pat_add __P((char *, int)); -void pat_chk __P((void)); -int pat_sel __P((ARCHD *)); -int pat_match __P((ARCHD *)); -int mod_name __P((ARCHD *)); -int set_dest __P((ARCHD *, char *, int)); +int rep_add(char *); +int pat_add(char *, int); +void pat_chk(void); +int pat_sel(ARCHD *); +int pat_match(ARCHD *); +int mod_name(ARCHD *); +int set_dest(ARCHD *, char *, int); /* * pax.c @@ -244,67 +244,67 @@ extern int exit_val; extern int docrc; extern char *dirptr; extern char *argv0; -int main __P((int, char **)); -void sig_cleanup __P((int)); +int main(int, char **); +void sig_cleanup(int); /* * sel_subs.c */ -int sel_chk __P((ARCHD *)); -int grp_add __P((char *)); -int usr_add __P((char *)); -int trng_add __P((char *)); +int sel_chk(ARCHD *); +int grp_add(char *); +int usr_add(char *); +int trng_add(char *); /* * tables.c */ -int lnk_start __P((void)); -int chk_lnk __P((ARCHD *)); -void purg_lnk __P((ARCHD *)); -void lnk_end __P((void)); -int ftime_start __P((void)); -int chk_ftime __P((ARCHD *)); -int name_start __P((void)); -int add_name __P((char *, int, char *)); -void sub_name __P((char *, int *)); -int dev_start __P((void)); -int add_dev __P((ARCHD *)); -int map_dev __P((ARCHD *, u_long, u_long)); -int atdir_start __P((void)); -void atdir_end __P((void)); -void add_atdir __P((char *, dev_t, ino_t, time_t, time_t)); -int get_atdir __P((dev_t, ino_t, time_t *, time_t *)); -int dir_start __P((void)); -void add_dir __P((char *, int, struct stat *, int)); -void proc_dir __P((void)); -u_int st_hash __P((char *, int, int)); +int lnk_start(void); +int chk_lnk(ARCHD *); +void purg_lnk(ARCHD *); +void lnk_end(void); +int ftime_start(void); +int chk_ftime(ARCHD *); +int name_start(void); +int add_name(char *, int, char *); +void sub_name(char *, int *); +int dev_start(void); +int add_dev(ARCHD *); +int map_dev(ARCHD *, u_long, u_long); +int atdir_start(void); +void atdir_end(void); +void add_atdir(char *, dev_t, ino_t, time_t, time_t); +int get_atdir(dev_t, ino_t, time_t *, time_t *); +int dir_start(void); +void add_dir(char *, int, struct stat *, int); +void proc_dir(void); +u_int st_hash(char *, int, int); /* * tar.c */ extern int is_oldgnutar; -int tar_endwr __P((void)); -off_t tar_endrd __P((void)); -int tar_trail __P((char *, int, int *)); -int tar_id __P((char *, int)); -int tar_opt __P((void)); -int tar_rd __P((ARCHD *, char *)); -int tar_wr __P((ARCHD *)); -int ustar_strd __P((void)); -int ustar_stwr __P((void)); -int ustar_id __P((char *, int)); -int ustar_rd __P((ARCHD *, char *)); -int ustar_wr __P((ARCHD *)); -int tar_gnutar_X_compat __P((const char *)); +int tar_endwr(void); +off_t tar_endrd(void); +int tar_trail(char *, int, int *); +int tar_id(char *, int); +int tar_opt(void); +int tar_rd(ARCHD *, char *); +int tar_wr(ARCHD *); +int ustar_strd(void); +int ustar_stwr(void); +int ustar_id(char *, int); +int ustar_rd(ARCHD *, char *); +int ustar_wr(ARCHD *); +int tar_gnutar_X_compat(const char *); /* * tty_subs.c */ -int tty_init __P((void)); -void tty_prnt __P((char *, ...)) +int tty_init(void); +void tty_prnt(const char *, ...) __attribute__((format (printf, 1, 2))); -int tty_read __P((char *, int)); -void tty_warn __P((int, char *, ...)) +int tty_read(char *, int); +void tty_warn(int, const char *, ...) __attribute__((format (printf, 2, 3))); -void syswarn __P((int, int, char *, ...)) +void syswarn(int, int, const char *, ...) __attribute__((format (printf, 3, 4))); diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c index 52d93b7677aa..6dafaec90f4a 100644 --- a/bin/pax/file_subs.c +++ b/bin/pax/file_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: file_subs.c,v 1.19 2000/06/17 18:19:10 mrg Exp $ */ +/* $NetBSD: file_subs.c,v 1.20 2001/10/25 05:33:33 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: file_subs.c,v 1.19 2000/06/17 18:19:10 mrg Exp $"); +__RCSID("$NetBSD: file_subs.c,v 1.20 2001/10/25 05:33:33 lukem Exp $"); #endif #endif /* not lint */ @@ -63,7 +63,7 @@ __RCSID("$NetBSD: file_subs.c,v 1.19 2000/06/17 18:19:10 mrg Exp $"); #include "extern.h" static int -mk_link __P((char *,struct stat *,char *, int)); +mk_link(char *,struct stat *,char *, int); /* * routines that deal with file operations such as: creating, removing; @@ -81,14 +81,8 @@ mk_link __P((char *,struct stat *,char *, int)); * file descriptor or -1 for failure */ -#if __STDC__ int file_creat(ARCHD *arcn) -#else -int -file_creat(arcn) - ARCHD *arcn; -#endif { int fd = -1; mode_t file_mode; @@ -144,15 +138,8 @@ file_creat(arcn) * 0 for success, -1 for failure */ -#if __STDC__ void file_close(ARCHD *arcn, int fd) -#else -void -file_close(arcn, fd) - ARCHD *arcn; - int fd; -#endif { int res = 0; @@ -193,14 +180,8 @@ file_close(arcn, fd) * 0 if ok, -1 otherwise */ -#if __STDC__ int lnk_creat(ARCHD *arcn) -#else -int -lnk_creat(arcn) - ARCHD *arcn; -#endif { struct stat sb; @@ -233,14 +214,8 @@ lnk_creat(arcn) * 0 if cross_lnk() ok, -1 for fatal flaw (like linking to self). */ -#if __STDC__ int cross_lnk(ARCHD *arcn) -#else -int -cross_lnk(arcn) - ARCHD *arcn; -#endif { /* * try to make a link to original file (-l flag in copy mode). make @@ -263,14 +238,8 @@ cross_lnk(arcn) * 0 skip it file exists (-k) or may be the same as source file */ -#if __STDC__ int chk_same(ARCHD *arcn) -#else -int -chk_same(arcn) - ARCHD *arcn; -#endif { struct stat sb; @@ -306,18 +275,8 @@ chk_same(arcn) * allowed option). -1 an error occurred. */ -#if __STDC__ static int -mk_link(char *to, struct stat *to_sb, char *from, - int ign) -#else -static int -mk_link(to, to_sb, from, ign) - char *to; - struct stat *to_sb; - char *from; - int ign; -#endif +mk_link(char *to, struct stat *to_sb, char *from, int ign) { struct stat sb; int oerrno; @@ -388,14 +347,8 @@ mk_link(to, to_sb, from, ign) * 0 if ok, -1 otherwise */ -#if __STDC__ int node_creat(ARCHD *arcn) -#else -int -node_creat(arcn) - ARCHD *arcn; -#endif { int res; int ign = 0; @@ -552,15 +505,8 @@ node_creat(arcn) * 1 we found a directory and we were going to create a directory. */ -#if __STDC__ int unlnk_exist(char *name, int type) -#else -int -unlnk_exist(name, type) - char *name; - int type; -#endif { struct stat sb; @@ -610,16 +556,8 @@ unlnk_exist(name, type) * 0 otherwise */ -#if __STDC__ int chk_path( char *name, uid_t st_uid, gid_t st_gid) -#else -int -chk_path(name, st_uid, st_gid) - char *name; - uid_t st_uid; - gid_t st_gid; -#endif { char *spt = name; struct stat sb; @@ -703,17 +641,8 @@ chk_path(name, st_uid, st_gid) * not set request. */ -#if __STDC__ void set_ftime(char *fnm, time_t mtime, time_t atime, int frc) -#else -void -set_ftime(fnm, mtime, atime, frc) - char *fnm; - time_t mtime; - time_t atime; - int frc; -#endif { struct timeval tv[2]; struct stat sb; @@ -752,16 +681,8 @@ set_ftime(fnm, mtime, atime, frc) * 0 when set, -1 on failure */ -#if __STDC__ int set_ids(char *fnm, uid_t uid, gid_t gid) -#else -int -set_ids(fnm, uid, gid) - char *fnm; - uid_t uid; - gid_t gid; -#endif { if (lchown(fnm, uid, gid) < 0) { syswarn(1, errno, "Unable to set file uid/gid of %s", fnm); @@ -775,15 +696,8 @@ set_ids(fnm, uid, gid) * Set file access mode */ -#if __STDC__ void set_pmode(char *fnm, mode_t mode) -#else -void -set_pmode(fnm, mode) - char *fnm; - mode_t mode; -#endif { mode &= ABITS; if (lchmod(fnm, mode) < 0) @@ -795,15 +709,8 @@ set_pmode(fnm, mode) * set_chflags() * Set 4.4BSD file flags */ -#if __STDC__ void set_chflags(char *fnm, u_int32_t flags) -#else -void -set_chflags(fnm, flags) - char *fnm; - u_int32_t flags; -#endif { #if 0 @@ -861,21 +768,9 @@ set_chflags(fnm, flags) * number of bytes written, -1 on write (or lseek) error. */ -#if __STDC__ int file_write(int fd, char *str, int cnt, int *rem, int *isempt, int sz, char *name) -#else -int -file_write(fd, str, cnt, rem, isempt, sz, name) - int fd; - char *str; - int cnt; - int *rem; - int *isempt; - int sz; - char *name; -#endif { char *pt; char *end; @@ -966,16 +861,8 @@ file_write(fd, str, cnt, rem, isempt, sz, name) * write the last BYTE with a zero (back up one byte and write a zero). */ -#if __STDC__ void file_flush(int fd, char *fname, int isempt) -#else -void -file_flush(fd, fname, isempt) - int fd; - char *fname; - int isempt; -#endif { static char blnk[] = "\0"; @@ -1005,15 +892,8 @@ file_flush(fd, fname, isempt) * reset access time (tflag) do so (the times are stored in arcn). */ -#if __STDC__ void rdfile_close(ARCHD *arcn, int *fd) -#else -void -rdfile_close(arcn, fd) - ARCHD *arcn; - int *fd; -#endif { /* * make sure the file is open @@ -1042,15 +922,8 @@ rdfile_close(arcn, fd) * 0 if was able to calculate the crc, -1 otherwise */ -#if __STDC__ int set_crc(ARCHD *arcn, int fd) -#else -int -set_crc(arcn, fd) - ARCHD *arcn; - int fd; -#endif { int i; int res; diff --git a/bin/pax/ftree.c b/bin/pax/ftree.c index b7b5a4ed1b1a..95ff67deb049 100644 --- a/bin/pax/ftree.c +++ b/bin/pax/ftree.c @@ -1,4 +1,4 @@ -/* $NetBSD: ftree.c,v 1.10 2000/02/17 03:12:24 itohy Exp $ */ +/* $NetBSD: ftree.c,v 1.11 2001/10/25 05:33:33 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: ftree.c,v 1.10 2000/02/17 03:12:24 itohy Exp $"); +__RCSID("$NetBSD: ftree.c,v 1.11 2001/10/25 05:33:33 lukem Exp $"); #endif #endif /* not lint */ @@ -84,7 +84,13 @@ static FTREE *ftcur = NULL; /* current file arg being processed */ static FTSENT *ftent = NULL; /* current file tree entry */ static int ftree_skip; /* when set skip to next file arg */ -static int ftree_arg __P((void)); +static int ftree_arg(void); + +#ifdef NET2_FTS +#define FTS_ERRNO(x) errno +#else +#define FTS_ERRNO(x) (x)->fts_errno +#endif /* * ftree_start() @@ -96,13 +102,8 @@ static int ftree_arg __P((void)); * 0 if there is at least one valid file arg to process, -1 otherwise */ -#if __STDC__ int ftree_start(void) -#else -int -ftree_start() -#endif { /* * set up the operation mode of fts, open the first file arg. We must @@ -127,11 +128,11 @@ ftree_start() else ftsopts |= FTS_PHYSICAL; if (Hflag) -# ifdef NET2_FTS +#ifdef NET2_FTS tty_warn(0, "The -H flag is not supported on this version"); -# else +#else ftsopts |= FTS_COMFOLLOW; -# endif +#endif if (Xflag) ftsopts |= FTS_XDEV; @@ -155,15 +156,8 @@ ftree_start() * 0 if added to the linked list, -1 if failed */ -#if __STDC__ int ftree_add(char *str, int isdir) -#else -int -ftree_add(str, isdir) - char *str; - int isdir; -#endif { FTREE *ft; int len; @@ -206,14 +200,8 @@ ftree_add(str, isdir) * -n and -d processing. */ -#if __STDC__ void ftree_sel(ARCHD *arcn) -#else -void -ftree_sel(arcn) - ARCHD *arcn; -#endif { /* * set reference bit for this pattern. This linked list is only used @@ -245,13 +233,8 @@ ftree_sel(arcn) * have a selected member (reference count still 0) */ -#if __STDC__ void ftree_chk(void) -#else -void -ftree_chk() -#endif { FTREE *ft; int wban = 0; @@ -288,13 +271,8 @@ ftree_chk() * stdin). */ -#if __STDC__ static int ftree_arg(void) -#else -static int -ftree_arg() -#endif { char *pt; @@ -363,14 +341,8 @@ ftree_arg() * 0 when contents of arcn have been set with the next file, -1 when done. */ -#if __STDC__ int next_file(ARCHD *arcn) -#else -int -next_file(arcn) - ARCHD *arcn; -#endif { int cnt; time_t atime; @@ -436,13 +408,13 @@ next_file(arcn) * remember to force the time (this is -t on a read * directory, not a created directory). */ -# ifdef NET2_FTS - if (!tflag || (get_atdir(ftent->fts_statb.st_dev, - ftent->fts_statb.st_ino, &mtime, &atime) < 0)) -# else - if (!tflag || (get_atdir(ftent->fts_statp->st_dev, - ftent->fts_statp->st_ino, &mtime, &atime) < 0)) -# endif + if (!tflag || (get_atdir( +#ifdef NET2_FTS + ftent->fts_statb.st_dev, ftent->fts_statb.st_ino, +#else + ftent->fts_statp->st_dev, ftent->fts_statp->st_ino, +#endif + &mtime, &atime) < 0)) continue; set_ftime(ftent->fts_path, mtime, atime, 1); continue; @@ -454,28 +426,16 @@ next_file(arcn) ftent->fts_path); continue; case FTS_DNR: -# ifdef NET2_FTS - syswarn(1, errno, -# else - syswarn(1, ftent->fts_errno, -# endif + syswarn(1, FTS_ERRNO(ftent), "Unable to read directory %s", ftent->fts_path); continue; case FTS_ERR: -# ifdef NET2_FTS - syswarn(1, errno, -# else - syswarn(1, ftent->fts_errno, -# endif + syswarn(1, FTS_ERRNO(ftent), "File system traversal error"); continue; case FTS_NS: case FTS_NSOK: -# ifdef NET2_FTS - syswarn(1, errno, -# else - syswarn(1, ftent->fts_errno, -# endif + syswarn(1, FTS_ERRNO(ftent), "Unable to access %s", ftent->fts_path); continue; } @@ -488,11 +448,11 @@ next_file(arcn) arcn->pad = 0; arcn->ln_nlen = 0; arcn->ln_name[0] = '\0'; -# ifdef NET2_FTS +#ifdef NET2_FTS arcn->sb = ftent->fts_statb; -# else +#else arcn->sb = *(ftent->fts_statp); -# endif +#endif /* * file type based set up and copy into the arcn struct diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c index 7e8fa514f0a7..26c457568680 100644 --- a/bin/pax/gen_subs.c +++ b/bin/pax/gen_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: gen_subs.c,v 1.20 2001/01/04 15:39:51 lukem Exp $ */ +/* $NetBSD: gen_subs.c,v 1.21 2001/10/25 05:33:33 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)gen_subs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: gen_subs.c,v 1.20 2001/01/04 15:39:51 lukem Exp $"); +__RCSID("$NetBSD: gen_subs.c,v 1.21 2001/10/25 05:33:33 lukem Exp $"); #endif #endif /* not lint */ @@ -87,15 +87,8 @@ __RCSID("$NetBSD: gen_subs.c,v 1.20 2001/01/04 15:39:51 lukem Exp $"); * list the members of an archive in ls format */ -#if __STDC__ void ls_list(ARCHD *arcn, time_t now) -#else -void -ls_list(arcn, now) - ARCHD *arcn; - time_t now; -#endif { struct stat *sbp; char f_mode[MODELEN]; @@ -139,19 +132,10 @@ ls_list(arcn, now) * print device id's for devices, or sizes for other nodes */ if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK)) -# ifdef NET2_STAT - (void)printf("%4u,%4u ", MAJOR(sbp->st_rdev), - MINOR(sbp->st_rdev)); -# else (void)printf("%4lu,%4lu ", (long) MAJOR(sbp->st_rdev), (long) MINOR(sbp->st_rdev)); -# endif else { -# ifdef NET2_STAT - (void)printf("%9lu ", sbp->st_size); -# else - (void)printf("%9llu ", (long long)sbp->st_size); -# endif + (void)printf(OFFT_FP("9") " ", (OFFT_T)sbp->st_size); } /* @@ -173,14 +157,8 @@ ls_list(arcn, now) * print a short summary of file to tty. */ -#if __STDC__ void ls_tty(ARCHD *arcn) -#else -void -ls_tty(arcn) - ARCHD *arcn; -#endif { char f_date[DATELEN]; char f_mode[MODELEN]; @@ -210,16 +188,8 @@ ls_tty(arcn) * memset(). (or doing the memset() first). */ -#if __STDC__ void zf_strncpy(char *dest, const char *src, int len) -#else -void -zf_strncpy(dest, src, len) - char *dest; - char *src; - int len; -#endif { char *stop; @@ -239,16 +209,8 @@ zf_strncpy(dest, src, len) * doing a strncpy() then a strlen() */ -#if __STDC__ int l_strncpy(char *dest, const char *src, int len) -#else -int -l_strncpy(dest, src, len) - char *dest; - char *src; - int len; -#endif { char *stop; char *start; @@ -272,16 +234,8 @@ l_strncpy(dest, src, len) * unsigned long value */ -#if __STDC__ u_long asc_ul(char *str, int len, int base) -#else -u_long -asc_ul(str, len, base) - char *str; - int len; - int base; -#endif { char *stop; u_long tval = 0; @@ -323,17 +277,8 @@ asc_ul(str, len, base) * NOTE: the string created is NOT TERMINATED. */ -#if __STDC__ int ul_asc(u_long val, char *str, int len, int base) -#else -int -ul_asc(val, str, len, base) - u_long val; - char *str; - int len; - int base; -#endif { char *pt; u_long digit; @@ -377,28 +322,20 @@ ul_asc(val, str, len, base) #ifndef NET2_STAT /* - * asc_uqd() - * convert hex/octal character string into a u_quad_t. We do not have to - * check for overflow! (the headers in all supported formats are not large - * enough to create an overflow). + * asc_ull() + * convert hex/octal character string into a u_longlong_t. We do not have + * to to check for overflow! (the headers in all supported formats are + * not large enough to create an overflow). * NOTE: strings passed to us are NOT TERMINATED. * Return: - * u_quad_t value + * u_longlong_t value */ -#if __STDC__ -u_quad_t -asc_uqd(char *str, int len, int base) -#else -u_quad_t -asc_uqd(str, len, base) - char *str; - int len; - int base; -#endif +u_longlong_t +asc_ull(char *str, int len, int base) { char *stop; - u_quad_t tval = 0; + u_longlong_t tval = 0; stop = str + len; @@ -431,26 +368,17 @@ asc_uqd(str, len, base) } /* - * uqd_asc() - * convert an u_quad_t into a hex/oct ascii string. pads with LEADING + * ull_asc() + * convert an u_longlong_t into a hex/oct ascii string. pads with LEADING * ascii 0's to fill string completely * NOTE: the string created is NOT TERMINATED. */ -#if __STDC__ int -uqd_asc(u_quad_t val, char *str, int len, int base) -#else -int -uqd_asc(val, str, len, base) - u_quad_t val; - char *str; - int len; - int base; -#endif +ull_asc(u_longlong_t val, char *str, int len, int base) { char *pt; - u_quad_t digit; + u_longlong_t digit; /* * WARNING str is not '\0' terminated by this routine @@ -468,13 +396,13 @@ uqd_asc(val, str, len, base) *pt-- = '0' + (char)digit; else *pt-- = 'a' + (char)(digit - 10); - if ((val = (val >> 4)) == (u_quad_t)0) + if ((val = (val >> 4)) == (u_longlong_t)0) break; } } else { while (pt >= str) { *pt-- = '0' + (char)(val & 0x7); - if ((val = (val >> 3)) == (u_quad_t)0) + if ((val = (val >> 3)) == (u_longlong_t)0) break; } } @@ -484,7 +412,7 @@ uqd_asc(val, str, len, base) */ while (pt >= str) *pt-- = '0'; - if (val != (u_quad_t)0) + if (val != (u_longlong_t)0) return(-1); return(0); } @@ -498,7 +426,8 @@ check_Aflag(void) return 1; if (Aflag == 0) { Aflag = -1; - tty_warn(0, "Removing leading / from absolute path names in the archive"); + tty_warn(0, + "Removing leading / from absolute path names in the archive"); } return 0; } diff --git a/bin/pax/getoldopt.c b/bin/pax/getoldopt.c index 757c07abf4b6..edc3f24456a7 100644 --- a/bin/pax/getoldopt.c +++ b/bin/pax/getoldopt.c @@ -1,4 +1,4 @@ -/* $NetBSD: getoldopt.c,v 1.10 2000/07/04 17:17:49 thorpej Exp $ */ +/* $NetBSD: getoldopt.c,v 1.11 2001/10/25 05:33:33 lukem Exp $ */ /* * Plug-compatible replacement for getopt() for parsing tar-like @@ -11,7 +11,7 @@ #include #ifndef lint -__RCSID("$NetBSD: getoldopt.c,v 1.10 2000/07/04 17:17:49 thorpej Exp $"); +__RCSID("$NetBSD: getoldopt.c,v 1.11 2001/10/25 05:33:33 lukem Exp $"); #endif /* not lint */ #include @@ -23,12 +23,8 @@ __RCSID("$NetBSD: getoldopt.c,v 1.10 2000/07/04 17:17:49 thorpej Exp $"); #include "extern.h" int -getoldopt(argc, argv, optstring, longopts, index) - int argc; - char **argv; - const char *optstring; - struct option *longopts; - int *index; +getoldopt(int argc, char **argv, const char *optstring, + struct option *longopts, int *index) { static char *key; /* Points to next keyletter */ static char use_getopt; /* !=0 if argv[1][0] was '-' */ diff --git a/bin/pax/options.c b/bin/pax/options.c index d45256c6e02d..917c63cfdd90 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -1,4 +1,4 @@ -/* $NetBSD: options.c,v 1.32 2001/07/22 13:33:58 wiz Exp $ */ +/* $NetBSD: options.c,v 1.33 2001/10/25 05:33:33 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: options.c,v 1.32 2001/07/22 13:33:58 wiz Exp $"); +__RCSID("$NetBSD: options.c,v 1.33 2001/10/25 05:33:33 lukem Exp $"); #endif #endif /* not lint */ @@ -76,18 +76,18 @@ static OPLIST *ophead = NULL; /* head for format specific options -x */ static OPLIST *optail = NULL; /* option tail */ static char *firstminusC; /* first -C argument encountered. */ -static int no_op __P((void)); -static void printflg __P((unsigned int)); -static int c_frmt __P((const void *, const void *)); -static off_t str_offt __P((char *)); -static void pax_options __P((int, char **)); -static void pax_usage __P((void)); -static void tar_options __P((int, char **)); -static void tar_usage __P((void)); -static void cpio_options __P((int, char **)); -static void cpio_usage __P((void)); +static int no_op(void); +static void printflg(unsigned int); +static int c_frmt(const void *, const void *); +static off_t str_offt(char *); +static void pax_options(int, char **); +static void pax_usage(void); +static void tar_options(int, char **); +static void tar_usage(void); +static void cpio_options(int, char **); +static void cpio_usage(void); -static void checkpositionalminusC __P((char ***, int (*)(char *, int))); +static void checkpositionalminusC(char ***, int (*)(char *, int)); #define GZIP_CMD "gzip" /* command to run as gzip */ #define COMPRESS_CMD "compress" /* command to run as compress */ @@ -153,15 +153,8 @@ int ford[] = {F_USTAR, F_TAR, F_SV4CRC, F_SV4CPIO, F_CPIO, F_BCPIO, -1}; * parser */ -#if __STDC__ void options(int argc, char **argv) -#else -void -options(argc, argv) - int argc; - char **argv; -#endif { /* @@ -188,15 +181,8 @@ options(argc, argv) * the user specified a legal set of flags. If not, complain and exit */ -#if __STDC__ static void pax_options(int argc, char **argv) -#else -static void -pax_options(argc, argv) - int argc; - char **argv; -#endif { int c; int i; @@ -719,15 +705,8 @@ struct option tar_longopts[] = { { 0, 0, 0, 0 }, }; -#if __STDC__ static void tar_options(int argc, char **argv) -#else -static void -tar_options(argc, argv) - int argc; - char **argv; -#endif { int c; int fstdin = 0; @@ -975,15 +954,8 @@ tar_options(argc, argv) * the user specified a legal set of flags. If not, complain and exit */ -#if __STDC__ static void cpio_options(int argc, char **argv) -#else -static void -cpio_options(argc, argv) - int argc; - char **argv; -#endif { FSUB tmp; unsigned int flg = 0; @@ -1244,14 +1216,8 @@ cpio_options(argc, argv) * print out those invalid flag sets found to the user */ -#if __STDC__ static void printflg(unsigned int flg) -#else -static void -printflg(flg) - unsigned int flg; -#endif { int nxt; int pos = 0; @@ -1271,15 +1237,8 @@ printflg(flg) * by the user */ -#if __STDC__ static int c_frmt(const void *a, const void *b) -#else -static int -c_frmt(a, b) - void *a; - void *b; -#endif { return(strcmp(((FSUB *)a)->name, ((FSUB *)b)->name)); } @@ -1292,13 +1251,8 @@ c_frmt(a, b) * pointer to next OPLIST entry or NULL (end of list). */ -#if __STDC__ OPLIST * opt_next(void) -#else -OPLIST * -opt_next() -#endif { OPLIST *opt; @@ -1313,13 +1267,8 @@ opt_next() * when the format does not support options. */ -#if __STDC__ int bad_opt(void) -#else -int -bad_opt() -#endif { OPLIST *opt; @@ -1344,14 +1293,8 @@ bad_opt() * 0 if format in name=value format, -1 if -o is passed junk */ -#if __STDC__ int opt_add(const char *str) -#else -int -opt_add(str) - const char *str; -#endif { OPLIST *opt; char *frpt; @@ -1413,25 +1356,14 @@ opt_add(str) * 0 for an error, a positive value o.w. */ -#if __STDC__ static off_t str_offt(char *val) -#else -static off_t -str_offt(val) - char *val; -#endif { char *expr; off_t num, t; -# ifdef NET2_STAT - num = strtol(val, &expr, 0); - if ((num == LONG_MAX) || (num <= 0) || (expr == val)) -# else - num = strtoq(val, &expr, 0); - if ((num == QUAD_MAX) || (num <= 0) || (expr == val)) -# endif + num = STRTOOFFT(val, &expr, 0); + if ((num == OFFT_MAX) || (num <= 0) || (expr == val)) return(0); switch(*expr) { @@ -1488,13 +1420,8 @@ str_offt(val) * 0 */ -#if __STDC__ static int no_op(void) -#else -static int -no_op() -#endif { return(0); } @@ -1504,13 +1431,8 @@ no_op() * print the usage summary to the user */ -#if __STDC__ void pax_usage(void) -#else -void -pax_usage() -#endif { (void)fputs("usage: pax [-cdnvz] [-E limit] [-f archive] ", stderr); (void)fputs("[-s replstr] ... [-U user] ...", stderr); @@ -1544,13 +1466,8 @@ pax_usage() * print the usage summary to the user */ -#if __STDC__ void tar_usage(void) -#else -void -tar_usage() -#endif { (void)fputs("usage: tar -{txru}[cevfbhlmopwBLPX014578] [tapefile] ", stderr); @@ -1564,13 +1481,8 @@ tar_usage() * print the usage summary to the user */ -#if __STDC__ void cpio_usage(void) -#else -void -cpio_usage() -#endif { #if 1 @@ -1604,14 +1516,8 @@ cpio_usage() * Returns: -1 for listing, else what ftree_add or pat_add returned. */ -#ifdef __STDC__ int opt_chdir(char *name) -#else -int -opt_chdir(name) - char *name; -#endif { switch (act) { default: @@ -1631,15 +1537,8 @@ opt_chdir(name) * checkpositionalminusC(argvp, addfunc) */ -#ifdef __STDC__ void checkpositionalminusC(char ***argvp, int (*addfunc)(char *, int)) -#else -void -checkpositionalminusC(argvp, addfunc) - char ***argvp; - int (*addfunc)(); -#endif { while (**argvp != (char *)NULL) { if (!strcmp(**argvp, "-C")) { diff --git a/bin/pax/pat_rep.c b/bin/pax/pat_rep.c index 8afd3cea343c..1e70c2ad3007 100644 --- a/bin/pax/pat_rep.c +++ b/bin/pax/pat_rep.c @@ -1,4 +1,4 @@ -/* $NetBSD: pat_rep.c,v 1.11 2000/02/17 03:12:25 itohy Exp $ */ +/* $NetBSD: pat_rep.c,v 1.12 2001/10/25 05:33:33 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)pat_rep.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: pat_rep.c,v 1.11 2000/02/17 03:12:25 itohy Exp $"); +__RCSID("$NetBSD: pat_rep.c,v 1.12 2001/10/25 05:33:33 lukem Exp $"); #endif #endif /* not lint */ @@ -77,15 +77,15 @@ static PATTERN *pattail = NULL; /* file pattern match list tail */ static REPLACE *rephead = NULL; /* replacement string list head */ static REPLACE *reptail = NULL; /* replacement string list tail */ -static int rep_name __P((char *, int *, int)); -static int tty_rename __P((ARCHD *)); -static int fix_path __P((char *, int *, char *, int)); -static int fn_match __P((char *, char *, char **)); -static char * range_match __P((char *, int)); +static int rep_name(char *, int *, int); +static int tty_rename(ARCHD *); +static int fix_path(char *, int *, char *, int); +static int fn_match(char *, char *, char **); +static char * range_match(char *, int); #ifdef NET2_REGEX -static int resub __P((regexp *, char *, char *, char *)); +static int resub(regexp *, char *, char *, char *); #else -static int resub __P((regex_t *, regmatch_t *, char *, char *, char *, char *)); +static int resub(regex_t *, regmatch_t *, char *, char *, char *, char *); #endif /* @@ -104,22 +104,16 @@ static int resub __P((regex_t *, regmatch_t *, char *, char *, char *, char *)); * the list of replacement patterns; -1 otherwise. */ -#if __STDC__ int rep_add(char *str) -#else -int -rep_add(str) - char *str; -#endif { char *pt1; char *pt2; REPLACE *rep; -# ifndef NET2_REGEX +#ifndef NET2_REGEX int res; char rebuf[BUFSIZ]; -# endif +#endif /* * throw out the bad parameters @@ -152,14 +146,14 @@ rep_add(str) } *pt1 = '\0'; -# ifdef NET2_REGEX +#ifdef NET2_REGEX if ((rep->rcmp = regcomp(str+1)) == NULL) { -# else +#else if ((res = regcomp(&(rep->rcmp), str+1, 0)) != 0) { regerror(res, &(rep->rcmp), rebuf, sizeof(rebuf)); tty_warn(1, "%s while compiling regular expression %s", rebuf, str); -# endif +#endif (void)free((char *)rep); return(-1); } @@ -188,11 +182,11 @@ rep_add(str) rep->flgs |= PRNT; break; default: -# ifdef NET2_REGEX +#ifdef NET2_REGEX (void)free((char *)rep->rcmp); -# else +#else regfree(&(rep->rcmp)); -# endif +#endif (void)free((char *)rep); *pt1 = *str; tty_warn(1, "Invalid replacement string option %s", @@ -228,15 +222,8 @@ rep_add(str) * 0 if the pattern was added to the list, -1 otherwise */ -#if __STDC__ int pat_add(char *str, int ischdir) -#else -int -pat_add(str ischdir) - char *str; - int ischdir; -#endif { PATTERN *pt; @@ -278,13 +265,8 @@ pat_add(str ischdir) * a selected archive member. */ -#if __STDC__ void pat_chk(void) -#else -void -pat_chk() -#endif { PATTERN *pt; int wban = 0; @@ -320,14 +302,8 @@ pat_chk() * match, -1 otherwise. */ -#if __STDC__ int pat_sel(ARCHD *arcn) -#else -int -pat_sel(arcn) - ARCHD *arcn; -#endif { PATTERN *pt; PATTERN **ppt; @@ -445,14 +421,8 @@ pat_sel(arcn) * looking for more members) */ -#if __STDC__ int pat_match(ARCHD *arcn) -#else -int -pat_match(arcn) - ARCHD *arcn; -#endif { PATTERN *pt; @@ -529,16 +499,8 @@ pat_match(arcn) * Note: *pend may be changed to show where the prefix ends. */ -#if __STDC__ static int fn_match(char *pattern, char *string, char **pend) -#else -static int -fn_match(pattern, string, pend) - char *pattern; - char *string; - char **pend; -#endif { char c; char test; @@ -610,15 +572,8 @@ fn_match(pattern, string, pend) /* NOTREACHED */ } -#ifdef __STDC__ static char * range_match(char *pattern, int test) -#else -static char * -range_match(pattern, test) - char *pattern; - int test; -#endif { char c; char c2; @@ -660,14 +615,8 @@ range_match(pattern, test) * 0 continue to process file, 1 skip this file, -1 pax is finished */ -#if __STDC__ int mod_name(ARCHD *arcn) -#else -int -mod_name(arcn) - ARCHD *arcn; -#endif { int res = 0; @@ -727,14 +676,8 @@ mod_name(arcn) * 0 process this file, 1 skip this file, -1 we need to exit pax */ -#if __STDC__ static int tty_rename(ARCHD *arcn) -#else -static int -tty_rename(arcn) - ARCHD *arcn; -#endif { char tmpname[PAXPATHLEN+2]; int res; @@ -798,16 +741,8 @@ tty_rename(arcn) * 0 if ok, -1 if failure (name too long) */ -#if __STDC__ int set_dest(ARCHD *arcn, char *dest_dir, int dir_len) -#else -int -set_dest(arcn, dest_dir, dir_len) - ARCHD *arcn; - char *dest_dir; - int dir_len; -#endif { if (fix_path(arcn->name, &(arcn->nlen), dest_dir, dir_len) < 0) return(-1); @@ -833,17 +768,8 @@ set_dest(arcn, dest_dir, dir_len) * 0 if ok, -1 if the final name is too long */ -#if __STDC__ static int fix_path( char *or_name, int *or_len, char *dir_name, int dir_len) -#else -static int -fix_path(or_name, or_len, dir_name, dir_len) - char *or_name; - int *or_len; - char *dir_name; - int dir_len; -#endif { char *src; char *dest; @@ -905,16 +831,8 @@ fix_path(or_name, or_len, dir_name, dir_len) * ended up empty) */ -#if __STDC__ static int rep_name(char *name, int *nlen, int prnt) -#else -static int -rep_name(name, nlen, prnt) - char *name; - int *nlen; - int prnt; -#endif { REPLACE *pt; char *inpt; @@ -923,9 +841,9 @@ rep_name(name, nlen, prnt) char *rpt; int found = 0; int res; -# ifndef NET2_REGEX +#ifndef NET2_REGEX regmatch_t pm[MAXSUBEXP]; -# endif +#endif char nname[PAXPATHLEN+1]; /* final result of all replacements */ char buf1[PAXPATHLEN+1]; /* where we work on the name */ @@ -952,11 +870,11 @@ rep_name(name, nlen, prnt) * check for a successful substitution, if not go to * the next pattern, or cleanup if we were global */ -# ifdef NET2_REGEX +#ifdef NET2_REGEX if (regexec(pt->rcmp, inpt) == 0) -# else +#else if (regexec(&(pt->rcmp), inpt, MAXSUBEXP, pm, 0) != 0) -# endif +#endif break; /* @@ -967,11 +885,11 @@ rep_name(name, nlen, prnt) * do not create a string too long). */ found = 1; -# ifdef NET2_REGEX +#ifdef NET2_REGEX rpt = pt->rcmp->startp[0]; -# else +#else rpt = inpt + pm[0].rm_so; -# endif +#endif while ((inpt < rpt) && (outpt < endpt)) *outpt++ = *inpt++; @@ -984,12 +902,13 @@ rep_name(name, nlen, prnt) * replacement string and place it the prefix in the * final output. If we have problems, skip it. */ -# ifdef NET2_REGEX - if ((res = resub(pt->rcmp,pt->nstr,outpt,endpt)) < 0) { -# else - if ((res = resub(&(pt->rcmp),pm,pt->nstr,inpt, - outpt,endpt)) < 0) { -# endif + if ((res = +#ifdef NET2_REGEX + resub(pt->rcmp,pt->nstr,outpt,endpt) +#else + resub(&(pt->rcmp),pm,pt->nstr,inpt, outpt,endpt) +#endif + ) < 0) { if (prnt) tty_warn(1, "Replacement name error %s", name); @@ -1007,11 +926,11 @@ rep_name(name, nlen, prnt) * the final result. Make sure we do not overrun the * output buffer */ -# ifdef NET2_REGEX +#ifdef NET2_REGEX inpt = pt->rcmp->endp[0]; -# else +#else inpt += pm[0].rm_eo - pm[0].rm_so; -# endif +#endif if ((outpt == endpt) || (*inpt == '\0')) break; @@ -1078,17 +997,8 @@ rep_name(name, nlen, prnt) * -1 if error, or the number of characters added to the destination. */ -#if __STDC__ static int resub(regexp *prog, char *src, char *dest, char *destend) -#else -static int -resub(prog, src, dest, destend) - regexp *prog; - char *src; - char *dest; - char *destend; -#endif { char *spt; char *dpt; @@ -1136,20 +1046,9 @@ resub(prog, src, dest, destend) * -1 if error, or the number of characters added to the destination. */ -#if __STDC__ static int resub(regex_t *rp, regmatch_t *pm, char *src, char *txt, char *dest, char *destend) -#else -static int -resub(rp, pm, src, txt, dest, destend) - regex_t *rp; - regmatch_t *pm; - char *src; - char *txt; - char *dest; - char *destend; -#endif { char *spt; char *dpt; diff --git a/bin/pax/pax.c b/bin/pax/pax.c index 153809b61f15..ad3fcff02e32 100644 --- a/bin/pax/pax.c +++ b/bin/pax/pax.c @@ -1,4 +1,4 @@ -/* $NetBSD: pax.c,v 1.13 2000/10/22 15:41:31 kleink Exp $ */ +/* $NetBSD: pax.c,v 1.14 2001/10/25 05:33:33 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ #if 0 static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: pax.c,v 1.13 2000/10/22 15:41:31 kleink Exp $"); +__RCSID("$NetBSD: pax.c,v 1.14 2001/10/25 05:33:33 lukem Exp $"); #endif #endif /* not lint */ @@ -63,7 +63,7 @@ __RCSID("$NetBSD: pax.c,v 1.13 2000/10/22 15:41:31 kleink Exp $"); #include #include "pax.h" #include "extern.h" -static int gen_init __P((void)); +static int gen_init(void); /* * PAX main routines, general globals and some simple start up routines @@ -223,15 +223,8 @@ sigset_t s_mask; /* signal mask for cleanup critical sect */ * Return: 0 if ok, 1 otherwise */ -#if __STDC__ int main(int argc, char **argv) -#else -int -main(argc, argv) - int argc; - char **argv; -#endif { /* * parse options, determine operational mode, general init @@ -277,14 +270,8 @@ main(argc, argv) * never.... */ -#if __STDC__ void sig_cleanup(int which_sig) -#else -void -sig_cleanup(which_sig) - int which_sig; -#endif { /* * restore modes and times for any dirs we may have created @@ -311,13 +298,8 @@ sig_cleanup(which_sig) * when dealing with a medium to large sized archives. */ -#if __STDC__ static int gen_init(void) -#else -static int -gen_init() -#endif { struct rlimit reslimit; struct sigaction n_hand; diff --git a/bin/pax/pax.h b/bin/pax/pax.h index c42885cb0dc2..cee845b302d7 100644 --- a/bin/pax/pax.h +++ b/bin/pax/pax.h @@ -1,4 +1,4 @@ -/* $NetBSD: pax.h,v 1.10 2001/09/04 21:47:31 wiz Exp $ */ +/* $NetBSD: pax.h,v 1.11 2001/10/25 05:33:33 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -166,13 +166,13 @@ typedef struct { int inhead; /* is the trailer encoded in a valid header? */ /* if not, trailers are assumed to be found */ /* in invalid headers (i.e like tar) */ - int (*id) /* checks if a buffer is a valid header */ - __P((char *, int)); /* returns 1 if it is, o.w. returns a 0 */ - int (*st_rd) /* initialize routine for read. so format */ - __P((void)); /* can set up tables etc before it starts */ + int (*id)(char *, int); /* checks if a buffer is a valid header */ + /* returns 1 if it is, o.w. returns a 0 */ + int (*st_rd)(void); /* initialize routine for read. so format */ + /* can set up tables etc before it starts */ /* reading an archive */ int (*rd) /* read header routine. passed a pointer to */ - __P((ARCHD *, char *)); /* ARCHD. It must extract the info */ + (ARCHD *, char *); /* ARCHD. It must extract the info */ /* from the format and store it in the ARCHD */ /* struct. This routine is expected to fill */ /* all the fields in the ARCHD (including */ @@ -183,14 +183,13 @@ typedef struct { /* amount of padding and the number of bytes */ /* of data which follow the header. This info */ /* is used to skip to the next file header */ - off_t (*end_rd) /* read cleanup. Allows format to clean up */ - __P((void)); /* and MUST RETURN THE LENGTH OF THE TRAILER */ + off_t (*end_rd)(void); /* read cleanup. Allows format to clean up */ + /* and MUST RETURN THE LENGTH OF THE TRAILER */ /* RECORD (so append knows how many bytes */ /* to move back to rewrite the trailer) */ - int (*st_wr) /* initialize routine for write operations */ - __P((void)); - int (*wr) /* write archive header. Passed an ARCHD */ - __P((ARCHD *)); /* filled with the specs on the next file to */ + int (*st_wr)(void); /* initialize routine for write operations */ + int (*wr)(ARCHD *); /* write archive header. Passed an ARCHD */ + /* filled with the specs on the next file to */ /* archived. Returns a 1 if no file data is */ /* is to be stored; 0 if file data is to be */ /* added. A -1 is returned if a write */ @@ -199,25 +198,24 @@ typedef struct { /* the proper padding can be added after */ /* file data. This routine must NEVER write */ /* a flawed archive header. */ - int (*end_wr) /* end write. write the trailer and do any */ - __P((void)); /* other format specific functions needed */ + int (*end_wr)(void); /* end write. write the trailer and do any */ + /* other format specific functions needed */ /* at the ecnd of a archive write */ int (*trail) /* returns 0 if a valid trailer, -1 if not */ - __P((char *, int, int *)); /* For formats which encode the */ + (char *, int, int *); /* For formats which encode the */ /* trailer outside of a valid header, a */ /* return value of 1 indicates that the block */ /* passed to it can never contain a valid */ /* header (skip this block, no point in */ /* looking at it) */ int (*subtrail) /* read/process file data from the archive */ - __P((ARCHD *)); /* this function is called for trailers */ + (ARCHD *); /* this function is called for trailers */ /* inside headers. */ int (*rd_data) /* read/process file data from the archive */ - __P((ARCHD *, int, off_t *)); + (ARCHD *, int, off_t *); int (*wr_data) /* write/process file data to the archive */ - __P((ARCHD *, int, off_t *)); - int (*options) /* process format specific options (-o) */ - __P((void)); + (ARCHD *, int, off_t *); + int (*options)(void); /* process format specific options (-o) */ } FSUB; /* @@ -253,3 +251,26 @@ typedef struct oplist { * ${TMPDIR} or, as a fall-back, _PATH_TMP. */ #define TMPFILE "paxXXXXXX" + +/* + * Macros to manipulate off_t as a u_long or u_longlong_t + */ +#ifdef NET2_STAT +#define OFFT_F "%lu" +#define OFFT_FP(x) "%" x "lu" +#define OFFT_T u_long +#define ASC_OFFT(x,y,z) asc_ul(x,y,z) +#define OFFT_ASC(w,x,y,z) ul_asc((u_long)w,x,y,z) +#define OFFT_OCT(w,x,y,z) ul_oct((u_long)w,x,y,z) +#define STRTOOFFT(x,y,z) strtol(x,y,z) +#define OFFT_MAX LONG_MAX +#else +#define OFFT_F "%llu" +#define OFFT_FP(x) "%" x "llu" +#define OFFT_T u_longlong_t +#define ASC_OFFT(x,y,z) asc_ull(x,y,z) +#define OFFT_ASC(w,x,y,z) ull_asc((u_longlong_t)w,x,y,z) +#define OFFT_OCT(w,x,y,z) ull_oct((u_longlong_t)w,x,y,z) +#define STRTOOFFT(x,y,z) strtoll(x,y,z) +#define OFFT_MAX ULLONG_MAX +#endif diff --git a/bin/pax/sel_subs.c b/bin/pax/sel_subs.c index 7eb4c79e126b..07aa4243639e 100644 --- a/bin/pax/sel_subs.c +++ b/bin/pax/sel_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: sel_subs.c,v 1.12 2000/02/17 03:12:26 itohy Exp $ */ +/* $NetBSD: sel_subs.c,v 1.13 2001/10/25 05:33:33 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)sel_subs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: sel_subs.c,v 1.12 2000/02/17 03:12:26 itohy Exp $"); +__RCSID("$NetBSD: sel_subs.c,v 1.13 2001/10/25 05:33:33 lukem Exp $"); #endif #endif /* not lint */ @@ -66,10 +66,10 @@ __RCSID("$NetBSD: sel_subs.c,v 1.12 2000/02/17 03:12:26 itohy Exp $"); #include "sel_subs.h" #include "extern.h" -static int str_sec __P((const char *, time_t *)); -static int usr_match __P((ARCHD *)); -static int grp_match __P((ARCHD *)); -static int trng_match __P((ARCHD *)); +static int str_sec(const char *, time_t *); +static int usr_match(ARCHD *); +static int grp_match(ARCHD *); +static int trng_match(ARCHD *); static TIME_RNG *trhead = NULL; /* time range list head */ static TIME_RNG *trtail = NULL; /* time range list tail */ @@ -87,14 +87,8 @@ static GRPT **grptb = NULL; /* group selection table */ * 0 if this archive member should be processed, 1 if it should be skipped */ -#if __STDC__ int sel_chk(ARCHD *arcn) -#else -int -sel_chk(arcn) - ARCHD *arcn; -#endif { if (((usrtb != NULL) && usr_match(arcn)) || ((grptb != NULL) && grp_match(arcn)) || @@ -118,14 +112,8 @@ sel_chk(arcn) * 0 if added ok, -1 otherwise; */ -#if __STDC__ int usr_add(char *str) -#else -int -usr_add(str) - char *str; -#endif { u_int indx; USRT *pt; @@ -159,11 +147,7 @@ usr_add(str) } uid = (uid_t)pw->pw_uid; } else -# ifdef NET2_STAT - uid = (uid_t)atoi(str+1); -# else uid = (uid_t)strtoul(str+1, (char **)NULL, 10); -# endif endpwent(); /* @@ -198,14 +182,8 @@ usr_add(str) * 0 if this archive member should be processed, 1 if it should be skipped */ -#if __STDC__ static int usr_match(ARCHD *arcn) -#else -static int -usr_match(arcn) - ARCHD *arcn; -#endif { USRT *pt; @@ -232,14 +210,8 @@ usr_match(arcn) * 0 if added ok, -1 otherwise; */ -#if __STDC__ int grp_add(char *str) -#else -int -grp_add(str) - char *str; -#endif { u_int indx; GRPT *pt; @@ -274,11 +246,7 @@ grp_add(str) } gid = (gid_t)gr->gr_gid; } else -# ifdef NET2_STAT - gid = (gid_t)atoi(str+1); -# else gid = (gid_t)strtoul(str+1, (char **)NULL, 10); -# endif endgrent(); /* @@ -313,14 +281,8 @@ grp_add(str) * 0 if this archive member should be processed, 1 if it should be skipped */ -#if __STDC__ static int grp_match(ARCHD *arcn) -#else -static int -grp_match(arcn) - ARCHD *arcn; -#endif { GRPT *pt; @@ -369,14 +331,8 @@ grp_match(arcn) * 0 if the time range was added to the list, -1 otherwise */ -#if __STDC__ int trng_add(char *str) -#else -int -trng_add(str) - char *str; -#endif { TIME_RNG *pt; char *up_pt = NULL; @@ -516,14 +472,8 @@ trng_add(str) * 0 if this archive member should be processed, 1 if it should be skipped */ -#if __STDC__ static int trng_match(ARCHD *arcn) -#else -static int -trng_match(arcn) - ARCHD *arcn; -#endif { TIME_RNG *pt; @@ -593,15 +543,8 @@ trng_match(arcn) #define ATOI2(s) ((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0')) -#if __STDC__ static int str_sec(const char *p, time_t *tval) -#else -static int -str_sec(p, tval) - const char *p; - time_t *tval; -#endif { struct tm *lt; const char *dot, *t; diff --git a/bin/pax/tables.c b/bin/pax/tables.c index 9fe00ddbcf18..b0ca97ce873c 100644 --- a/bin/pax/tables.c +++ b/bin/pax/tables.c @@ -1,4 +1,4 @@ -/* $NetBSD: tables.c,v 1.14 2001/10/24 11:28:55 lukem Exp $ */ +/* $NetBSD: tables.c,v 1.15 2001/10/25 05:33:33 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: tables.c,v 1.14 2001/10/24 11:28:55 lukem Exp $"); +__RCSID("$NetBSD: tables.c,v 1.15 2001/10/25 05:33:33 lukem Exp $"); #endif #endif /* not lint */ @@ -88,7 +88,7 @@ static u_long dircnt; /* entries in dir time/mode storage */ #endif static int ffd = -1; /* tmp file for file time table name storage */ -static DEVT *chk_dev __P((dev_t, int)); +static DEVT *chk_dev(dev_t, int); /* * hard link table routines @@ -113,13 +113,8 @@ static DEVT *chk_dev __P((dev_t, int)); * 0 if created, -1 if failure */ -#if __STDC__ int lnk_start(void) -#else -int -lnk_start() -#endif { if (ltab != NULL) return(0); @@ -142,14 +137,8 @@ lnk_start() * if found returns 1; if not found returns 0; -1 on error */ -#if __STDC__ int chk_lnk(ARCHD *arcn) -#else -int -chk_lnk(arcn) - ARCHD *arcn; -#endif { HRDLNK *pt; HRDLNK **ppt; @@ -234,14 +223,8 @@ chk_lnk(arcn) * we do not want to accidently point another file at it later on. */ -#if __STDC__ void purg_lnk(ARCHD *arcn) -#else -void -purg_lnk(arcn) - ARCHD *arcn; -#endif { HRDLNK *pt; HRDLNK **ppt; @@ -294,13 +277,8 @@ purg_lnk(arcn) * write phase */ -#if __STDC__ void lnk_end(void) -#else -void -lnk_end() -#endif { int i; HRDLNK *pt; @@ -359,13 +337,8 @@ lnk_end() * 0 if the table and file was created ok, -1 otherwise */ -#if __STDC__ int ftime_start(void) -#else -int -ftime_start() -#endif { const char *tmpdir; char template[MAXPATHLEN]; @@ -406,14 +379,8 @@ ftime_start() * -1 on error */ -#if __STDC__ int chk_ftime(ARCHD *arcn) -#else -int -chk_ftime(arcn) - ARCHD *arcn; -#endif { FTM *pt; int namelen; @@ -531,13 +498,8 @@ chk_ftime(arcn) * 0 if successful, -1 otherwise */ -#if __STDC__ int name_start(void) -#else -int -name_start() -#endif { if (ntab != NULL) return(0); @@ -558,16 +520,8 @@ name_start() * 0 if added, -1 otherwise */ -#if __STDC__ int add_name(char *oname, int onamelen, char *nname) -#else -int -add_name(oname, onamelen, nname) - char *oname; - int onamelen; - char *nname; -#endif { NAMT *pt; u_int indx; @@ -634,15 +588,8 @@ add_name(oname, onamelen, nname) * new name (oname is the link to name) */ -#if __STDC__ void sub_name(char *oname, int *onamelen) -#else -void -sub_name(oname, onamelen) - char *oname; - int *onamelen; -#endif { NAMT *pt; u_int indx; @@ -724,13 +671,8 @@ sub_name(oname, onamelen) * 0 if successful, -1 otherwise */ -#if __STDC__ int dev_start(void) -#else -int -dev_start() -#endif { if (dtab != NULL) return(0); @@ -751,14 +693,8 @@ dev_start() * 0 if added ok, -1 otherwise */ -#if __STDC__ int add_dev(ARCHD *arcn) -#else -int -add_dev(arcn) - ARCHD *arcn; -#endif { if (chk_dev(arcn->sb.st_dev, 1) == NULL) return(-1); @@ -778,15 +714,8 @@ add_dev(arcn) * is returned (indicates an error). */ -#if __STDC__ static DEVT * chk_dev(dev_t dev, int add) -#else -static DEVT * -chk_dev(dev, add) - dev_t dev; - int add; -#endif { DEVT *pt; u_int indx; @@ -843,16 +772,8 @@ chk_dev(dev, add) * 0 if all ok, -1 otherwise. */ -#if __STDC__ int map_dev(ARCHD *arcn, u_long dev_mask, u_long ino_mask) -#else -int -map_dev(arcn, dev_mask, ino_mask) - ARCHD *arcn; - u_long dev_mask; - u_long ino_mask; -#endif { DEVT *pt; DLIST *dpt; @@ -994,13 +915,8 @@ map_dev(arcn, dev_mask, ino_mask) * 0 is created ok, -1 otherwise. */ -#if __STDC__ int atdir_start(void) -#else -int -atdir_start() -#endif { if (atab != NULL) return(0); @@ -1020,13 +936,8 @@ atdir_start() * entries are for directories READ by pax */ -#if __STDC__ void atdir_end(void) -#else -void -atdir_end() -#endif { ATDIR *pt; int i; @@ -1056,18 +967,8 @@ atdir_end() * and chained by inode number. This is for directories READ by pax */ -#if __STDC__ void add_atdir(char *fname, dev_t dev, ino_t ino, time_t mtime, time_t atime) -#else -void -add_atdir(fname, dev, ino, mtime, atime) - char *fname; - dev_t dev; - ino_t ino; - time_t mtime; - time_t atime; -#endif { ATDIR *pt; u_int indx; @@ -1128,17 +1029,8 @@ add_atdir(fname, dev, ino, mtime, atime) * 0 if found, -1 if not found. */ -#if __STDC__ int get_atdir(dev_t dev, ino_t ino, time_t *mtime, time_t *atime) -#else -int -get_atdir(dev, ino, mtime, atime) - dev_t dev; - ino_t ino; - time_t *mtime; - time_t *atime; -#endif { ATDIR *pt; ATDIR **ppt; @@ -1216,13 +1108,8 @@ static DIRDATA *dirdata_head; * 0 if ok, -1 otherwise */ -#if __STDC__ int dir_start(void) -#else -int -dir_start() -#endif { #ifdef DIRS_USE_FILE const char *tmpdir; @@ -1262,17 +1149,8 @@ dir_start() * pax spec) */ -#if __STDC__ void add_dir(char *name, int nlen, struct stat *psb, int frc_mode) -#else -void -add_dir(name, nlen, psb, frc_mode) - char *name; - int nlen; - struct stat *psb; - int frc_mode; -#endif { #ifdef DIRS_USE_FILE DIRDATA dblk; @@ -1338,13 +1216,8 @@ add_dir(name, nlen, psb, frc_mode) * by pax */ -#if __STDC__ void proc_dir(void) -#else -void -proc_dir() -#endif { #ifdef DIRS_USE_FILE char name[PAXPATHLEN+1]; @@ -1431,16 +1304,8 @@ proc_dir() * the hash value of the string MOD (%) the table size. */ -#if __STDC__ u_int st_hash(char *name, int len, int tabsz) -#else -u_int -st_hash(name, len, tabsz) - char *name; - int len; - int tabsz; -#endif { char *pt; char *dest; diff --git a/bin/pax/tar.c b/bin/pax/tar.c index 1d1b0b1be407..055984511974 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -1,4 +1,4 @@ -/* $NetBSD: tar.c,v 1.18 2000/02/17 03:12:26 itohy Exp $ */ +/* $NetBSD: tar.c,v 1.19 2001/10/25 05:33:34 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: tar.c,v 1.18 2000/02/17 03:12:26 itohy Exp $"); +__RCSID("$NetBSD: tar.c,v 1.19 2001/10/25 05:33:34 lukem Exp $"); #endif #endif /* not lint */ @@ -68,11 +68,11 @@ __RCSID("$NetBSD: tar.c,v 1.18 2000/02/17 03:12:26 itohy Exp $"); * Routines for reading, writing and header identify of various versions of tar */ -static u_long tar_chksm __P((char *, int)); -static char *name_split __P((char *, int)); -static int ul_oct __P((u_long, char *, int, int)); +static u_long tar_chksm(char *, int); +static char *name_split(char *, int); +static int ul_oct(u_long, char *, int, int); #ifndef NET2_STAT -static int uqd_oct __P((u_quad_t, char *, int, int)); +static int ull_oct(u_longlong_t, char *, int, int); #endif /* @@ -90,13 +90,8 @@ char *gnu_hack_string; /* ././@LongLink hackery */ * 0 if ok, -1 otherwise (what wr_skip returns) */ -#if __STDC__ int tar_endwr(void) -#else -int -tar_endwr() -#endif { return(wr_skip((off_t)(NULLCNT*BLKMULT))); } @@ -108,13 +103,8 @@ tar_endwr() * size of trailer (2 * BLKMULT) */ -#if __STDC__ off_t tar_endrd(void) -#else -off_t -tar_endrd() -#endif { return((off_t)(NULLCNT*BLKMULT)); } @@ -130,16 +120,8 @@ tar_endrd() * could never contain a header. */ -#if __STDC__ int tar_trail(char *buf, int in_resync, int *cnt) -#else -int -tar_trail(buf, in_resync, cnt) - char *buf; - int in_resync; - int *cnt; -#endif { int i; @@ -181,17 +163,8 @@ tar_trail(buf, in_resync, cnt) * 0 if the number fit into the string, -1 otherwise */ -#if __STDC__ static int ul_oct(u_long val, char *str, int len, int term) -#else -static int -ul_oct(val, str, len, term) - u_long val; - char *str; - int len; - int term; -#endif { char *pt; @@ -235,8 +208,8 @@ ul_oct(val, str, len, term) #ifndef NET2_STAT /* - * uqd_oct() - * convert an u_quad_t to an octal string. one of many oddball field + * ull_oct() + * convert an u_longlong_t to an octal string. one of many oddball field * termination characters are used by the various versions of tar in the * different fields. term selects which kind to use. str is '0' padded * at the front to len. we are unable to use only one format as many old @@ -245,17 +218,8 @@ ul_oct(val, str, len, term) * 0 if the number fit into the string, -1 otherwise */ -#if __STDC__ static int -uqd_oct(u_quad_t val, char *str, int len, int term) -#else -static int -uqd_oct(val, str, len, term) - u_quad_t val; - char *str; - int len; - int term; -#endif +ull_oct(u_longlong_t val, char *str, int len, int term) { char *pt; @@ -292,7 +256,7 @@ uqd_oct(val, str, len, term) while (pt >= str) *pt-- = '0'; - if (val != (u_quad_t)0) + if (val != (u_longlong_t)0) return(-1); return(0); } @@ -308,15 +272,8 @@ uqd_oct(val, str, len, term) * unsigned long checksum */ -#if __STDC__ static u_long tar_chksm(char *blk, int len) -#else -static u_long -tar_chksm(blk, len) - char *blk; - int len; -#endif { char *stop; char *pt; @@ -356,15 +313,8 @@ tar_chksm(blk, len) * 0 if a tar header, -1 otherwise */ -#if __STDC__ int tar_id(char *blk, int size) -#else -int -tar_id(blk, size) - char *blk; - int size; -#endif { HD_TAR *hd; HD_USTAR *uhd; @@ -397,13 +347,8 @@ tar_id(blk, size) * 0 if ok -1 otherwise */ -#if __STDC__ int tar_opt(void) -#else -int -tar_opt() -#endif { OPLIST *opt; @@ -441,15 +386,8 @@ tar_opt() * 0 */ -#if __STDC__ int tar_rd(ARCHD *arcn, char *buf) -#else -int -tar_rd(arcn, buf) - ARCHD *arcn; - char *buf; -#endif { HD_TAR *hd; char *pt; @@ -481,11 +419,7 @@ tar_rd(arcn, buf) 0xfff); arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT); arcn->sb.st_gid = (gid_t)asc_ul(hd->gid, sizeof(hd->gid), OCT); -# ifdef NET2_STAT - arcn->sb.st_size = (off_t)asc_ul(hd->size, sizeof(hd->size), OCT); -# else - arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT); -# endif + arcn->sb.st_size = (off_t)ASC_OFFT(hd->size, sizeof(hd->size), OCT); arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT); arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime; @@ -594,14 +528,8 @@ tar_rd(arcn, buf) * data to write after the header, -1 if archive write failed */ -#if __STDC__ int tar_wr(ARCHD *arcn) -#else -int -tar_wr(arcn) - ARCHD *arcn; -#endif { HD_TAR *hd; int len; @@ -703,13 +631,7 @@ tar_wr(arcn) */ hd->linkflag = AREGTYPE; memset(hd->linkname, 0, sizeof(hd->linkname)); -# ifdef NET2_STAT - if (ul_oct((u_long)arcn->sb.st_size, hd->size, - sizeof(hd->size), 1)) { -# else - if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size, - sizeof(hd->size), 1)) { -# endif + if (OFFT_OCT(arcn->sb.st_size, hd->size, sizeof(hd->size), 1)) { tty_warn(1,"File is too large for tar %s", arcn->org_name); return(1); @@ -761,13 +683,8 @@ tar_wr(arcn) * 0 if ok, -1 otherwise */ -#if __STDC__ int ustar_strd(void) -#else -int -ustar_strd() -#endif { return(0); } @@ -779,13 +696,8 @@ ustar_strd() * 0 if ok, -1 otherwise */ -#if __STDC__ int ustar_stwr(void) -#else -int -ustar_stwr() -#endif { return(0); } @@ -798,15 +710,8 @@ ustar_stwr() * 0 if a ustar header, -1 otherwise */ -#if __STDC__ int ustar_id(char *blk, int size) -#else -int -ustar_id(blk, size) - char *blk; - int size; -#endif { HD_USTAR *hd; @@ -839,15 +744,8 @@ ustar_id(blk, size) * 0 */ -#if __STDC__ int ustar_rd(ARCHD *arcn, char *buf) -#else -int -ustar_rd(arcn, buf) - ARCHD *arcn; - char *buf; -#endif { HD_USTAR *hd; char *dest; @@ -886,11 +784,7 @@ ustar_rd(arcn, buf) */ arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode, sizeof(hd->mode), OCT) & 0xfff); -# ifdef NET2_STAT - arcn->sb.st_size = (off_t)asc_ul(hd->size, sizeof(hd->size), OCT); -# else - arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT); -# endif + arcn->sb.st_size = (off_t)ASC_OFFT(hd->size, sizeof(hd->size), OCT); arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT); arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime; @@ -1002,14 +896,8 @@ ustar_rd(arcn, buf) * data to write after the header, -1 if archive write failed */ -#if __STDC__ int ustar_wr(ARCHD *arcn) -#else -int -ustar_wr(arcn) - ARCHD *arcn; -#endif { HD_USTAR *hd; char *pt; @@ -1125,13 +1013,7 @@ ustar_wr(arcn) memset(hd->devmajor, 0, sizeof(hd->devmajor)); memset(hd->devminor, 0, sizeof(hd->devminor)); arcn->pad = TAR_PAD(arcn->sb.st_size); -# ifdef NET2_STAT - if (ul_oct((u_long)arcn->sb.st_size, hd->size, - sizeof(hd->size), 3)) { -# else - if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size, - sizeof(hd->size), 3)) { -# endif + if (OFFT_OCT(arcn->sb.st_size, hd->size, sizeof(hd->size), 3)) { tty_warn(1,"File is too long for ustar %s", arcn->org_name); return(1); @@ -1192,15 +1074,8 @@ ustar_wr(arcn) * the file name is too long */ -#if __STDC__ static char * name_split(char *name, int len) -#else -static char * -name_split(name, len) - char *name; - int len; -#endif { char *start; diff --git a/bin/pax/tty_subs.c b/bin/pax/tty_subs.c index 80a132a41cc1..251c0eee42a3 100644 --- a/bin/pax/tty_subs.c +++ b/bin/pax/tty_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: tty_subs.c,v 1.9 2001/09/24 13:22:25 wiz Exp $ */ +/* $NetBSD: tty_subs.c,v 1.10 2001/10/25 05:33:34 lukem Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)tty_subs.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: tty_subs.c,v 1.9 2001/09/24 13:22:25 wiz Exp $"); +__RCSID("$NetBSD: tty_subs.c,v 1.10 2001/10/25 05:33:34 lukem Exp $"); #endif #endif /* not lint */ @@ -59,11 +59,7 @@ __RCSID("$NetBSD: tty_subs.c,v 1.9 2001/09/24 13:22:25 wiz Exp $"); #include #include "pax.h" #include "extern.h" -#if __STDC__ #include -#else -#include -#endif /* * routines that deal with I/O to and from the user @@ -79,13 +75,8 @@ static FILE *ttyinf = NULL; /* input pointing at control tty */ * open fails, future ops that require user input will get an EOF */ -#if __STDC__ int tty_init(void) -#else -int -tty_init() -#endif { int ttyfd; @@ -111,24 +102,13 @@ tty_init() * if there is no controlling terminal, just return. */ -#if __STDC__ void -tty_prnt(char *fmt, ...) -#else -void -tty_prnt(fmt, va_alist) - char *fmt; - va_dcl -#endif +tty_prnt(const char *fmt, ...) { va_list ap; if (ttyoutf == NULL) return; -# if __STDC__ va_start(ap, fmt); -# else - va_start(ap); -# endif (void)vfprintf(ttyoutf, fmt, ap); va_end(ap); (void)fflush(ttyoutf); @@ -142,15 +122,8 @@ tty_prnt(fmt, va_alist) * 0 if data was read, -1 otherwise. */ -#if __STDC__ int tty_read(char *str, int len) -#else -int -tty_read(str, len) - char *str; - int len; -#endif { char *pt; @@ -172,23 +145,11 @@ tty_read(str, len) * will be non-zero. */ -#if __STDC__ void -tty_warn(int set, char *fmt, ...) -#else -void -tty_warn(set, fmt, va_alist) - int set; - char *fmt; - va_dcl -#endif +tty_warn(int set, const char *fmt, ...) { va_list ap; -# if __STDC__ va_start(ap, fmt); -# else - va_start(ap); -# endif if (set) exit_val = 1; /* @@ -211,24 +172,11 @@ tty_warn(set, fmt, va_alist) * will be non-zero. */ -#if __STDC__ void -syswarn(int set, int errnum, char *fmt, ...) -#else -void -syswarn(set, errnum, fmt, va_alist) - int set; - int errnum; - char *fmt; - va_dcl -#endif +syswarn(int set, int errnum, const char *fmt, ...) { va_list ap; -# if __STDC__ va_start(ap, fmt); -# else - va_start(ap); -# endif if (set) exit_val = 1; /*