--- /dev/null
+# Configuration file for git-buildpackage and friends
+
+[DEFAULT]
+# the default build command:
+#builder = debuild -i\.git/ -I.git
+# the default clean command:
+#cleaner = debuild clean
+# the default branch for upstream sources:
+upstream-branch = upstream
+# the default branch for the debian patch:
+debian-branch = master
+# the default tag formats used:
+#upstream-tag = upstream/%(version)s
+#debian-tag = debian/%(version)s
+# use pristine-tar:
+pristine-tar = True
+
+# Options only affecting git-buildpackage
+[git-buildpackage]
+#upstream-branch = dfsgclean
+# uncomment this to automatically GPG sign tags
+#sign-tags = True
+# keyid to GPG sign tags with
+#keyid = 0xdeadbeef
+# push to a remote repository after a successful tag:
+posttag = git push --mirror
+# use this for more svn-buildpackage like behaviour:
+export-dir = ../build-area/pax/
+#tarball-dir = ../tarballs/
+
+# Options only affecting git-import-orig
+[git-import-orig]
+#upstream-branch = newupstream
+#debian-branch = dfsgclean
+#filter = .svn
+
+# Options only affecting git-import-dsc
+[git-import-dsc]
+#upstream-branch = svn-upstream
+#filter = [ 'CVS', '.cvsignore' ]
+
+# Options only affecting git-dch
+[git-dch]
+#git-log = --no-merges
+#snapshot-number = snapshot + 1
+
PROG= pax
SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
- tar.c tty_subs.c
-MAN= pax.1 tar.1 cpio.1
-LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio
+ tar.c tty_subs.c fgetln.c strmode.c strlcpy.c vis.c
+OBJS= $(SRCS:.c=.o)
+MAN= pax.1
-.include <bsd.prog.mk>
+CFLAGS= -Wall -O2 -g\
+ -DNET2_STAT -D_PATH_DEFTAPE=\"/dev/rmt0\" -DDEBIAN -D_GNU_SOURCE
+
+prefix=/usr/local
+
+pax: $(OBJS)
+ $(CC) $(CFLAGS) $(OBJS) -o $@ $(LIBS)
+
+clean:
+ $(RM) *.o
+
+realclean: clean
+ $(RM) $(PROG)
+
+install:
+ install -d -m 755 $(prefix)/bin $(prefix)/share/man/man1
+ install -s -m 755 $(PROG) $(prefix)/bin
+ install -m 644 $(MAN) $(prefix)/share/man/man1
--- /dev/null
+# $OpenBSD: Makefile,v 1.9 1997/09/21 11:35:28 deraadt Exp $
+
+# To install on versions prior to BSD 4.4 the following may have to be
+# defined with CFLAGS +=
+#
+# -DNET2_STAT Use NET2 or older stat structure. The version of the
+# stat structure is easily determined by looking at the
+# basic type of an off_t (often defined in the file:
+# /usr/include/sys/types.h). If off_t is a long (and is
+# NOT A quad) then you must define NET2_STAT.
+# This define is important, as if you do have a quad_t
+# off_t and define NET2_STAT, pax will compile but will
+# NOT RUN PROPERLY.
+#
+# -DNET2_FTS Use the older NET2 fts. To identify the version,
+# examine the file: /usr/include/fts.h. If FTS_COMFOLLOW
+# is not defined then you must define NET2_FTS.
+# Pax may not compile if this not (un)defined properly.
+#
+# -DNET2_REGEX Use the older regexp.h not regex.h. The regex version
+# is determined by looking at the value returned by
+# regexec() (man 3 regexec). If regexec return a 1 for
+# success (and NOT a 0 for success) you have the older
+# regex routines and must define NET2_REGEX.
+# Pax may not compile if this not (un)defined properly.
+
+PROG= pax
+SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
+ gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
+ tar.c tty_subs.c
+MAN= pax.1 tar.1 cpio.1
+LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio
+
+.include <bsd.prog.mk>
/*
* ar_start_gzip()
- * starts the gzip compression/decompression process as a child, using magic
- * to keep the fd the same in the calling function (parent).
+ * starts the compress, gzip or bzip2 compression/decompression process
+ * as a child, using magic to keep the fd the same in the calling function
+ * (parent).
*/
void
ar_start_gzip(int fd, const char *gzip_program, int wr)
#include <sys/types.h>
#include <sys/time.h>
+#include <time.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <signal.h>
* No entry for this uid, we will add it
*/
if (!pwopn) {
+#ifdef DEBIAN
+ setpwent();
+#else
setpassent(1);
+#endif
++pwopn;
}
if (ptr == NULL)
* No entry for this gid, we will add it
*/
if (!gropn) {
+#ifdef DEBIAN
+ setgrent();
+#else
setgroupent(1);
+#endif
++gropn;
}
if (ptr == NULL)
}
if (!pwopn) {
+#ifdef DEBIAN
+ setpwent();
+#else
setpassent(1);
+#endif
++pwopn;
}
}
if (!gropn) {
+#ifdef DEBIAN
+ setgrent();
+#else
setgroupent(1);
+#endif
++gropn;
}
if (ptr == NULL)
#endif /* not lint */
#include <sys/types.h>
+#include <sys/sysmacros.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/param.h>
--- /dev/null
+pax (1:20090728-1) UNRELEASED; urgency=low
+
+ * new upstream version synthesized from OpenBSD CVS HEAD,
+ closes: #434470, #277738
+
+ -- Bdale Garbee <bdale@gag.com> Mon, 11 Aug 2008 17:58:52 -0300
+
+pax (1:1.5-16) unstable; urgency=low
+
+ * patch for -s irregularities from Stephane Chazelas, closes: #451361
+ * clean up various lintian warnings
+
+ -- Bdale Garbee <bdale@gag.com> Tue, 11 Dec 2007 23:13:03 -0700
+
+pax (1:1.5-15) unstable; urgency=low
+
+ * update priority in control file to match override
+ * patch to fix archiving of 100 byte pathnames, closes: #191127
+ * patch to fix full prefix field in ustar format, closes: #201768
+
+ -- Bdale Garbee <bdale@gag.com> Sun, 30 May 2004 00:48:29 -0300
+
+pax (1:1.5-14) unstable; urgency=low
+
+ * merge bzip2 support patch from Stephen Williams, closes: #178995
+
+ -- Bdale Garbee <bdale@gag.com> Tue, 18 Feb 2003 01:20:50 -0700
+
+pax (1:1.5-13) unstable; urgency=low
+
+ * apply patch from Anthony Towns to fix minor POSIX incompliance observed
+ during LSB certification work, closes: #139943
+
+ -- Bdale Garbee <bdale@gag.com> Thu, 15 Aug 2002 14:56:57 -0600
+
+pax (1:1.5-12) unstable; urgency=low
+
+ * apply patch from Adam Heath for off-by-one error in tar.c when a file
+ has a long name, and the prefix is being filled for a posix tar header.
+ The last byte in the prefix wasn't being set to \0, closes: #128980
+ * minor cosmetic changes to debian/ files
+
+ -- Bdale Garbee <bdale@gag.com> Mon, 14 Jan 2002 13:58:46 -0700
+
+pax (1:1.5-11) unstable; urgency=low
+
+ * change man page to fix references to POSIX standard, closes: #97839
+
+ -- Bdale Garbee <bdale@gag.com> Tue, 1 Jan 2002 09:43:00 -0700
+
+pax (1:1.5-10) unstable; urgency=low
+
+ * undo #if DEBIAN clause in file_subs.c that forced used of chown instead
+ of lchown, since it's not necessary with modern kernels and causes other
+ problems, closes: #110253
+ * get rid of suidregister stuff, update standards version, etc
+
+ -- Bdale Garbee <bdale@gag.com> Sun, 30 Dec 2001 20:42:33 -0700
+
+pax (1:1.5-9) unstable; urgency=low
+
+ * trim extended description since paxutils is still not out, closes: #79035
+ * fix sys/time.h + time.h inclusion problems, closes: #100790, #105191
+
+ -- Bdale Garbee <bdale@gag.com> Sun, 22 Jul 2001 23:20:46 -0600
+
+pax (1:1.5-8) stable unstable; urgency=low
+
+ * oops. rebuild with appropriate libraries for potato, closes: #75012
+
+ -- Bdale Garbee <bdale@gag.com> Fri, 20 Oct 2000 12:16:17 -0600
+
+pax (1:1.5-7) stable unstable; urgency=low
+
+ * apply patch from Geoff Clare <geoff@gclare.org.uk> that fixes problem with
+ "full" name fields in ustar format. Target stable since this can cause
+ file loss under some circumstances. Closes: #71644
+
+ -- Bdale Garbee <bdale@gag.com> Sun, 15 Oct 2000 23:25:49 -0600
+
+pax (1:1.5-6) unstable; urgency=low
+
+ * update to latest standards, add Build-Depends, get FHS'ed
+
+ -- Bdale Garbee <bdale@gag.com> Fri, 7 Jan 2000 20:39:46 -0700
+
+pax (1:1.5-5) unstable; urgency=low
+
+ * patches from Roman Hodek to include <sys/sysmacros.h> for glibc2.1,
+ closes 41656.
+
+ -- Bdale Garbee <bdale@gag.com> Mon, 2 Aug 1999 01:51:03 -0600
+
+pax (1:1.5-4) unstable; urgency=low
+
+ * hack to fix compile problems with glibc-2.1, closes 34668
+
+ -- Bdale Garbee <bdale@gag.com> Mon, 24 May 1999 23:45:16 -0600
+
+pax (1:1.5-3) unstable; urgency=low
+
+ * new maintainer
+ * freshen to pick up changes in latest OpenBSD pax source, and to get back
+ to an upstream orig and Debian diffs configuration
+ * rewrite rules file to use debhelper
+ * update long description to indicate that this package will eventually
+ be obsoleted by paxutils, a pre-release of which I'm working with now
+
+ -- Bdale Garbee <bdale@gag.com> Wed, 2 Dec 1998 21:21:57 -0700
+
+pax (1:1.5-2) unstable; urgency=low
+
+ * changed Maintainer address to official and working Debian address
+
+ * renamed md5sum to md5sums.
+
+ -- David Frey <dfrey@debian.org> Fri, 13 Feb 1998 23:15:39 +0100
+
+pax (1:1.5-1) unstable; urgency=low
+
+ * Initial Release of the OpenBSD's pax program from Keith Muller
+
+ -- David Frey <dFrey@debian.org> Wed, 10 Dec 1997 12:57:48 +0100
--- /dev/null
+Source: pax
+Section: utils
+Priority: optional
+Maintainer: Bdale Garbee <bdale@gag.com>
+Build-Depends: debhelper (>= 5)
+Standards-Version: 3.8.0
+
+Package: pax
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: Portable Archive Interchange
+ Pax is an archiving utility that reads and writes tar and cpio formats,
+ both the traditional ones and the extended formats specified in IEEE 1003.1.
+ It handles multi-volume archives and automatically determines the format
+ of an archive while reading it. Three user interfaces are
+ supported: tar, cpio, and pax. The pax interface was designed by IEEE
+ 1003.2 as a compromise in the chronic controversy over which of tar or
+ cpio is best.
+ .
+ This is the free OpenBSD's version written by Keith Muller.
--- /dev/null
+This package was debianized by David Frey <dfrey@debian.org> on
+Wed Dec 10 19:01:25 CET 1997.
+
+Pax was downloaded from ftp://ftp.openbsd.org/pub/OpenBSD/src/bin/pax/
+
+Copyright:
+
+the pax program:
+ * Copyright (c) 1992 Keith Muller.
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Keith Muller of the University of California, San Diego.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+
+strmode.c was copied from FreeBSD 2.1.5:
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+
+fgetln.c was donated by Andrew Dougherty and has the following
+copyright notice (the original BSD fgetln is not portable):
+
+ This fgetline implementation was written by Andrew Dougherty
+ <doughera@lafayette.edu>. I hearby place it in the public domain.
+ As a courtesy, please leave my name attached to the source.
+
+ This code comes with no warranty whatsoever, and I take no
+ responsibility for any consequences of its use.
+
+The rest (adding the packaging information, rewriting the Makefile etc)
+was done by me, David Frey and is in the public domain.
--- /dev/null
+#!/usr/bin/make -f
+
+# comment this to turn off verbose mode.
+export DH_VERBOSE=1
+
+build: build-stamp
+build-stamp:
+ dh_testdir
+
+ $(MAKE)
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp install-stamp
+
+ [ ! -f Makefile ] || $(MAKE) realclean
+
+ dh_clean
+
+install: install-stamp
+install-stamp: build-stamp
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ $(MAKE) prefix=`pwd`/debian/pax/usr install
+
+ touch install-stamp
+
+# Build architecture-independent files here.
+binary-indep: build install
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_installexamples
+ dh_installmenu
+ dh_installcron
+ dh_installmanpages cpio.1 tar.1
+ dh_installchangelogs
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+source diff:
+ @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
--- /dev/null
+/* fgetline: Read one line of input and return a pointer to
+ that line. Necessary space is obtained from malloc.
+ (char *) NULL is returned on EOF.
+
+ Andy Dougherty doughera@lafcol.lafayette.edu
+ Dept. of Physics
+ Lafayette College, Easton PA 18042
+
+ Successive calls to fgetline() overwrite the original buffer.
+ If you want to preserve the data, you must do something like
+ the following (the +1's are for '\0' characters):
+
+ tmp = fgetline(fp);
+ ntmp = Ealloc(strlen(tmp)+1, sizeof(char));
+ strncpy(ntmp, tmp, strlen(tmp)+1);
+
+ A line is defined as all characters up to (and including) the next
+ newline character or end of file.
+ The string is terminated by a NULL character.
+
+ * Version 1.1 A. Dougherty 2/7/94
+ Don't call realloc() just to save a few bytes.
+ Check return value from realloc(). (NULL is allowed under POSIX,
+ though I've never hit it.)
+
+ * Version 1.0 A. Dougherty 2/27/91
+
+ This fgetline implementation was written by Andrew Dougherty
+ <doughera@lafayette.edu>. I hearby place it in the public domain.
+ As a courtesy, please leave my name attached to the source.
+
+ This code comes with no warranty whatsoever, and I take no
+ responsibility for any consequences of its use.
+*/
+
+/* Algorithm: A local static buffer "buf" is maintained. The current
+ length (space available) is in the static variable "avail".
+ Read in characters into this buffer. If need more space, call
+ malloc().
+
+ Aside: We have computed strlen(buf) in this function. It
+ seems a shame to throw it away.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#define LINELEN 128 /* A decent guess that should only rarely be
+ overwritten.
+ */
+#define OK_TO_WASTE 512 /* Don't bother trying to realloc() back to
+ a smaller buffer if you'd only end up
+ wasting OK_TO_WASTE bytes.
+ */
+
+void *Emalloc(size_t len) /* David */
+{
+ char *p;
+
+ p=malloc(len);
+ if (p == NULL) {
+ perror("out of memory (Emalloc)");
+ exit(2);
+
+ }
+ return p;
+}
+
+void *Erealloc(char *p, size_t len) /* David */
+{
+ p=realloc(p, len);
+ if (p == NULL) {
+ perror("out of memory (Erealloc)");
+ exit(2);
+
+ }
+ return p;
+}
+
+char *
+fgetln(FILE *fp, size_t *length)
+ {
+ static char *buf = NULL;
+ static size_t avail = 0;
+ int c;
+ char *p; /* Temporary used for reducing length. */
+ int len;
+
+ if (avail == 0)
+ {
+ buf = (char *) Emalloc(LINELEN * sizeof(char));
+ avail = LINELEN;
+ }
+
+ len = 0; /* Current length */
+
+ while ((c=getc(fp)) != EOF)
+ {
+ if (len >= avail) /* Need to ask for space */
+ {
+ avail += LINELEN; /* Maybe avail *= 2 would be better */
+ buf = (char *) Erealloc((void *) buf, avail * sizeof(char));
+ }
+ buf[len] = c;
+ len++;
+ if (c == '\n')
+ break;
+ }
+
+ if (c == EOF && len == 0)
+ return (char *) NULL;
+
+ /* Add terminating '\0' character */
+ if (len >= avail) /* Need 1 more space */
+ buf = (char *) Erealloc((void *) buf, (len+1) * sizeof(char));
+ buf[len] = '\0';
+
+ /* Should we bother to try reclaiming memory? (Otherwise, this
+ function will hold onto enough memory to hold the longest
+ line for the entire duration of the program.)
+ */
+ if (avail - len > OK_TO_WASTE)
+ {
+ p = (char *) Erealloc((void *) buf, (len+1) * sizeof(char));
+ if (p != NULL)
+ {
+ buf = p;
+ avail = len + 1;
+ }
+ }
+ *length=len-1;
+ return buf;
+ }
--- /dev/null
+/* fgetline: Read one line of input and return a pointer to
+ that line. Necessary space is obtained from malloc.
+ (char *) NULL is returned on EOF.
+
+ Andy Dougherty doughera@lafcol.lafayette.edu
+ Dept. of Physics
+ Lafayette College, Easton PA 18042
+
+ This fgetline implementation was written by Andrew Dougherty
+ <doughera@lafayette.edu>. I hearby place it in the public domain.
+ As a courtesy, please leave my name attached to the source.
+
+ This code comes with no warranty whatsoever, and I take no
+ responsibility for any consequences of its use.
+*/
+
+char *fgetln(FILE *fp, size_t *length);
#endif /* not lint */
#include <sys/types.h>
+#include <sys/sysmacros.h>
#include <sys/time.h>
+#include <time.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <stdio.h>
-#include <tzfile.h>
+#include "tzfile.h"
#include <utmp.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
-#include <vis.h>
+#include "vis.h"
#include "pax.h"
#include "extern.h"
+#include "strmode.h"
+
/*
* a collection of general purpose subroutines used by pax
*/
*/
#define MODELEN 20
#define DATELEN 64
+#define DAYSPERNYEAR 365
+/* #define SECSPERDAY 86400 */
+/* #define VIS_CSTYLE 0 */
#define SIXMONTHS ((DAYSPERNYEAR / 2) * SECSPERDAY)
#define CURFRMT "%b %e %H:%M"
#define OLDFRMT "%b %e %Y"
/*
* if printing to a tty, use vis(3) to print special characters.
*/
- if (isatty(fileno(fp))) {
+ if (0 && isatty(fileno(fp))) {
for (cp = str; *cp; cp++) {
(void)vis(visbuf, cp[0], VIS_CSTYLE, cp[1]);
(void)fputs(visbuf, fp);
#include "tar.h"
#include "extern.h"
+#include "fgetln.h" /* added, David */
+
/*
* Routines which handle command line options
*/
static void printflg(unsigned int);
static int c_frmt(const void *, const void *);
static off_t str_offt(char *);
-static char *getline(FILE *fp);
+static char *bsd_getline(FILE *fp);
static void pax_options(int, char **);
static void pax_usage(void);
static void tar_options(int, char **);
paxwarn(1, "Unable to open file '%s' for read", file);
tar_usage();
}
- while ((str = getline(fp)) != NULL) {
+ while ((str = bsd_getline(fp)) != NULL) {
if (pat_add(str, dir) < 0)
tar_usage();
sawpat = 1;
paxwarn(1, "Unable to open file '%s' for read", file);
tar_usage();
}
- while ((str = getline(fp)) != NULL) {
+ while ((str = bsd_getline(fp)) != NULL) {
if (ftree_add(str, 0) < 0)
tar_usage();
}
paxwarn(1, "Unable to open file '%s' for read", optarg);
cpio_usage();
}
- while ((str = getline(fp)) != NULL) {
+ while ((str = bsd_getline(fp)) != NULL) {
pat_add(str, NULL);
}
fclose(fp);
* no read errors allowed on updates/append operation!
*/
maxflt = 0;
- while ((str = getline(stdin)) != NULL) {
+ while ((str = bsd_getline(stdin)) != NULL) {
ftree_add(str, 0);
}
if (getline_error) {
if ((num == LONG_MAX) || (num <= 0) || (expr == val))
# else
num = strtoq(val, &expr, 0);
- if ((num == QUAD_MAX) || (num <= 0) || (expr == val))
+ if ((num == LLONG_MAX) || (num <= 0) || (expr == val))
# endif
return(0);
}
char *
-getline(FILE *f)
+bsd_getline(FILE *f)
{
char *name, *temp;
size_t len;
The
.Nm
utility is compliant with the
-.St -p1003.1-2008
+POSIX 1003.1-2008
specification.
.Pp
The flags
char *ltmfrmt; /* -v locale time format (if any) */
char *argv0; /* root of argv[0] */
sigset_t s_mask; /* signal mask for cleanup critical sect */
-FILE *listf = stderr; /* file pointer to print file list to */
+FILE *listf; /* file pointer to print file list to */
char *tempfile; /* tempfile to use for mkstemp(3) */
char *tempbase; /* basename of tempfile to use for mkstemp(3) */
char *tmpdir;
size_t tdlen;
+ /*
+ * On some systems, stderr is not a constant, so we initialize listf
+ * immediately to emulate the behavior.
+ */
+ listf=stderr;
+
/*
* Keep a reference to cwd, so we can always come back home.
*/
#define OCT 8
#define _PAX_ 1
#define _TFILE_BASE "paxXXXXXXXXXX"
+
+/* hack since we're pulling routines in from OpenBSD library to this dir */
+size_t strlcpy(char *, const char *, size_t);
+char * vis(char *, int, int, int);
+
#include <sys/types.h>
#include <sys/time.h>
+#include <time.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <tzfile.h>
+#include <time.h>
#include <unistd.h>
#include "pax.h"
#include "sel_subs.h"
#include "extern.h"
+#define TM_YEAR_BASE 1900
+
static int str_sec(const char *, time_t *);
static int usr_match(ARCHD *);
static int grp_match(ARCHD *);
--- /dev/null
+/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0) {
+ while (--n != 0) {
+ if ((*d++ = *s++) == '\0')
+ break;
+ }
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
--- /dev/null
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strmode.c 8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+
+void
+strmode(mode, p)
+ register mode_t mode;
+ register char *p;
+{
+ /* print type */
+ switch (mode & S_IFMT) {
+ case S_IFDIR: /* directory */
+ *p++ = 'd';
+ break;
+ case S_IFCHR: /* character special */
+ *p++ = 'c';
+ break;
+ case S_IFBLK: /* block special */
+ *p++ = 'b';
+ break;
+ case S_IFREG: /* regular */
+ *p++ = '-';
+ break;
+ case S_IFLNK: /* symbolic link */
+ *p++ = 'l';
+ break;
+ case S_IFSOCK: /* socket */
+ *p++ = 's';
+ break;
+#ifdef S_IFIFO
+ case S_IFIFO: /* fifo */
+ *p++ = 'p';
+ break;
+#endif
+ default: /* unknown */
+ *p++ = '?';
+ break;
+ }
+ /* usr */
+ if (mode & S_IRUSR)
+ *p++ = 'r';
+ else
+ *p++ = '-';
+ if (mode & S_IWUSR)
+ *p++ = 'w';
+ else
+ *p++ = '-';
+ switch (mode & (S_IXUSR | S_ISUID)) {
+ case 0:
+ *p++ = '-';
+ break;
+ case S_IXUSR:
+ *p++ = 'x';
+ break;
+ case S_ISUID:
+ *p++ = 'S';
+ break;
+ case S_IXUSR | S_ISUID:
+ *p++ = 's';
+ break;
+ }
+ /* group */
+ if (mode & S_IRGRP)
+ *p++ = 'r';
+ else
+ *p++ = '-';
+ if (mode & S_IWGRP)
+ *p++ = 'w';
+ else
+ *p++ = '-';
+ switch (mode & (S_IXGRP | S_ISGID)) {
+ case 0:
+ *p++ = '-';
+ break;
+ case S_IXGRP:
+ *p++ = 'x';
+ break;
+ case S_ISGID:
+ *p++ = 'S';
+ break;
+ case S_IXGRP | S_ISGID:
+ *p++ = 's';
+ break;
+ }
+ /* other */
+ if (mode & S_IROTH)
+ *p++ = 'r';
+ else
+ *p++ = '-';
+ if (mode & S_IWOTH)
+ *p++ = 'w';
+ else
+ *p++ = '-';
+ switch (mode & (S_IXOTH | S_ISVTX)) {
+ case 0:
+ *p++ = '-';
+ break;
+ case S_IXOTH:
+ *p++ = 'x';
+ break;
+ case S_ISVTX:
+ *p++ = 'T';
+ break;
+ case S_IXOTH | S_ISVTX:
+ *p++ = 't';
+ break;
+ }
+ *p++ = ' '; /* will be a '+' if ACL's implemented */
+ *p = '\0';
+}
--- /dev/null
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+void strmode(mode_t mode, char *p);
#endif /* not lint */
#include <sys/types.h>
+#include <sys/sysmacros.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/param.h>
/*
* see if the filename is split into two parts. if, so joint the parts.
* we copy the prefix first and add a / between the prefix and name.
+ *
+ * the length passed to l_strncpy must be the length of the field
+ * being copied *from*, since these fields are NOT null terminated
+ * when full. the destination buffer is plenty big enough to hold
+ * the longest supported ustar path length, so there's no need
+ * to check against that.
*/
dest = arcn->name;
if (*(hd->prefix) != '\0') {
--- /dev/null
+/*-
+ * Copyright (c) 1982, 1986, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)types.h 8.4 (Berkeley) 1/21/94
+ * $Id: types.h,v 1.1 2001-07-23 05:20:01 bdale Exp $
+ */
+
+#ifndef _SYS_TYPES_H_
+#define _SYS_TYPES_H_
+
+#include <sys/cdefs.h>
+
+/* Machine type dependent parameters. */
+#include <machine/endian.h>
+
+#ifndef _POSIX_SOURCE
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+typedef unsigned short ushort; /* Sys V compatibility */
+typedef unsigned int uint; /* Sys V compatibility */
+#endif
+
+typedef unsigned long long u_quad_t; /* quads */
+typedef long long quad_t;
+typedef quad_t * qaddr_t;
+
+typedef char * caddr_t; /* core address */
+typedef long daddr_t; /* disk address */
+typedef unsigned long dev_t; /* device number */
+typedef unsigned long fixpt_t; /* fixed point number */
+typedef unsigned long gid_t; /* group id */
+typedef unsigned long ino_t; /* inode number */
+typedef unsigned short mode_t; /* permissions */
+typedef unsigned short nlink_t; /* link count */
+typedef quad_t off_t; /* file offset */
+typedef long pid_t; /* process id */
+typedef long segsz_t; /* segment size */
+typedef long swblk_t; /* swap offset */
+typedef unsigned long uid_t; /* user id */
+
+/*
+ * This belongs in unistd.h, but is placed here to ensure that programs
+ * casting the second parameter of lseek to off_t will get the correct
+ * version of lseek.
+ */
+#ifndef KERNEL
+__BEGIN_DECLS
+off_t lseek __P((int, off_t, int));
+__END_DECLS
+#endif
+
+#ifndef _POSIX_SOURCE
+/*
+ * minor() gives a cookie instead of an index since we don't want to
+ * change the meanings of bits 0-15 or waste time and space shifting
+ * bits 16-31 for devices that don't use them.
+ */
+#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
+#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
+#define makedev(x,y) ((dev_t)(((x)<<8) | (y))) /* create dev_t */
+#endif
+
+#include <machine/ansi.h>
+#include <machine/types.h>
+
+#ifdef _BSD_CLOCK_T_
+typedef _BSD_CLOCK_T_ clock_t;
+#undef _BSD_CLOCK_T_
+#endif
+
+#ifdef _BSD_SIZE_T_
+typedef _BSD_SIZE_T_ size_t;
+#undef _BSD_SIZE_T_
+#endif
+
+#ifdef _BSD_SSIZE_T_
+typedef _BSD_SSIZE_T_ ssize_t;
+#undef _BSD_SSIZE_T_
+#endif
+
+#ifdef _BSD_TIME_T_
+typedef _BSD_TIME_T_ time_t;
+#undef _BSD_TIME_T_
+#endif
+
+#ifndef _POSIX_SOURCE
+#define NBBY 8 /* number of bits in a byte */
+
+/*
+ * Select uses bit masks of file descriptors in longs. These macros
+ * manipulate such bit fields (the filesystem macros use chars).
+ * FD_SETSIZE may be defined by the user, but the default here should
+ * be enough for most uses.
+ */
+#ifndef FD_SETSIZE
+#define FD_SETSIZE 256
+#endif
+
+typedef long fd_mask;
+#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
+
+#ifndef howmany
+#define howmany(x, y) (((x)+((y)-1))/(y))
+#endif
+
+typedef struct fd_set {
+ fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
+} fd_set;
+
+#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
+#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
+#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
+#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f)))
+#define FD_ZERO(p) bzero(p, sizeof(*(p)))
+
+#if defined(__STDC__) && defined(KERNEL)
+/*
+ * Forward structure declarations for function prototypes. We include the
+ * common structures that cross subsystem boundaries here; others are mostly
+ * used in the same place that the structure is defined.
+ */
+struct proc;
+struct pgrp;
+struct ucred;
+struct rusage;
+struct file;
+struct buf;
+struct tty;
+struct uio;
+#endif
+
+#endif /* !_POSIX_SOURCE */
+#endif /* !_SYS_TYPES_H_ */
--- /dev/null
+/*
+ * Ported to Linux's Second Extended File System as part of the
+ * dump and restore backup suit
+ * Remy Card <Remy.Card@freenix.fr>, 1994, 1995
+ *
+ */
+
+/*
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Arthur David Olson of the National Cancer Institute.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tzfile.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _TZFILE_H_
+#define _TZFILE_H_
+
+/*
+ * Information about time zone files.
+ */
+ /* Time zone object file directory */
+#define TZDIR "/usr/share/zoneinfo"
+#define TZDEFAULT "/etc/localtime"
+#define TZDEFRULES "posixrules"
+
+/*
+** Each file begins with. . .
+*/
+
+struct tzhead {
+ char tzh_reserved[24]; /* reserved for future use */
+ char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
+ char tzh_leapcnt[4]; /* coded number of leap seconds */
+ char tzh_timecnt[4]; /* coded number of transition times */
+ char tzh_typecnt[4]; /* coded number of local time types */
+ char tzh_charcnt[4]; /* coded number of abbr. chars */
+};
+
+/*
+** . . .followed by. . .
+**
+** tzh_timecnt (char [4])s coded transition times a la time(2)
+** tzh_timecnt (unsigned char)s types of local time starting at above
+** tzh_typecnt repetitions of
+** one (char [4]) coded GMT offset in seconds
+** one (unsigned char) used to set tm_isdst
+** one (unsigned char) that's an abbreviation list index
+** tzh_charcnt (char)s '\0'-terminated zone abbreviations
+** tzh_leapcnt repetitions of
+** one (char [4]) coded leap second transition times
+** one (char [4]) total correction after above
+** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
+** time is standard time, if FALSE,
+** transition time is wall clock time
+** if absent, transition times are
+** assumed to be wall clock time
+*/
+
+/*
+** In the current implementation, "tzset()" refuses to deal with files that
+** exceed any of the limits below.
+*/
+
+/*
+** The TZ_MAX_TIMES value below is enough to handle a bit more than a
+** year's worth of solar time (corrected daily to the nearest second) or
+** 138 years of Pacific Presidential Election time
+** (where there are three time zone transitions every fourth year).
+*/
+#define TZ_MAX_TIMES 370
+
+#define NOSOLAR /* 4BSD doesn't currently handle solar time */
+
+#ifndef NOSOLAR
+#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
+#else
+#define TZ_MAX_TYPES 10 /* Maximum number of local time types */
+#endif
+
+#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
+
+#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
+
+#define SECSPERMIN 60
+#define MINSPERHOUR 60
+#define HOURSPERDAY 24
+#define DAYSPERWEEK 7
+#define DAYSPERNYEAR 365
+#define DAYSPERLYEAR 366
+#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
+#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
+#define MONSPERYEAR 12
+
+#define TM_SUNDAY 0
+#define TM_MONDAY 1
+#define TM_TUESDAY 2
+#define TM_WEDNESDAY 3
+#define TM_THURSDAY 4
+#define TM_FRIDAY 5
+#define TM_SATURDAY 6
+
+#define TM_JANUARY 0
+#define TM_FEBRUARY 1
+#define TM_MARCH 2
+#define TM_APRIL 3
+#define TM_MAY 4
+#define TM_JUNE 5
+#define TM_JULY 6
+#define TM_AUGUST 7
+#define TM_SEPTEMBER 8
+#define TM_OCTOBER 9
+#define TM_NOVEMBER 10
+#define TM_DECEMBER 11
+
+#define TM_YEAR_BASE 1900
+
+#define EPOCH_YEAR 1970
+#define EPOCH_WDAY TM_THURSDAY
+
+/*
+** Accurate only for the past couple of centuries;
+** that will probably do.
+*/
+
+#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
+
+#endif /* !_TZFILE_H_ */
--- /dev/null
+/* $OpenBSD: vis.c,v 1.19 2005/09/01 17:15:49 millert Exp $ */
+/*-
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <limits.h>
+#include <ctype.h>
+#include <string.h>
+#include "vis.h"
+
+#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
+#define isvisible(c) \
+ (((u_int)(c) <= UCHAR_MAX && isascii((u_char)(c)) && \
+ (((c) != '*' && (c) != '?' && (c) != '[' && (c) != '#') || \
+ (flag & VIS_GLOB) == 0) && isgraph((u_char)(c))) || \
+ ((flag & VIS_SP) == 0 && (c) == ' ') || \
+ ((flag & VIS_TAB) == 0 && (c) == '\t') || \
+ ((flag & VIS_NL) == 0 && (c) == '\n') || \
+ ((flag & VIS_SAFE) && ((c) == '\b' || \
+ (c) == '\007' || (c) == '\r' || \
+ isgraph((u_char)(c)))))
+
+/*
+ * vis - visually encode characters
+ */
+char *
+vis(char *dst, int c, int flag, int nextc)
+{
+ if (isvisible(c)) {
+ *dst++ = c;
+ if (c == '\\' && (flag & VIS_NOSLASH) == 0)
+ *dst++ = '\\';
+ *dst = '\0';
+ return (dst);
+ }
+
+ if (flag & VIS_CSTYLE) {
+ switch(c) {
+ case '\n':
+ *dst++ = '\\';
+ *dst++ = 'n';
+ goto done;
+ case '\r':
+ *dst++ = '\\';
+ *dst++ = 'r';
+ goto done;
+ case '\b':
+ *dst++ = '\\';
+ *dst++ = 'b';
+ goto done;
+ case '\a':
+ *dst++ = '\\';
+ *dst++ = 'a';
+ goto done;
+ case '\v':
+ *dst++ = '\\';
+ *dst++ = 'v';
+ goto done;
+ case '\t':
+ *dst++ = '\\';
+ *dst++ = 't';
+ goto done;
+ case '\f':
+ *dst++ = '\\';
+ *dst++ = 'f';
+ goto done;
+ case ' ':
+ *dst++ = '\\';
+ *dst++ = 's';
+ goto done;
+ case '\0':
+ *dst++ = '\\';
+ *dst++ = '0';
+ if (isoctal(nextc)) {
+ *dst++ = '0';
+ *dst++ = '0';
+ }
+ goto done;
+ }
+ }
+ if (((c & 0177) == ' ') || (flag & VIS_OCTAL) ||
+ ((flag & VIS_GLOB) && (c == '*' || c == '?' || c == '[' || c == '#'))) {
+ *dst++ = '\\';
+ *dst++ = ((u_char)c >> 6 & 07) + '0';
+ *dst++ = ((u_char)c >> 3 & 07) + '0';
+ *dst++ = ((u_char)c & 07) + '0';
+ goto done;
+ }
+ if ((flag & VIS_NOSLASH) == 0)
+ *dst++ = '\\';
+ if (c & 0200) {
+ c &= 0177;
+ *dst++ = 'M';
+ }
+ if (iscntrl((u_char)c)) {
+ *dst++ = '^';
+ if (c == 0177)
+ *dst++ = '?';
+ else
+ *dst++ = c + '@';
+ } else {
+ *dst++ = '-';
+ *dst++ = c;
+ }
+done:
+ *dst = '\0';
+ return (dst);
+}
+
+/*
+ * strvis, strnvis, strvisx - visually encode characters from src into dst
+ *
+ * Dst must be 4 times the size of src to account for possible
+ * expansion. The length of dst, not including the trailing NULL,
+ * is returned.
+ *
+ * Strnvis will write no more than siz-1 bytes (and will NULL terminate).
+ * The number of bytes needed to fully encode the string is returned.
+ *
+ * Strvisx encodes exactly len bytes from src into dst.
+ * This is useful for encoding a block of data.
+ */
+int
+strvis(char *dst, const char *src, int flag)
+{
+ char c;
+ char *start;
+
+ for (start = dst; (c = *src);)
+ dst = vis(dst, c, flag, *++src);
+ *dst = '\0';
+ return (dst - start);
+}
+
+int
+strnvis(char *dst, const char *src, size_t siz, int flag)
+{
+ char *start, *end;
+ char tbuf[5];
+ int c, i;
+
+ i = 0;
+ for (start = dst, end = start + siz - 1; (c = *src) && dst < end; ) {
+ if (isvisible(c)) {
+ i = 1;
+ *dst++ = c;
+ if (c == '\\' && (flag & VIS_NOSLASH) == 0) {
+ /* need space for the extra '\\' */
+ if (dst < end)
+ *dst++ = '\\';
+ else {
+ dst--;
+ i = 2;
+ break;
+ }
+ }
+ src++;
+ } else {
+ i = vis(tbuf, c, flag, *++src) - tbuf;
+ if (dst + i <= end) {
+ memcpy(dst, tbuf, i);
+ dst += i;
+ } else {
+ src--;
+ break;
+ }
+ }
+ }
+ if (siz > 0)
+ *dst = '\0';
+ if (dst + i > end) {
+ /* adjust return value for truncation */
+ while ((c = *src))
+ dst += vis(tbuf, c, flag, *++src) - tbuf;
+ }
+ return (dst - start);
+}
+
+int
+strvisx(char *dst, const char *src, size_t len, int flag)
+{
+ char c;
+ char *start;
+
+ for (start = dst; len > 1; len--) {
+ c = *src;
+ dst = vis(dst, c, flag, *++src);
+ }
+ if (len)
+ dst = vis(dst, *src, flag, '\0');
+ *dst = '\0';
+ return (dst - start);
+}
--- /dev/null
+/* $OpenBSD: vis.h,v 1.11 2005/08/09 19:38:31 millert Exp $ */
+/* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vis.h 5.9 (Berkeley) 4/3/91
+ */
+
+#ifndef _VIS_H_
+#define _VIS_H_
+
+/*
+ * to select alternate encoding format
+ */
+#define VIS_OCTAL 0x01 /* use octal \ddd format */
+#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropriate */
+
+/*
+ * to alter set of characters encoded (default is to encode all
+ * non-graphic except space, tab, and newline).
+ */
+#define VIS_SP 0x04 /* also encode space */
+#define VIS_TAB 0x08 /* also encode tab */
+#define VIS_NL 0x10 /* also encode newline */
+#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
+#define VIS_SAFE 0x20 /* only encode "unsafe" characters */
+
+/*
+ * other
+ */
+#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
+#define VIS_GLOB 0x100 /* encode glob(3) magics and '#' */
+
+/*
+ * unvis return codes
+ */
+#define UNVIS_VALID 1 /* character valid */
+#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
+#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
+#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
+#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
+
+/*
+ * unvis flags
+ */
+#define UNVIS_END 1 /* no more characters */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+char *vis(char *, int, int, int);
+int strvis(char *, const char *, int);
+int strnvis(char *, const char *, size_t, int)
+ __attribute__ ((__bounded__(__string__,1,3)));
+int strvisx(char *, const char *, size_t, int)
+ __attribute__ ((__bounded__(__string__,1,3)));
+int strunvis(char *, const char *);
+int unvis(char *, char, int *, int);
+ssize_t strnunvis(char *, const char *, size_t)
+ __attribute__ ((__bounded__(__string__,1,3)));
+
+__END_DECLS
+
+#endif /* !_VIS_H_ */