- ansi KNF (just remove all the #ifndef __STDC__ prototype junk,

leaving the ansi stuff)
- use longlong_t instead of quad_t (etc), and rename *uqd*() -> *ull*()
- clean up the NET2_STAT stuff similar to ftpd; provide #defines and
  macros which select which cast to use, etc
- clean up the NET2_FTS and NET2_REGEX #define use
This commit is contained in:
lukem 2001-10-25 05:33:32 +00:00
parent 68a03bad5d
commit c1bd745ccb
18 changed files with 353 additions and 1588 deletions

View File

@ -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 # @(#)Makefile 8.1 (Berkeley) 5/31/93
# To install on versions prior to BSD 4.4 the following may have to be # 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 # stat structure is easily determined by looking at the
# basic type of an off_t (often defined in the file: # basic type of an off_t (often defined in the file:
# /usr/include/sys/types.h). If off_t is a long (and is # /usr/include/sys/types.h). If off_t is a long (and is
# NOT A quad) then you must define NET2_STAT. # NOT A longlong_t) then you must define NET2_STAT.
# This define is important, as if you do have a quad_t # This define is important, as if you do have a longlong_t
# off_t and define NET2_STAT, pax will compile but will # off_t and define NET2_STAT, pax will compile but will
# NOT RUN PROPERLY. # NOT RUN PROPERLY.
# #

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)ar_io.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)ar_io.c 8.2 (Berkeley) 4/18/94";
#else #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
#endif /* not lint */ #endif /* not lint */
@ -92,11 +92,11 @@ int minusCfd = -1; /* active -C directory */
int curdirfd = -1; /* original current directory */ int curdirfd = -1; /* original current directory */
int force_one_volume; /* 1 if we ignore volume changes */ 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; extern sigset_t s_mask;
static void ar_start_gzip __P((int)); static void ar_start_gzip(int);
static const char *timefmt __P((char *, size_t, off_t, time_t)); static const char *timefmt(char *, size_t, off_t, time_t);
static const char *sizefmt __P((char *, size_t, off_t)); static const char *sizefmt(char *, size_t, off_t);
/* /*
* ar_open() * ar_open()
@ -107,14 +107,8 @@ static const char *sizefmt __P((char *, size_t, off_t));
* -1 on failure, 0 otherwise * -1 on failure, 0 otherwise
*/ */
#if __STDC__
int int
ar_open(const char *name) ar_open(const char *name)
#else
int
ar_open(name)
const char *name;
#endif
{ {
struct mtget mb; struct mtget mb;
@ -324,13 +318,8 @@ ar_open(name)
* ar_close() * ar_close()
* closes archive device, increments volume number, and prints i/o summary * closes archive device, increments volume number, and prints i/o summary
*/ */
#if __STDC__
void void
ar_close(void) ar_close(void)
#else
void
ar_close()
#endif
{ {
FILE *outf; FILE *outf;
@ -417,13 +406,8 @@ ar_close()
* other side of the pipe from getting a SIGPIPE (pax will stop * other side of the pipe from getting a SIGPIPE (pax will stop
* reading an archive once a format dependent trailer is detected). * reading an archive once a format dependent trailer is detected).
*/ */
#if __STDC__
void void
ar_drain(void) ar_drain(void)
#else
void
ar_drain()
#endif
{ {
int res; int res;
char drbuf[MAXBLK]; char drbuf[MAXBLK];
@ -454,13 +438,8 @@ ar_drain()
* 0 if all ready to write, -1 otherwise * 0 if all ready to write, -1 otherwise
*/ */
#if __STDC__
int int
ar_set_wr(void) ar_set_wr(void)
#else
int
ar_set_wr()
#endif
{ {
off_t cpos; off_t cpos;
@ -497,13 +476,8 @@ ar_set_wr()
* 0 if we can append, -1 otherwise. * 0 if we can append, -1 otherwise.
*/ */
#if __STDC__
int int
ar_app_ok(void) ar_app_ok(void)
#else
int
ar_app_ok()
#endif
{ {
if (artyp == ISPIPE) { if (artyp == ISPIPE) {
tty_warn(1, tty_warn(1,
@ -528,16 +502,8 @@ ar_app_ok()
* Number of bytes written. -1 indicates an error. * Number of bytes written. -1 indicates an error.
*/ */
#if __STDC__
int int
read_with_restart(int fd, void *buf, int bsz) 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; 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. * Number of bytes read. 0 for end of file, -1 for an error.
*/ */
#if __STDC__
int int
xread(int fd, void *buf, int bsz) xread(int fd, void *buf, int bsz)
#else
int
xread(fd, buf, bsz)
int fd;
void *buf;
int bsz;
#endif
{ {
char *b = buf; char *b = buf;
int nread = 0; int nread = 0;
@ -591,16 +549,8 @@ xread(fd, buf, bsz)
* Number of bytes written. -1 indicates an error. * Number of bytes written. -1 indicates an error.
*/ */
#if __STDC__
int int
write_with_restart(int fd, void *buf, int bsz) 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; int r;
@ -619,16 +569,8 @@ write_with_restart(fd, buf, bsz)
* Number of bytes written. -1 indicates an error. * Number of bytes written. -1 indicates an error.
*/ */
#if __STDC__
int int
xwrite(int fd, void *buf, int bsz) xwrite(int fd, void *buf, int bsz)
#else
int
xwrite(fd, buf, bsz)
int fd;
void *buf;
int bsz;
#endif
{ {
char *b = buf; char *b = buf;
int written = 0; 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. * Number of bytes in buffer. 0 for end of file, -1 for a read error.
*/ */
#if __STDC__
int int
ar_read(char *buf, int cnt) ar_read(char *buf, int cnt)
#else
int
ar_read(buf, cnt)
char *buf;
int cnt;
#endif
{ {
int res = 0; int res = 0;
@ -744,15 +679,8 @@ ar_read(buf, cnt)
* error in the archive occurred. * error in the archive occurred.
*/ */
#if __STDC__
int int
ar_write(char *buf, int bsz) ar_write(char *buf, int bsz)
#else
int
ar_write(buf, bsz)
char *buf;
int bsz;
#endif
{ {
int res; int res;
off_t cpos; off_t cpos;
@ -872,13 +800,8 @@ ar_write(buf, bsz)
* 0 when ok to try i/o again, -1 otherwise. * 0 when ok to try i/o again, -1 otherwise.
*/ */
#if __STDC__
int int
ar_rdsync(void) ar_rdsync(void)
#else
int
ar_rdsync()
#endif
{ {
long fsbz; long fsbz;
off_t cpos; off_t cpos;
@ -963,15 +886,8 @@ ar_rdsync()
* partial move (the amount moved is in skipped) * partial move (the amount moved is in skipped)
*/ */
#if __STDC__
int int
ar_fow(off_t sksz, off_t *skipped) 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 cpos;
off_t mpos; off_t mpos;
@ -1032,14 +948,8 @@ ar_fow(sksz, skipped)
* 0 if moved the requested distance, -1 on complete failure * 0 if moved the requested distance, -1 on complete failure
*/ */
#if __STDC__
int int
ar_rev(off_t sksz) ar_rev(off_t sksz)
#else
int
ar_rev(sksz)
off_t sksz;
#endif
{ {
off_t cpos; off_t cpos;
struct mtop mb; struct mtop mb;
@ -1171,13 +1081,8 @@ ar_rev(sksz)
* physical block size if ok (ok > 0), -1 otherwise * physical block size if ok (ok > 0), -1 otherwise
*/ */
#if __STDC__
static int static int
get_phys(void) get_phys(void)
#else
static int
get_phys()
#endif
{ {
int padsz = 0; int padsz = 0;
int res; int res;
@ -1289,13 +1194,8 @@ get_phys()
* 0 when ready to continue, -1 when all done * 0 when ready to continue, -1 when all done
*/ */
#if __STDC__
int int
ar_next(void) ar_next(void)
#else
int
ar_next()
#endif
{ {
char buf[PAXPATHLEN+2]; char buf[PAXPATHLEN+2];
static int freeit = 0; static int freeit = 0;
@ -1441,16 +1341,11 @@ ar_next()
* to keep the fd the same in the calling function (parent). * to keep the fd the same in the calling function (parent).
*/ */
void void
#ifdef __STDC__
ar_start_gzip(int fd) ar_start_gzip(int fd)
#else
ar_start_gzip(fd)
int fd;
#endif
{ {
pid_t pid; pid_t pid;
int fds[2]; int fds[2];
char *gzip_flags; const char *gzip_flags;
if (pipe(fds) < 0) if (pipe(fds) < 0)
err(1, "could not pipe"); err(1, "could not pipe");
@ -1504,13 +1399,8 @@ timefmt(buf, size, sz, tm)
off_t sz; off_t sz;
time_t tm; time_t tm;
{ {
#ifdef NET2_STAT (void)snprintf(buf, size, "%lu secs (" OFFT_F " bytes/sec)",
(void)snprintf(buf, size, "%lu secs (%lu bytes/sec)", (unsigned long)tm, (OFFT_T)(sz / tm));
(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
return buf; return buf;
} }
@ -1520,22 +1410,12 @@ sizefmt(buf, size, sz)
size_t size; size_t size;
off_t sz; off_t sz;
{ {
#ifdef NET2_STAT (void)snprintf(buf, size, OFFT_F " bytes", (OFFT_T)sz);
(void)snprintf(buf, size, "%lu bytes", (unsigned long)sz);
#else
(void)snprintf(buf, size, "%llu bytes", (unsigned long long)sz);
#endif
return buf; return buf;
} }
#if __STDC__
void void
ar_summary(int n) ar_summary(int n)
#else
void
ar_summary(n)
int n;
#endif
{ {
time_t secs; time_t secs;
int len; int len;
@ -1614,14 +1494,8 @@ ar_summary(n)
* Returns 0 if all went well, else -1. * Returns 0 if all went well, else -1.
*/ */
#ifdef __STDC__
int int
ar_dochdir(char *name) ar_dochdir(char *name)
#else
int
ar_dochdir(name)
char *name;
#endif
{ {
if (curdirfd == -1) { if (curdirfd == -1) {
/* first time. remember where we came from */ /* first time. remember where we came from */

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94";
#else #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
#endif /* not lint */ #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 "pax.h"
#include "extern.h" #include "extern.h"
static void wr_archive __P((ARCHD *, int is_app)); static void wr_archive(ARCHD *, int is_app);
static int get_arc __P((void)); static int get_arc(void);
static int next_head __P((ARCHD *)); static int next_head(ARCHD *);
extern sigset_t s_mask; extern sigset_t s_mask;
/* /*
@ -82,13 +82,8 @@ ARCHD archd;
* (no pattern matches all). * (no pattern matches all).
*/ */
#if __STDC__
void void
list(void) list(void)
#else
void
list()
#endif
{ {
ARCHD *arcn; ARCHD *arcn;
int res; int res;
@ -163,13 +158,8 @@ list()
* pattern(s) (no patterns extracts all members) * pattern(s) (no patterns extracts all members)
*/ */
#if __STDC__
void void
extract(void) extract(void)
#else
void
extract()
#endif
{ {
ARCHD *arcn; ARCHD *arcn;
int res; int res;
@ -364,21 +354,14 @@ extract()
* previously written archive. * previously written archive.
*/ */
#if __STDC__
static void static void
wr_archive(ARCHD *arcn, int is_app) wr_archive(ARCHD *arcn, int is_app)
#else
static void
wr_archive(arcn, is_app)
ARCHD *arcn;
int is_app;
#endif
{ {
int res; int res;
int hlk; int hlk;
int wr_one; int wr_one;
off_t cnt; off_t cnt;
int (*wrf) __P((ARCHD *)); int (*wrf)(ARCHD *);
int fd = -1; int fd = -1;
/* /*
@ -570,13 +553,8 @@ wr_archive(arcn, is_app)
* over write existing files that it creates. * over write existing files that it creates.
*/ */
#if __STDC__
void void
append(void) append(void)
#else
void
append()
#endif
{ {
ARCHD *arcn; ARCHD *arcn;
int res; int res;
@ -710,13 +688,8 @@ append()
* write a new archive * write a new archive
*/ */
#if __STDC__
void void
archive(void) archive(void)
#else
void
archive()
#endif
{ {
/* /*
@ -740,13 +713,8 @@ archive()
* (except the files are forced to be under the destination directory). * (except the files are forced to be under the destination directory).
*/ */
#if __STDC__
void void
copy(void) copy(void)
#else
void
copy()
#endif
{ {
ARCHD *arcn; ARCHD *arcn;
int res; int res;
@ -991,14 +959,8 @@ copy()
* the specs for rd_wrbuf() for more details) * the specs for rd_wrbuf() for more details)
*/ */
#if __STDC__
static int static int
next_head(ARCHD *arcn) next_head(ARCHD *arcn)
#else
static int
next_head(arcn)
ARCHD *arcn;
#endif
{ {
int ret; int ret;
char *hdend; char *hdend;
@ -1142,13 +1104,8 @@ next_head(arcn)
* 0 if archive found -1 otherwise * 0 if archive found -1 otherwise
*/ */
#if __STDC__
static int static int
get_arc(void) get_arc(void)
#else
static int
get_arc()
#endif
{ {
int i; int i;
int hdsz = 0; int hdsz = 0;

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)buf_subs.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)buf_subs.c 8.2 (Berkeley) 4/18/94";
#else #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
#endif /* not lint */ #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 * 0 if ok, -1 if the user specified write block size violates pax spec
*/ */
#if __STDC__
int int
wr_start(void) wr_start(void)
#else
int
wr_start()
#endif
{ {
buf = &(bufmem[BLKMULT]); buf = &(bufmem[BLKMULT]);
/* /*
@ -138,13 +133,8 @@ wr_start()
* 0 if ok, -1 otherwise * 0 if ok, -1 otherwise
*/ */
#if __STDC__
int int
rd_start(void) rd_start(void)
#else
int
rd_start()
#endif
{ {
/* /*
* leave space for the header pushback (see get_arc()). If we are * 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 * set up buffer system for copying within the file system
*/ */
#if __STDC__
void void
cp_start(void) cp_start(void)
#else
void
cp_start()
#endif
{ {
buf = &(bufmem[BLKMULT]); buf = &(bufmem[BLKMULT]);
rdblksz = blksz = MAXBLK; rdblksz = blksz = MAXBLK;
@ -227,14 +212,8 @@ cp_start()
* 0 for success, -1 for failure * 0 for success, -1 for failure
*/ */
#if __STDC__
int int
appnd_start(off_t skcnt) appnd_start(off_t skcnt)
#else
int
appnd_start(skcnt)
off_t skcnt;
#endif
{ {
int res; int res;
off_t cnt; off_t cnt;
@ -332,13 +311,8 @@ appnd_start(skcnt)
* 0 on success, and -1 on failure * 0 on success, and -1 on failure
*/ */
#if __STDC__
int int
rd_sync(void) rd_sync(void)
#else
int
rd_sync()
#endif
{ {
int errcnt = 0; int errcnt = 0;
int res; int res;
@ -407,15 +381,8 @@ rd_sync()
* pback space is increased. * pback space is increased.
*/ */
#if __STDC__
void void
pback(char *pt, int cnt) pback(char *pt, int cnt)
#else
void
pback(pt, cnt)
char *pt;
int cnt;
#endif
{ {
bufpt -= cnt; bufpt -= cnt;
memcpy(bufpt, pt, 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. * 0 if ok, -1 failure, and 1 when EOF on the archive volume was detected.
*/ */
#if __STDC__
int int
rd_skip(off_t skcnt) rd_skip(off_t skcnt)
#else
int
rd_skip(skcnt)
off_t skcnt;
#endif
{ {
off_t res; off_t res;
off_t cnt; off_t cnt;
@ -505,13 +466,8 @@ rd_skip(skcnt)
* BE a requirement.... * BE a requirement....
*/ */
#if __STDC__
void void
wr_fin(void) wr_fin(void)
#else
void
wr_fin()
#endif
{ {
if (bufpt > buf) { if (bufpt > buf) {
memset(bufpt, 0, bufend - bufpt); memset(bufpt, 0, bufend - bufpt);
@ -531,15 +487,8 @@ wr_fin()
* 0 if buffer was filled ok, -1 o.w. (buffer flush failure) * 0 if buffer was filled ok, -1 o.w. (buffer flush failure)
*/ */
#if __STDC__
int int
wr_rdbuf(char *out, int outcnt) wr_rdbuf(char *out, int outcnt)
#else
int
wr_rdbuf(out, outcnt)
char *out;
int outcnt;
#endif
{ {
int cnt; int cnt;
@ -574,15 +523,8 @@ wr_rdbuf(out, outcnt)
* -1 is a read error * -1 is a read error
*/ */
#if __STDC__
int int
rd_wrbuf(char *in, int cpcnt) rd_wrbuf(char *in, int cpcnt)
#else
int
rd_wrbuf(in, cpcnt)
char *in;
int cpcnt;
#endif
{ {
int res; int res;
int cnt; int cnt;
@ -629,14 +571,8 @@ rd_wrbuf(in, cpcnt)
* 0 if ok, -1 if there was a buf_flush failure * 0 if ok, -1 if there was a buf_flush failure
*/ */
#if __STDC__
int int
wr_skip(off_t skcnt) wr_skip(off_t skcnt)
#else
int
wr_skip(skcnt)
off_t skcnt;
#endif
{ {
int cnt; int cnt;
@ -673,16 +609,8 @@ wr_skip(skcnt)
* 0, but "left" is set to be greater than zero. * 0, but "left" is set to be greater than zero.
*/ */
#if __STDC__
int int
wr_rdfile(ARCHD *arcn, int ifd, off_t *left) 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 cnt;
int res = 0; 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 * we return a 0 but "left" is set to be the amount unwritten
*/ */
#if __STDC__
int int
rd_wrfile(ARCHD *arcn, int ofd, off_t *left) 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; int cnt = 0;
off_t size = arcn->sb.st_size; 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. * destination file so we can properly copy files with holes.
*/ */
#if __STDC__
void void
cp_file(ARCHD *arcn, int fd1, int fd2) cp_file(ARCHD *arcn, int fd1, int fd2)
#else
void
cp_file(arcn, fd1, fd2)
ARCHD *arcn;
int fd1;
int fd2;
#endif
{ {
int cnt; int cnt;
off_t cpcnt = 0L; off_t cpcnt = 0L;
@ -930,13 +842,8 @@ cp_file(arcn, fd1, fd2)
* 0 when finished (user specified termination in ar_next()). * 0 when finished (user specified termination in ar_next()).
*/ */
#if __STDC__
int int
buf_fill(void) buf_fill(void)
#else
int
buf_fill()
#endif
{ {
int cnt; int cnt;
static int fini = 0; static int fini = 0;
@ -980,14 +887,8 @@ buf_fill()
* 0 if all is ok, -1 when a write error occurs. * 0 if all is ok, -1 when a write error occurs.
*/ */
#if __STDC__
int int
buf_flush(int bufcnt) buf_flush(int bufcnt)
#else
int
buf_flush(bufcnt)
int bufcnt;
#endif
{ {
int cnt; int cnt;
int push = 0; int push = 0;

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)cpio.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)cpio.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #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 "cpio.h"
#include "extern.h" #include "extern.h"
static int rd_nm __P((ARCHD *, int)); static int rd_nm(ARCHD *, int);
static int rd_ln_nm __P((ARCHD *)); static int rd_ln_nm(ARCHD *);
static int com_rd __P((ARCHD *)); static int com_rd(ARCHD *);
/* /*
* Routines which support the different cpio versions * 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()) * 0 if ok -1 otherwise (the return values of lnk_start())
*/ */
#if __STDC__
int int
cpio_strd(void) cpio_strd(void)
#else
int
cpio_strd()
#endif
{ {
return(lnk_start()); return(lnk_start());
} }
@ -101,14 +96,8 @@ cpio_strd()
* 0 if a valid trailer, -1 if not a valid trailer, * 0 if a valid trailer, -1 if not a valid trailer,
*/ */
#if __STDC__
int int
cpio_subtrail(ARCHD *arcn) cpio_subtrail(ARCHD *arcn)
#else
int
cpio_subtrail(arcn)
ARCHD *arcn;
#endif
{ {
/* /*
* look for trailer id in file we are about to process * look for trailer id in file we are about to process
@ -125,14 +114,8 @@ cpio_subtrail(arcn)
* 0 * 0
*/ */
#if __STDC__
static int static int
com_rd(ARCHD *arcn) com_rd(ARCHD *arcn)
#else
static int
com_rd(arcn)
ARCHD *arcn;
#endif
{ {
arcn->skip = 0; arcn->skip = 0;
arcn->pat = NULL; arcn->pat = NULL;
@ -180,13 +163,8 @@ com_rd(arcn)
* result of the write of the trailer from the cpio specific write func * result of the write of the trailer from the cpio specific write func
*/ */
#if __STDC__
int int
cpio_endwr(void) cpio_endwr(void)
#else
int
cpio_endwr()
#endif
{ {
ARCHD last; ARCHD last;
@ -208,15 +186,8 @@ cpio_endwr()
* 0 if ok, -1 otherwise * 0 if ok, -1 otherwise
*/ */
#if __STDC__
static int static int
rd_nm(ARCHD *arcn, int nsz) rd_nm(ARCHD *arcn, int nsz)
#else
static int
rd_nm(arcn, nsz)
ARCHD *arcn;
int nsz;
#endif
{ {
/* /*
* do not even try bogus values * do not even try bogus values
@ -245,27 +216,16 @@ rd_nm(arcn, nsz)
* 0 if ok, -1 otherwise * 0 if ok, -1 otherwise
*/ */
#if __STDC__
static int static int
rd_ln_nm(ARCHD *arcn) rd_ln_nm(ARCHD *arcn)
#else
static int
rd_ln_nm(arcn)
ARCHD *arcn;
#endif
{ {
/* /*
* check the length specified for bogus values * check the length specified for bogus values
*/ */
if ((arcn->sb.st_size == 0) || if ((arcn->sb.st_size == 0) ||
(arcn->sb.st_size >= sizeof(arcn->ln_name))) { (arcn->sb.st_size >= sizeof(arcn->ln_name))) {
# ifdef NET2_STAT tty_warn(1, "Cpio link name length is invalid: " OFFT_F,
tty_warn(1, "Cpio link name length is invalid: %lu", (OFFT_T) arcn->sb.st_size);
arcn->sb.st_size);
# else
tty_warn(1, "Cpio link name length is invalid: %llu",
(unsigned long long) arcn->sb.st_size);
# endif
return(-1); return(-1);
} }
@ -302,15 +262,8 @@ rd_ln_nm(arcn)
* 0 if a valid header, -1 otherwise * 0 if a valid header, -1 otherwise
*/ */
#if __STDC__
int int
cpio_id(char *blk, int size) cpio_id(char *blk, int size)
#else
int
cpio_id(blk, size)
char *blk;
int size;
#endif
{ {
if ((size < sizeof(HD_CPIO)) || if ((size < sizeof(HD_CPIO)) ||
(strncmp(blk, AMAGIC, sizeof(AMAGIC) - 1) != 0)) (strncmp(blk, AMAGIC, sizeof(AMAGIC) - 1) != 0))
@ -326,15 +279,8 @@ cpio_id(blk, size)
* 0 if a valid header, -1 otherwise. * 0 if a valid header, -1 otherwise.
*/ */
#if __STDC__
int int
cpio_rd(ARCHD *arcn, char *buf) cpio_rd(ARCHD *arcn, char *buf)
#else
int
cpio_rd(arcn, buf)
ARCHD *arcn;
char *buf;
#endif
{ {
int nsz; int nsz;
HD_CPIO *hd; 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), arcn->sb.st_mtime = (time_t)asc_ul(hd->c_mtime, sizeof(hd->c_mtime),
OCT); OCT);
arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime; arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
# ifdef NET2_STAT arcn->sb.st_size = (off_t)ASC_OFFT(hd->c_filesize,
arcn->sb.st_size = (off_t)asc_ul(hd->c_filesize,sizeof(hd->c_filesize), sizeof(hd->c_filesize), OCT);
OCT);
# else
arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize,sizeof(hd->c_filesize),
OCT);
# endif
/* /*
* check name size and if valid, read in the name of this entry (name * 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 * size of trailer header in this format
*/ */
#if __STDC__
off_t off_t
cpio_endrd(void) cpio_endrd(void)
#else
off_t
cpio_endrd()
#endif
{ {
return((off_t)(sizeof(HD_CPIO) + sizeof(TRAILER))); return((off_t)(sizeof(HD_CPIO) + sizeof(TRAILER)));
} }
@ -427,13 +363,8 @@ cpio_endrd()
* 0 if ok, -1 otherwise (what dev_start() returns) * 0 if ok, -1 otherwise (what dev_start() returns)
*/ */
#if __STDC__
int int
cpio_stwr(void) cpio_stwr(void)
#else
int
cpio_stwr()
#endif
{ {
return(dev_start()); return(dev_start());
} }
@ -447,14 +378,8 @@ cpio_stwr()
* data to write after the header, -1 if archive write failed * data to write after the header, -1 if archive write failed
*/ */
#if __STDC__
int int
cpio_wr(ARCHD *arcn) cpio_wr(ARCHD *arcn)
#else
int
cpio_wr(arcn)
ARCHD *arcn;
#endif
{ {
HD_CPIO *hd; HD_CPIO *hd;
int nsz; int nsz;
@ -479,13 +404,8 @@ cpio_wr(arcn)
/* /*
* set data size for file data * set data size for file data
*/ */
# ifdef NET2_STAT if (OFFT_ASC(arcn->sb.st_size, hd->c_filesize,
if (ul_asc((u_long)arcn->sb.st_size, hd->c_filesize,
sizeof(hd->c_filesize), OCT)) { 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", tty_warn(1,"File is too large for cpio format %s",
arcn->org_name); arcn->org_name);
return(1); return(1);
@ -585,15 +505,8 @@ cpio_wr(arcn)
* 0 if a valid header, -1 otherwise * 0 if a valid header, -1 otherwise
*/ */
#if __STDC__
int int
vcpio_id(char *blk, int size) vcpio_id(char *blk, int size)
#else
int
vcpio_id(blk, size)
char *blk;
int size;
#endif
{ {
if ((size < sizeof(HD_VCPIO)) || if ((size < sizeof(HD_VCPIO)) ||
(strncmp(blk, AVMAGIC, sizeof(AVMAGIC) - 1) != 0)) (strncmp(blk, AVMAGIC, sizeof(AVMAGIC) - 1) != 0))
@ -609,15 +522,8 @@ vcpio_id(blk, size)
* 0 if a valid header, -1 otherwise * 0 if a valid header, -1 otherwise
*/ */
#if __STDC__
int int
crc_id(char *blk, int size) crc_id(char *blk, int size)
#else
int
crc_id(blk, size)
char *blk;
int size;
#endif
{ {
if ((size < sizeof(HD_VCPIO)) || if ((size < sizeof(HD_VCPIO)) ||
(strncmp(blk, AVCMAGIC, sizeof(AVCMAGIC) - 1) != 0)) (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()) * 0 if ok -1 otherwise (the return values of lnk_start())
*/ */
#if __STDC__
int int
crc_strd(void) crc_strd(void)
#else
int
crc_strd()
#endif
{ {
docrc = 1; docrc = 1;
return(lnk_start()); return(lnk_start());
@ -652,15 +553,8 @@ crc_strd()
* 0 if a valid header, -1 otherwise. * 0 if a valid header, -1 otherwise.
*/ */
#if __STDC__
int int
vcpio_rd(ARCHD *arcn, char *buf) vcpio_rd(ARCHD *arcn, char *buf)
#else
int
vcpio_rd(arcn, buf)
ARCHD *arcn;
char *buf;
#endif
{ {
HD_VCPIO *hd; HD_VCPIO *hd;
dev_t devminor; 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_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_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; arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
# ifdef NET2_STAT arcn->sb.st_size = (off_t)ASC_OFFT(hd->c_filesize,
arcn->sb.st_size = (off_t)asc_ul(hd->c_filesize,
sizeof(hd->c_filesize), HEX); 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), arcn->sb.st_nlink = (nlink_t)asc_ul(hd->c_nlink, sizeof(hd->c_nlink),
HEX); HEX);
devmajor = (dev_t)asc_ul(hd->c_maj, sizeof(hd->c_maj), 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 * size of trailer header in this format
*/ */
#if __STDC__
off_t off_t
vcpio_endrd(void) vcpio_endrd(void)
#else
off_t
vcpio_endrd()
#endif
{ {
return((off_t)(sizeof(HD_VCPIO) + sizeof(TRAILER) + return((off_t)(sizeof(HD_VCPIO) + sizeof(TRAILER) +
(VCPIO_PAD(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) * 0 if ok, -1 otherwise (what dev_start() returns)
*/ */
#if __STDC__
int int
crc_stwr(void) crc_stwr(void)
#else
int
crc_stwr()
#endif
{ {
docrc = 1; docrc = 1;
return(dev_start()); return(dev_start());
@ -798,14 +677,8 @@ crc_stwr()
* NO data to write after the header, -1 if archive write failed * NO data to write after the header, -1 if archive write failed
*/ */
#if __STDC__
int int
vcpio_wr(ARCHD *arcn) vcpio_wr(ARCHD *arcn)
#else
int
vcpio_wr(arcn)
ARCHD *arcn;
#endif
{ {
HD_VCPIO *hd; HD_VCPIO *hd;
unsigned int nsz; unsigned int nsz;
@ -848,13 +721,8 @@ vcpio_wr(arcn)
* much to pad. * much to pad.
*/ */
arcn->pad = VCPIO_PAD(arcn->sb.st_size); arcn->pad = VCPIO_PAD(arcn->sb.st_size);
# ifdef NET2_STAT if (OFFT_ASC(arcn->sb.st_size, hd->c_filesize,
if (ul_asc((u_long)arcn->sb.st_size, hd->c_filesize,
sizeof(hd->c_filesize), HEX)) { 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", tty_warn(1,"File is too large for sv4cpio format %s",
arcn->org_name); arcn->org_name);
return(1); return(1);
@ -963,15 +831,8 @@ vcpio_wr(arcn)
* 0 if a valid header, -1 otherwise * 0 if a valid header, -1 otherwise
*/ */
#if __STDC__
int int
bcpio_id(char *blk, int size) bcpio_id(char *blk, int size)
#else
int
bcpio_id(blk, size)
char *blk;
int size;
#endif
{ {
if (size < sizeof(HD_BCPIO)) if (size < sizeof(HD_BCPIO))
return(-1); return(-1);
@ -998,15 +859,8 @@ bcpio_id(blk, size)
* 0 if a valid header, -1 otherwise. * 0 if a valid header, -1 otherwise.
*/ */
#if __STDC__
int int
bcpio_rd(ARCHD *arcn, char *buf) bcpio_rd(ARCHD *arcn, char *buf)
#else
int
bcpio_rd(arcn, buf)
ARCHD *arcn;
char *buf;
#endif
{ {
HD_BCPIO *hd; HD_BCPIO *hd;
int nsz; int nsz;
@ -1102,13 +956,8 @@ bcpio_rd(arcn, buf)
* size of trailer header in this format * size of trailer header in this format
*/ */
#if __STDC__
off_t off_t
bcpio_endrd(void) bcpio_endrd(void)
#else
off_t
bcpio_endrd()
#endif
{ {
return((off_t)(sizeof(HD_BCPIO) + sizeof(TRAILER) + return((off_t)(sizeof(HD_BCPIO) + sizeof(TRAILER) +
(BCPIO_PAD(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 * data to write after the header, -1 if archive write failed
*/ */
#if __STDC__
int int
bcpio_wr(ARCHD *arcn) bcpio_wr(ARCHD *arcn)
#else
int
bcpio_wr(arcn)
ARCHD *arcn;
#endif
{ {
HD_BCPIO *hd; HD_BCPIO *hd;
int nsz; int nsz;

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -53,39 +53,39 @@ extern int curdirfd;
extern const char *gzip_program; extern const char *gzip_program;
extern time_t starttime; extern time_t starttime;
extern int force_one_volume; extern int force_one_volume;
int ar_open __P((const char *)); int ar_open(const char *);
void ar_close __P((void)); void ar_close(void);
void ar_drain __P((void)); void ar_drain(void);
int ar_set_wr __P((void)); int ar_set_wr(void);
int ar_app_ok __P((void)); int ar_app_ok(void);
#ifdef SYS_NO_RESTART #ifdef SYS_NO_RESTART
int read_with_restart __P((int, void *, int)); int read_with_restart(int, void *, int);
int write_with_restart __P((int, void *, int)); int write_with_restart(int, void *, int);
#else #else
#define read_with_restart read #define read_with_restart read
#define write_with_restart write #define write_with_restart write
#endif #endif
int xread __P((int, void *, int)); int xread(int, void *, int);
int xwrite __P((int, void *, int)); int xwrite(int, void *, int);
int ar_read __P((char *, int)); int ar_read(char *, int);
int ar_write __P((char *, int)); int ar_write(char *, int);
int ar_rdsync __P((void)); int ar_rdsync(void);
int ar_fow __P((off_t, off_t *)); int ar_fow(off_t, off_t *);
int ar_rev __P((off_t )); int ar_rev(off_t );
int ar_next __P((void)); int ar_next(void);
void ar_summary __P((int)); void ar_summary(int);
int ar_dochdir __P((char *)); int ar_dochdir(char *);
/* /*
* ar_subs.c * ar_subs.c
*/ */
extern u_long flcnt; extern u_long flcnt;
extern ARCHD archd; extern ARCHD archd;
void list __P((void)); void list(void);
void extract __P((void)); void extract(void);
void append __P((void)); void append(void);
void archive __P((void)); void archive(void);
void copy __P((void)); void copy(void);
/* /*
* buf_subs.c * buf_subs.c
@ -97,97 +97,97 @@ extern int rdblksz;
extern off_t wrlimit; extern off_t wrlimit;
extern off_t rdcnt; extern off_t rdcnt;
extern off_t wrcnt; extern off_t wrcnt;
int wr_start __P((void)); int wr_start(void);
int rd_start __P((void)); int rd_start(void);
void cp_start __P((void)); void cp_start(void);
int appnd_start __P((off_t)); int appnd_start(off_t);
int rd_sync __P((void)); int rd_sync(void);
void pback __P((char *, int)); void pback(char *, int);
int rd_skip __P((off_t)); int rd_skip(off_t);
void wr_fin __P((void)); void wr_fin(void);
int wr_rdbuf __P((char *, int)); int wr_rdbuf(char *, int);
int rd_wrbuf __P((char *, int)); int rd_wrbuf(char *, int);
int wr_skip __P((off_t)); int wr_skip(off_t);
int wr_rdfile __P((ARCHD *, int, off_t *)); int wr_rdfile(ARCHD *, int, off_t *);
int rd_wrfile __P((ARCHD *, int, off_t *)); int rd_wrfile(ARCHD *, int, off_t *);
void cp_file __P((ARCHD *, int, int)); void cp_file(ARCHD *, int, int);
int buf_fill __P((void)); int buf_fill(void);
int buf_flush __P((int)); int buf_flush(int);
/* /*
* cpio.c * cpio.c
*/ */
extern int cpio_swp_head; extern int cpio_swp_head;
int cpio_strd __P((void)); int cpio_strd(void);
int cpio_subtrail __P((ARCHD *)); int cpio_subtrail(ARCHD *);
int cpio_endwr __P((void)); int cpio_endwr(void);
int cpio_id __P((char *, int)); int cpio_id(char *, int);
int cpio_rd __P((ARCHD *, char *)); int cpio_rd(ARCHD *, char *);
off_t cpio_endrd __P((void)); off_t cpio_endrd(void);
int cpio_stwr __P((void)); int cpio_stwr(void);
int cpio_wr __P((ARCHD *)); int cpio_wr(ARCHD *);
int vcpio_id __P((char *, int)); int vcpio_id(char *, int);
int crc_id __P((char *, int)); int crc_id(char *, int);
int crc_strd __P((void)); int crc_strd(void);
int vcpio_rd __P((ARCHD *, char *)); int vcpio_rd(ARCHD *, char *);
off_t vcpio_endrd __P((void)); off_t vcpio_endrd(void);
int crc_stwr __P((void)); int crc_stwr(void);
int vcpio_wr __P((ARCHD *)); int vcpio_wr(ARCHD *);
int bcpio_id __P((char *, int)); int bcpio_id(char *, int);
int bcpio_rd __P((ARCHD *, char *)); int bcpio_rd(ARCHD *, char *);
off_t bcpio_endrd __P((void)); off_t bcpio_endrd(void);
int bcpio_wr __P((ARCHD *)); int bcpio_wr(ARCHD *);
/* /*
* file_subs.c * file_subs.c
*/ */
extern char *gnu_hack_string; extern char *gnu_hack_string;
int file_creat __P((ARCHD *)); int file_creat(ARCHD *);
void file_close __P((ARCHD *, int)); void file_close(ARCHD *, int);
int lnk_creat __P((ARCHD *)); int lnk_creat(ARCHD *);
int cross_lnk __P((ARCHD *)); int cross_lnk(ARCHD *);
int chk_same __P((ARCHD *)); int chk_same(ARCHD *);
int node_creat __P((ARCHD *)); int node_creat(ARCHD *);
int unlnk_exist __P((char *, int)); int unlnk_exist(char *, int);
int chk_path __P((char *, uid_t, gid_t)); int chk_path(char *, uid_t, gid_t);
void set_ftime __P((char *fnm, time_t mtime, time_t atime, int frc)); void set_ftime(char *fnm, time_t mtime, time_t atime, int frc);
int set_ids __P((char *, uid_t, gid_t)); int set_ids(char *, uid_t, gid_t);
void set_pmode __P((char *, mode_t)); void set_pmode(char *, mode_t);
void set_chflags __P((char *fnm, u_int32_t flags)); void set_chflags(char *fnm, u_int32_t flags);
int file_write __P((int, char *, int, int *, int *, int, char *)); int file_write(int, char *, int, int *, int *, int, char *);
void file_flush __P((int, char *, int)); void file_flush(int, char *, int);
void rdfile_close __P((ARCHD *, int *)); void rdfile_close(ARCHD *, int *);
int set_crc __P((ARCHD *, int)); int set_crc(ARCHD *, int);
/* /*
* ftree.c * ftree.c
*/ */
int ftree_start __P((void)); int ftree_start(void);
int ftree_add __P((char *, int)); int ftree_add(char *, int);
void ftree_sel __P((ARCHD *)); void ftree_sel(ARCHD *);
void ftree_chk __P((void)); void ftree_chk(void);
int next_file __P((ARCHD *)); int next_file(ARCHD *);
/* /*
* gen_subs.c * gen_subs.c
*/ */
void ls_list __P((ARCHD *, time_t)); void ls_list(ARCHD *, time_t);
void ls_tty __P((ARCHD *)); void ls_tty(ARCHD *);
void zf_strncpy __P((char *, const char *, int)); void zf_strncpy(char *, const char *, int);
int l_strncpy __P((char *, const char *, int)); int l_strncpy(char *, const char *, int);
u_long asc_ul __P((char *, int, int)); u_long asc_ul(char *, int, int);
int ul_asc __P((u_long, char *, int, int)); int ul_asc(u_long, char *, int, int);
#ifndef NET2_STAT #ifndef NET2_STAT
u_quad_t asc_uqd __P((char *, int, int)); u_longlong_t asc_ull(char *, int, int);
int uqd_asc __P((u_quad_t, char *, int, int)); int ull_asc(u_longlong_t, char *, int, int);
#endif #endif
int check_Aflag __P((void)); int check_Aflag(void);
/* /*
* getoldopt.c * getoldopt.c
*/ */
struct option; struct option;
int getoldopt __P((int, char **, const char *, struct option *, int *)); int getoldopt(int, char **, const char *, struct option *, int *);
/* /*
* options.c * options.c
@ -195,22 +195,22 @@ int getoldopt __P((int, char **, const char *, struct option *, int *));
extern FSUB fsub[]; extern FSUB fsub[];
extern int ford[]; extern int ford[];
extern int cpio_mode; extern int cpio_mode;
void options __P((int, char **)); void options(int, char **);
OPLIST * opt_next __P((void)); OPLIST * opt_next(void);
int opt_add __P((const char *)); int opt_add(const char *);
int opt_chdir __P((char *)); int opt_chdir(char *);
int bad_opt __P((void)); int bad_opt(void);
/* /*
* pat_rep.c * pat_rep.c
*/ */
int rep_add __P((char *)); int rep_add(char *);
int pat_add __P((char *, int)); int pat_add(char *, int);
void pat_chk __P((void)); void pat_chk(void);
int pat_sel __P((ARCHD *)); int pat_sel(ARCHD *);
int pat_match __P((ARCHD *)); int pat_match(ARCHD *);
int mod_name __P((ARCHD *)); int mod_name(ARCHD *);
int set_dest __P((ARCHD *, char *, int)); int set_dest(ARCHD *, char *, int);
/* /*
* pax.c * pax.c
@ -244,67 +244,67 @@ extern int exit_val;
extern int docrc; extern int docrc;
extern char *dirptr; extern char *dirptr;
extern char *argv0; extern char *argv0;
int main __P((int, char **)); int main(int, char **);
void sig_cleanup __P((int)); void sig_cleanup(int);
/* /*
* sel_subs.c * sel_subs.c
*/ */
int sel_chk __P((ARCHD *)); int sel_chk(ARCHD *);
int grp_add __P((char *)); int grp_add(char *);
int usr_add __P((char *)); int usr_add(char *);
int trng_add __P((char *)); int trng_add(char *);
/* /*
* tables.c * tables.c
*/ */
int lnk_start __P((void)); int lnk_start(void);
int chk_lnk __P((ARCHD *)); int chk_lnk(ARCHD *);
void purg_lnk __P((ARCHD *)); void purg_lnk(ARCHD *);
void lnk_end __P((void)); void lnk_end(void);
int ftime_start __P((void)); int ftime_start(void);
int chk_ftime __P((ARCHD *)); int chk_ftime(ARCHD *);
int name_start __P((void)); int name_start(void);
int add_name __P((char *, int, char *)); int add_name(char *, int, char *);
void sub_name __P((char *, int *)); void sub_name(char *, int *);
int dev_start __P((void)); int dev_start(void);
int add_dev __P((ARCHD *)); int add_dev(ARCHD *);
int map_dev __P((ARCHD *, u_long, u_long)); int map_dev(ARCHD *, u_long, u_long);
int atdir_start __P((void)); int atdir_start(void);
void atdir_end __P((void)); void atdir_end(void);
void add_atdir __P((char *, dev_t, ino_t, time_t, time_t)); void add_atdir(char *, dev_t, ino_t, time_t, time_t);
int get_atdir __P((dev_t, ino_t, time_t *, time_t *)); int get_atdir(dev_t, ino_t, time_t *, time_t *);
int dir_start __P((void)); int dir_start(void);
void add_dir __P((char *, int, struct stat *, int)); void add_dir(char *, int, struct stat *, int);
void proc_dir __P((void)); void proc_dir(void);
u_int st_hash __P((char *, int, int)); u_int st_hash(char *, int, int);
/* /*
* tar.c * tar.c
*/ */
extern int is_oldgnutar; extern int is_oldgnutar;
int tar_endwr __P((void)); int tar_endwr(void);
off_t tar_endrd __P((void)); off_t tar_endrd(void);
int tar_trail __P((char *, int, int *)); int tar_trail(char *, int, int *);
int tar_id __P((char *, int)); int tar_id(char *, int);
int tar_opt __P((void)); int tar_opt(void);
int tar_rd __P((ARCHD *, char *)); int tar_rd(ARCHD *, char *);
int tar_wr __P((ARCHD *)); int tar_wr(ARCHD *);
int ustar_strd __P((void)); int ustar_strd(void);
int ustar_stwr __P((void)); int ustar_stwr(void);
int ustar_id __P((char *, int)); int ustar_id(char *, int);
int ustar_rd __P((ARCHD *, char *)); int ustar_rd(ARCHD *, char *);
int ustar_wr __P((ARCHD *)); int ustar_wr(ARCHD *);
int tar_gnutar_X_compat __P((const char *)); int tar_gnutar_X_compat(const char *);
/* /*
* tty_subs.c * tty_subs.c
*/ */
int tty_init __P((void)); int tty_init(void);
void tty_prnt __P((char *, ...)) void tty_prnt(const char *, ...)
__attribute__((format (printf, 1, 2))); __attribute__((format (printf, 1, 2)));
int tty_read __P((char *, int)); int tty_read(char *, int);
void tty_warn __P((int, char *, ...)) void tty_warn(int, const char *, ...)
__attribute__((format (printf, 2, 3))); __attribute__((format (printf, 2, 3)));
void syswarn __P((int, int, char *, ...)) void syswarn(int, int, const char *, ...)
__attribute__((format (printf, 3, 4))); __attribute__((format (printf, 3, 4)));

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #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" #include "extern.h"
static int 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; * 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 * file descriptor or -1 for failure
*/ */
#if __STDC__
int int
file_creat(ARCHD *arcn) file_creat(ARCHD *arcn)
#else
int
file_creat(arcn)
ARCHD *arcn;
#endif
{ {
int fd = -1; int fd = -1;
mode_t file_mode; mode_t file_mode;
@ -144,15 +138,8 @@ file_creat(arcn)
* 0 for success, -1 for failure * 0 for success, -1 for failure
*/ */
#if __STDC__
void void
file_close(ARCHD *arcn, int fd) file_close(ARCHD *arcn, int fd)
#else
void
file_close(arcn, fd)
ARCHD *arcn;
int fd;
#endif
{ {
int res = 0; int res = 0;
@ -193,14 +180,8 @@ file_close(arcn, fd)
* 0 if ok, -1 otherwise * 0 if ok, -1 otherwise
*/ */
#if __STDC__
int int
lnk_creat(ARCHD *arcn) lnk_creat(ARCHD *arcn)
#else
int
lnk_creat(arcn)
ARCHD *arcn;
#endif
{ {
struct stat sb; struct stat sb;
@ -233,14 +214,8 @@ lnk_creat(arcn)
* 0 if cross_lnk() ok, -1 for fatal flaw (like linking to self). * 0 if cross_lnk() ok, -1 for fatal flaw (like linking to self).
*/ */
#if __STDC__
int int
cross_lnk(ARCHD *arcn) 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 * 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 * 0 skip it file exists (-k) or may be the same as source file
*/ */
#if __STDC__
int int
chk_same(ARCHD *arcn) chk_same(ARCHD *arcn)
#else
int
chk_same(arcn)
ARCHD *arcn;
#endif
{ {
struct stat sb; struct stat sb;
@ -306,18 +275,8 @@ chk_same(arcn)
* allowed option). -1 an error occurred. * allowed option). -1 an error occurred.
*/ */
#if __STDC__
static int static int
mk_link(char *to, struct stat *to_sb, char *from, mk_link(char *to, struct stat *to_sb, char *from, int ign)
int ign)
#else
static int
mk_link(to, to_sb, from, ign)
char *to;
struct stat *to_sb;
char *from;
int ign;
#endif
{ {
struct stat sb; struct stat sb;
int oerrno; int oerrno;
@ -388,14 +347,8 @@ mk_link(to, to_sb, from, ign)
* 0 if ok, -1 otherwise * 0 if ok, -1 otherwise
*/ */
#if __STDC__
int int
node_creat(ARCHD *arcn) node_creat(ARCHD *arcn)
#else
int
node_creat(arcn)
ARCHD *arcn;
#endif
{ {
int res; int res;
int ign = 0; int ign = 0;
@ -552,15 +505,8 @@ node_creat(arcn)
* 1 we found a directory and we were going to create a directory. * 1 we found a directory and we were going to create a directory.
*/ */
#if __STDC__
int int
unlnk_exist(char *name, int type) unlnk_exist(char *name, int type)
#else
int
unlnk_exist(name, type)
char *name;
int type;
#endif
{ {
struct stat sb; struct stat sb;
@ -610,16 +556,8 @@ unlnk_exist(name, type)
* 0 otherwise * 0 otherwise
*/ */
#if __STDC__
int int
chk_path( char *name, uid_t st_uid, gid_t st_gid) 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; char *spt = name;
struct stat sb; struct stat sb;
@ -703,17 +641,8 @@ chk_path(name, st_uid, st_gid)
* not set request. * not set request.
*/ */
#if __STDC__
void void
set_ftime(char *fnm, time_t mtime, time_t atime, int frc) 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 timeval tv[2];
struct stat sb; struct stat sb;
@ -752,16 +681,8 @@ set_ftime(fnm, mtime, atime, frc)
* 0 when set, -1 on failure * 0 when set, -1 on failure
*/ */
#if __STDC__
int int
set_ids(char *fnm, uid_t uid, gid_t gid) 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) { if (lchown(fnm, uid, gid) < 0) {
syswarn(1, errno, "Unable to set file uid/gid of %s", fnm); 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 * Set file access mode
*/ */
#if __STDC__
void void
set_pmode(char *fnm, mode_t mode) set_pmode(char *fnm, mode_t mode)
#else
void
set_pmode(fnm, mode)
char *fnm;
mode_t mode;
#endif
{ {
mode &= ABITS; mode &= ABITS;
if (lchmod(fnm, mode) < 0) if (lchmod(fnm, mode) < 0)
@ -795,15 +709,8 @@ set_pmode(fnm, mode)
* set_chflags() * set_chflags()
* Set 4.4BSD file flags * Set 4.4BSD file flags
*/ */
#if __STDC__
void void
set_chflags(char *fnm, u_int32_t flags) set_chflags(char *fnm, u_int32_t flags)
#else
void
set_chflags(fnm, flags)
char *fnm;
u_int32_t flags;
#endif
{ {
#if 0 #if 0
@ -861,21 +768,9 @@ set_chflags(fnm, flags)
* number of bytes written, -1 on write (or lseek) error. * number of bytes written, -1 on write (or lseek) error.
*/ */
#if __STDC__
int int
file_write(int fd, char *str, int cnt, int *rem, int *isempt, int sz, file_write(int fd, char *str, int cnt, int *rem, int *isempt, int sz,
char *name) 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 *pt;
char *end; 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). * write the last BYTE with a zero (back up one byte and write a zero).
*/ */
#if __STDC__
void void
file_flush(int fd, char *fname, int isempt) 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"; 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). * reset access time (tflag) do so (the times are stored in arcn).
*/ */
#if __STDC__
void void
rdfile_close(ARCHD *arcn, int *fd) rdfile_close(ARCHD *arcn, int *fd)
#else
void
rdfile_close(arcn, fd)
ARCHD *arcn;
int *fd;
#endif
{ {
/* /*
* make sure the file is open * make sure the file is open
@ -1042,15 +922,8 @@ rdfile_close(arcn, fd)
* 0 if was able to calculate the crc, -1 otherwise * 0 if was able to calculate the crc, -1 otherwise
*/ */
#if __STDC__
int int
set_crc(ARCHD *arcn, int fd) set_crc(ARCHD *arcn, int fd)
#else
int
set_crc(arcn, fd)
ARCHD *arcn;
int fd;
#endif
{ {
int i; int i;
int res; int res;

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94";
#else #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
#endif /* not lint */ #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 FTSENT *ftent = NULL; /* current file tree entry */
static int ftree_skip; /* when set skip to next file arg */ 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() * 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 * 0 if there is at least one valid file arg to process, -1 otherwise
*/ */
#if __STDC__
int int
ftree_start(void) ftree_start(void)
#else
int
ftree_start()
#endif
{ {
/* /*
* set up the operation mode of fts, open the first file arg. We must * set up the operation mode of fts, open the first file arg. We must
@ -127,11 +128,11 @@ ftree_start()
else else
ftsopts |= FTS_PHYSICAL; ftsopts |= FTS_PHYSICAL;
if (Hflag) if (Hflag)
# ifdef NET2_FTS #ifdef NET2_FTS
tty_warn(0, "The -H flag is not supported on this version"); tty_warn(0, "The -H flag is not supported on this version");
# else #else
ftsopts |= FTS_COMFOLLOW; ftsopts |= FTS_COMFOLLOW;
# endif #endif
if (Xflag) if (Xflag)
ftsopts |= FTS_XDEV; ftsopts |= FTS_XDEV;
@ -155,15 +156,8 @@ ftree_start()
* 0 if added to the linked list, -1 if failed * 0 if added to the linked list, -1 if failed
*/ */
#if __STDC__
int int
ftree_add(char *str, int isdir) ftree_add(char *str, int isdir)
#else
int
ftree_add(str, isdir)
char *str;
int isdir;
#endif
{ {
FTREE *ft; FTREE *ft;
int len; int len;
@ -206,14 +200,8 @@ ftree_add(str, isdir)
* -n and -d processing. * -n and -d processing.
*/ */
#if __STDC__
void void
ftree_sel(ARCHD *arcn) ftree_sel(ARCHD *arcn)
#else
void
ftree_sel(arcn)
ARCHD *arcn;
#endif
{ {
/* /*
* set reference bit for this pattern. This linked list is only used * 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) * have a selected member (reference count still 0)
*/ */
#if __STDC__
void void
ftree_chk(void) ftree_chk(void)
#else
void
ftree_chk()
#endif
{ {
FTREE *ft; FTREE *ft;
int wban = 0; int wban = 0;
@ -288,13 +271,8 @@ ftree_chk()
* stdin). * stdin).
*/ */
#if __STDC__
static int static int
ftree_arg(void) ftree_arg(void)
#else
static int
ftree_arg()
#endif
{ {
char *pt; char *pt;
@ -363,14 +341,8 @@ ftree_arg()
* 0 when contents of arcn have been set with the next file, -1 when done. * 0 when contents of arcn have been set with the next file, -1 when done.
*/ */
#if __STDC__
int int
next_file(ARCHD *arcn) next_file(ARCHD *arcn)
#else
int
next_file(arcn)
ARCHD *arcn;
#endif
{ {
int cnt; int cnt;
time_t atime; time_t atime;
@ -436,13 +408,13 @@ next_file(arcn)
* remember to force the time (this is -t on a read * remember to force the time (this is -t on a read
* directory, not a created directory). * directory, not a created directory).
*/ */
# ifdef NET2_FTS if (!tflag || (get_atdir(
if (!tflag || (get_atdir(ftent->fts_statb.st_dev, #ifdef NET2_FTS
ftent->fts_statb.st_ino, &mtime, &atime) < 0)) ftent->fts_statb.st_dev, ftent->fts_statb.st_ino,
# else #else
if (!tflag || (get_atdir(ftent->fts_statp->st_dev, ftent->fts_statp->st_dev, ftent->fts_statp->st_ino,
ftent->fts_statp->st_ino, &mtime, &atime) < 0)) #endif
# endif &mtime, &atime) < 0))
continue; continue;
set_ftime(ftent->fts_path, mtime, atime, 1); set_ftime(ftent->fts_path, mtime, atime, 1);
continue; continue;
@ -454,28 +426,16 @@ next_file(arcn)
ftent->fts_path); ftent->fts_path);
continue; continue;
case FTS_DNR: case FTS_DNR:
# ifdef NET2_FTS syswarn(1, FTS_ERRNO(ftent),
syswarn(1, errno,
# else
syswarn(1, ftent->fts_errno,
# endif
"Unable to read directory %s", ftent->fts_path); "Unable to read directory %s", ftent->fts_path);
continue; continue;
case FTS_ERR: case FTS_ERR:
# ifdef NET2_FTS syswarn(1, FTS_ERRNO(ftent),
syswarn(1, errno,
# else
syswarn(1, ftent->fts_errno,
# endif
"File system traversal error"); "File system traversal error");
continue; continue;
case FTS_NS: case FTS_NS:
case FTS_NSOK: case FTS_NSOK:
# ifdef NET2_FTS syswarn(1, FTS_ERRNO(ftent),
syswarn(1, errno,
# else
syswarn(1, ftent->fts_errno,
# endif
"Unable to access %s", ftent->fts_path); "Unable to access %s", ftent->fts_path);
continue; continue;
} }
@ -488,11 +448,11 @@ next_file(arcn)
arcn->pad = 0; arcn->pad = 0;
arcn->ln_nlen = 0; arcn->ln_nlen = 0;
arcn->ln_name[0] = '\0'; arcn->ln_name[0] = '\0';
# ifdef NET2_FTS #ifdef NET2_FTS
arcn->sb = ftent->fts_statb; arcn->sb = ftent->fts_statb;
# else #else
arcn->sb = *(ftent->fts_statp); arcn->sb = *(ftent->fts_statp);
# endif #endif
/* /*
* file type based set up and copy into the arcn struct * file type based set up and copy into the arcn struct

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)gen_subs.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)gen_subs.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #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 * list the members of an archive in ls format
*/ */
#if __STDC__
void void
ls_list(ARCHD *arcn, time_t now) ls_list(ARCHD *arcn, time_t now)
#else
void
ls_list(arcn, now)
ARCHD *arcn;
time_t now;
#endif
{ {
struct stat *sbp; struct stat *sbp;
char f_mode[MODELEN]; char f_mode[MODELEN];
@ -139,19 +132,10 @@ ls_list(arcn, now)
* print device id's for devices, or sizes for other nodes * print device id's for devices, or sizes for other nodes
*/ */
if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK)) 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), (void)printf("%4lu,%4lu ", (long) MAJOR(sbp->st_rdev),
(long) MINOR(sbp->st_rdev)); (long) MINOR(sbp->st_rdev));
# endif
else { else {
# ifdef NET2_STAT (void)printf(OFFT_FP("9") " ", (OFFT_T)sbp->st_size);
(void)printf("%9lu ", sbp->st_size);
# else
(void)printf("%9llu ", (long long)sbp->st_size);
# endif
} }
/* /*
@ -173,14 +157,8 @@ ls_list(arcn, now)
* print a short summary of file to tty. * print a short summary of file to tty.
*/ */
#if __STDC__
void void
ls_tty(ARCHD *arcn) ls_tty(ARCHD *arcn)
#else
void
ls_tty(arcn)
ARCHD *arcn;
#endif
{ {
char f_date[DATELEN]; char f_date[DATELEN];
char f_mode[MODELEN]; char f_mode[MODELEN];
@ -210,16 +188,8 @@ ls_tty(arcn)
* memset(). (or doing the memset() first). * memset(). (or doing the memset() first).
*/ */
#if __STDC__
void void
zf_strncpy(char *dest, const char *src, int len) 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; char *stop;
@ -239,16 +209,8 @@ zf_strncpy(dest, src, len)
* doing a strncpy() then a strlen() * doing a strncpy() then a strlen()
*/ */
#if __STDC__
int int
l_strncpy(char *dest, const char *src, int len) 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 *stop;
char *start; char *start;
@ -272,16 +234,8 @@ l_strncpy(dest, src, len)
* unsigned long value * unsigned long value
*/ */
#if __STDC__
u_long u_long
asc_ul(char *str, int len, int base) 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; char *stop;
u_long tval = 0; u_long tval = 0;
@ -323,17 +277,8 @@ asc_ul(str, len, base)
* NOTE: the string created is NOT TERMINATED. * NOTE: the string created is NOT TERMINATED.
*/ */
#if __STDC__
int int
ul_asc(u_long val, char *str, int len, int base) 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; char *pt;
u_long digit; u_long digit;
@ -377,28 +322,20 @@ ul_asc(val, str, len, base)
#ifndef NET2_STAT #ifndef NET2_STAT
/* /*
* asc_uqd() * asc_ull()
* convert hex/octal character string into a u_quad_t. We do not have to * convert hex/octal character string into a u_longlong_t. We do not have
* check for overflow! (the headers in all supported formats are not large * to to check for overflow! (the headers in all supported formats are
* enough to create an overflow). * not large enough to create an overflow).
* NOTE: strings passed to us are NOT TERMINATED. * NOTE: strings passed to us are NOT TERMINATED.
* Return: * Return:
* u_quad_t value * u_longlong_t value
*/ */
#if __STDC__ u_longlong_t
u_quad_t asc_ull(char *str, int len, int base)
asc_uqd(char *str, int len, int base)
#else
u_quad_t
asc_uqd(str, len, base)
char *str;
int len;
int base;
#endif
{ {
char *stop; char *stop;
u_quad_t tval = 0; u_longlong_t tval = 0;
stop = str + len; stop = str + len;
@ -431,26 +368,17 @@ asc_uqd(str, len, base)
} }
/* /*
* uqd_asc() * ull_asc()
* convert an u_quad_t into a hex/oct ascii string. pads with LEADING * convert an u_longlong_t into a hex/oct ascii string. pads with LEADING
* ascii 0's to fill string completely * ascii 0's to fill string completely
* NOTE: the string created is NOT TERMINATED. * NOTE: the string created is NOT TERMINATED.
*/ */
#if __STDC__
int int
uqd_asc(u_quad_t val, char *str, int len, int base) ull_asc(u_longlong_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
{ {
char *pt; char *pt;
u_quad_t digit; u_longlong_t digit;
/* /*
* WARNING str is not '\0' terminated by this routine * WARNING str is not '\0' terminated by this routine
@ -468,13 +396,13 @@ uqd_asc(val, str, len, base)
*pt-- = '0' + (char)digit; *pt-- = '0' + (char)digit;
else else
*pt-- = 'a' + (char)(digit - 10); *pt-- = 'a' + (char)(digit - 10);
if ((val = (val >> 4)) == (u_quad_t)0) if ((val = (val >> 4)) == (u_longlong_t)0)
break; break;
} }
} else { } else {
while (pt >= str) { while (pt >= str) {
*pt-- = '0' + (char)(val & 0x7); *pt-- = '0' + (char)(val & 0x7);
if ((val = (val >> 3)) == (u_quad_t)0) if ((val = (val >> 3)) == (u_longlong_t)0)
break; break;
} }
} }
@ -484,7 +412,7 @@ uqd_asc(val, str, len, base)
*/ */
while (pt >= str) while (pt >= str)
*pt-- = '0'; *pt-- = '0';
if (val != (u_quad_t)0) if (val != (u_longlong_t)0)
return(-1); return(-1);
return(0); return(0);
} }
@ -498,7 +426,8 @@ check_Aflag(void)
return 1; return 1;
if (Aflag == 0) { if (Aflag == 0) {
Aflag = -1; 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; return 0;
} }

View File

@ -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 * Plug-compatible replacement for getopt() for parsing tar-like
@ -11,7 +11,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #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 */ #endif /* not lint */
#include <stdio.h> #include <stdio.h>
@ -23,12 +23,8 @@ __RCSID("$NetBSD: getoldopt.c,v 1.10 2000/07/04 17:17:49 thorpej Exp $");
#include "extern.h" #include "extern.h"
int int
getoldopt(argc, argv, optstring, longopts, index) getoldopt(int argc, char **argv, const char *optstring,
int argc; struct option *longopts, int *index)
char **argv;
const char *optstring;
struct option *longopts;
int *index;
{ {
static char *key; /* Points to next keyletter */ static char *key; /* Points to next keyletter */
static char use_getopt; /* !=0 if argv[1][0] was '-' */ static char use_getopt; /* !=0 if argv[1][0] was '-' */

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
#else #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
#endif /* not lint */ #endif /* not lint */
@ -76,18 +76,18 @@ static OPLIST *ophead = NULL; /* head for format specific options -x */
static OPLIST *optail = NULL; /* option tail */ static OPLIST *optail = NULL; /* option tail */
static char *firstminusC; /* first -C argument encountered. */ static char *firstminusC; /* first -C argument encountered. */
static int no_op __P((void)); static int no_op(void);
static void printflg __P((unsigned int)); static void printflg(unsigned int);
static int c_frmt __P((const void *, const void *)); static int c_frmt(const void *, const void *);
static off_t str_offt __P((char *)); static off_t str_offt(char *);
static void pax_options __P((int, char **)); static void pax_options(int, char **);
static void pax_usage __P((void)); static void pax_usage(void);
static void tar_options __P((int, char **)); static void tar_options(int, char **);
static void tar_usage __P((void)); static void tar_usage(void);
static void cpio_options __P((int, char **)); static void cpio_options(int, char **);
static void cpio_usage __P((void)); 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 GZIP_CMD "gzip" /* command to run as gzip */
#define COMPRESS_CMD "compress" /* command to run as compress */ #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 * parser
*/ */
#if __STDC__
void void
options(int argc, char **argv) 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 * the user specified a legal set of flags. If not, complain and exit
*/ */
#if __STDC__
static void static void
pax_options(int argc, char **argv) pax_options(int argc, char **argv)
#else
static void
pax_options(argc, argv)
int argc;
char **argv;
#endif
{ {
int c; int c;
int i; int i;
@ -719,15 +705,8 @@ struct option tar_longopts[] = {
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 },
}; };
#if __STDC__
static void static void
tar_options(int argc, char **argv) tar_options(int argc, char **argv)
#else
static void
tar_options(argc, argv)
int argc;
char **argv;
#endif
{ {
int c; int c;
int fstdin = 0; int fstdin = 0;
@ -975,15 +954,8 @@ tar_options(argc, argv)
* the user specified a legal set of flags. If not, complain and exit * the user specified a legal set of flags. If not, complain and exit
*/ */
#if __STDC__
static void static void
cpio_options(int argc, char **argv) cpio_options(int argc, char **argv)
#else
static void
cpio_options(argc, argv)
int argc;
char **argv;
#endif
{ {
FSUB tmp; FSUB tmp;
unsigned int flg = 0; unsigned int flg = 0;
@ -1244,14 +1216,8 @@ cpio_options(argc, argv)
* print out those invalid flag sets found to the user * print out those invalid flag sets found to the user
*/ */
#if __STDC__
static void static void
printflg(unsigned int flg) printflg(unsigned int flg)
#else
static void
printflg(flg)
unsigned int flg;
#endif
{ {
int nxt; int nxt;
int pos = 0; int pos = 0;
@ -1271,15 +1237,8 @@ printflg(flg)
* by the user * by the user
*/ */
#if __STDC__
static int static int
c_frmt(const void *a, const void *b) 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)); 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). * pointer to next OPLIST entry or NULL (end of list).
*/ */
#if __STDC__
OPLIST * OPLIST *
opt_next(void) opt_next(void)
#else
OPLIST *
opt_next()
#endif
{ {
OPLIST *opt; OPLIST *opt;
@ -1313,13 +1267,8 @@ opt_next()
* when the format does not support options. * when the format does not support options.
*/ */
#if __STDC__
int int
bad_opt(void) bad_opt(void)
#else
int
bad_opt()
#endif
{ {
OPLIST *opt; OPLIST *opt;
@ -1344,14 +1293,8 @@ bad_opt()
* 0 if format in name=value format, -1 if -o is passed junk * 0 if format in name=value format, -1 if -o is passed junk
*/ */
#if __STDC__
int int
opt_add(const char *str) opt_add(const char *str)
#else
int
opt_add(str)
const char *str;
#endif
{ {
OPLIST *opt; OPLIST *opt;
char *frpt; char *frpt;
@ -1413,25 +1356,14 @@ opt_add(str)
* 0 for an error, a positive value o.w. * 0 for an error, a positive value o.w.
*/ */
#if __STDC__
static off_t static off_t
str_offt(char *val) str_offt(char *val)
#else
static off_t
str_offt(val)
char *val;
#endif
{ {
char *expr; char *expr;
off_t num, t; off_t num, t;
# ifdef NET2_STAT num = STRTOOFFT(val, &expr, 0);
num = strtol(val, &expr, 0); if ((num == OFFT_MAX) || (num <= 0) || (expr == val))
if ((num == LONG_MAX) || (num <= 0) || (expr == val))
# else
num = strtoq(val, &expr, 0);
if ((num == QUAD_MAX) || (num <= 0) || (expr == val))
# endif
return(0); return(0);
switch(*expr) { switch(*expr) {
@ -1488,13 +1420,8 @@ str_offt(val)
* 0 * 0
*/ */
#if __STDC__
static int static int
no_op(void) no_op(void)
#else
static int
no_op()
#endif
{ {
return(0); return(0);
} }
@ -1504,13 +1431,8 @@ no_op()
* print the usage summary to the user * print the usage summary to the user
*/ */
#if __STDC__
void void
pax_usage(void) pax_usage(void)
#else
void
pax_usage()
#endif
{ {
(void)fputs("usage: pax [-cdnvz] [-E limit] [-f archive] ", stderr); (void)fputs("usage: pax [-cdnvz] [-E limit] [-f archive] ", stderr);
(void)fputs("[-s replstr] ... [-U user] ...", stderr); (void)fputs("[-s replstr] ... [-U user] ...", stderr);
@ -1544,13 +1466,8 @@ pax_usage()
* print the usage summary to the user * print the usage summary to the user
*/ */
#if __STDC__
void void
tar_usage(void) tar_usage(void)
#else
void
tar_usage()
#endif
{ {
(void)fputs("usage: tar -{txru}[cevfbhlmopwBLPX014578] [tapefile] ", (void)fputs("usage: tar -{txru}[cevfbhlmopwBLPX014578] [tapefile] ",
stderr); stderr);
@ -1564,13 +1481,8 @@ tar_usage()
* print the usage summary to the user * print the usage summary to the user
*/ */
#if __STDC__
void void
cpio_usage(void) cpio_usage(void)
#else
void
cpio_usage()
#endif
{ {
#if 1 #if 1
@ -1604,14 +1516,8 @@ cpio_usage()
* Returns: -1 for listing, else what ftree_add or pat_add returned. * Returns: -1 for listing, else what ftree_add or pat_add returned.
*/ */
#ifdef __STDC__
int int
opt_chdir(char *name) opt_chdir(char *name)
#else
int
opt_chdir(name)
char *name;
#endif
{ {
switch (act) { switch (act) {
default: default:
@ -1631,15 +1537,8 @@ opt_chdir(name)
* checkpositionalminusC(argvp, addfunc) * checkpositionalminusC(argvp, addfunc)
*/ */
#ifdef __STDC__
void void
checkpositionalminusC(char ***argvp, int (*addfunc)(char *, int)) checkpositionalminusC(char ***argvp, int (*addfunc)(char *, int))
#else
void
checkpositionalminusC(argvp, addfunc)
char ***argvp;
int (*addfunc)();
#endif
{ {
while (**argvp != (char *)NULL) { while (**argvp != (char *)NULL) {
if (!strcmp(**argvp, "-C")) { if (!strcmp(**argvp, "-C")) {

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)pat_rep.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)pat_rep.c 8.2 (Berkeley) 4/18/94";
#else #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
#endif /* not lint */ #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 *rephead = NULL; /* replacement string list head */
static REPLACE *reptail = NULL; /* replacement string list tail */ static REPLACE *reptail = NULL; /* replacement string list tail */
static int rep_name __P((char *, int *, int)); static int rep_name(char *, int *, int);
static int tty_rename __P((ARCHD *)); static int tty_rename(ARCHD *);
static int fix_path __P((char *, int *, char *, int)); static int fix_path(char *, int *, char *, int);
static int fn_match __P((char *, char *, char **)); static int fn_match(char *, char *, char **);
static char * range_match __P((char *, int)); static char * range_match(char *, int);
#ifdef NET2_REGEX #ifdef NET2_REGEX
static int resub __P((regexp *, char *, char *, char *)); static int resub(regexp *, char *, char *, char *);
#else #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 #endif
/* /*
@ -104,22 +104,16 @@ static int resub __P((regex_t *, regmatch_t *, char *, char *, char *, char *));
* the list of replacement patterns; -1 otherwise. * the list of replacement patterns; -1 otherwise.
*/ */
#if __STDC__
int int
rep_add(char *str) rep_add(char *str)
#else
int
rep_add(str)
char *str;
#endif
{ {
char *pt1; char *pt1;
char *pt2; char *pt2;
REPLACE *rep; REPLACE *rep;
# ifndef NET2_REGEX #ifndef NET2_REGEX
int res; int res;
char rebuf[BUFSIZ]; char rebuf[BUFSIZ];
# endif #endif
/* /*
* throw out the bad parameters * throw out the bad parameters
@ -152,14 +146,14 @@ rep_add(str)
} }
*pt1 = '\0'; *pt1 = '\0';
# ifdef NET2_REGEX #ifdef NET2_REGEX
if ((rep->rcmp = regcomp(str+1)) == NULL) { if ((rep->rcmp = regcomp(str+1)) == NULL) {
# else #else
if ((res = regcomp(&(rep->rcmp), str+1, 0)) != 0) { if ((res = regcomp(&(rep->rcmp), str+1, 0)) != 0) {
regerror(res, &(rep->rcmp), rebuf, sizeof(rebuf)); regerror(res, &(rep->rcmp), rebuf, sizeof(rebuf));
tty_warn(1, "%s while compiling regular expression %s", rebuf, tty_warn(1, "%s while compiling regular expression %s", rebuf,
str); str);
# endif #endif
(void)free((char *)rep); (void)free((char *)rep);
return(-1); return(-1);
} }
@ -188,11 +182,11 @@ rep_add(str)
rep->flgs |= PRNT; rep->flgs |= PRNT;
break; break;
default: default:
# ifdef NET2_REGEX #ifdef NET2_REGEX
(void)free((char *)rep->rcmp); (void)free((char *)rep->rcmp);
# else #else
regfree(&(rep->rcmp)); regfree(&(rep->rcmp));
# endif #endif
(void)free((char *)rep); (void)free((char *)rep);
*pt1 = *str; *pt1 = *str;
tty_warn(1, "Invalid replacement string option %s", 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 * 0 if the pattern was added to the list, -1 otherwise
*/ */
#if __STDC__
int int
pat_add(char *str, int ischdir) pat_add(char *str, int ischdir)
#else
int
pat_add(str ischdir)
char *str;
int ischdir;
#endif
{ {
PATTERN *pt; PATTERN *pt;
@ -278,13 +265,8 @@ pat_add(str ischdir)
* a selected archive member. * a selected archive member.
*/ */
#if __STDC__
void void
pat_chk(void) pat_chk(void)
#else
void
pat_chk()
#endif
{ {
PATTERN *pt; PATTERN *pt;
int wban = 0; int wban = 0;
@ -320,14 +302,8 @@ pat_chk()
* match, -1 otherwise. * match, -1 otherwise.
*/ */
#if __STDC__
int int
pat_sel(ARCHD *arcn) pat_sel(ARCHD *arcn)
#else
int
pat_sel(arcn)
ARCHD *arcn;
#endif
{ {
PATTERN *pt; PATTERN *pt;
PATTERN **ppt; PATTERN **ppt;
@ -445,14 +421,8 @@ pat_sel(arcn)
* looking for more members) * looking for more members)
*/ */
#if __STDC__
int int
pat_match(ARCHD *arcn) pat_match(ARCHD *arcn)
#else
int
pat_match(arcn)
ARCHD *arcn;
#endif
{ {
PATTERN *pt; PATTERN *pt;
@ -529,16 +499,8 @@ pat_match(arcn)
* Note: *pend may be changed to show where the prefix ends. * Note: *pend may be changed to show where the prefix ends.
*/ */
#if __STDC__
static int static int
fn_match(char *pattern, char *string, char **pend) 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 c;
char test; char test;
@ -610,15 +572,8 @@ fn_match(pattern, string, pend)
/* NOTREACHED */ /* NOTREACHED */
} }
#ifdef __STDC__
static char * static char *
range_match(char *pattern, int test) range_match(char *pattern, int test)
#else
static char *
range_match(pattern, test)
char *pattern;
int test;
#endif
{ {
char c; char c;
char c2; char c2;
@ -660,14 +615,8 @@ range_match(pattern, test)
* 0 continue to process file, 1 skip this file, -1 pax is finished * 0 continue to process file, 1 skip this file, -1 pax is finished
*/ */
#if __STDC__
int int
mod_name(ARCHD *arcn) mod_name(ARCHD *arcn)
#else
int
mod_name(arcn)
ARCHD *arcn;
#endif
{ {
int res = 0; int res = 0;
@ -727,14 +676,8 @@ mod_name(arcn)
* 0 process this file, 1 skip this file, -1 we need to exit pax * 0 process this file, 1 skip this file, -1 we need to exit pax
*/ */
#if __STDC__
static int static int
tty_rename(ARCHD *arcn) tty_rename(ARCHD *arcn)
#else
static int
tty_rename(arcn)
ARCHD *arcn;
#endif
{ {
char tmpname[PAXPATHLEN+2]; char tmpname[PAXPATHLEN+2];
int res; int res;
@ -798,16 +741,8 @@ tty_rename(arcn)
* 0 if ok, -1 if failure (name too long) * 0 if ok, -1 if failure (name too long)
*/ */
#if __STDC__
int int
set_dest(ARCHD *arcn, char *dest_dir, int dir_len) 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) if (fix_path(arcn->name, &(arcn->nlen), dest_dir, dir_len) < 0)
return(-1); return(-1);
@ -833,17 +768,8 @@ set_dest(arcn, dest_dir, dir_len)
* 0 if ok, -1 if the final name is too long * 0 if ok, -1 if the final name is too long
*/ */
#if __STDC__
static int static int
fix_path( char *or_name, int *or_len, char *dir_name, int dir_len) 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 *src;
char *dest; char *dest;
@ -905,16 +831,8 @@ fix_path(or_name, or_len, dir_name, dir_len)
* ended up empty) * ended up empty)
*/ */
#if __STDC__
static int static int
rep_name(char *name, int *nlen, int prnt) 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; REPLACE *pt;
char *inpt; char *inpt;
@ -923,9 +841,9 @@ rep_name(name, nlen, prnt)
char *rpt; char *rpt;
int found = 0; int found = 0;
int res; int res;
# ifndef NET2_REGEX #ifndef NET2_REGEX
regmatch_t pm[MAXSUBEXP]; regmatch_t pm[MAXSUBEXP];
# endif #endif
char nname[PAXPATHLEN+1]; /* final result of all replacements */ char nname[PAXPATHLEN+1]; /* final result of all replacements */
char buf1[PAXPATHLEN+1]; /* where we work on the name */ 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 * check for a successful substitution, if not go to
* the next pattern, or cleanup if we were global * the next pattern, or cleanup if we were global
*/ */
# ifdef NET2_REGEX #ifdef NET2_REGEX
if (regexec(pt->rcmp, inpt) == 0) if (regexec(pt->rcmp, inpt) == 0)
# else #else
if (regexec(&(pt->rcmp), inpt, MAXSUBEXP, pm, 0) != 0) if (regexec(&(pt->rcmp), inpt, MAXSUBEXP, pm, 0) != 0)
# endif #endif
break; break;
/* /*
@ -967,11 +885,11 @@ rep_name(name, nlen, prnt)
* do not create a string too long). * do not create a string too long).
*/ */
found = 1; found = 1;
# ifdef NET2_REGEX #ifdef NET2_REGEX
rpt = pt->rcmp->startp[0]; rpt = pt->rcmp->startp[0];
# else #else
rpt = inpt + pm[0].rm_so; rpt = inpt + pm[0].rm_so;
# endif #endif
while ((inpt < rpt) && (outpt < endpt)) while ((inpt < rpt) && (outpt < endpt))
*outpt++ = *inpt++; *outpt++ = *inpt++;
@ -984,12 +902,13 @@ rep_name(name, nlen, prnt)
* replacement string and place it the prefix in the * replacement string and place it the prefix in the
* final output. If we have problems, skip it. * final output. If we have problems, skip it.
*/ */
# ifdef NET2_REGEX if ((res =
if ((res = resub(pt->rcmp,pt->nstr,outpt,endpt)) < 0) { #ifdef NET2_REGEX
# else resub(pt->rcmp,pt->nstr,outpt,endpt)
if ((res = resub(&(pt->rcmp),pm,pt->nstr,inpt, #else
outpt,endpt)) < 0) { resub(&(pt->rcmp),pm,pt->nstr,inpt, outpt,endpt)
# endif #endif
) < 0) {
if (prnt) if (prnt)
tty_warn(1, "Replacement name error %s", tty_warn(1, "Replacement name error %s",
name); name);
@ -1007,11 +926,11 @@ rep_name(name, nlen, prnt)
* the final result. Make sure we do not overrun the * the final result. Make sure we do not overrun the
* output buffer * output buffer
*/ */
# ifdef NET2_REGEX #ifdef NET2_REGEX
inpt = pt->rcmp->endp[0]; inpt = pt->rcmp->endp[0];
# else #else
inpt += pm[0].rm_eo - pm[0].rm_so; inpt += pm[0].rm_eo - pm[0].rm_so;
# endif #endif
if ((outpt == endpt) || (*inpt == '\0')) if ((outpt == endpt) || (*inpt == '\0'))
break; break;
@ -1078,17 +997,8 @@ rep_name(name, nlen, prnt)
* -1 if error, or the number of characters added to the destination. * -1 if error, or the number of characters added to the destination.
*/ */
#if __STDC__
static int static int
resub(regexp *prog, char *src, char *dest, char *destend) 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 *spt;
char *dpt; char *dpt;
@ -1136,20 +1046,9 @@ resub(prog, src, dest, destend)
* -1 if error, or the number of characters added to the destination. * -1 if error, or the number of characters added to the destination.
*/ */
#if __STDC__
static int static int
resub(regex_t *rp, regmatch_t *pm, char *src, char *txt, char *dest, resub(regex_t *rp, regmatch_t *pm, char *src, char *txt, char *dest,
char *destend) 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 *spt;
char *dpt; char *dpt;

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94";
#else #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
#endif /* not lint */ #endif /* not lint */
@ -63,7 +63,7 @@ __RCSID("$NetBSD: pax.c,v 1.13 2000/10/22 15:41:31 kleink Exp $");
#include <errno.h> #include <errno.h>
#include "pax.h" #include "pax.h"
#include "extern.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 * 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 * Return: 0 if ok, 1 otherwise
*/ */
#if __STDC__
int int
main(int argc, char **argv) main(int argc, char **argv)
#else
int
main(argc, argv)
int argc;
char **argv;
#endif
{ {
/* /*
* parse options, determine operational mode, general init * parse options, determine operational mode, general init
@ -277,14 +270,8 @@ main(argc, argv)
* never.... * never....
*/ */
#if __STDC__
void void
sig_cleanup(int which_sig) 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 * 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. * when dealing with a medium to large sized archives.
*/ */
#if __STDC__
static int static int
gen_init(void) gen_init(void)
#else
static int
gen_init()
#endif
{ {
struct rlimit reslimit; struct rlimit reslimit;
struct sigaction n_hand; struct sigaction n_hand;

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -166,13 +166,13 @@ typedef struct {
int inhead; /* is the trailer encoded in a valid header? */ int inhead; /* is the trailer encoded in a valid header? */
/* if not, trailers are assumed to be found */ /* if not, trailers are assumed to be found */
/* in invalid headers (i.e like tar) */ /* in invalid headers (i.e like tar) */
int (*id) /* checks if a buffer is a valid header */ int (*id)(char *, int); /* checks if a buffer is a valid header */
__P((char *, int)); /* returns 1 if it is, o.w. returns a 0 */ /* returns 1 if it is, o.w. returns a 0 */
int (*st_rd) /* initialize routine for read. so format */ int (*st_rd)(void); /* initialize routine for read. so format */
__P((void)); /* can set up tables etc before it starts */ /* can set up tables etc before it starts */
/* reading an archive */ /* reading an archive */
int (*rd) /* read header routine. passed a pointer to */ 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 */ /* from the format and store it in the ARCHD */
/* struct. This routine is expected to fill */ /* struct. This routine is expected to fill */
/* all the fields in the ARCHD (including */ /* all the fields in the ARCHD (including */
@ -183,14 +183,13 @@ typedef struct {
/* amount of padding and the number of bytes */ /* amount of padding and the number of bytes */
/* of data which follow the header. This info */ /* of data which follow the header. This info */
/* is used to skip to the next file header */ /* is used to skip to the next file header */
off_t (*end_rd) /* read cleanup. Allows format to clean up */ off_t (*end_rd)(void); /* read cleanup. Allows format to clean up */
__P((void)); /* and MUST RETURN THE LENGTH OF THE TRAILER */ /* and MUST RETURN THE LENGTH OF THE TRAILER */
/* RECORD (so append knows how many bytes */ /* RECORD (so append knows how many bytes */
/* to move back to rewrite the trailer) */ /* to move back to rewrite the trailer) */
int (*st_wr) /* initialize routine for write operations */ int (*st_wr)(void); /* initialize routine for write operations */
__P((void)); int (*wr)(ARCHD *); /* write archive header. Passed an ARCHD */
int (*wr) /* write archive header. Passed an ARCHD */ /* filled with the specs on the next file to */
__P((ARCHD *)); /* filled with the specs on the next file to */
/* archived. Returns a 1 if no file data is */ /* archived. Returns a 1 if no file data is */
/* is to be stored; 0 if file data is to be */ /* is to be stored; 0 if file data is to be */
/* added. A -1 is returned if a write */ /* added. A -1 is returned if a write */
@ -199,25 +198,24 @@ typedef struct {
/* the proper padding can be added after */ /* the proper padding can be added after */
/* file data. This routine must NEVER write */ /* file data. This routine must NEVER write */
/* a flawed archive header. */ /* a flawed archive header. */
int (*end_wr) /* end write. write the trailer and do any */ int (*end_wr)(void); /* end write. write the trailer and do any */
__P((void)); /* other format specific functions needed */ /* other format specific functions needed */
/* at the ecnd of a archive write */ /* at the ecnd of a archive write */
int (*trail) /* returns 0 if a valid trailer, -1 if not */ 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 */ /* trailer outside of a valid header, a */
/* return value of 1 indicates that the block */ /* return value of 1 indicates that the block */
/* passed to it can never contain a valid */ /* passed to it can never contain a valid */
/* header (skip this block, no point in */ /* header (skip this block, no point in */
/* looking at it) */ /* looking at it) */
int (*subtrail) /* read/process file data from the archive */ 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. */ /* inside headers. */
int (*rd_data) /* read/process file data from the archive */ 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 */ int (*wr_data) /* write/process file data to the archive */
__P((ARCHD *, int, off_t *)); (ARCHD *, int, off_t *);
int (*options) /* process format specific options (-o) */ int (*options)(void); /* process format specific options (-o) */
__P((void));
} FSUB; } FSUB;
/* /*
@ -253,3 +251,26 @@ typedef struct oplist {
* ${TMPDIR} or, as a fall-back, _PATH_TMP. * ${TMPDIR} or, as a fall-back, _PATH_TMP.
*/ */
#define TMPFILE "paxXXXXXX" #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

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)sel_subs.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)sel_subs.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #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 "sel_subs.h"
#include "extern.h" #include "extern.h"
static int str_sec __P((const char *, time_t *)); static int str_sec(const char *, time_t *);
static int usr_match __P((ARCHD *)); static int usr_match(ARCHD *);
static int grp_match __P((ARCHD *)); static int grp_match(ARCHD *);
static int trng_match __P((ARCHD *)); static int trng_match(ARCHD *);
static TIME_RNG *trhead = NULL; /* time range list head */ static TIME_RNG *trhead = NULL; /* time range list head */
static TIME_RNG *trtail = NULL; /* time range list tail */ 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 * 0 if this archive member should be processed, 1 if it should be skipped
*/ */
#if __STDC__
int int
sel_chk(ARCHD *arcn) sel_chk(ARCHD *arcn)
#else
int
sel_chk(arcn)
ARCHD *arcn;
#endif
{ {
if (((usrtb != NULL) && usr_match(arcn)) || if (((usrtb != NULL) && usr_match(arcn)) ||
((grptb != NULL) && grp_match(arcn)) || ((grptb != NULL) && grp_match(arcn)) ||
@ -118,14 +112,8 @@ sel_chk(arcn)
* 0 if added ok, -1 otherwise; * 0 if added ok, -1 otherwise;
*/ */
#if __STDC__
int int
usr_add(char *str) usr_add(char *str)
#else
int
usr_add(str)
char *str;
#endif
{ {
u_int indx; u_int indx;
USRT *pt; USRT *pt;
@ -159,11 +147,7 @@ usr_add(str)
} }
uid = (uid_t)pw->pw_uid; uid = (uid_t)pw->pw_uid;
} else } else
# ifdef NET2_STAT
uid = (uid_t)atoi(str+1);
# else
uid = (uid_t)strtoul(str+1, (char **)NULL, 10); uid = (uid_t)strtoul(str+1, (char **)NULL, 10);
# endif
endpwent(); endpwent();
/* /*
@ -198,14 +182,8 @@ usr_add(str)
* 0 if this archive member should be processed, 1 if it should be skipped * 0 if this archive member should be processed, 1 if it should be skipped
*/ */
#if __STDC__
static int static int
usr_match(ARCHD *arcn) usr_match(ARCHD *arcn)
#else
static int
usr_match(arcn)
ARCHD *arcn;
#endif
{ {
USRT *pt; USRT *pt;
@ -232,14 +210,8 @@ usr_match(arcn)
* 0 if added ok, -1 otherwise; * 0 if added ok, -1 otherwise;
*/ */
#if __STDC__
int int
grp_add(char *str) grp_add(char *str)
#else
int
grp_add(str)
char *str;
#endif
{ {
u_int indx; u_int indx;
GRPT *pt; GRPT *pt;
@ -274,11 +246,7 @@ grp_add(str)
} }
gid = (gid_t)gr->gr_gid; gid = (gid_t)gr->gr_gid;
} else } else
# ifdef NET2_STAT
gid = (gid_t)atoi(str+1);
# else
gid = (gid_t)strtoul(str+1, (char **)NULL, 10); gid = (gid_t)strtoul(str+1, (char **)NULL, 10);
# endif
endgrent(); endgrent();
/* /*
@ -313,14 +281,8 @@ grp_add(str)
* 0 if this archive member should be processed, 1 if it should be skipped * 0 if this archive member should be processed, 1 if it should be skipped
*/ */
#if __STDC__
static int static int
grp_match(ARCHD *arcn) grp_match(ARCHD *arcn)
#else
static int
grp_match(arcn)
ARCHD *arcn;
#endif
{ {
GRPT *pt; GRPT *pt;
@ -369,14 +331,8 @@ grp_match(arcn)
* 0 if the time range was added to the list, -1 otherwise * 0 if the time range was added to the list, -1 otherwise
*/ */
#if __STDC__
int int
trng_add(char *str) trng_add(char *str)
#else
int
trng_add(str)
char *str;
#endif
{ {
TIME_RNG *pt; TIME_RNG *pt;
char *up_pt = NULL; 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 * 0 if this archive member should be processed, 1 if it should be skipped
*/ */
#if __STDC__
static int static int
trng_match(ARCHD *arcn) trng_match(ARCHD *arcn)
#else
static int
trng_match(arcn)
ARCHD *arcn;
#endif
{ {
TIME_RNG *pt; TIME_RNG *pt;
@ -593,15 +543,8 @@ trng_match(arcn)
#define ATOI2(s) ((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0')) #define ATOI2(s) ((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))
#if __STDC__
static int static int
str_sec(const char *p, time_t *tval) 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; struct tm *lt;
const char *dot, *t; const char *dot, *t;

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@ -88,7 +88,7 @@ static u_long dircnt; /* entries in dir time/mode storage */
#endif #endif
static int ffd = -1; /* tmp file for file time table name storage */ 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 * hard link table routines
@ -113,13 +113,8 @@ static DEVT *chk_dev __P((dev_t, int));
* 0 if created, -1 if failure * 0 if created, -1 if failure
*/ */
#if __STDC__
int int
lnk_start(void) lnk_start(void)
#else
int
lnk_start()
#endif
{ {
if (ltab != NULL) if (ltab != NULL)
return(0); return(0);
@ -142,14 +137,8 @@ lnk_start()
* if found returns 1; if not found returns 0; -1 on error * if found returns 1; if not found returns 0; -1 on error
*/ */
#if __STDC__
int int
chk_lnk(ARCHD *arcn) chk_lnk(ARCHD *arcn)
#else
int
chk_lnk(arcn)
ARCHD *arcn;
#endif
{ {
HRDLNK *pt; HRDLNK *pt;
HRDLNK **ppt; HRDLNK **ppt;
@ -234,14 +223,8 @@ chk_lnk(arcn)
* we do not want to accidently point another file at it later on. * we do not want to accidently point another file at it later on.
*/ */
#if __STDC__
void void
purg_lnk(ARCHD *arcn) purg_lnk(ARCHD *arcn)
#else
void
purg_lnk(arcn)
ARCHD *arcn;
#endif
{ {
HRDLNK *pt; HRDLNK *pt;
HRDLNK **ppt; HRDLNK **ppt;
@ -294,13 +277,8 @@ purg_lnk(arcn)
* write phase * write phase
*/ */
#if __STDC__
void void
lnk_end(void) lnk_end(void)
#else
void
lnk_end()
#endif
{ {
int i; int i;
HRDLNK *pt; HRDLNK *pt;
@ -359,13 +337,8 @@ lnk_end()
* 0 if the table and file was created ok, -1 otherwise * 0 if the table and file was created ok, -1 otherwise
*/ */
#if __STDC__
int int
ftime_start(void) ftime_start(void)
#else
int
ftime_start()
#endif
{ {
const char *tmpdir; const char *tmpdir;
char template[MAXPATHLEN]; char template[MAXPATHLEN];
@ -406,14 +379,8 @@ ftime_start()
* -1 on error * -1 on error
*/ */
#if __STDC__
int int
chk_ftime(ARCHD *arcn) chk_ftime(ARCHD *arcn)
#else
int
chk_ftime(arcn)
ARCHD *arcn;
#endif
{ {
FTM *pt; FTM *pt;
int namelen; int namelen;
@ -531,13 +498,8 @@ chk_ftime(arcn)
* 0 if successful, -1 otherwise * 0 if successful, -1 otherwise
*/ */
#if __STDC__
int int
name_start(void) name_start(void)
#else
int
name_start()
#endif
{ {
if (ntab != NULL) if (ntab != NULL)
return(0); return(0);
@ -558,16 +520,8 @@ name_start()
* 0 if added, -1 otherwise * 0 if added, -1 otherwise
*/ */
#if __STDC__
int int
add_name(char *oname, int onamelen, char *nname) add_name(char *oname, int onamelen, char *nname)
#else
int
add_name(oname, onamelen, nname)
char *oname;
int onamelen;
char *nname;
#endif
{ {
NAMT *pt; NAMT *pt;
u_int indx; u_int indx;
@ -634,15 +588,8 @@ add_name(oname, onamelen, nname)
* new name (oname is the link to name) * new name (oname is the link to name)
*/ */
#if __STDC__
void void
sub_name(char *oname, int *onamelen) sub_name(char *oname, int *onamelen)
#else
void
sub_name(oname, onamelen)
char *oname;
int *onamelen;
#endif
{ {
NAMT *pt; NAMT *pt;
u_int indx; u_int indx;
@ -724,13 +671,8 @@ sub_name(oname, onamelen)
* 0 if successful, -1 otherwise * 0 if successful, -1 otherwise
*/ */
#if __STDC__
int int
dev_start(void) dev_start(void)
#else
int
dev_start()
#endif
{ {
if (dtab != NULL) if (dtab != NULL)
return(0); return(0);
@ -751,14 +693,8 @@ dev_start()
* 0 if added ok, -1 otherwise * 0 if added ok, -1 otherwise
*/ */
#if __STDC__
int int
add_dev(ARCHD *arcn) add_dev(ARCHD *arcn)
#else
int
add_dev(arcn)
ARCHD *arcn;
#endif
{ {
if (chk_dev(arcn->sb.st_dev, 1) == NULL) if (chk_dev(arcn->sb.st_dev, 1) == NULL)
return(-1); return(-1);
@ -778,15 +714,8 @@ add_dev(arcn)
* is returned (indicates an error). * is returned (indicates an error).
*/ */
#if __STDC__
static DEVT * static DEVT *
chk_dev(dev_t dev, int add) chk_dev(dev_t dev, int add)
#else
static DEVT *
chk_dev(dev, add)
dev_t dev;
int add;
#endif
{ {
DEVT *pt; DEVT *pt;
u_int indx; u_int indx;
@ -843,16 +772,8 @@ chk_dev(dev, add)
* 0 if all ok, -1 otherwise. * 0 if all ok, -1 otherwise.
*/ */
#if __STDC__
int int
map_dev(ARCHD *arcn, u_long dev_mask, u_long ino_mask) 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; DEVT *pt;
DLIST *dpt; DLIST *dpt;
@ -994,13 +915,8 @@ map_dev(arcn, dev_mask, ino_mask)
* 0 is created ok, -1 otherwise. * 0 is created ok, -1 otherwise.
*/ */
#if __STDC__
int int
atdir_start(void) atdir_start(void)
#else
int
atdir_start()
#endif
{ {
if (atab != NULL) if (atab != NULL)
return(0); return(0);
@ -1020,13 +936,8 @@ atdir_start()
* entries are for directories READ by pax * entries are for directories READ by pax
*/ */
#if __STDC__
void void
atdir_end(void) atdir_end(void)
#else
void
atdir_end()
#endif
{ {
ATDIR *pt; ATDIR *pt;
int i; int i;
@ -1056,18 +967,8 @@ atdir_end()
* and chained by inode number. This is for directories READ by pax * and chained by inode number. This is for directories READ by pax
*/ */
#if __STDC__
void void
add_atdir(char *fname, dev_t dev, ino_t ino, time_t mtime, time_t atime) 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; ATDIR *pt;
u_int indx; u_int indx;
@ -1128,17 +1029,8 @@ add_atdir(fname, dev, ino, mtime, atime)
* 0 if found, -1 if not found. * 0 if found, -1 if not found.
*/ */
#if __STDC__
int int
get_atdir(dev_t dev, ino_t ino, time_t *mtime, time_t *atime) 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 *pt;
ATDIR **ppt; ATDIR **ppt;
@ -1216,13 +1108,8 @@ static DIRDATA *dirdata_head;
* 0 if ok, -1 otherwise * 0 if ok, -1 otherwise
*/ */
#if __STDC__
int int
dir_start(void) dir_start(void)
#else
int
dir_start()
#endif
{ {
#ifdef DIRS_USE_FILE #ifdef DIRS_USE_FILE
const char *tmpdir; const char *tmpdir;
@ -1262,17 +1149,8 @@ dir_start()
* pax spec) * pax spec)
*/ */
#if __STDC__
void void
add_dir(char *name, int nlen, struct stat *psb, int frc_mode) 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 #ifdef DIRS_USE_FILE
DIRDATA dblk; DIRDATA dblk;
@ -1338,13 +1216,8 @@ add_dir(name, nlen, psb, frc_mode)
* by pax * by pax
*/ */
#if __STDC__
void void
proc_dir(void) proc_dir(void)
#else
void
proc_dir()
#endif
{ {
#ifdef DIRS_USE_FILE #ifdef DIRS_USE_FILE
char name[PAXPATHLEN+1]; char name[PAXPATHLEN+1];
@ -1431,16 +1304,8 @@ proc_dir()
* the hash value of the string MOD (%) the table size. * the hash value of the string MOD (%) the table size.
*/ */
#if __STDC__
u_int u_int
st_hash(char *name, int len, int tabsz) 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 *pt;
char *dest; char *dest;

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94";
#else #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
#endif /* not lint */ #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 * Routines for reading, writing and header identify of various versions of tar
*/ */
static u_long tar_chksm __P((char *, int)); static u_long tar_chksm(char *, int);
static char *name_split __P((char *, int)); static char *name_split(char *, int);
static int ul_oct __P((u_long, char *, int, int)); static int ul_oct(u_long, char *, int, int);
#ifndef NET2_STAT #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 #endif
/* /*
@ -90,13 +90,8 @@ char *gnu_hack_string; /* ././@LongLink hackery */
* 0 if ok, -1 otherwise (what wr_skip returns) * 0 if ok, -1 otherwise (what wr_skip returns)
*/ */
#if __STDC__
int int
tar_endwr(void) tar_endwr(void)
#else
int
tar_endwr()
#endif
{ {
return(wr_skip((off_t)(NULLCNT*BLKMULT))); return(wr_skip((off_t)(NULLCNT*BLKMULT)));
} }
@ -108,13 +103,8 @@ tar_endwr()
* size of trailer (2 * BLKMULT) * size of trailer (2 * BLKMULT)
*/ */
#if __STDC__
off_t off_t
tar_endrd(void) tar_endrd(void)
#else
off_t
tar_endrd()
#endif
{ {
return((off_t)(NULLCNT*BLKMULT)); return((off_t)(NULLCNT*BLKMULT));
} }
@ -130,16 +120,8 @@ tar_endrd()
* could never contain a header. * could never contain a header.
*/ */
#if __STDC__
int int
tar_trail(char *buf, int in_resync, int *cnt) 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; int i;
@ -181,17 +163,8 @@ tar_trail(buf, in_resync, cnt)
* 0 if the number fit into the string, -1 otherwise * 0 if the number fit into the string, -1 otherwise
*/ */
#if __STDC__
static int static int
ul_oct(u_long val, char *str, int len, int term) 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; char *pt;
@ -235,8 +208,8 @@ ul_oct(val, str, len, term)
#ifndef NET2_STAT #ifndef NET2_STAT
/* /*
* uqd_oct() * ull_oct()
* convert an u_quad_t to an octal string. one of many oddball field * 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 * termination characters are used by the various versions of tar in the
* different fields. term selects which kind to use. str is '0' padded * 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 * 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 * 0 if the number fit into the string, -1 otherwise
*/ */
#if __STDC__
static int static int
uqd_oct(u_quad_t val, char *str, int len, int term) ull_oct(u_longlong_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
{ {
char *pt; char *pt;
@ -292,7 +256,7 @@ uqd_oct(val, str, len, term)
while (pt >= str) while (pt >= str)
*pt-- = '0'; *pt-- = '0';
if (val != (u_quad_t)0) if (val != (u_longlong_t)0)
return(-1); return(-1);
return(0); return(0);
} }
@ -308,15 +272,8 @@ uqd_oct(val, str, len, term)
* unsigned long checksum * unsigned long checksum
*/ */
#if __STDC__
static u_long static u_long
tar_chksm(char *blk, int len) tar_chksm(char *blk, int len)
#else
static u_long
tar_chksm(blk, len)
char *blk;
int len;
#endif
{ {
char *stop; char *stop;
char *pt; char *pt;
@ -356,15 +313,8 @@ tar_chksm(blk, len)
* 0 if a tar header, -1 otherwise * 0 if a tar header, -1 otherwise
*/ */
#if __STDC__
int int
tar_id(char *blk, int size) tar_id(char *blk, int size)
#else
int
tar_id(blk, size)
char *blk;
int size;
#endif
{ {
HD_TAR *hd; HD_TAR *hd;
HD_USTAR *uhd; HD_USTAR *uhd;
@ -397,13 +347,8 @@ tar_id(blk, size)
* 0 if ok -1 otherwise * 0 if ok -1 otherwise
*/ */
#if __STDC__
int int
tar_opt(void) tar_opt(void)
#else
int
tar_opt()
#endif
{ {
OPLIST *opt; OPLIST *opt;
@ -441,15 +386,8 @@ tar_opt()
* 0 * 0
*/ */
#if __STDC__
int int
tar_rd(ARCHD *arcn, char *buf) tar_rd(ARCHD *arcn, char *buf)
#else
int
tar_rd(arcn, buf)
ARCHD *arcn;
char *buf;
#endif
{ {
HD_TAR *hd; HD_TAR *hd;
char *pt; char *pt;
@ -481,11 +419,7 @@ tar_rd(arcn, buf)
0xfff); 0xfff);
arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT); 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); arcn->sb.st_gid = (gid_t)asc_ul(hd->gid, sizeof(hd->gid), OCT);
# ifdef NET2_STAT arcn->sb.st_size = (off_t)ASC_OFFT(hd->size, sizeof(hd->size), OCT);
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_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), 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; 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 * data to write after the header, -1 if archive write failed
*/ */
#if __STDC__
int int
tar_wr(ARCHD *arcn) tar_wr(ARCHD *arcn)
#else
int
tar_wr(arcn)
ARCHD *arcn;
#endif
{ {
HD_TAR *hd; HD_TAR *hd;
int len; int len;
@ -703,13 +631,7 @@ tar_wr(arcn)
*/ */
hd->linkflag = AREGTYPE; hd->linkflag = AREGTYPE;
memset(hd->linkname, 0, sizeof(hd->linkname)); memset(hd->linkname, 0, sizeof(hd->linkname));
# ifdef NET2_STAT if (OFFT_OCT(arcn->sb.st_size, hd->size, sizeof(hd->size), 1)) {
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
tty_warn(1,"File is too large for tar %s", tty_warn(1,"File is too large for tar %s",
arcn->org_name); arcn->org_name);
return(1); return(1);
@ -761,13 +683,8 @@ tar_wr(arcn)
* 0 if ok, -1 otherwise * 0 if ok, -1 otherwise
*/ */
#if __STDC__
int int
ustar_strd(void) ustar_strd(void)
#else
int
ustar_strd()
#endif
{ {
return(0); return(0);
} }
@ -779,13 +696,8 @@ ustar_strd()
* 0 if ok, -1 otherwise * 0 if ok, -1 otherwise
*/ */
#if __STDC__
int int
ustar_stwr(void) ustar_stwr(void)
#else
int
ustar_stwr()
#endif
{ {
return(0); return(0);
} }
@ -798,15 +710,8 @@ ustar_stwr()
* 0 if a ustar header, -1 otherwise * 0 if a ustar header, -1 otherwise
*/ */
#if __STDC__
int int
ustar_id(char *blk, int size) ustar_id(char *blk, int size)
#else
int
ustar_id(blk, size)
char *blk;
int size;
#endif
{ {
HD_USTAR *hd; HD_USTAR *hd;
@ -839,15 +744,8 @@ ustar_id(blk, size)
* 0 * 0
*/ */
#if __STDC__
int int
ustar_rd(ARCHD *arcn, char *buf) ustar_rd(ARCHD *arcn, char *buf)
#else
int
ustar_rd(arcn, buf)
ARCHD *arcn;
char *buf;
#endif
{ {
HD_USTAR *hd; HD_USTAR *hd;
char *dest; char *dest;
@ -886,11 +784,7 @@ ustar_rd(arcn, buf)
*/ */
arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode, sizeof(hd->mode), OCT) & arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode, sizeof(hd->mode), OCT) &
0xfff); 0xfff);
# ifdef NET2_STAT arcn->sb.st_size = (off_t)ASC_OFFT(hd->size, sizeof(hd->size), OCT);
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_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), 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; 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 * data to write after the header, -1 if archive write failed
*/ */
#if __STDC__
int int
ustar_wr(ARCHD *arcn) ustar_wr(ARCHD *arcn)
#else
int
ustar_wr(arcn)
ARCHD *arcn;
#endif
{ {
HD_USTAR *hd; HD_USTAR *hd;
char *pt; char *pt;
@ -1125,13 +1013,7 @@ ustar_wr(arcn)
memset(hd->devmajor, 0, sizeof(hd->devmajor)); memset(hd->devmajor, 0, sizeof(hd->devmajor));
memset(hd->devminor, 0, sizeof(hd->devminor)); memset(hd->devminor, 0, sizeof(hd->devminor));
arcn->pad = TAR_PAD(arcn->sb.st_size); arcn->pad = TAR_PAD(arcn->sb.st_size);
# ifdef NET2_STAT if (OFFT_OCT(arcn->sb.st_size, hd->size, sizeof(hd->size), 3)) {
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
tty_warn(1,"File is too long for ustar %s", tty_warn(1,"File is too long for ustar %s",
arcn->org_name); arcn->org_name);
return(1); return(1);
@ -1192,15 +1074,8 @@ ustar_wr(arcn)
* the file name is too long * the file name is too long
*/ */
#if __STDC__
static char * static char *
name_split(char *name, int len) name_split(char *name, int len)
#else
static char *
name_split(name, len)
char *name;
int len;
#endif
{ {
char *start; char *start;

View File

@ -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. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)tty_subs.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)tty_subs.c 8.2 (Berkeley) 4/18/94";
#else #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
#endif /* not lint */ #endif /* not lint */
@ -59,11 +59,7 @@ __RCSID("$NetBSD: tty_subs.c,v 1.9 2001/09/24 13:22:25 wiz Exp $");
#include <string.h> #include <string.h>
#include "pax.h" #include "pax.h"
#include "extern.h" #include "extern.h"
#if __STDC__
#include <stdarg.h> #include <stdarg.h>
#else
#include <varargs.h>
#endif
/* /*
* routines that deal with I/O to and from the user * 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 * open fails, future ops that require user input will get an EOF
*/ */
#if __STDC__
int int
tty_init(void) tty_init(void)
#else
int
tty_init()
#endif
{ {
int ttyfd; int ttyfd;
@ -111,24 +102,13 @@ tty_init()
* if there is no controlling terminal, just return. * if there is no controlling terminal, just return.
*/ */
#if __STDC__
void void
tty_prnt(char *fmt, ...) tty_prnt(const char *fmt, ...)
#else
void
tty_prnt(fmt, va_alist)
char *fmt;
va_dcl
#endif
{ {
va_list ap; va_list ap;
if (ttyoutf == NULL) if (ttyoutf == NULL)
return; return;
# if __STDC__
va_start(ap, fmt); va_start(ap, fmt);
# else
va_start(ap);
# endif
(void)vfprintf(ttyoutf, fmt, ap); (void)vfprintf(ttyoutf, fmt, ap);
va_end(ap); va_end(ap);
(void)fflush(ttyoutf); (void)fflush(ttyoutf);
@ -142,15 +122,8 @@ tty_prnt(fmt, va_alist)
* 0 if data was read, -1 otherwise. * 0 if data was read, -1 otherwise.
*/ */
#if __STDC__
int int
tty_read(char *str, int len) tty_read(char *str, int len)
#else
int
tty_read(str, len)
char *str;
int len;
#endif
{ {
char *pt; char *pt;
@ -172,23 +145,11 @@ tty_read(str, len)
* will be non-zero. * will be non-zero.
*/ */
#if __STDC__
void void
tty_warn(int set, char *fmt, ...) tty_warn(int set, const char *fmt, ...)
#else
void
tty_warn(set, fmt, va_alist)
int set;
char *fmt;
va_dcl
#endif
{ {
va_list ap; va_list ap;
# if __STDC__
va_start(ap, fmt); va_start(ap, fmt);
# else
va_start(ap);
# endif
if (set) if (set)
exit_val = 1; exit_val = 1;
/* /*
@ -211,24 +172,11 @@ tty_warn(set, fmt, va_alist)
* will be non-zero. * will be non-zero.
*/ */
#if __STDC__
void void
syswarn(int set, int errnum, char *fmt, ...) syswarn(int set, int errnum, const char *fmt, ...)
#else
void
syswarn(set, errnum, fmt, va_alist)
int set;
int errnum;
char *fmt;
va_dcl
#endif
{ {
va_list ap; va_list ap;
# if __STDC__
va_start(ap, fmt); va_start(ap, fmt);
# else
va_start(ap);
# endif
if (set) if (set)
exit_val = 1; exit_val = 1;
/* /*