From d6b761d3266516a4758ce34a6139e874a4acdd72 Mon Sep 17 00:00:00 2001 From: kris Date: Thu, 26 Apr 2001 08:37:00 +0000 Subject: [PATCH] Reduce diffs with OpenBSD: #if __STDC__ -> #ifdef __STDC__ pax_warn() -> paxwarn() sys_warn() -> syswarn() (foo *)NULL -> NULL bcopy -> memmove()/memcpy() bzero -> memset() Typo fixes sprintf() -> snprintf() rindex() -> strrchr() index() -> strchr() sys_errlist[] -> strerror() Obtained from: OpenBSD --- bin/pax/ar_io.c | 100 ++++++++++++++++++++++---------------------- bin/pax/ar_subs.c | 58 ++++++++++++------------- bin/pax/buf_subs.c | 90 +++++++++++++++++++-------------------- bin/pax/cache.c | 34 ++++++++------- bin/pax/cpio.c | 82 ++++++++++++++++++------------------ bin/pax/extern.h | 4 +- bin/pax/file_subs.c | 90 +++++++++++++++++++-------------------- bin/pax/ftree.c | 40 +++++++++--------- bin/pax/gen_subs.c | 20 ++++----- bin/pax/options.c | 68 +++++++++++++++--------------- bin/pax/pat_rep.c | 54 ++++++++++++------------ bin/pax/pax.c | 16 +++---- bin/pax/pax.h | 2 +- bin/pax/sel_subs.c | 54 ++++++++++++------------ bin/pax/tables.c | 90 +++++++++++++++++++-------------------- bin/pax/tar.c | 94 ++++++++++++++++++++--------------------- bin/pax/tty_subs.c | 38 ++++++++--------- 17 files changed, 468 insertions(+), 466 deletions(-) diff --git a/bin/pax/ar_io.c b/bin/pax/ar_io.c index b286aa6c88c6..0c86ff0843ac 100644 --- a/bin/pax/ar_io.c +++ b/bin/pax/ar_io.c @@ -92,7 +92,7 @@ extern sigset_t s_mask; * -1 on failure, 0 otherwise */ -#if __STDC__ +#ifdef __STDC__ int ar_open(char *name) #else @@ -120,14 +120,14 @@ ar_open(name) arfd = STDIN_FILENO; arcname = STDN; } else if ((arfd = open(name, EXT_MODE, DMOD)) < 0) - sys_warn(0, errno, "Failed open to read on %s", name); + syswarn(0, errno, "Failed open to read on %s", name); break; case ARCHIVE: if (name == NULL) { arfd = STDOUT_FILENO; arcname = STDO; } else if ((arfd = open(name, AR_MODE, DMOD)) < 0) - sys_warn(0, errno, "Failed open to write on %s", name); + syswarn(0, errno, "Failed open to write on %s", name); else can_unlnk = 1; break; @@ -136,7 +136,7 @@ ar_open(name) arfd = STDOUT_FILENO; arcname = STDO; } else if ((arfd = open(name, APP_MODE, DMOD)) < 0) - sys_warn(0, errno, "Failed open to read/write on %s", + syswarn(0, errno, "Failed open to read/write on %s", name); break; case COPY: @@ -154,14 +154,14 @@ ar_open(name) * set up is based on device type */ if (fstat(arfd, &arsb) < 0) { - sys_warn(0, errno, "Failed stat on %s", arcname); + syswarn(0, errno, "Failed stat on %s", arcname); (void)close(arfd); arfd = -1; can_unlnk = 0; return(-1); } if (S_ISDIR(arsb.st_mode)) { - pax_warn(0, "Cannot write an archive on top of a directory %s", + paxwarn(0, "Cannot write an archive on top of a directory %s", arcname); (void)close(arfd); arfd = -1; @@ -290,7 +290,7 @@ ar_open(name) * ar_close() * closes archive device, increments volume number, and prints i/o summary */ -#if __STDC__ +#ifdef __STDC__ void ar_close(void) #else @@ -405,7 +405,7 @@ ar_close() * other side of the pipe from getting a SIGPIPE (pax will stop * reading an archive once a format dependent trailer is detected). */ -#if __STDC__ +#ifdef __STDC__ void ar_drain(void) #else @@ -442,7 +442,7 @@ ar_drain() * 0 if all ready to write, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int ar_set_wr(void) #else @@ -470,7 +470,7 @@ ar_set_wr() */ if (((cpos = lseek(arfd, (off_t)0L, SEEK_CUR)) < 0) || (ftruncate(arfd, cpos) < 0)) { - sys_warn(1, errno, "Unable to truncate archive file"); + syswarn(1, errno, "Unable to truncate archive file"); return(-1); } return(0); @@ -485,7 +485,7 @@ ar_set_wr() * 0 if we can append, -1 otherwise. */ -#if __STDC__ +#ifdef __STDC__ int ar_app_ok(void) #else @@ -494,13 +494,13 @@ ar_app_ok() #endif { if (artyp == ISPIPE) { - pax_warn(1, "Cannot append to an archive obtained from a pipe."); + paxwarn(1, "Cannot append to an archive obtained from a pipe."); return(-1); } if (!invld_rec) return(0); - pax_warn(1,"Cannot append, device record size %d does not support %s spec", + paxwarn(1,"Cannot append, device record size %d does not support %s spec", rdblksz, argv0); return(-1); } @@ -514,7 +514,7 @@ ar_app_ok() * Number of bytes in buffer. 0 for end of file, -1 for a read error. */ -#if __STDC__ +#ifdef __STDC__ int ar_read(register char *buf, register int cnt) #else @@ -587,9 +587,9 @@ ar_read(buf, cnt) */ lstrval = res; if (res < 0) - sys_warn(1, errno, "Failed read on archive volume %d", arvol); + syswarn(1, errno, "Failed read on archive volume %d", arvol); else - pax_warn(0, "End of archive volume %d reached", arvol); + paxwarn(0, "End of archive volume %d reached", arvol); return(res); } @@ -604,7 +604,7 @@ ar_read(buf, cnt) * error in the archive occured. */ -#if __STDC__ +#ifdef __STDC__ int ar_write(register char *buf, register int bsz) #else @@ -668,7 +668,7 @@ ar_write(buf, bsz) if (res >= 0) break; if (errno == EACCES) { - pax_warn(0, "Write failed, archive is write protected."); + paxwarn(0, "Write failed, archive is write protected."); res = lstrval = 0; return(0); } @@ -706,18 +706,18 @@ ar_write(buf, bsz) * must quit right away. */ if (!wr_trail && (res <= 0)) { - pax_warn(1,"Unable to append, trailer re-write failed. Quitting."); + paxwarn(1,"Unable to append, trailer re-write failed. Quitting."); return(res); } if (res == 0) - pax_warn(0, "End of archive volume %d reached", arvol); + paxwarn(0, "End of archive volume %d reached", arvol); else if (res < 0) - sys_warn(1, errno, "Failed write to archive volume: %d", arvol); + syswarn(1, errno, "Failed write to archive volume: %d", arvol); else if (!frmt->blkalgn || ((res % frmt->blkalgn) == 0)) - pax_warn(0,"WARNING: partial archive write. Archive MAY BE FLAWED"); + paxwarn(0,"WARNING: partial archive write. Archive MAY BE FLAWED"); else - pax_warn(1,"WARNING: partial archive write. Archive IS FLAWED"); + paxwarn(1,"WARNING: partial archive write. Archive IS FLAWED"); return(res); } @@ -729,7 +729,7 @@ ar_write(buf, bsz) * 0 when ok to try i/o again, -1 otherwise. */ -#if __STDC__ +#ifdef __STDC__ int ar_rdsync(void) #else @@ -751,7 +751,7 @@ ar_rdsync() return(-1); if ((act == APPND) || (act == ARCHIVE)) { - pax_warn(1, "Cannot allow updates to an archive with flaws."); + paxwarn(1, "Cannot allow updates to an archive with flaws."); return(-1); } if (io_ok) @@ -803,10 +803,10 @@ ar_rdsync() break; } if (lstrval <= 0) { - pax_warn(1, "Unable to recover from an archive read failure."); + paxwarn(1, "Unable to recover from an archive read failure."); return(-1); } - pax_warn(0, "Attempting to recover from an archive read failure."); + paxwarn(0, "Attempting to recover from an archive read failure."); return(0); } @@ -820,7 +820,7 @@ ar_rdsync() * partial move (the amount moved is in skipped) */ -#if __STDC__ +#ifdef __STDC__ int ar_fow(off_t sksz, off_t *skipped) #else @@ -870,7 +870,7 @@ ar_fow(sksz, skipped) if (lseek(arfd, mpos, SEEK_SET) >= 0) return(0); } - sys_warn(1, errno, "Forward positioning operation on archive failed"); + syswarn(1, errno, "Forward positioning operation on archive failed"); lstrval = -1; return(-1); } @@ -886,7 +886,7 @@ ar_fow(sksz, skipped) * 0 if moved the requested distance, -1 on complete failure */ -#if __STDC__ +#ifdef __STDC__ int ar_rev(off_t sksz) #else @@ -912,7 +912,7 @@ ar_rev(sksz) /* * cannot go backwards on these critters */ - pax_warn(1, "Reverse positioning on pipes is not supported."); + paxwarn(1, "Reverse positioning on pipes is not supported."); lstrval = -1; return(-1); case ISREG: @@ -930,7 +930,7 @@ ar_rev(sksz) * First we figure out where we are in the archive. */ if ((cpos = lseek(arfd, (off_t)0L, SEEK_CUR)) < 0) { - sys_warn(1, errno, + syswarn(1, errno, "Unable to obtain current archive byte offset"); lstrval = -1; return(-1); @@ -948,14 +948,14 @@ ar_rev(sksz) /* * this should never happen */ - pax_warn(1,"Reverse position on previous volume."); + paxwarn(1,"Reverse position on previous volume."); lstrval = -1; return(-1); } cpos = (off_t)0L; } if (lseek(arfd, cpos, SEEK_SET) < 0) { - sys_warn(1, errno, "Unable to seek archive backwards"); + syswarn(1, errno, "Unable to seek archive backwards"); lstrval = -1; return(-1); } @@ -990,7 +990,7 @@ ar_rev(sksz) * ok we have to move. Make sure the tape drive can do it. */ if (sksz % phyblk) { - pax_warn(1, + paxwarn(1, "Tape drive unable to backspace requested amount"); lstrval = -1; return(-1); @@ -1002,7 +1002,7 @@ ar_rev(sksz) mb.mt_op = MTBSR; mb.mt_count = sksz/phyblk; if (ioctl(arfd, MTIOCTOP, &mb) < 0) { - sys_warn(1,errno, "Unable to backspace tape %d blocks.", + syswarn(1,errno, "Unable to backspace tape %d blocks.", mb.mt_count); lstrval = -1; return(-1); @@ -1024,7 +1024,7 @@ ar_rev(sksz) * physical block size if ok (ok > 0), -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ static int get_phys(void) #else @@ -1050,7 +1050,7 @@ get_phys() while ((res = read(arfd, scbuf, sizeof(scbuf))) > 0) padsz += res; if (res < 0) { - sys_warn(1, errno, "Unable to locate tape filemark."); + syswarn(1, errno, "Unable to locate tape filemark."); return(-1); } } @@ -1062,7 +1062,7 @@ get_phys() mb.mt_op = MTBSF; mb.mt_count = 1; if (ioctl(arfd, MTIOCTOP, &mb) < 0) { - sys_warn(1, errno, "Unable to backspace over tape filemark."); + syswarn(1, errno, "Unable to backspace over tape filemark."); return(-1); } @@ -1073,11 +1073,11 @@ get_phys() mb.mt_op = MTBSR; mb.mt_count = 1; if (ioctl(arfd, MTIOCTOP, &mb) < 0) { - sys_warn(1, errno, "Unable to backspace over last tape block."); + syswarn(1, errno, "Unable to backspace over last tape block."); return(-1); } if ((phyblk = read(arfd, scbuf, sizeof(scbuf))) <= 0) { - sys_warn(1, errno, "Cannot determine archive tape blocksize."); + syswarn(1, errno, "Cannot determine archive tape blocksize."); return(-1); } @@ -1088,13 +1088,13 @@ get_phys() while ((res = read(arfd, scbuf, sizeof(scbuf))) > 0) ; if (res < 0) { - sys_warn(1, errno, "Unable to locate tape filemark."); + syswarn(1, errno, "Unable to locate tape filemark."); return(-1); } mb.mt_op = MTBSF; mb.mt_count = 1; if (ioctl(arfd, MTIOCTOP, &mb) < 0) { - sys_warn(1, errno, "Unable to backspace over tape filemark."); + syswarn(1, errno, "Unable to backspace over tape filemark."); return(-1); } @@ -1114,7 +1114,7 @@ get_phys() * never fail). */ if (padsz % phyblk) { - pax_warn(1, "Tape drive unable to backspace requested amount"); + paxwarn(1, "Tape drive unable to backspace requested amount"); return(-1); } @@ -1125,7 +1125,7 @@ get_phys() mb.mt_op = MTBSR; mb.mt_count = padsz/phyblk; if (ioctl(arfd, MTIOCTOP, &mb) < 0) { - sys_warn(1,errno,"Unable to backspace tape over %d pad blocks", + syswarn(1,errno,"Unable to backspace tape over %d pad blocks", mb.mt_count); return(-1); } @@ -1142,7 +1142,7 @@ get_phys() * 0 when ready to continue, -1 when all done */ -#if __STDC__ +#ifdef __STDC__ int ar_next(void) #else @@ -1160,10 +1160,10 @@ ar_next() * also be called via a signal handler, so we must prevent a race. */ if (sigprocmask(SIG_BLOCK, &s_mask, &o_mask) < 0) - sys_warn(0, errno, "Unable to set signal mask"); + syswarn(0, errno, "Unable to set signal mask"); ar_close(); - if (sigprocmask(SIG_SETMASK, &o_mask, (sigset_t *)NULL) < 0) - sys_warn(0, errno, "Unable to restore signal mask"); + if (sigprocmask(SIG_SETMASK, &o_mask, NULL) < 0) + syswarn(0, errno, "Unable to restore signal mask"); if (done || !wr_trail) return(-1); @@ -1276,7 +1276,7 @@ ar_next() if ((arcname = strdup(buf)) == NULL) { done = 1; lstrval = -1; - pax_warn(0, "Cannot save archive name."); + paxwarn(0, "Cannot save archive name."); return(-1); } freeit = 1; diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c index 151fe2aa0206..02ac1a6e5e75 100644 --- a/bin/pax/ar_subs.c +++ b/bin/pax/ar_subs.c @@ -75,7 +75,7 @@ u_long flcnt; /* number of files processed */ * (no pattern matches all). */ -#if __STDC__ +#ifdef __STDC__ void list(void) #else @@ -103,7 +103,7 @@ list() if (vflag && ((uidtb_start() < 0) || (gidtb_start() < 0))) return; - now = time((time_t *)NULL); + now = time(NULL); /* * step through the archive until the format says it is done @@ -146,7 +146,7 @@ list() * the patterns supplied by the user were all matched */ (void)(*frmt->end_rd)(); - (void)sigprocmask(SIG_BLOCK, &s_mask, (sigset_t *)NULL); + (void)sigprocmask(SIG_BLOCK, &s_mask, NULL); ar_close(); pat_chk(); } @@ -157,7 +157,7 @@ list() * pattern(s) (no patterns extracts all members) */ -#if __STDC__ +#ifdef __STDC__ void extract(void) #else @@ -333,7 +333,7 @@ extract() * to avoid chance for multiple entry into the cleanup code. */ (void)(*frmt->end_rd)(); - (void)sigprocmask(SIG_BLOCK, &s_mask, (sigset_t *)NULL); + (void)sigprocmask(SIG_BLOCK, &s_mask, NULL); ar_close(); proc_dir(); pat_chk(); @@ -345,7 +345,7 @@ extract() * previously written archive. */ -#if __STDC__ +#ifdef __STDC__ static void wr_archive(register ARCHD *arcn, int is_app) #else @@ -426,7 +426,7 @@ wr_archive(arcn, is_app) * the link table). */ if ((fd = open(arcn->org_name, O_RDONLY, 0)) < 0) { - sys_warn(1,errno, "Unable to open %s to read", + syswarn(1,errno, "Unable to open %s to read", arcn->org_name); purg_lnk(arcn); continue; @@ -519,7 +519,7 @@ wr_archive(arcn, is_app) (*frmt->end_wr)(); wr_fin(); } - (void)sigprocmask(SIG_BLOCK, &s_mask, (sigset_t *)NULL); + (void)sigprocmask(SIG_BLOCK, &s_mask, NULL); ar_close(); if (tflag) proc_dir(); @@ -548,7 +548,7 @@ wr_archive(arcn, is_app) * over write existing files that it creates. */ -#if __STDC__ +#ifdef __STDC__ void append(void) #else @@ -573,7 +573,7 @@ append() if (get_arc() < 0) return; if ((orgfrmt != NULL) && (orgfrmt != frmt)) { - pax_warn(1, "Cannot mix current archive format %s with %s", + paxwarn(1, "Cannot mix current archive format %s with %s", frmt->name, orgfrmt->name); return; } @@ -689,7 +689,7 @@ append() * write a new archive */ -#if __STDC__ +#ifdef __STDC__ void archive(void) #else @@ -720,7 +720,7 @@ archive() * (except the files are forced to be under the destination directory). */ -#if __STDC__ +#ifdef __STDC__ void copy(void) #else @@ -754,12 +754,12 @@ copy() drem = PAXPATHLEN - dlen; if (stat(dirptr, &sb) < 0) { - sys_warn(1, errno, "Cannot access destination directory %s", + syswarn(1, errno, "Cannot access destination directory %s", dirptr); return; } if (!S_ISDIR(sb.st_mode)) { - pax_warn(1, "Destination is not a directory %s", dirptr); + paxwarn(1, "Destination is not a directory %s", dirptr); return; } @@ -813,7 +813,7 @@ copy() else res = 0; if ((arcn->nlen - res) > drem) { - pax_warn(1, "Destination pathname too long %s", + paxwarn(1, "Destination pathname too long %s", arcn->name); continue; } @@ -918,7 +918,7 @@ copy() * first open source file and then create the destination file */ if ((fdsrc = open(arcn->org_name, O_RDONLY, 0)) < 0) { - sys_warn(1, errno, "Unable to open %s to read", + syswarn(1, errno, "Unable to open %s to read", arcn->org_name); purg_lnk(arcn); continue; @@ -947,7 +947,7 @@ copy() * patterns were selected block off signals to avoid chance for * multiple entry into the cleanup code. */ - (void)sigprocmask(SIG_BLOCK, &s_mask, (sigset_t *)NULL); + (void)sigprocmask(SIG_BLOCK, &s_mask, NULL); ar_close(); proc_dir(); ftree_chk(); @@ -972,7 +972,7 @@ copy() * the specs for rd_wrbuf() for more details) */ -#if __STDC__ +#ifdef __STDC__ static int next_head(register ARCHD *arcn) #else @@ -1010,16 +1010,16 @@ next_head(arcn) * storage device, better give the user the bad news. */ if ((ret == 0) || (rd_sync() < 0)) { - pax_warn(1,"Premature end of file on archive read"); + paxwarn(1,"Premature end of file on archive read"); return(-1); } if (!in_resync) { if (act == APPND) { - pax_warn(1, + paxwarn(1, "Archive I/O error, cannot continue"); return(-1); } - pax_warn(1,"Archive I/O error. Trying to recover."); + paxwarn(1,"Archive I/O error. Trying to recover."); ++in_resync; } @@ -1080,13 +1080,13 @@ next_head(arcn) */ if (!in_resync) { if (act == APPND) { - pax_warn(1,"Unable to append, archive header flaw"); + paxwarn(1,"Unable to append, archive header flaw"); return(-1); } - pax_warn(1,"Invalid header, starting valid header search."); + paxwarn(1,"Invalid header, starting valid header search."); ++in_resync; } - bcopy(hdbuf+1, hdbuf, shftsz); + memmove(hdbuf, hdbuf+1, shftsz); res = 1; hdend = hdbuf + shftsz; } @@ -1118,7 +1118,7 @@ next_head(arcn) * 0 if archive found -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ static int get_arc(void) #else @@ -1175,7 +1175,7 @@ get_arc() if (!notice) { if (act == APPND) return(-1); - pax_warn(1,"Cannot identify format. Searching..."); + paxwarn(1,"Cannot identify format. Searching..."); ++notice; } } @@ -1210,7 +1210,7 @@ get_arc() if (!notice) { if (act == APPND) return(-1); - pax_warn(1, "Cannot identify format. Searching..."); + paxwarn(1, "Cannot identify format. Searching..."); ++notice; } @@ -1221,7 +1221,7 @@ get_arc() * portable manner */ if (--hdsz > 0) { - bcopy(hdbuf+1, hdbuf, hdsz); + memmove(hdbuf, hdbuf+1, hdsz); res = BLKMULT - hdsz; hdend = hdbuf + hdsz; } else { @@ -1235,6 +1235,6 @@ get_arc() /* * we cannot find a header, bow, apologize and quit */ - pax_warn(1, "Sorry, unable to determine archive format."); + paxwarn(1, "Sorry, unable to determine archive format."); return(-1); } diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c index 50c30761a3e5..58e7dc4cca80 100644 --- a/bin/pax/buf_subs.c +++ b/bin/pax/buf_subs.c @@ -83,7 +83,7 @@ off_t rdcnt; /* # of bytes read on current vol */ * 0 if ok, -1 if the user specified write block size violates pax spec */ -#if __STDC__ +#ifdef __STDC__ int wr_start(void) #else @@ -102,12 +102,12 @@ wr_start() if (!wrblksz) wrblksz = frmt->bsz; if (wrblksz > MAXBLK) { - pax_warn(1, "Write block size of %d too large, maximum is: %d", + paxwarn(1, "Write block size of %d too large, maximum is: %d", wrblksz, MAXBLK); return(-1); } if (wrblksz % BLKMULT) { - pax_warn(1, "Write block size of %d is not a %d byte multiple", + paxwarn(1, "Write block size of %d is not a %d byte multiple", wrblksz, BLKMULT); return(-1); } @@ -131,7 +131,7 @@ wr_start() * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int rd_start(void) #else @@ -147,12 +147,12 @@ rd_start() buf = &(bufmem[BLKMULT]); if ((act == APPND) && wrblksz) { if (wrblksz > MAXBLK) { - pax_warn(1,"Write block size %d too large, maximum is: %d", + paxwarn(1,"Write block size %d too large, maximum is: %d", wrblksz, MAXBLK); return(-1); } if (wrblksz % BLKMULT) { - pax_warn(1, "Write block size %d is not a %d byte multiple", + paxwarn(1, "Write block size %d is not a %d byte multiple", wrblksz, BLKMULT); return(-1); } @@ -174,7 +174,7 @@ rd_start() * set up buffer system for copying within the file system */ -#if __STDC__ +#ifdef __STDC__ void cp_start(void) #else @@ -218,7 +218,7 @@ cp_start() * 0 for success, -1 for failure */ -#if __STDC__ +#ifdef __STDC__ int appnd_start(off_t skcnt) #else @@ -231,7 +231,7 @@ appnd_start(skcnt) off_t cnt; if (exit_val != 0) { - pax_warn(0, "Cannot append to an archive that may have flaws."); + paxwarn(0, "Cannot append to an archive that may have flaws."); return(-1); } /* @@ -308,7 +308,7 @@ appnd_start(skcnt) return(0); out: - pax_warn(1, "Unable to rewrite archive trailer, cannot append."); + paxwarn(1, "Unable to rewrite archive trailer, cannot append."); return(-1); } @@ -323,7 +323,7 @@ appnd_start(skcnt) * 0 on success, and -1 on failure */ -#if __STDC__ +#ifdef __STDC__ int rd_sync(void) #else @@ -340,7 +340,7 @@ rd_sync() if (maxflt == 0) return(-1); if (act == APPND) { - pax_warn(1, "Unable to append when there are archive read errors."); + paxwarn(1, "Unable to append when there are archive read errors."); return(-1); } @@ -374,7 +374,7 @@ rd_sync() * can extract out of the archive. */ if ((maxflt > 0) && (++errcnt > maxflt)) - pax_warn(0,"Archive read error limit (%d) reached",maxflt); + paxwarn(0,"Archive read error limit (%d) reached",maxflt); else if (ar_rdsync() == 0) continue; if (ar_next() < 0) @@ -396,7 +396,7 @@ rd_sync() * pback space is increased. */ -#if __STDC__ +#ifdef __STDC__ void pback(char *pt, int cnt) #else @@ -407,7 +407,7 @@ pback(pt, cnt) #endif { bufpt -= cnt; - bcopy(pt, bufpt, cnt); + memcpy(bufpt, pt, cnt); return; } @@ -419,7 +419,7 @@ pback(pt, cnt) * 0 if ok, -1 failure, and 1 when EOF on the archive volume was detected. */ -#if __STDC__ +#ifdef __STDC__ int rd_skip(off_t skcnt) #else @@ -494,7 +494,7 @@ rd_skip(skcnt) * BE a requirement.... */ -#if __STDC__ +#ifdef __STDC__ void wr_fin(void) #else @@ -503,7 +503,7 @@ wr_fin() #endif { if (bufpt > buf) { - bzero(bufpt, bufend - bufpt); + memset(bufpt, 0, bufend - bufpt); bufpt = bufend; (void)buf_flush(blksz); } @@ -520,7 +520,7 @@ wr_fin() * 0 if buffer was filled ok, -1 o.w. (buffer flush failure) */ -#if __STDC__ +#ifdef __STDC__ int wr_rdbuf(register char *out, register int outcnt) #else @@ -544,7 +544,7 @@ wr_rdbuf(out, outcnt) * only move what we have space for */ cnt = MIN(cnt, outcnt); - bcopy(out, bufpt, cnt); + memcpy(bufpt, out, cnt); bufpt += cnt; out += cnt; outcnt -= cnt; @@ -563,7 +563,7 @@ wr_rdbuf(out, outcnt) * -1 is a read error */ -#if __STDC__ +#ifdef __STDC__ int rd_wrbuf(register char *in, register int cpcnt) #else @@ -599,7 +599,7 @@ rd_wrbuf(in, cpcnt) * state of buffer */ cnt = MIN(cnt, incnt); - bcopy(bufpt, in, cnt); + memcpy(in, bufpt, cnt); bufpt += cnt; incnt -= cnt; in += cnt; @@ -618,7 +618,7 @@ rd_wrbuf(in, cpcnt) * 0 if ok, -1 if there was a buf_flush failure */ -#if __STDC__ +#ifdef __STDC__ int wr_skip(off_t skcnt) #else @@ -637,7 +637,7 @@ wr_skip(skcnt) if ((cnt <= 0) && ((cnt = buf_flush(blksz)) < 0)) return(-1); cnt = MIN(cnt, skcnt); - bzero(bufpt, cnt); + memset(bufpt, 0, cnt); bufpt += cnt; skcnt -= cnt; } @@ -653,7 +653,7 @@ wr_skip(skcnt) * it is important that we always write EXACTLY the number of bytes that * the format specific write routine told us to. The file can also get * bigger, so reading to the end of file would create an improper archive, - * we just detect this case and pax_warn the user. We never create a bad + * we just detect this case and warn the user. We never create a bad * archive if we can avoid it. Of course trying to archive files that are * active is asking for trouble. It we fail, we pass back how much we * could NOT copy and let the caller deal with it. @@ -662,7 +662,7 @@ wr_skip(skcnt) * 0, but "left" is set to be greater than zero. */ -#if __STDC__ +#ifdef __STDC__ int wr_rdfile(ARCHD *arcn, int ifd, off_t *left) #else @@ -699,13 +699,13 @@ wr_rdfile(arcn, ifd, left) * or the file read failed. */ if (res < 0) - sys_warn(1, errno, "Read fault on %s", arcn->org_name); + syswarn(1, errno, "Read fault on %s", arcn->org_name); else if (size != 0L) - pax_warn(1, "File changed size during read %s", arcn->org_name); + paxwarn(1, "File changed size during read %s", arcn->org_name); else if (fstat(ifd, &sb) < 0) - sys_warn(1, errno, "Failed stat on %s", arcn->org_name); + syswarn(1, errno, "Failed stat on %s", arcn->org_name); else if (arcn->sb.st_mtime != sb.st_mtime) - pax_warn(1, "File %s was modified during copy to archive", + paxwarn(1, "File %s was modified during copy to archive", arcn->org_name); *left = size; return(0); @@ -731,7 +731,7 @@ wr_rdfile(arcn, ifd, left) * we return a 0 but "left" is set to be the amount unwritten */ -#if __STDC__ +#ifdef __STDC__ int rd_wrfile(ARCHD *arcn, int ofd, off_t *left) #else @@ -760,7 +760,7 @@ rd_wrfile(arcn, ofd, left) if (sb.st_blksize > 0) sz = (int)sb.st_blksize; } else - sys_warn(0,errno,"Unable to obtain block size for file %s",fnm); + syswarn(0,errno,"Unable to obtain block size for file %s",fnm); rem = sz; *left = 0L; @@ -816,7 +816,7 @@ rd_wrfile(arcn, ofd, left) * calculated crc to the crc stored in the archive */ if (docrc && (size == 0L) && (arcn->crc != crc)) - pax_warn(1,"Actual crc does not match expected crc %s",arcn->name); + paxwarn(1,"Actual crc does not match expected crc %s",arcn->name); return(0); } @@ -827,7 +827,7 @@ rd_wrfile(arcn, ofd, left) * destination file so we can properly copy files with holes. */ -#if __STDC__ +#ifdef __STDC__ void cp_file(ARCHD *arcn, int fd1, int fd2) #else @@ -863,7 +863,7 @@ cp_file(arcn, fd1, fd2) if (sb.st_blksize > 0) sz = sb.st_blksize; } else - sys_warn(0,errno,"Unable to obtain block size for file %s",fnm); + syswarn(0,errno,"Unable to obtain block size for file %s",fnm); rem = sz; /* @@ -885,15 +885,15 @@ cp_file(arcn, fd1, fd2) * check to make sure the copy is valid. */ if (res < 0) - sys_warn(1, errno, "Failed write during copy of %s to %s", + syswarn(1, errno, "Failed write during copy of %s to %s", arcn->org_name, arcn->name); else if (cpcnt != arcn->sb.st_size) - pax_warn(1, "File %s changed size during copy to %s", + paxwarn(1, "File %s changed size during copy to %s", arcn->org_name, arcn->name); else if (fstat(fd1, &sb) < 0) - sys_warn(1, errno, "Failed stat of %s", arcn->org_name); + syswarn(1, errno, "Failed stat of %s", arcn->org_name); else if (arcn->sb.st_mtime != sb.st_mtime) - pax_warn(1, "File %s was modified during copy to %s", + paxwarn(1, "File %s was modified during copy to %s", arcn->org_name, arcn->name); /* @@ -916,7 +916,7 @@ cp_file(arcn, fd1, fd2) * 0 when finished (user specified termination in ar_next()). */ -#if __STDC__ +#ifdef __STDC__ int buf_fill(void) #else @@ -966,7 +966,7 @@ buf_fill() * 0 if all is ok, -1 when a write error occurs. */ -#if __STDC__ +#ifdef __STDC__ int buf_flush(register int bufcnt) #else @@ -986,7 +986,7 @@ buf_flush(bufcnt) * at least one record. We always round limit UP to next blocksize. */ if ((wrlimit > 0) && (wrcnt > wrlimit)) { - pax_warn(0, "User specified archive volume byte limit reached."); + paxwarn(0, "User specified archive volume byte limit reached."); if (ar_next() < 0) { wrcnt = 0; exit_val = 1; @@ -1029,7 +1029,7 @@ buf_flush(bufcnt) * check for more than 1 block of push, and if * so we loop back to write again */ - bcopy(bufend, buf, push); + memcpy(buf, bufend, push); bufpt = buf + push; if (push >= blksz) { push -= blksz; @@ -1042,14 +1042,14 @@ buf_flush(bufcnt) /* * Oh drat we got a partial write! * if format doesnt care about alignment let it go, - * we pax_warned the user in ar_write().... but this means + * we warned the user in ar_write().... but this means * the last record on this volume violates pax spec.... */ totcnt += cnt; wrcnt += cnt; bufpt = buf + cnt; cnt = bufcnt - cnt; - bcopy(bufpt, buf, cnt); + memcpy(buf, bufpt, cnt); bufpt = buf + cnt; if (!frmt->blkalgn || ((cnt % frmt->blkalgn) == 0)) return(totcnt); diff --git a/bin/pax/cache.c b/bin/pax/cache.c index 7f3b37f6ee12..040e18b928f0 100644 --- a/bin/pax/cache.c +++ b/bin/pax/cache.c @@ -76,7 +76,7 @@ static GIDC **grptb = NULL; /* group name to gid cache */ * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int uidtb_start(void) #else @@ -92,7 +92,7 @@ uidtb_start() return(-1); if ((uidtb = (UIDC **)calloc(UID_SZ, sizeof(UIDC *))) == NULL) { ++fail; - pax_warn(1, "Unable to allocate memory for user id cache table"); + paxwarn(1, "Unable to allocate memory for user id cache table"); return(-1); } return(0); @@ -105,7 +105,7 @@ uidtb_start() * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int gidtb_start(void) #else @@ -121,7 +121,7 @@ gidtb_start() return(-1); if ((gidtb = (GIDC **)calloc(GID_SZ, sizeof(GIDC *))) == NULL) { ++fail; - pax_warn(1, "Unable to allocate memory for group id cache table"); + paxwarn(1, "Unable to allocate memory for group id cache table"); return(-1); } return(0); @@ -134,7 +134,7 @@ gidtb_start() * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int usrtb_start(void) #else @@ -150,7 +150,7 @@ usrtb_start() return(-1); if ((usrtb = (UIDC **)calloc(UNM_SZ, sizeof(UIDC *))) == NULL) { ++fail; - pax_warn(1, "Unable to allocate memory for user name cache table"); + paxwarn(1, "Unable to allocate memory for user name cache table"); return(-1); } return(0); @@ -163,7 +163,7 @@ usrtb_start() * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int grptb_start(void) #else @@ -179,7 +179,7 @@ grptb_start() return(-1); if ((grptb = (GIDC **)calloc(GNM_SZ, sizeof(GIDC *))) == NULL) { ++fail; - pax_warn(1,"Unable to allocate memory for group name cache table"); + paxwarn(1,"Unable to allocate memory for group name cache table"); return(-1); } return(0); @@ -193,7 +193,7 @@ grptb_start() * Pointer to stored name (or a empty string) */ -#if __STDC__ +#ifdef __STDC__ char * name_uid(uid_t uid, int frc) #else @@ -242,9 +242,10 @@ name_uid(uid, frc) ptr->uid = uid; ptr->valid = INVALID; # ifdef NET2_STAT - (void)sprintf(ptr->name, "%u", uid); + (void)snprintf(ptr->name, sizeof(ptr->name), "%u", uid); # else - (void)sprintf(ptr->name, "%lu", (u_long)uid); + (void)snprintf(ptr->name, sizeof(ptr->name), "%lu", + (unsigned long)uid); # endif if (frc == 0) return(""); @@ -270,7 +271,7 @@ name_uid(uid, frc) * Pointer to stored name (or a empty string) */ -#if __STDC__ +#ifdef __STDC__ char * name_gid(gid_t gid, int frc) #else @@ -319,9 +320,10 @@ name_gid(gid, frc) ptr->gid = gid; ptr->valid = INVALID; # ifdef NET2_STAT - (void)sprintf(ptr->name, "%u", gid); + (void)snprintf(ptr->name, sizeof(ptr->name), "%u", gid); # else - (void)sprintf(ptr->name, "%lu", (u_long)gid); + (void)snprintf(ptr->name, sizeof(ptr->name), "%lu", + (unsigned long)gid); # endif if (frc == 0) return(""); @@ -346,7 +348,7 @@ name_gid(gid, frc) * the uid (if any) for a user name, or a -1 if no match can be found */ -#if __STDC__ +#ifdef __STDC__ int uid_name(char *name, uid_t *uid) #else @@ -416,7 +418,7 @@ uid_name(name, uid) * the gid (if any) for a group name, or a -1 if no match can be found */ -#if __STDC__ +#ifdef __STDC__ int gid_name(char *name, gid_t *gid) #else diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c index 626a77d94c54..d6ad17d55b69 100644 --- a/bin/pax/cpio.c +++ b/bin/pax/cpio.c @@ -75,7 +75,7 @@ static int swp_head; /* binary cpio header byte swap */ * 0 if ok -1 otherwise (the return values of lnk_start()) */ -#if __STDC__ +#ifdef __STDC__ int cpio_strd(void) #else @@ -96,7 +96,7 @@ cpio_strd() * 0 if a valid trailer, -1 if not a valid trailer, */ -#if __STDC__ +#ifdef __STDC__ int cpio_trail(register ARCHD *arcn) #else @@ -120,7 +120,7 @@ cpio_trail(arcn) * 0 */ -#if __STDC__ +#ifdef __STDC__ static int com_rd(register ARCHD *arcn) #else @@ -175,7 +175,7 @@ com_rd(arcn) * result of the write of the trailer from the cpio specific write func */ -#if __STDC__ +#ifdef __STDC__ int cpio_endwr(void) #else @@ -188,7 +188,7 @@ cpio_endwr() /* * create a trailer request and call the proper format write function */ - bzero((char *)&last, sizeof(last)); + memset(&last, 0, sizeof(last)); last.nlen = sizeof(TRAILER) - 1; last.type = PAX_REG; last.sb.st_nlink = 1; @@ -203,7 +203,7 @@ cpio_endwr() * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ static int rd_nm(register ARCHD *arcn, int nsz) #else @@ -217,7 +217,7 @@ rd_nm(arcn, nsz) * do not even try bogus values */ if ((nsz == 0) || (nsz > sizeof(arcn->name))) { - pax_warn(1, "Cpio file name length %d is out of range", nsz); + paxwarn(1, "Cpio file name length %d is out of range", nsz); return(-1); } @@ -226,7 +226,7 @@ rd_nm(arcn, nsz) */ if ((rd_wrbuf(arcn->name,nsz) != nsz) || (arcn->name[nsz-1] != '\0') || (arcn->name[0] == '\0')) { - pax_warn(1, "Cpio file name in header is corrupted"); + paxwarn(1, "Cpio file name in header is corrupted"); return(-1); } return(0); @@ -240,7 +240,7 @@ rd_nm(arcn, nsz) * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ static int rd_ln_nm(register ARCHD *arcn) #else @@ -255,10 +255,10 @@ rd_ln_nm(arcn) if ((arcn->sb.st_size == 0) || (arcn->sb.st_size >= sizeof(arcn->ln_name))) { # ifdef NET2_STAT - pax_warn(1, "Cpio link name length is invalid: %lu", + paxwarn(1, "Cpio link name length is invalid: %lu", arcn->sb.st_size); # else - pax_warn(1, "Cpio link name length is invalid: %qu", + paxwarn(1, "Cpio link name length is invalid: %qu", arcn->sb.st_size); # endif return(-1); @@ -269,7 +269,7 @@ rd_ln_nm(arcn) */ if (rd_wrbuf(arcn->ln_name, (int)arcn->sb.st_size) != (int)arcn->sb.st_size) { - pax_warn(1, "Cpio link name read error"); + paxwarn(1, "Cpio link name read error"); return(-1); } arcn->ln_nlen = arcn->sb.st_size; @@ -279,7 +279,7 @@ rd_ln_nm(arcn) * watch out for those empty link names */ if (arcn->ln_name[0] == '\0') { - pax_warn(1, "Cpio link name is corrupt"); + paxwarn(1, "Cpio link name is corrupt"); return(-1); } return(0); @@ -297,7 +297,7 @@ rd_ln_nm(arcn) * 0 if a valid header, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int cpio_id(char *blk, int size) #else @@ -321,7 +321,7 @@ cpio_id(blk, size) * 0 if a valid header, -1 otherwise. */ -#if __STDC__ +#ifdef __STDC__ int cpio_rd(register ARCHD *arcn, register char *buf) #else @@ -404,7 +404,7 @@ cpio_rd(arcn, buf) * size of trailer header in this format */ -#if __STDC__ +#ifdef __STDC__ off_t cpio_endrd(void) #else @@ -422,7 +422,7 @@ cpio_endrd() * 0 if ok, -1 otherwise (what dev_start() returns) */ -#if __STDC__ +#ifdef __STDC__ int cpio_stwr(void) #else @@ -442,7 +442,7 @@ cpio_stwr() * data to write after the header, -1 if archive write failed */ -#if __STDC__ +#ifdef __STDC__ int cpio_wr(register ARCHD *arcn) #else @@ -481,7 +481,7 @@ cpio_wr(arcn) if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize, sizeof(hd->c_filesize), OCT)) { # endif - pax_warn(1,"File is too large for cpio format %s", + paxwarn(1,"File is too large for cpio format %s", arcn->org_name); return(1); } @@ -532,7 +532,7 @@ cpio_wr(arcn) */ if ((wr_rdbuf(hdblk, (int)sizeof(HD_CPIO)) < 0) || (wr_rdbuf(arcn->name, nsz) < 0)) { - pax_warn(1, "Unable to write cpio header for %s", arcn->org_name); + paxwarn(1, "Unable to write cpio header for %s", arcn->org_name); return(-1); } @@ -551,7 +551,7 @@ cpio_wr(arcn) * next file as we are done. */ if (wr_rdbuf(arcn->ln_name, arcn->ln_nlen) < 0) { - pax_warn(1,"Unable to write cpio link name for %s",arcn->org_name); + paxwarn(1,"Unable to write cpio link name for %s",arcn->org_name); return(-1); } return(1); @@ -560,7 +560,7 @@ cpio_wr(arcn) /* * header field is out of range */ - pax_warn(1, "Cpio header field is too small to store file %s", + paxwarn(1, "Cpio header field is too small to store file %s", arcn->org_name); return(1); } @@ -578,7 +578,7 @@ cpio_wr(arcn) * 0 if a valid header, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int vcpio_id(char *blk, int size) #else @@ -602,7 +602,7 @@ vcpio_id(blk, size) * 0 if a valid header, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int crc_id(char *blk, int size) #else @@ -625,7 +625,7 @@ crc_id(blk, size) * 0 if ok -1 otherwise (the return values of lnk_start()) */ -#if __STDC__ +#ifdef __STDC__ int crc_strd(void) #else @@ -645,7 +645,7 @@ crc_strd() * 0 if a valid header, -1 otherwise. */ -#if __STDC__ +#ifdef __STDC__ int vcpio_rd(register ARCHD *arcn, register char *buf) #else @@ -751,7 +751,7 @@ vcpio_rd(arcn, buf) * size of trailer header in this format */ -#if __STDC__ +#ifdef __STDC__ off_t vcpio_endrd(void) #else @@ -770,7 +770,7 @@ vcpio_endrd() * 0 if ok, -1 otherwise (what dev_start() returns) */ -#if __STDC__ +#ifdef __STDC__ int crc_stwr(void) #else @@ -791,7 +791,7 @@ crc_stwr() * NO data to write after the header, -1 if archive write failed */ -#if __STDC__ +#ifdef __STDC__ int vcpio_wr(register ARCHD *arcn) #else @@ -848,7 +848,7 @@ vcpio_wr(arcn) if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize, sizeof(hd->c_filesize), HEX)) { # endif - pax_warn(1,"File is too large for sv4cpio format %s", + paxwarn(1,"File is too large for sv4cpio format %s", arcn->org_name); return(1); } @@ -906,7 +906,7 @@ vcpio_wr(arcn) if ((wr_rdbuf(hdblk, (int)sizeof(HD_VCPIO)) < 0) || (wr_rdbuf(arcn->name, (int)nsz) < 0) || (wr_skip((off_t)(VCPIO_PAD(sizeof(HD_VCPIO) + nsz))) < 0)) { - pax_warn(1,"Could not write sv4cpio header for %s",arcn->org_name); + paxwarn(1,"Could not write sv4cpio header for %s",arcn->org_name); return(-1); } @@ -928,7 +928,7 @@ vcpio_wr(arcn) */ if ((wr_rdbuf(arcn->ln_name, arcn->ln_nlen) < 0) || (wr_skip((off_t)(VCPIO_PAD(arcn->ln_nlen))) < 0)) { - pax_warn(1,"Could not write sv4cpio link name for %s", + paxwarn(1,"Could not write sv4cpio link name for %s", arcn->org_name); return(-1); } @@ -938,7 +938,7 @@ vcpio_wr(arcn) /* * header field is out of range */ - pax_warn(1,"Sv4cpio header field is too small for file %s",arcn->org_name); + paxwarn(1,"Sv4cpio header field is too small for file %s",arcn->org_name); return(1); } @@ -954,7 +954,7 @@ vcpio_wr(arcn) * 0 if a valid header, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int bcpio_id(char *blk, int size) #else @@ -989,7 +989,7 @@ bcpio_id(blk, size) * 0 if a valid header, -1 otherwise. */ -#if __STDC__ +#ifdef __STDC__ int bcpio_rd(register ARCHD *arcn, register char *buf) #else @@ -1093,7 +1093,7 @@ bcpio_rd(arcn, buf) * size of trailer header in this format */ -#if __STDC__ +#ifdef __STDC__ off_t bcpio_endrd(void) #else @@ -1116,7 +1116,7 @@ bcpio_endrd() * data to write after the header, -1 if archive write failed */ -#if __STDC__ +#ifdef __STDC__ int bcpio_wr(register ARCHD *arcn) #else @@ -1159,7 +1159,7 @@ bcpio_wr(arcn) t_offt = (off_t)(SHRT_EXT(hd->h_filesize_1)); t_offt = (t_offt<<16) | ((off_t)(SHRT_EXT(hd->h_filesize_2))); if (arcn->sb.st_size != t_offt) { - pax_warn(1,"File is too large for bcpio format %s", + paxwarn(1,"File is too large for bcpio format %s", arcn->org_name); return(1); } @@ -1244,7 +1244,7 @@ bcpio_wr(arcn) if ((wr_rdbuf(hdblk, (int)sizeof(HD_BCPIO)) < 0) || (wr_rdbuf(arcn->name, nsz) < 0) || (wr_skip((off_t)(BCPIO_PAD(sizeof(HD_BCPIO) + nsz))) < 0)) { - pax_warn(1, "Could not write bcpio header for %s", arcn->org_name); + paxwarn(1, "Could not write bcpio header for %s", arcn->org_name); return(-1); } @@ -1266,7 +1266,7 @@ bcpio_wr(arcn) */ if ((wr_rdbuf(arcn->ln_name, arcn->ln_nlen) < 0) || (wr_skip((off_t)(BCPIO_PAD(arcn->ln_nlen))) < 0)) { - pax_warn(1,"Could not write bcpio link name for %s",arcn->org_name); + paxwarn(1,"Could not write bcpio link name for %s",arcn->org_name); return(-1); } return(1); @@ -1275,6 +1275,6 @@ bcpio_wr(arcn) /* * header field is out of range */ - pax_warn(1,"Bcpio header field is too small for file %s", arcn->org_name); + paxwarn(1,"Bcpio header field is too small for file %s", arcn->org_name); return(1); } diff --git a/bin/pax/extern.h b/bin/pax/extern.h index 89a5840a5796..528ce6c2b26f 100644 --- a/bin/pax/extern.h +++ b/bin/pax/extern.h @@ -284,5 +284,5 @@ int ustar_wr __P((register ARCHD *)); int tty_init __P((void)); void tty_prnt __P((const char *, ...)) __printflike(1, 2); int tty_read __P((char *, int)); -void pax_warn __P((int, const char *, ...)) __printflike(2, 3); -void sys_warn __P((int, int, const char *, ...)) __printflike(3, 4); +void paxwarn __P((int, const char *, ...)) __printflike(2, 3); +void syswarn __P((int, int, const char *, ...)) __printflike(3, 4); diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c index b8f2a4917c7b..b3126f5b266e 100644 --- a/bin/pax/file_subs.c +++ b/bin/pax/file_subs.c @@ -75,7 +75,7 @@ mk_link __P((register char *,register struct stat *,register char *, int)); * file descriptor or -1 for failure */ -#if __STDC__ +#ifdef __STDC__ int file_creat(register ARCHD *arcn) #else @@ -123,7 +123,7 @@ file_creat(arcn) break; oerrno = errno; if (chk_path(arcn->name,arcn->sb.st_uid,arcn->sb.st_gid) < 0) { - sys_warn(1, oerrno, "Unable to create %s", arcn->name); + syswarn(1, oerrno, "Unable to create %s", arcn->name); return(-1); } } @@ -138,7 +138,7 @@ file_creat(arcn) * 0 for success, -1 for failure */ -#if __STDC__ +#ifdef __STDC__ void file_close(register ARCHD *arcn, int fd) #else @@ -153,7 +153,7 @@ file_close(arcn, fd) if (fd < 0) return; if (close(fd) < 0) - sys_warn(0, errno, "Unable to close file descriptor on %s", + syswarn(0, errno, "Unable to close file descriptor on %s", arcn->name); /* @@ -185,7 +185,7 @@ file_close(arcn, fd) * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int lnk_creat(register ARCHD *arcn) #else @@ -201,13 +201,13 @@ lnk_creat(arcn) * is not a directory, so we lstat and check */ if (lstat(arcn->ln_name, &sb) < 0) { - sys_warn(1,errno,"Unable to link to %s from %s", arcn->ln_name, + syswarn(1,errno,"Unable to link to %s from %s", arcn->ln_name, arcn->name); return(-1); } if (S_ISDIR(sb.st_mode)) { - pax_warn(1, "A hard link to the directory %s is not allowed", + paxwarn(1, "A hard link to the directory %s is not allowed", arcn->ln_name); return(-1); } @@ -218,14 +218,14 @@ lnk_creat(arcn) /* * cross_lnk() * Create a hard link to arcn->org_name from arcn->name. Only used in copy - * with the -l flag. No pax_warning or error if this does not succeed (we will + * with the -l flag. No warning or error if this does not succeed (we will * then just create the file) * Return: * 1 if copy() should try to create this file node * 0 if cross_lnk() ok, -1 for fatal flaw (like linking to self). */ -#if __STDC__ +#ifdef __STDC__ int cross_lnk(register ARCHD *arcn) #else @@ -255,7 +255,7 @@ cross_lnk(arcn) * 0 skip it file exists (-k) or may be the same as source file */ -#if __STDC__ +#ifdef __STDC__ int chk_same(register ARCHD *arcn) #else @@ -279,7 +279,7 @@ chk_same(arcn) * better make sure the user does not have src == dest by mistake */ if ((arcn->sb.st_dev == sb.st_dev) && (arcn->sb.st_ino == sb.st_ino)) { - pax_warn(1, "Unable to copy %s, file would overwrite itself", + paxwarn(1, "Unable to copy %s, file would overwrite itself", arcn->name); return(0); } @@ -298,7 +298,7 @@ chk_same(arcn) * allowed option). -1 an error occurred. */ -#if __STDC__ +#ifdef __STDC__ static int mk_link(register char *to, register struct stat *to_sb, register char *from, int ign) @@ -326,7 +326,7 @@ mk_link(to, to_sb, from, ign) * make sure it is not the same file, protect the user */ if ((to_sb->st_dev==sb.st_dev)&&(to_sb->st_ino == sb.st_ino)) { - pax_warn(1, "Unable to link file %s to itself", to); + paxwarn(1, "Unable to link file %s to itself", to); return(-1);; } @@ -335,12 +335,12 @@ mk_link(to, to_sb, from, ign) */ if (S_ISDIR(sb.st_mode)) { if (rmdir(from) < 0) { - sys_warn(1, errno, "Unable to remove %s", from); + syswarn(1, errno, "Unable to remove %s", from); return(-1); } } else if (unlink(from) < 0) { if (!ign) { - sys_warn(1, errno, "Unable to remove %s", from); + syswarn(1, errno, "Unable to remove %s", from); return(-1); } return(1); @@ -359,7 +359,7 @@ mk_link(to, to_sb, from, ign) if (chk_path(from, to_sb->st_uid, to_sb->st_gid) == 0) continue; if (!ign) { - sys_warn(1, oerrno, "Could not link to %s from %s", to, + syswarn(1, oerrno, "Could not link to %s from %s", to, from); return(-1); } @@ -380,7 +380,7 @@ mk_link(to, to_sb, from, ign) * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int node_creat(register ARCHD *arcn) #else @@ -426,7 +426,7 @@ node_creat(arcn) /* * Skip sockets, operation has no meaning under BSD */ - pax_warn(0, + paxwarn(0, "%s skipped. Sockets cannot be copied or extracted", arcn->name); return(-1); @@ -442,7 +442,7 @@ node_creat(arcn) /* * we should never get here */ - pax_warn(0, "%s has an unknown file type, skipping", + paxwarn(0, "%s has an unknown file type, skipping", arcn->name); return(-1); } @@ -466,7 +466,7 @@ node_creat(arcn) continue; if (chk_path(arcn->name,arcn->sb.st_uid,arcn->sb.st_gid) < 0) { - sys_warn(1, oerrno, "Could not create: %s", arcn->name); + syswarn(1, oerrno, "Could not create: %s", arcn->name); return(-1); } } @@ -501,7 +501,7 @@ node_creat(arcn) */ if (access(arcn->name, R_OK | W_OK | X_OK) < 0) { if (lstat(arcn->name, &sb) < 0) { - sys_warn(0, errno,"Could not access %s (stat)", + syswarn(0, errno,"Could not access %s (stat)", arcn->name); set_pmode(arcn->name,file_mode | S_IRWXU); } else { @@ -543,7 +543,7 @@ node_creat(arcn) * 1 we found a directory and we were going to create a directory. */ -#if __STDC__ +#ifdef __STDC__ int unlnk_exist(register char *name, register int type) #else @@ -571,7 +571,7 @@ unlnk_exist(name, type) if (rmdir(name) < 0) { if (type == PAX_DIR) return(1); - sys_warn(1,errno,"Unable to remove directory %s", name); + syswarn(1,errno,"Unable to remove directory %s", name); return(-1); } return(0); @@ -581,7 +581,7 @@ unlnk_exist(name, type) * try to get rid of all non-directory type nodes */ if (unlink(name) < 0) { - sys_warn(1, errno, "Could not unlink %s", name); + syswarn(1, errno, "Could not unlink %s", name); return(-1); } return(0); @@ -601,7 +601,7 @@ unlnk_exist(name, type) * 0 otherwise */ -#if __STDC__ +#ifdef __STDC__ int chk_path( register char *name, uid_t st_uid, gid_t st_gid) #else @@ -684,7 +684,7 @@ chk_path(name, st_uid, st_gid) /* * set_ftime() * Set the access time and modification time for a named file. If frc is - * non-zero we force these times to be set even if the the user did not + * non-zero we force these times to be set even if the user did not * request access and/or modification time preservation (this is also * used by -t to reset access times). * When ign is zero, only those times the user has asked for are set, the @@ -693,7 +693,7 @@ chk_path(name, st_uid, st_gid) * not set request. */ -#if __STDC__ +#ifdef __STDC__ void set_ftime(char *fnm, time_t mtime, time_t atime, int frc) #else @@ -721,14 +721,14 @@ set_ftime(fnm, mtime, atime, frc) if (!pmtime) tv[1].tv_sec = (long)sb.st_mtime; } else - sys_warn(0,errno,"Unable to obtain file stats %s", fnm); + syswarn(0,errno,"Unable to obtain file stats %s", fnm); } /* * set the times */ if (utimes(fnm, tv) < 0) - sys_warn(1, errno, "Access/modification time set failed on: %s", + syswarn(1, errno, "Access/modification time set failed on: %s", fnm); return; } @@ -740,7 +740,7 @@ set_ftime(fnm, mtime, atime, frc) * 0 when set, -1 on failure */ -#if __STDC__ +#ifdef __STDC__ int set_ids(char *fnm, uid_t uid, gid_t gid) #else @@ -752,7 +752,7 @@ set_ids(fnm, uid, gid) #endif { if (chown(fnm, uid, gid) < 0) { - sys_warn(1, errno, "Unable to set file uid/gid of %s", fnm); + syswarn(1, errno, "Unable to set file uid/gid of %s", fnm); return(-1); } return(0); @@ -763,7 +763,7 @@ set_ids(fnm, uid, gid) * Set file access mode */ -#if __STDC__ +#ifdef __STDC__ void set_pmode(char *fnm, mode_t mode) #else @@ -775,7 +775,7 @@ set_pmode(fnm, mode) { mode &= ABITS; if (chmod(fnm, mode) < 0) - sys_warn(1, errno, "Could not set permissions on %s", fnm); + syswarn(1, errno, "Could not set permissions on %s", fnm); return; } @@ -827,7 +827,7 @@ set_pmode(fnm, mode) * number of bytes written, -1 on write (or lseek) error. */ -#if __STDC__ +#ifdef __STDC__ int file_write(int fd, char *str, register int cnt, int *rem, int *isempt, int sz, char *name) @@ -888,7 +888,7 @@ file_write(fd, str, cnt, rem, isempt, sz, name) * skip, buf is empty so far */ if (lseek(fd, (off_t)wcnt, SEEK_CUR) < 0) { - sys_warn(1,errno,"File seek on %s", + syswarn(1,errno,"File seek on %s", name); return(-1); } @@ -905,7 +905,7 @@ file_write(fd, str, cnt, rem, isempt, sz, name) * have non-zero data in this file system block, have to write */ if (write(fd, st, wcnt) != wcnt) { - sys_warn(1, errno, "Failed write to file %s", name); + syswarn(1, errno, "Failed write to file %s", name); return(-1); } st += wcnt; @@ -920,7 +920,7 @@ file_write(fd, str, cnt, rem, isempt, sz, name) * write the last BYTE with a zero (back up one byte and write a zero). */ -#if __STDC__ +#ifdef __STDC__ void file_flush(int fd, char *fname, int isempt) #else @@ -944,12 +944,12 @@ file_flush(fd, fname, isempt) * move back one byte and write a zero */ if (lseek(fd, (off_t)-1, SEEK_CUR) < 0) { - sys_warn(1, errno, "Failed seek on file %s", fname); + syswarn(1, errno, "Failed seek on file %s", fname); return; } if (write(fd, blnk, 1) < 0) - sys_warn(1, errno, "Failed write to file %s", fname); + syswarn(1, errno, "Failed write to file %s", fname); return; } @@ -959,7 +959,7 @@ file_flush(fd, fname, isempt) * reset access time (tflag) do so (the times are stored in arcn). */ -#if __STDC__ +#ifdef __STDC__ void rdfile_close(register ARCHD *arcn, register int *fd) #else @@ -996,7 +996,7 @@ rdfile_close(arcn, fd) * 0 if was able to calculate the crc, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int set_crc(register ARCHD *arcn, register int fd) #else @@ -1042,13 +1042,13 @@ set_crc(arcn, fd) * they can create inconsistant archive copies. */ if (cpcnt != arcn->sb.st_size) - pax_warn(1, "File changed size %s", arcn->org_name); + paxwarn(1, "File changed size %s", arcn->org_name); else if (fstat(fd, &sb) < 0) - sys_warn(1, errno, "Failed stat on %s", arcn->org_name); + syswarn(1, errno, "Failed stat on %s", arcn->org_name); else if (arcn->sb.st_mtime != sb.st_mtime) - pax_warn(1, "File %s was modified during read", arcn->org_name); + paxwarn(1, "File %s was modified during read", arcn->org_name); else if (lseek(fd, (off_t)0L, SEEK_SET) < 0) - sys_warn(1, errno, "File rewind failed on: %s", arcn->org_name); + syswarn(1, errno, "File rewind failed on: %s", arcn->org_name); else { arcn->crc = crc; return(0); diff --git a/bin/pax/ftree.c b/bin/pax/ftree.c index ba1e4890e455..772404b9a3bb 100644 --- a/bin/pax/ftree.c +++ b/bin/pax/ftree.c @@ -91,7 +91,7 @@ static int ftree_arg __P((void)); * 0 if there is at least one valid file arg to process, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int ftree_start(void) #else @@ -123,7 +123,7 @@ ftree_start() ftsopts |= FTS_PHYSICAL; if (Hflag) # ifdef NET2_FTS - pax_warn(0, "The -H flag is not supported on this version"); + paxwarn(0, "The -H flag is not supported on this version"); # else ftsopts |= FTS_COMFOLLOW; # endif @@ -131,7 +131,7 @@ ftree_start() ftsopts |= FTS_XDEV; if ((fthead == NULL) && ((farray[0] = malloc(PAXPATHLEN+2)) == NULL)) { - pax_warn(1, "Unable to allocate memory for file name buffer"); + paxwarn(1, "Unable to allocate memory for file name buffer"); return(-1); } @@ -150,7 +150,7 @@ ftree_start() * 0 if added to the linked list, -1 if failed */ -#if __STDC__ +#ifdef __STDC__ int ftree_add(register char *str) #else @@ -166,7 +166,7 @@ ftree_add(str) * simple check for bad args */ if ((str == NULL) || (*str == '\0')) { - pax_warn(0, "Invalid file name arguement"); + paxwarn(0, "Invalid file name argument"); return(-1); } @@ -176,7 +176,7 @@ ftree_add(str) * trailing / the user may pass us. (watch out for / by itself). */ if ((ft = (FTREE *)malloc(sizeof(FTREE))) == NULL) { - pax_warn(0, "Unable to allocate memory for filename"); + paxwarn(0, "Unable to allocate memory for filename"); return(-1); } @@ -200,7 +200,7 @@ ftree_add(str) * -n and -d processing. */ -#if __STDC__ +#ifdef __STDC__ void ftree_sel(register ARCHD *arcn) #else @@ -239,7 +239,7 @@ ftree_sel(arcn) * have a selected member (reference count still 0) */ -#if __STDC__ +#ifdef __STDC__ void ftree_chk(void) #else @@ -264,7 +264,7 @@ ftree_chk() if (ft->refcnt > 0) continue; if (wban == 0) { - pax_warn(1,"WARNING! These file names were not selected:"); + paxwarn(1,"WARNING! These file names were not selected:"); ++wban; } (void)fprintf(stderr, "%s\n", ft->fname); @@ -281,7 +281,7 @@ ftree_chk() * stdin). */ -#if __STDC__ +#ifdef __STDC__ static int ftree_arg(void) #else @@ -315,7 +315,7 @@ ftree_arg() *pt = '\0'; } else { /* - * the user supplied the file args as arguements to pax + * the user supplied the file args as arguments to pax */ if (ftcur == NULL) ftcur = fthead; @@ -346,7 +346,7 @@ ftree_arg() * 0 when contents of arcn have been set with the next file, -1 when done. */ -#if __STDC__ +#ifdef __STDC__ int next_file(register ARCHD *arcn) #else @@ -424,30 +424,30 @@ next_file(arcn) /* * fts claims a file system cycle */ - pax_warn(1,"File system cycle found at %s",ftent->fts_path); + paxwarn(1,"File system cycle found at %s",ftent->fts_path); continue; case FTS_DNR: # ifdef NET2_FTS - sys_warn(1, errno, + syswarn(1, errno, # else - sys_warn(1, ftent->fts_errno, + syswarn(1, ftent->fts_errno, # endif "Unable to read directory %s", ftent->fts_path); continue; case FTS_ERR: # ifdef NET2_FTS - sys_warn(1, errno, + syswarn(1, errno, # else - sys_warn(1, ftent->fts_errno, + syswarn(1, ftent->fts_errno, # endif "File system traversal error"); continue; case FTS_NS: case FTS_NSOK: # ifdef NET2_FTS - sys_warn(1, errno, + syswarn(1, errno, # else - sys_warn(1, ftent->fts_errno, + syswarn(1, ftent->fts_errno, # endif "Unable to access %s", ftent->fts_path); continue; @@ -509,7 +509,7 @@ next_file(arcn) */ if ((cnt = readlink(ftent->fts_path, arcn->ln_name, PAXPATHLEN - 1)) < 0) { - sys_warn(1, errno, "Unable to read symlink %s", + syswarn(1, errno, "Unable to read symlink %s", ftent->fts_path); continue; } diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c index 02845b7422e5..a22bd96dee42 100644 --- a/bin/pax/gen_subs.c +++ b/bin/pax/gen_subs.c @@ -81,7 +81,7 @@ static int d_first = -1; * list the members of an archive in ls format */ -#if __STDC__ +#ifdef __STDC__ void ls_list(register ARCHD *arcn, time_t now) #else @@ -168,7 +168,7 @@ ls_list(arcn, now) * print a short summary of file to tty. */ -#if __STDC__ +#ifdef __STDC__ void ls_tty(register ARCHD *arcn) #else @@ -184,7 +184,7 @@ ls_tty(arcn) if (d_first < 0) d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); - if ((arcn->sb.st_mtime + SIXMONTHS) <= time((time_t *)NULL)) + if ((arcn->sb.st_mtime + SIXMONTHS) <= time(NULL)) timefrmt = d_first ? OLDFRMTD : OLDFRMTM; else timefrmt = d_first ? CURFRMTD : CURFRMTM; @@ -205,10 +205,10 @@ ls_tty(arcn) * copy src to dest up to len chars (stopping at first '\0'), when src is * shorter than len, pads to len with '\0'. big performance win (and * a lot easier to code) over strncpy(), then a strlen() then a - * bzero(). (or doing the bzero() first). + * memset(). (or doing the memset() first). */ -#if __STDC__ +#ifdef __STDC__ void zf_strncpy(register char *dest, register char *src, int len) #else @@ -237,7 +237,7 @@ zf_strncpy(dest, src, len) * doing a strncpy() then a strlen() */ -#if __STDC__ +#ifdef __STDC__ int l_strncpy(register char *dest, register char *src, int len) #else @@ -270,7 +270,7 @@ l_strncpy(dest, src, len) * unsigned long value */ -#if __STDC__ +#ifdef __STDC__ u_long asc_ul(register char *str, int len, register int base) #else @@ -321,7 +321,7 @@ asc_ul(str, len, base) * NOTE: the string created is NOT TERMINATED. */ -#if __STDC__ +#ifdef __STDC__ int ul_asc(u_long val, register char *str, register int len, register int base) #else @@ -384,7 +384,7 @@ ul_asc(val, str, len, base) * u_quad_t value */ -#if __STDC__ +#ifdef __STDC__ u_quad_t asc_uqd(register char *str, int len, register int base) #else @@ -435,7 +435,7 @@ asc_uqd(str, len, base) * NOTE: the string created is NOT TERMINATED. */ -#if __STDC__ +#ifdef __STDC__ int uqd_asc(u_quad_t val, register char *str, register int len, register int base) #else diff --git a/bin/pax/options.c b/bin/pax/options.c index 8d1d758f1ca2..90f540b36dd6 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -134,7 +134,7 @@ int ford[] = {5, 4, 3, 2, 1, 0, -1 }; * parser */ -#if __STDC__ +#ifdef __STDC__ void options(register int argc, register char **argv) #else @@ -172,7 +172,7 @@ options(argc, argv) * the user specified a legal set of flags. If not, complain and exit */ -#if __STDC__ +#ifdef __STDC__ static void pax_options(register int argc, register char **argv) #else @@ -207,7 +207,7 @@ pax_options(argc, argv) */ flg |= BF; if ((wrblksz = (int)str_offt(optarg)) <= 0) { - pax_warn(1, "Invalid block size %s", optarg); + paxwarn(1, "Invalid block size %s", optarg); pax_usage(); } break; @@ -309,7 +309,7 @@ pax_options(argc, argv) pmode = 1; break; default: - pax_warn(1, "Invalid -p string: %c", *pt); + paxwarn(1, "Invalid -p string: %c", *pt); pax_usage(); break; } @@ -369,7 +369,7 @@ pax_options(argc, argv) flg |= XF; break; } - pax_warn(1, "Unknown -x format: %s", optarg); + paxwarn(1, "Unknown -x format: %s", optarg); (void)fputs("pax: Known -x formats are:", stderr); for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i) (void)fprintf(stderr, " %s", fsub[i].name); @@ -382,11 +382,11 @@ pax_options(argc, argv) * single archive volume. */ if ((wrlimit = str_offt(optarg)) <= 0) { - pax_warn(1, "Invalid write limit %s", optarg); + paxwarn(1, "Invalid write limit %s", optarg); pax_usage(); } if (wrlimit % BLKMULT) { - pax_warn(1, "Write limit is not a %d byte multiple", + paxwarn(1, "Write limit is not a %d byte multiple", BLKMULT); pax_usage(); } @@ -410,7 +410,7 @@ pax_options(argc, argv) if (strcmp(NONE, optarg) == 0) maxflt = -1; else if ((maxflt = atoi(optarg)) < 0) { - pax_warn(1, "Error count value must be positive"); + paxwarn(1, "Error count value must be positive"); pax_usage(); } break; @@ -545,7 +545,7 @@ pax_options(argc, argv) break; case COPY: if (optind >= argc) { - pax_warn(0, "Destination directory was not supplied"); + paxwarn(0, "Destination directory was not supplied"); pax_usage(); } --argc; @@ -571,7 +571,7 @@ pax_options(argc, argv) * the user specified a legal set of flags. If not, complain and exit */ -#if __STDC__ +#ifdef __STDC__ static void tar_options(register int argc, register char **argv) #else @@ -601,12 +601,12 @@ tar_options(argc, argv) /* * specify blocksize */ - if (*argv == (char *)NULL) { - pax_warn(1,"blocksize must be specified with 'b'"); + if (*argv == NULL) { + paxwarn(1,"blocksize must be specified with 'b'"); tar_usage(); } if ((wrblksz = (int)str_offt(*argv)) <= 0) { - pax_warn(1, "Invalid block size %s", *argv); + paxwarn(1, "Invalid block size %s", *argv); tar_usage(); } ++argv; @@ -627,8 +627,8 @@ tar_options(argc, argv) /* * filename where the archive is stored */ - if (*argv == (char *)NULL) { - pax_warn(1, "filename must be specified with 'f'"); + if (*argv == NULL) { + paxwarn(1, "filename must be specified with 'f'"); tar_usage(); } if ((argv[0][0] == '-') && (argv[0][1]== '\0')) { @@ -760,13 +760,13 @@ tar_options(argc, argv) case LIST: case EXTRACT: default: - while (*argv != (char *)NULL) + while (*argv != NULL) if (pat_add(*argv++) < 0) tar_usage(); break; case ARCHIVE: case APPND: - while (*argv != (char *)NULL) + while (*argv != NULL) if (ftree_add(*argv++) < 0) tar_usage(); /* @@ -775,9 +775,9 @@ tar_options(argc, argv) maxflt = 0; break; } - if (!fstdin && ((arcname == (char *)NULL) || (*arcname == '\0'))) { + if (!fstdin && ((arcname == NULL) || (*arcname == '\0'))) { arcname = getenv("TAPE"); - if ((arcname == (char *)NULL) || (*arcname == '\0')) + if ((arcname == NULL) || (*arcname == '\0')) arcname = DEV_8; } } @@ -789,7 +789,7 @@ tar_options(argc, argv) * the user specified a legal set of flags. If not, complain and exit */ -#if __STDC__ +#ifdef __STDC__ static void cpio_options(register int argc, register char **argv) #else @@ -807,7 +807,7 @@ cpio_options(argc, argv) * print out those invalid flag sets found to the user */ -#if __STDC__ +#ifdef __STDC__ static void printflg(unsigned int flg) #else @@ -834,7 +834,7 @@ printflg(flg) * by the user */ -#if __STDC__ +#ifdef __STDC__ static int c_frmt(const void *a, const void *b) #else @@ -855,7 +855,7 @@ c_frmt(a, b) * pointer to next OPLIST entry or NULL (end of list). */ -#if __STDC__ +#ifdef __STDC__ OPLIST * opt_next(void) #else @@ -876,7 +876,7 @@ opt_next() * when the format does not support options. */ -#if __STDC__ +#ifdef __STDC__ int bad_opt(void) #else @@ -891,7 +891,7 @@ bad_opt() /* * print all we were given */ - pax_warn(1,"These format options are not supported"); + paxwarn(1,"These format options are not supported"); while ((opt = opt_next()) != NULL) (void)fprintf(stderr, "\t%s = %s\n", opt->name, opt->value); pax_usage(); @@ -907,7 +907,7 @@ bad_opt() * 0 if format in name=value format, -1 if -o is passed junk */ -#if __STDC__ +#ifdef __STDC__ int opt_add(register char *str) #else @@ -922,7 +922,7 @@ opt_add(str) register char *endpt; if ((str == NULL) || (*str == '\0')) { - pax_warn(0, "Invalid option name"); + paxwarn(0, "Invalid option name"); return(-1); } frpt = endpt = str; @@ -936,11 +936,11 @@ opt_add(str) if ((endpt = strchr(frpt, ',')) != NULL) *endpt = '\0'; if ((pt = strchr(frpt, '=')) == NULL) { - pax_warn(0, "Invalid options format"); + paxwarn(0, "Invalid options format"); return(-1); } if ((opt = (OPLIST *)malloc(sizeof(OPLIST))) == NULL) { - pax_warn(0, "Unable to allocate space for option list"); + paxwarn(0, "Unable to allocate space for option list"); return(-1); } *pt++ = '\0'; @@ -976,7 +976,7 @@ opt_add(str) * 0 for an error, a positive value o.w. */ -#if __STDC__ +#ifdef __STDC__ static off_t str_offt(char *val) #else @@ -1051,7 +1051,7 @@ str_offt(val) * 0 */ -#if __STDC__ +#ifdef __STDC__ static int no_op(void) #else @@ -1067,7 +1067,7 @@ no_op() * print the usage summary to the user */ -#if __STDC__ +#ifdef __STDC__ void pax_usage(void) #else @@ -1106,7 +1106,7 @@ pax_usage() * print the usage summary to the user */ -#if __STDC__ +#ifdef __STDC__ void tar_usage(void) #else @@ -1126,7 +1126,7 @@ tar_usage() * print the usage summary to the user */ -#if __STDC__ +#ifdef __STDC__ void cpio_usage(void) #else diff --git a/bin/pax/pat_rep.c b/bin/pax/pat_rep.c index e68a0ebf6035..d6ecd5360da6 100644 --- a/bin/pax/pat_rep.c +++ b/bin/pax/pat_rep.c @@ -98,7 +98,7 @@ static int resub __P((regex_t *, regmatch_t *, char *, char *, char *)); * the list of replacement patterns; -1 otherwise. */ -#if __STDC__ +#ifdef __STDC__ int rep_add(register char *str) #else @@ -119,7 +119,7 @@ rep_add(str) * throw out the bad parameters */ if ((str == NULL) || (*str == '\0')) { - pax_warn(1, "Empty replacement string"); + paxwarn(1, "Empty replacement string"); return(-1); } @@ -128,7 +128,7 @@ rep_add(str) * this expression */ if ((pt1 = strchr(str+1, *str)) == NULL) { - pax_warn(1, "Invalid replacement string %s", str); + paxwarn(1, "Invalid replacement string %s", str); return(-1); } @@ -137,7 +137,7 @@ rep_add(str) * and split out the regular expression and try to compile it */ if ((rep = (REPLACE *)malloc(sizeof(REPLACE))) == NULL) { - pax_warn(1, "Unable to allocate memory for replacement string"); + paxwarn(1, "Unable to allocate memory for replacement string"); return(-1); } @@ -147,7 +147,7 @@ rep_add(str) # else if ((res = regcomp(&(rep->rcmp), str+1, 0)) != 0) { regerror(res, &(rep->rcmp), rebuf, sizeof(rebuf)); - pax_warn(1, "%s while compiling regular expression %s", rebuf, str); + paxwarn(1, "%s while compiling regular expression %s", rebuf, str); # endif (void)free((char *)rep); return(-1); @@ -166,7 +166,7 @@ rep_add(str) regfree(&(rep->rcmp)); # endif (void)free((char *)rep); - pax_warn(1, "Invalid replacement string %s", str); + paxwarn(1, "Invalid replacement string %s", str); return(-1); } @@ -196,7 +196,7 @@ rep_add(str) # endif (void)free((char *)rep); *pt1 = *str; - pax_warn(1, "Invalid replacement string option %s", str); + paxwarn(1, "Invalid replacement string option %s", str); return(-1); } ++pt2; @@ -226,7 +226,7 @@ rep_add(str) * 0 if the pattern was added to the list, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int pat_add(char *str) #else @@ -241,7 +241,7 @@ pat_add(str) * throw out the junk */ if ((str == NULL) || (*str == '\0')) { - pax_warn(1, "Empty pattern string"); + paxwarn(1, "Empty pattern string"); return(-1); } @@ -251,7 +251,7 @@ pat_add(str) * node to the end of the pattern list */ if ((pt = (PATTERN *)malloc(sizeof(PATTERN))) == NULL) { - pax_warn(1, "Unable to allocate memory for pattern string"); + paxwarn(1, "Unable to allocate memory for pattern string"); return(-1); } @@ -275,7 +275,7 @@ pat_add(str) * a selected archive member. */ -#if __STDC__ +#ifdef __STDC__ void pat_chk(void) #else @@ -294,7 +294,7 @@ pat_chk() if (pt->flgs & MTCH) continue; if (!wban) { - pax_warn(1, "WARNING! These patterns were not matched:"); + paxwarn(1, "WARNING! These patterns were not matched:"); ++wban; } (void)fprintf(stderr, "%s\n", pt->pstr); @@ -317,7 +317,7 @@ pat_chk() * match, -1 otherwise. */ -#if __STDC__ +#ifdef __STDC__ int pat_sel(register ARCHD *arcn) #else @@ -373,7 +373,7 @@ pat_sel(arcn) *pt->pend = '\0'; if ((pt->pstr = strdup(arcn->name)) == NULL) { - pax_warn(1, "Pattern select out of memory"); + paxwarn(1, "Pattern select out of memory"); if (pt->pend != NULL) *pt->pend = '/'; pt->pend = NULL; @@ -421,7 +421,7 @@ pat_sel(arcn) /* * should never happen.... */ - pax_warn(1, "Pattern list inconsistant"); + paxwarn(1, "Pattern list inconsistant"); return(-1); } *ppt = pt->fow; @@ -442,7 +442,7 @@ pat_sel(arcn) * looking for more members) */ -#if __STDC__ +#ifdef __STDC__ int pat_match(register ARCHD *arcn) #else @@ -520,7 +520,7 @@ pat_match(arcn) * Note: *pend may be changed to show where the prefix ends. */ -#if __STDC__ +#ifdef __STDC__ static int fn_match(register char *pattern, register char *string, char **pend) #else @@ -651,7 +651,7 @@ range_match(pattern, test) * 0 continue to process file, 1 skip this file, -1 pax is finished */ -#if __STDC__ +#ifdef __STDC__ int mod_name(register ARCHD *arcn) #else @@ -718,7 +718,7 @@ mod_name(arcn) * 0 process this file, 1 skip this file, -1 we need to exit pax */ -#if __STDC__ +#ifdef __STDC__ static int tty_rename(register ARCHD *arcn) #else @@ -790,7 +790,7 @@ tty_rename(arcn) * 0 if ok, -1 if failure (name too long) */ -#if __STDC__ +#ifdef __STDC__ int set_dest(register ARCHD *arcn, char *dest_dir, int dir_len) #else @@ -825,7 +825,7 @@ set_dest(arcn, dest_dir, dir_len) * 0 if ok, -1 if the final name is too long */ -#if __STDC__ +#ifdef __STDC__ static int fix_path( char *or_name, int *or_len, char *dir_name, int dir_len) #else @@ -856,7 +856,7 @@ fix_path(or_name, or_len, dir_name, dir_len) --dest; } if ((len = dest - or_name) > PAXPATHLEN) { - pax_warn(1, "File name %s/%s, too long", dir_name, start); + paxwarn(1, "File name %s/%s, too long", dir_name, start); return(-1); } *or_len = len; @@ -897,7 +897,7 @@ fix_path(or_name, or_len, dir_name, dir_len) * ended up empty) */ -#if __STDC__ +#ifdef __STDC__ static int rep_name(char *name, int *nlen, int prnt) #else @@ -983,7 +983,7 @@ rep_name(name, nlen, prnt) < 0) { # endif if (prnt) - pax_warn(1, "Replacement name error %s", + paxwarn(1, "Replacement name error %s", name); return(1); } @@ -1034,7 +1034,7 @@ rep_name(name, nlen, prnt) *outpt = '\0'; if ((outpt == endpt) && (*inpt != '\0')) { if (prnt) - pax_warn(1,"Replacement name too long %s >> %s", + paxwarn(1,"Replacement name too long %s >> %s", name, nname); return(1); } @@ -1071,7 +1071,7 @@ rep_name(name, nlen, prnt) * -1 if error, or the number of characters added to the destination. */ -#if __STDC__ +#ifdef __STDC__ static int resub(regexp *prog, char *src, char *dest, register char *destend) #else @@ -1129,7 +1129,7 @@ resub(prog, src, dest, destend) * -1 if error, or the number of characters added to the destination. */ -#if __STDC__ +#ifdef __STDC__ static int resub(regex_t *rp, register regmatch_t *pm, char *src, char *dest, register char *destend) diff --git a/bin/pax/pax.c b/bin/pax/pax.c index 5eb57eabc5ec..034584f9214f 100644 --- a/bin/pax/pax.c +++ b/bin/pax/pax.c @@ -221,7 +221,7 @@ sigset_t s_mask; /* signal mask for cleanup critical sect */ * Return: 0 if ok, 1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int main(int argc, char **argv) #else @@ -246,7 +246,7 @@ main(argc, argv) tdlen--; tempfile = malloc(tdlen + 1 + sizeof(_TFILE_BASE)); if (tempfile == NULL) { - pax_warn(1, "Cannot allocate memory for temp file name."); + paxwarn(1, "Cannot allocate memory for temp file name."); return(exit_val); } if (tdlen) @@ -294,7 +294,7 @@ main(argc, argv) * never.... */ -#if __STDC__ +#ifdef __STDC__ void sig_cleanup(int which_sig) #else @@ -310,9 +310,9 @@ sig_cleanup(which_sig) */ vflag = vfpart = 1; if (which_sig == SIGXCPU) - pax_warn(0, "Cpu time limit reached, cleaning up."); + paxwarn(0, "Cpu time limit reached, cleaning up."); else - pax_warn(0, "Signal caught, cleaning up."); + paxwarn(0, "Signal caught, cleaning up."); ar_close(); proc_dir(); @@ -327,7 +327,7 @@ sig_cleanup(which_sig) * when dealing with a medium to large sized archives. */ -#if __STDC__ +#ifdef __STDC__ static int gen_init(void) #else @@ -383,7 +383,7 @@ gen_init() (sigaddset(&s_mask,SIGINT) < 0)||(sigaddset(&s_mask,SIGHUP) < 0) || (sigaddset(&s_mask,SIGPIPE) < 0)||(sigaddset(&s_mask,SIGQUIT)<0) || (sigaddset(&s_mask,SIGXCPU) < 0)||(sigaddset(&s_mask,SIGXFSZ)<0)) { - pax_warn(1, "Unable to set up signal mask"); + paxwarn(1, "Unable to set up signal mask"); return(-1); } n_hand.sa_mask = s_mask; @@ -422,6 +422,6 @@ gen_init() return(0); out: - sys_warn(1, errno, "Unable to set up signal handler"); + syswarn(1, errno, "Unable to set up signal handler"); return(-1); } diff --git a/bin/pax/pax.h b/bin/pax/pax.h index 3a8824b01517..ca8005f47b48 100644 --- a/bin/pax/pax.h +++ b/bin/pax/pax.h @@ -87,7 +87,7 @@ typedef struct { int bsz; /* default block size. used when the user */ /* does not specify a blocksize for writing */ /* Appends continue to with the blocksize */ - /* the archive is currently using.*/ + /* the archive is currently using. */ int hsz; /* Header size in bytes. this is the size of */ /* the smallest header this format supports. */ /* Headers are assumed to fit in a BLKMULT. */ diff --git a/bin/pax/sel_subs.c b/bin/pax/sel_subs.c index ba7b71e7e012..7a8a98b762e3 100644 --- a/bin/pax/sel_subs.c +++ b/bin/pax/sel_subs.c @@ -78,7 +78,7 @@ static GRPT **grptb = NULL; /* group selection table */ * 0 if this archive member should be processed, 1 if it should be skipped */ -#if __STDC__ +#ifdef __STDC__ int sel_chk(register ARCHD *arcn) #else @@ -109,7 +109,7 @@ sel_chk(arcn) * 0 if added ok, -1 otherwise; */ -#if __STDC__ +#ifdef __STDC__ int usr_add(register char *str) #else @@ -130,7 +130,7 @@ usr_add(str) return(-1); if ((usrtb == NULL) && ((usrtb = (USRT **)calloc(USR_TB_SZ, sizeof(USRT *))) == NULL)) { - pax_warn(1, "Unable to allocate memory for user selection table"); + paxwarn(1, "Unable to allocate memory for user selection table"); return(-1); } @@ -144,7 +144,7 @@ usr_add(str) if ((str[0] == '\\') && (str[1] == '#')) ++str; if ((pw = getpwnam(str)) == NULL) { - pax_warn(1, "Unable to find uid for user: %s", str); + paxwarn(1, "Unable to find uid for user: %s", str); return(-1); } uid = (uid_t)pw->pw_uid; @@ -152,7 +152,7 @@ usr_add(str) # 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, NULL, 10); # endif endpwent(); @@ -177,7 +177,7 @@ usr_add(str) usrtb[indx] = pt; return(0); } - pax_warn(1, "User selection table out of memory"); + paxwarn(1, "User selection table out of memory"); return(-1); } @@ -188,7 +188,7 @@ usr_add(str) * 0 if this archive member should be processed, 1 if it should be skipped */ -#if __STDC__ +#ifdef __STDC__ static int usr_match(register ARCHD *arcn) #else @@ -222,7 +222,7 @@ usr_match(arcn) * 0 if added ok, -1 otherwise; */ -#if __STDC__ +#ifdef __STDC__ int grp_add(register char *str) #else @@ -243,7 +243,7 @@ grp_add(str) return(-1); if ((grptb == NULL) && ((grptb = (GRPT **)calloc(GRP_TB_SZ, sizeof(GRPT *))) == NULL)) { - pax_warn(1, "Unable to allocate memory fo group selection table"); + paxwarn(1, "Unable to allocate memory fo group selection table"); return(-1); } @@ -257,7 +257,7 @@ grp_add(str) if ((str[0] == '\\') && (str[1] == '#')) ++str; if ((gr = getgrnam(str)) == NULL) { - pax_warn(1,"Cannot determine gid for group name: %s", str); + paxwarn(1,"Cannot determine gid for group name: %s", str); return(-1); } gid = (gid_t)gr->gr_gid; @@ -265,7 +265,7 @@ grp_add(str) # 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, NULL, 10); # endif endgrent(); @@ -290,7 +290,7 @@ grp_add(str) grptb[indx] = pt; return(0); } - pax_warn(1, "Group selection table out of memory"); + paxwarn(1, "Group selection table out of memory"); return(-1); } @@ -301,7 +301,7 @@ grp_add(str) * 0 if this archive member should be processed, 1 if it should be skipped */ -#if __STDC__ +#ifdef __STDC__ static int grp_match(register ARCHD *arcn) #else @@ -357,7 +357,7 @@ grp_match(arcn) * 0 if the time range was added to the list, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int trng_add(register char *str) #else @@ -376,14 +376,14 @@ trng_add(str) * throw out the badly formed time ranges */ if ((str == NULL) || (*str == '\0')) { - pax_warn(1, "Empty time range string"); + paxwarn(1, "Empty time range string"); return(-1); } /* * locate optional flags suffix /{cm}. */ - if ((flgpt = rindex(str, '/')) != NULL) + if ((flgpt = strrchr(str, '/')) != NULL) *flgpt++ = '\0'; for (stpt = str; *stpt != '\0'; ++stpt) { @@ -403,7 +403,7 @@ trng_add(str) ++dot; continue; } - pax_warn(1, "Improperly specified time range: %s", str); + paxwarn(1, "Improperly specified time range: %s", str); goto out; } @@ -411,7 +411,7 @@ trng_add(str) * allocate space for the time range and store the limits */ if ((pt = (TIME_RNG *)malloc(sizeof(TIME_RNG))) == NULL) { - pax_warn(1, "Unable to allocate memory for time range"); + paxwarn(1, "Unable to allocate memory for time range"); return(-1); } @@ -434,7 +434,7 @@ trng_add(str) pt->flgs |= CMPCTME; break; default: - pax_warn(1, "Bad option %c with time range %s", + paxwarn(1, "Bad option %c with time range %s", *flgpt, str); goto out; } @@ -445,13 +445,13 @@ trng_add(str) /* * start off with the current time */ - pt->low_time = pt->high_time = time((time_t *)NULL); + pt->low_time = pt->high_time = time(NULL); if (*str != '\0') { /* * add lower limit */ if (str_sec(str, &(pt->low_time)) < 0) { - pax_warn(1, "Illegal lower time range %s", str); + paxwarn(1, "Illegal lower time range %s", str); (void)free((char *)pt); goto out; } @@ -463,7 +463,7 @@ trng_add(str) * add upper limit */ if (str_sec(up_pt, &(pt->high_time)) < 0) { - pax_warn(1, "Illegal upper time range %s", up_pt); + paxwarn(1, "Illegal upper time range %s", up_pt); (void)free((char *)pt); goto out; } @@ -474,7 +474,7 @@ trng_add(str) */ if (pt->flgs & HASLOW) { if (pt->low_time > pt->high_time) { - pax_warn(1, "Upper %s and lower %s time overlap", + paxwarn(1, "Upper %s and lower %s time overlap", up_pt, str); (void)free((char *)pt); return(-1); @@ -492,7 +492,7 @@ trng_add(str) return(0); out: - pax_warn(1, "Time range format is: [yy[mm[dd[hh]]]]mm[.ss][/[c][m]]"); + paxwarn(1, "Time range format is: [yy[mm[dd[hh]]]]mm[.ss][/[c][m]]"); return(-1); } @@ -503,7 +503,7 @@ trng_add(str) * 0 if this archive member should be processed, 1 if it should be skipped */ -#if __STDC__ +#ifdef __STDC__ static int trng_match(register ARCHD *arcn) #else @@ -578,7 +578,7 @@ trng_match(arcn) * 0 if converted ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ static int str_sec(register char *str, time_t *tval) #else @@ -592,7 +592,7 @@ str_sec(str, tval) register char *dot = NULL; lt = localtime(tval); - if ((dot = index(str, '.')) != NULL) { + if ((dot = strchr(str, '.')) != NULL) { /* * seconds (.ss) */ diff --git a/bin/pax/tables.c b/bin/pax/tables.c index d4c61c59f162..519fe11bc96d 100644 --- a/bin/pax/tables.c +++ b/bin/pax/tables.c @@ -105,7 +105,7 @@ static DEVT *chk_dev __P((dev_t, int)); * 0 if created, -1 if failure */ -#if __STDC__ +#ifdef __STDC__ int lnk_start(void) #else @@ -116,7 +116,7 @@ lnk_start() if (ltab != NULL) return(0); if ((ltab = (HRDLNK **)calloc(L_TAB_SZ, sizeof(HRDLNK *))) == NULL) { - pax_warn(1, "Cannot allocate memory for hard link table"); + paxwarn(1, "Cannot allocate memory for hard link table"); return(-1); } return(0); @@ -134,7 +134,7 @@ lnk_start() * if found returns 1; if not found returns 0; -1 on error */ -#if __STDC__ +#ifdef __STDC__ int chk_lnk(register ARCHD *arcn) #else @@ -216,7 +216,7 @@ chk_lnk(arcn) (void)free((char *)pt); } - pax_warn(1, "Hard link table out of memory"); + paxwarn(1, "Hard link table out of memory"); return(-1); } @@ -227,7 +227,7 @@ chk_lnk(arcn) * we do not want to accidently point another file at it later on. */ -#if __STDC__ +#ifdef __STDC__ void purg_lnk(register ARCHD *arcn) #else @@ -287,7 +287,7 @@ purg_lnk(arcn) * write phase */ -#if __STDC__ +#ifdef __STDC__ void lnk_end(void) #else @@ -352,7 +352,7 @@ lnk_end() * 0 if the table and file was created ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int ftime_start(void) #else @@ -363,7 +363,7 @@ ftime_start() if (ftab != NULL) return(0); if ((ftab = (FTM **)calloc(F_TAB_SZ, sizeof(FTM *))) == NULL) { - pax_warn(1, "Cannot allocate memory for file time table"); + paxwarn(1, "Cannot allocate memory for file time table"); return(-1); } @@ -373,7 +373,7 @@ ftime_start() */ memcpy(tempbase, _TFILE_BASE, sizeof(_TFILE_BASE)); if ((ffd = mkstemp(tempfile)) < 0) { - sys_warn(1, errno, "Unable to create temporary file: %s", + syswarn(1, errno, "Unable to create temporary file: %s", tempfile); return(-1); } @@ -394,7 +394,7 @@ ftime_start() * -1 on error */ -#if __STDC__ +#ifdef __STDC__ int chk_ftime(register ARCHD *arcn) #else @@ -432,12 +432,12 @@ chk_ftime(arcn) * from the scratch file. */ if (lseek(ffd,pt->seek,SEEK_SET) != pt->seek) { - sys_warn(1, errno, + syswarn(1, errno, "Failed ftime table seek"); return(-1); } if (read(ffd, ckname, namelen) != namelen) { - sys_warn(1, errno, + syswarn(1, errno, "Failed ftime table read"); return(-1); } @@ -489,11 +489,11 @@ chk_ftime(arcn) ftab[indx] = pt; return(0); } - sys_warn(1, errno, "Failed write to file time table"); + syswarn(1, errno, "Failed write to file time table"); } else - sys_warn(1, errno, "Failed seek on file time table"); + syswarn(1, errno, "Failed seek on file time table"); } else - pax_warn(1, "File time table ran out of memory"); + paxwarn(1, "File time table ran out of memory"); if (pt != NULL) (void)free((char *)pt); @@ -519,7 +519,7 @@ chk_ftime(arcn) * 0 if successful, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int name_start(void) #else @@ -530,7 +530,7 @@ name_start() if (ntab != NULL) return(0); if ((ntab = (NAMT **)calloc(N_TAB_SZ, sizeof(NAMT *))) == NULL) { - pax_warn(1, "Cannot allocate memory for interactive rename table"); + paxwarn(1, "Cannot allocate memory for interactive rename table"); return(-1); } return(0); @@ -545,7 +545,7 @@ name_start() * 0 if added, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int add_name(register char *oname, int onamelen, char *nname) #else @@ -563,7 +563,7 @@ add_name(oname, onamelen, nname) /* * should never happen */ - pax_warn(0, "No interactive rename table, links may fail\n"); + paxwarn(0, "No interactive rename table, links may fail\n"); return(0); } @@ -589,7 +589,7 @@ add_name(oname, onamelen, nname) (void)free((char *)pt->nname); if ((pt->nname = strdup(nname)) == NULL) { - pax_warn(1, "Cannot update rename table"); + paxwarn(1, "Cannot update rename table"); return(-1); } return(0); @@ -610,7 +610,7 @@ add_name(oname, onamelen, nname) } (void)free((char *)pt); } - pax_warn(1, "Interactive rename table out of memory"); + paxwarn(1, "Interactive rename table out of memory"); return(-1); } @@ -621,7 +621,7 @@ add_name(oname, onamelen, nname) * new name (oname is the link to name) */ -#if __STDC__ +#ifdef __STDC__ void sub_name(register char *oname, int *onamelen) #else @@ -645,7 +645,7 @@ sub_name(oname, onamelen) while (pt != NULL) { /* - * walk down the hash cahin looking for a match + * walk down the hash chain looking for a match */ if (strcmp(oname, pt->oname) == 0) { /* @@ -712,7 +712,7 @@ sub_name(oname, onamelen) * 0 if successful, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int dev_start(void) #else @@ -723,7 +723,7 @@ dev_start() if (dtab != NULL) return(0); if ((dtab = (DEVT **)calloc(D_TAB_SZ, sizeof(DEVT *))) == NULL) { - pax_warn(1, "Cannot allocate memory for device mapping table"); + paxwarn(1, "Cannot allocate memory for device mapping table"); return(-1); } return(0); @@ -739,7 +739,7 @@ dev_start() * 0 if added ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int add_dev(register ARCHD *arcn) #else @@ -766,7 +766,7 @@ add_dev(arcn) * is returned (indicates an error). */ -#if __STDC__ +#ifdef __STDC__ static DEVT * chk_dev(dev_t dev, int add) #else @@ -809,7 +809,7 @@ chk_dev(dev, add) * list must be NULL. */ if ((pt = (DEVT *)malloc(sizeof(DEVT))) == NULL) { - pax_warn(1, "Device map table out of memory"); + paxwarn(1, "Device map table out of memory"); return(NULL); } pt->dev = dev; @@ -831,7 +831,7 @@ chk_dev(dev, add) * 0 if all ok, -1 otherwise. */ -#if __STDC__ +#ifdef __STDC__ int map_dev(register ARCHD *arcn, u_long dev_mask, u_long ino_mask) #else @@ -951,9 +951,9 @@ map_dev(arcn, dev_mask, ino_mask) return(0); bad: - pax_warn(1, "Unable to fix truncated inode/device field when storing %s", + paxwarn(1, "Unable to fix truncated inode/device field when storing %s", arcn->name); - pax_warn(0, "Archive may create improper hard links when extracted"); + paxwarn(0, "Archive may create improper hard links when extracted"); return(0); } @@ -981,7 +981,7 @@ map_dev(arcn, dev_mask, ino_mask) * 0 is created ok, -1 otherwise. */ -#if __STDC__ +#ifdef __STDC__ int atdir_start(void) #else @@ -992,7 +992,7 @@ atdir_start() if (atab != NULL) return(0); if ((atab = (ATDIR **)calloc(A_TAB_SZ, sizeof(ATDIR *))) == NULL) { - pax_warn(1,"Cannot allocate space for directory access time table"); + paxwarn(1,"Cannot allocate space for directory access time table"); return(-1); } return(0); @@ -1006,7 +1006,7 @@ atdir_start() * entries are for directories READ by pax */ -#if __STDC__ +#ifdef __STDC__ void atdir_end(void) #else @@ -1042,7 +1042,7 @@ atdir_end() * and chained by inode number. This is for directories READ by pax */ -#if __STDC__ +#ifdef __STDC__ void add_atdir(char *fname, dev_t dev, ino_t ino, time_t mtime, time_t atime) #else @@ -1099,7 +1099,7 @@ add_atdir(fname, dev, ino, mtime, atime) (void)free((char *)pt); } - pax_warn(1, "Directory access time reset table ran out of memory"); + paxwarn(1, "Directory access time reset table ran out of memory"); return; } @@ -1114,7 +1114,7 @@ add_atdir(fname, dev, ino, mtime, atime) * 0 if found, -1 if not found. */ -#if __STDC__ +#ifdef __STDC__ int get_atdir(dev_t dev, ino_t ino, time_t *mtime, time_t *atime) #else @@ -1198,7 +1198,7 @@ get_atdir(dev, ino, mtime, atime) * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int dir_start(void) #else @@ -1217,7 +1217,7 @@ dir_start() (void)unlink(tempfile); return(0); } - pax_warn(1, "Unable to create temporary file for directory times: %s", + paxwarn(1, "Unable to create temporary file for directory times: %s", tempfile); return(-1); } @@ -1235,7 +1235,7 @@ dir_start() * pax spec) */ -#if __STDC__ +#ifdef __STDC__ void add_dir(char *name, int nlen, struct stat *psb, int frc_mode) #else @@ -1257,7 +1257,7 @@ add_dir(name, nlen, psb, frc_mode) * in the trailer */ if ((dblk.npos = lseek(dirfd, 0L, SEEK_CUR)) < 0) { - pax_warn(1,"Unable to store mode and times for directory: %s",name); + paxwarn(1,"Unable to store mode and times for directory: %s",name); return; } @@ -1275,7 +1275,7 @@ add_dir(name, nlen, psb, frc_mode) return; } - pax_warn(1,"Unable to store mode and times for created directory: %s",name); + paxwarn(1,"Unable to store mode and times for created directory: %s",name); return; } @@ -1285,7 +1285,7 @@ add_dir(name, nlen, psb, frc_mode) * by pax */ -#if __STDC__ +#ifdef __STDC__ void proc_dir(void) #else @@ -1331,7 +1331,7 @@ proc_dir() (void)close(dirfd); dirfd = -1; if (cnt != dircnt) - pax_warn(1,"Unable to set mode and times for created directories"); + paxwarn(1,"Unable to set mode and times for created directories"); return; } @@ -1353,7 +1353,7 @@ proc_dir() * the hash value of the string MOD (%) the table size. */ -#if __STDC__ +#ifdef __STDC__ u_int st_hash(char *name, int len, int tabsz) #else diff --git a/bin/pax/tar.c b/bin/pax/tar.c index f5415f4f74ae..c6d5b89f83fd 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -78,7 +78,7 @@ static int tar_nodir; /* do not write dirs under old tar */ * 0 if ok, -1 otherwise (what wr_skip returns) */ -#if __STDC__ +#ifdef __STDC__ int tar_endwr(void) #else @@ -96,7 +96,7 @@ tar_endwr() * size of trailer (2 * BLKMULT) */ -#if __STDC__ +#ifdef __STDC__ off_t tar_endrd(void) #else @@ -118,7 +118,7 @@ tar_endrd() * could never contain a header. */ -#if __STDC__ +#ifdef __STDC__ int tar_trail(register char *buf, register int in_resync, register int *cnt) #else @@ -169,7 +169,7 @@ tar_trail(buf, in_resync, cnt) * 0 if the number fit into the string, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ static int ul_oct(u_long val, register char *str, register int len, int term) #else @@ -233,7 +233,7 @@ ul_oct(val, str, len, term) * 0 if the number fit into the string, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ static int uqd_oct(u_quad_t val, register char *str, register int len, int term) #else @@ -296,7 +296,7 @@ uqd_oct(val, str, len, term) * unsigned long checksum */ -#if __STDC__ +#ifdef __STDC__ static u_long tar_chksm(register char *blk, register int len) #else @@ -344,7 +344,7 @@ tar_chksm(blk, len) * 0 if a tar header, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int tar_id(register char *blk, int size) #else @@ -385,7 +385,7 @@ tar_id(blk, size) * 0 if ok -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int tar_opt(void) #else @@ -398,9 +398,9 @@ tar_opt() while ((opt = opt_next()) != NULL) { if (strcmp(opt->name, TAR_OPTION) || strcmp(opt->value, TAR_NODIR)) { - pax_warn(1, "Unknown tar format -o option/value pair %s=%s", + paxwarn(1, "Unknown tar format -o option/value pair %s=%s", opt->name, opt->value); - pax_warn(1,"%s=%s is the only supported tar format option", + paxwarn(1,"%s=%s is the only supported tar format option", TAR_OPTION, TAR_NODIR); return(-1); } @@ -409,7 +409,7 @@ tar_opt() * we only support one option, and only when writing */ if ((act != APPND) && (act != ARCHIVE)) { - pax_warn(1, "%s=%s is only supported when writing.", + paxwarn(1, "%s=%s is only supported when writing.", opt->name, opt->value); return(-1); } @@ -427,7 +427,7 @@ tar_opt() * 0 */ -#if __STDC__ +#ifdef __STDC__ int tar_rd(register ARCHD *arcn, register char *buf) #else @@ -550,7 +550,7 @@ tar_rd(arcn, buf) * data to write after the header, -1 if archive write failed */ -#if __STDC__ +#ifdef __STDC__ int tar_wr(register ARCHD *arcn) #else @@ -575,23 +575,23 @@ tar_wr(arcn) return(1); break; case PAX_CHR: - pax_warn(1, "Tar cannot archive a character device %s", + paxwarn(1, "Tar cannot archive a character device %s", arcn->org_name); return(1); case PAX_BLK: - pax_warn(1, "Tar cannot archive a block device %s", arcn->org_name); + paxwarn(1, "Tar cannot archive a block device %s", arcn->org_name); return(1); case PAX_SCK: - pax_warn(1, "Tar cannot archive a socket %s", arcn->org_name); + paxwarn(1, "Tar cannot archive a socket %s", arcn->org_name); return(1); case PAX_FIF: - pax_warn(1, "Tar cannot archive a fifo %s", arcn->org_name); + paxwarn(1, "Tar cannot archive a fifo %s", arcn->org_name); return(1); case PAX_SLK: case PAX_HLK: case PAX_HRG: if (arcn->ln_nlen > sizeof(hd->linkname)) { - pax_warn(1,"Link name too long for tar %s", arcn->ln_name); + paxwarn(1,"Link name too long for tar %s", arcn->ln_name); return(1); } break; @@ -608,7 +608,7 @@ tar_wr(arcn) if (arcn->type == PAX_DIR) ++len; if (len > sizeof(hd->name)) { - pax_warn(1, "File name too long for tar %s", arcn->name); + paxwarn(1, "File name too long for tar %s", arcn->name); return(1); } @@ -631,7 +631,7 @@ tar_wr(arcn) * dirs, so no pad. */ hd->linkflag = AREGTYPE; - bzero(hd->linkname, sizeof(hd->linkname)); + memset(hd->linkname, 0, sizeof(hd->linkname)); hd->name[len-1] = '/'; if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 1)) goto out; @@ -656,7 +656,7 @@ tar_wr(arcn) * data follows this file, so set the pad */ hd->linkflag = AREGTYPE; - bzero(hd->linkname, sizeof(hd->linkname)); + memset(hd->linkname, 0, sizeof(hd->linkname)); # ifdef NET2_STAT if (ul_oct((u_long)arcn->sb.st_size, hd->size, sizeof(hd->size), 1)) { @@ -664,7 +664,7 @@ tar_wr(arcn) if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size, sizeof(hd->size), 1)) { # endif - pax_warn(1,"File is too large for tar %s", arcn->org_name); + paxwarn(1,"File is too large for tar %s", arcn->org_name); return(1); } arcn->pad = TAR_PAD(arcn->sb.st_size); @@ -699,7 +699,7 @@ tar_wr(arcn) /* * header field is out of range */ - pax_warn(1, "Tar header field is too small for %s", arcn->org_name); + paxwarn(1, "Tar header field is too small for %s", arcn->org_name); return(1); } @@ -714,7 +714,7 @@ tar_wr(arcn) * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int ustar_strd(void) #else @@ -734,7 +734,7 @@ ustar_strd() * 0 if ok, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int ustar_stwr(void) #else @@ -755,7 +755,7 @@ ustar_stwr() * 0 if a ustar header, -1 otherwise */ -#if __STDC__ +#ifdef __STDC__ int ustar_id(char *blk, int size) #else @@ -794,7 +794,7 @@ ustar_id(blk, size) * 0 */ -#if __STDC__ +#ifdef __STDC__ int ustar_rd(register ARCHD *arcn, register char *buf) #else @@ -952,7 +952,7 @@ ustar_rd(arcn, buf) * data to write after the header, -1 if archive write failed */ -#if __STDC__ +#ifdef __STDC__ int ustar_wr(register ARCHD *arcn) #else @@ -969,7 +969,7 @@ ustar_wr(arcn) * check for those file system types ustar cannot store */ if (arcn->type == PAX_SCK) { - pax_warn(1, "Ustar cannot archive a socket %s", arcn->org_name); + paxwarn(1, "Ustar cannot archive a socket %s", arcn->org_name); return(1); } @@ -978,7 +978,7 @@ ustar_wr(arcn) */ if (((arcn->type == PAX_SLK) || (arcn->type == PAX_HLK) || (arcn->type == PAX_HRG)) && (arcn->ln_nlen >= sizeof(hd->linkname))){ - pax_warn(1, "Link name too long for ustar %s", arcn->ln_name); + paxwarn(1, "Link name too long for ustar %s", arcn->ln_name); return(1); } @@ -987,7 +987,7 @@ ustar_wr(arcn) * pt != arcn->name, the name has to be split */ if ((pt = name_split(arcn->name, arcn->nlen)) == NULL) { - pax_warn(1, "File name too long for ustar %s", arcn->name); + paxwarn(1, "File name too long for ustar %s", arcn->name); return(1); } hd = (HD_USTAR *)hdblk; @@ -1005,7 +1005,7 @@ ustar_wr(arcn) zf_strncpy(hd->prefix, arcn->name, sizeof(hd->prefix)); *pt++ = '/'; } else - bzero(hd->prefix, sizeof(hd->prefix)); + memset(hd->prefix, 0, sizeof(hd->prefix)); /* * copy the name part. this may be the whole path or the part after @@ -1019,9 +1019,9 @@ ustar_wr(arcn) switch(arcn->type) { case PAX_DIR: hd->typeflag = DIRTYPE; - bzero(hd->linkname, sizeof(hd->linkname)); - bzero(hd->devmajor, sizeof(hd->devmajor)); - bzero(hd->devminor, sizeof(hd->devminor)); + memset(hd->linkname, 0, sizeof(hd->linkname)); + memset(hd->devmajor, 0, sizeof(hd->devmajor)); + memset(hd->devminor, 0, sizeof(hd->devminor)); if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) goto out; break; @@ -1031,7 +1031,7 @@ ustar_wr(arcn) hd->typeflag = CHRTYPE; else hd->typeflag = BLKTYPE; - bzero(hd->linkname, sizeof(hd->linkname)); + memset(hd->linkname, 0, sizeof(hd->linkname)); if (ul_oct((u_long)MAJOR(arcn->sb.st_rdev), hd->devmajor, sizeof(hd->devmajor), 3) || ul_oct((u_long)MINOR(arcn->sb.st_rdev), hd->devminor, @@ -1041,9 +1041,9 @@ ustar_wr(arcn) break; case PAX_FIF: hd->typeflag = FIFOTYPE; - bzero(hd->linkname, sizeof(hd->linkname)); - bzero(hd->devmajor, sizeof(hd->devmajor)); - bzero(hd->devminor, sizeof(hd->devminor)); + memset(hd->linkname, 0, sizeof(hd->linkname)); + memset(hd->devmajor, 0, sizeof(hd->devmajor)); + memset(hd->devminor, 0, sizeof(hd->devminor)); if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) goto out; break; @@ -1055,8 +1055,8 @@ ustar_wr(arcn) else hd->typeflag = LNKTYPE; zf_strncpy(hd->linkname,arcn->ln_name, sizeof(hd->linkname)); - bzero(hd->devmajor, sizeof(hd->devmajor)); - bzero(hd->devminor, sizeof(hd->devminor)); + memset(hd->devmajor, 0, sizeof(hd->devmajor)); + memset(hd->devminor, 0, sizeof(hd->devminor)); if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) goto out; break; @@ -1070,9 +1070,9 @@ ustar_wr(arcn) hd->typeflag = CONTTYPE; else hd->typeflag = REGTYPE; - bzero(hd->linkname, sizeof(hd->linkname)); - bzero(hd->devmajor, sizeof(hd->devmajor)); - bzero(hd->devminor, sizeof(hd->devminor)); + memset(hd->linkname, 0, sizeof(hd->linkname)); + memset(hd->devmajor, 0, sizeof(hd->devmajor)); + memset(hd->devminor, 0, sizeof(hd->devminor)); arcn->pad = TAR_PAD(arcn->sb.st_size); # ifdef NET2_STAT if (ul_oct((u_long)arcn->sb.st_size, hd->size, @@ -1081,7 +1081,7 @@ ustar_wr(arcn) if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size, sizeof(hd->size), 3)) { # endif - pax_warn(1,"File is too long for ustar %s",arcn->org_name); + paxwarn(1,"File is too long for ustar %s",arcn->org_name); return(1); } break; @@ -1122,7 +1122,7 @@ ustar_wr(arcn) /* * header field is out of range */ - pax_warn(1, "Ustar header field is too small for %s", arcn->org_name); + paxwarn(1, "Ustar header field is too small for %s", arcn->org_name); return(1); } @@ -1138,7 +1138,7 @@ ustar_wr(arcn) * the file name is too long */ -#if __STDC__ +#ifdef __STDC__ static char * name_split(register char *name, register int len) #else diff --git a/bin/pax/tty_subs.c b/bin/pax/tty_subs.c index 805567c05e71..f4df26575792 100644 --- a/bin/pax/tty_subs.c +++ b/bin/pax/tty_subs.c @@ -52,7 +52,7 @@ static const char rcsid[] = #include #include "pax.h" #include "extern.h" -#if __STDC__ +#ifdef __STDC__ #include #else #include @@ -72,7 +72,7 @@ static FILE *ttyinf = NULL; /* input pointing at control tty */ * open fails, future ops that require user input will get an EOF */ -#if __STDC__ +#ifdef __STDC__ int tty_init(void) #else @@ -92,7 +92,7 @@ tty_init() } if (iflag) { - pax_warn(1, "Fatal error, cannot open %s", DEVTTY); + paxwarn(1, "Fatal error, cannot open %s", DEVTTY); return(-1); } return(0); @@ -104,7 +104,7 @@ tty_init() * if there is no controlling terminal, just return. */ -#if __STDC__ +#ifdef __STDC__ void tty_prnt(const char *fmt, ...) #else @@ -115,7 +115,7 @@ tty_prnt(fmt, va_alist) #endif { va_list ap; -# if __STDC__ +# ifdef __STDC__ va_start(ap, fmt); # else va_start(ap); @@ -135,7 +135,7 @@ tty_prnt(fmt, va_alist) * 0 if data was read, -1 otherwise. */ -#if __STDC__ +#ifdef __STDC__ int tty_read(char *str, int len) #else @@ -160,24 +160,24 @@ tty_read(str, len) } /* - * pax_warn() - * write a pax_warning message to stderr. if "set" the exit value of pax + * paxwarn() + * write a warning message to stderr. if "set" the exit value of pax * will be non-zero. */ -#if __STDC__ +#ifdef __STDC__ void -pax_warn(int set, const char *fmt, ...) +paxwarn(int set, const char *fmt, ...) #else void -pax_warn(set, fmt, va_alist) +paxwarn(set, fmt, va_alist) int set; const char *fmt; va_dcl #endif { va_list ap; -# if __STDC__ +# ifdef __STDC__ va_start(ap, fmt); # else va_start(ap); @@ -199,17 +199,17 @@ pax_warn(set, fmt, va_alist) } /* - * sys_warn() - * write a pax_warning message to stderr. if "set" the exit value of pax + * syswarn() + * write a warning message to stderr. if "set" the exit value of pax * will be non-zero. */ -#if __STDC__ +#ifdef __STDC__ void -sys_warn(int set, int errnum, const char *fmt, ...) +syswarn(int set, int errnum, const char *fmt, ...) #else void -sys_warn(set, errnum, fmt, va_alist) +syswarn(set, errnum, fmt, va_alist) int set; int errnum; const char *fmt; @@ -217,7 +217,7 @@ sys_warn(set, errnum, fmt, va_alist) #endif { va_list ap; -# if __STDC__ +# ifdef __STDC__ va_start(ap, fmt); # else va_start(ap); @@ -240,6 +240,6 @@ sys_warn(set, errnum, fmt, va_alist) * format and print the errno */ if (errnum > 0) - (void)fprintf(stderr, " <%s>", sys_errlist[errnum]); + (void)fprintf(stderr, " <%s>", strerror(errnum)); (void)fputc('\n', stderr); }