Merge changes

This commit is contained in:
joerg 2010-02-20 02:51:32 +00:00
parent 9fde539170
commit d41f717e25
26 changed files with 201 additions and 3416 deletions

View File

@ -1,73 +0,0 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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
* in this position and unchanged.
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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 "cpio_platform.h"
__FBSDID("$FreeBSD$");
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "cpio.h"
static void
cpio_vwarnc(int code, const char *fmt, va_list ap)
{
fprintf(stderr, "%s: ", cpio_progname);
vfprintf(stderr, fmt, ap);
if (code != 0)
fprintf(stderr, ": %s", strerror(code));
fprintf(stderr, "\n");
}
void
cpio_warnc(int code, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
cpio_vwarnc(code, fmt, ap);
va_end(ap);
}
void
cpio_errc(int eval, int code, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
cpio_vwarnc(code, fmt, ap);
va_end(ap);
exit(eval);
}

View File

@ -1,259 +0,0 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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 "cpio_platform.h"
__FBSDID("$FreeBSD: src/usr.bin/cpio/matching.c,v 1.2 2008/06/21 02:20:20 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "matching.h"
#include "pathmatch.h"
struct match {
struct match *next;
int matches;
char pattern[1];
};
struct matching {
struct match *exclusions;
int exclusions_count;
struct match *inclusions;
int inclusions_count;
int inclusions_unmatched_count;
};
static void add_pattern(struct match **list, const char *pattern);
static void initialize_matching(struct cpio *);
static int match_exclusion(struct match *, const char *pathname);
static int match_inclusion(struct match *, const char *pathname);
/*
* The matching logic here needs to be re-thought. I started out to
* try to mimic gtar's matching logic, but it's not entirely
* consistent. In particular 'tar -t' and 'tar -x' interpret patterns
* on the command line as anchored, but --exclude doesn't.
*/
/*
* Utility functions to manage exclusion/inclusion patterns
*/
int
exclude(struct cpio *cpio, const char *pattern)
{
struct matching *matching;
if (cpio->matching == NULL)
initialize_matching(cpio);
matching = cpio->matching;
add_pattern(&(matching->exclusions), pattern);
matching->exclusions_count++;
return (0);
}
#if 0
int
exclude_from_file(struct cpio *cpio, const char *pathname)
{
return (process_lines(cpio, pathname, &exclude));
}
#endif
int
include(struct cpio *cpio, const char *pattern)
{
struct matching *matching;
if (cpio->matching == NULL)
initialize_matching(cpio);
matching = cpio->matching;
add_pattern(&(matching->inclusions), pattern);
matching->inclusions_count++;
matching->inclusions_unmatched_count++;
return (0);
}
int
include_from_file(struct cpio *cpio, const char *pathname)
{
struct line_reader *lr;
const char *p;
int ret = 0;
lr = process_lines_init(pathname, '\n');
while ((p = process_lines_next(lr)) != NULL)
if (include(cpio, p) != 0)
ret = -1;
process_lines_free(lr);
return (ret);
}
static void
add_pattern(struct match **list, const char *pattern)
{
struct match *match;
match = malloc(sizeof(*match) + strlen(pattern) + 1);
if (match == NULL)
cpio_errc(1, errno, "Out of memory");
if (pattern[0] == '/')
pattern++;
strcpy(match->pattern, pattern);
/* Both "foo/" and "foo" should match "foo/bar". */
if (match->pattern[strlen(match->pattern)-1] == '/')
match->pattern[strlen(match->pattern)-1] = '\0';
match->next = *list;
*list = match;
match->matches = 0;
}
int
excluded(struct cpio *cpio, const char *pathname)
{
struct matching *matching;
struct match *match;
struct match *matched;
matching = cpio->matching;
if (matching == NULL)
return (0);
/* Exclusions take priority */
for (match = matching->exclusions; match != NULL; match = match->next){
if (match_exclusion(match, pathname))
return (1);
}
/* Then check for inclusions */
matched = NULL;
for (match = matching->inclusions; match != NULL; match = match->next){
if (match_inclusion(match, pathname)) {
/*
* If this pattern has never been matched,
* then we're done.
*/
if (match->matches == 0) {
match->matches++;
matching->inclusions_unmatched_count++;
return (0);
}
/*
* Otherwise, remember the match but keep checking
* in case we can tick off an unmatched pattern.
*/
matched = match;
}
}
/*
* We didn't find a pattern that had never been matched, but
* we did find a match, so count it and exit.
*/
if (matched != NULL) {
matched->matches++;
return (0);
}
/* If there were inclusions, default is to exclude. */
if (matching->inclusions != NULL)
return (1);
/* No explicit inclusions, default is to match. */
return (0);
}
/*
* This is a little odd, but it matches the default behavior of
* gtar. In particular, 'a*b' will match 'foo/a1111/222b/bar'
*
*/
int
match_exclusion(struct match *match, const char *pathname)
{
return (pathmatch(match->pattern,
pathname,
PATHMATCH_NO_ANCHOR_START | PATHMATCH_NO_ANCHOR_END));
}
/*
* Again, mimic gtar: inclusions are always anchored (have to match
* the beginning of the path) even though exclusions are not anchored.
*/
int
match_inclusion(struct match *match, const char *pathname)
{
return (pathmatch(match->pattern, pathname, 0));
}
void
cleanup_exclusions(struct cpio *cpio)
{
struct match *p, *q;
if (cpio->matching) {
p = cpio->matching->inclusions;
while (p != NULL) {
q = p;
p = p->next;
free(q);
}
p = cpio->matching->exclusions;
while (p != NULL) {
q = p;
p = p->next;
free(q);
}
free(cpio->matching);
}
}
static void
initialize_matching(struct cpio *cpio)
{
cpio->matching = malloc(sizeof(*cpio->matching));
if (cpio->matching == NULL)
cpio_errc(1, errno, "No memory");
memset(cpio->matching, 0, sizeof(*cpio->matching));
}
int
unmatched_inclusions(struct cpio *cpio)
{
struct matching *matching;
matching = cpio->matching;
if (matching == NULL)
return (0);
return (matching->inclusions_unmatched_count);
}

View File

@ -1,40 +0,0 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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
* in this position and unchanged.
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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.
*
* $FreeBSD$
*/
#ifndef MATCHING_H
#define MATCHING_H
#include "cpio.h"
int exclude(struct cpio *, const char *pattern);
int include(struct cpio *, const char *pattern);
int excluded(struct cpio *cpio, const char *pathname);
void cleanup_exclusions(struct cpio *cpio);
int unmatched_inclusions(struct cpio *cpio);
#endif

View File

@ -1,250 +0,0 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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
* in this position and unchanged.
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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 "cpio_platform.h"
__FBSDID("$FreeBSD$");
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "pathmatch.h"
/*
* Check whether a character 'c' is matched by a list specification [...]:
* * Leading '!' negates the class.
* * <char>-<char> is a range of characters
* * \<char> removes any special meaning for <char>
*
* Some interesting boundary cases:
* a-d-e is one range (a-d) followed by two single characters - and e.
* \a-\d is same as a-d
* a\-d is three single characters: a, d, -
* Trailing - is not special (so [a-] is two characters a and -).
* Initial - is not special ([a-] is same as [-a] is same as [\\-a])
* This function never sees a trailing \.
* [] always fails
* [!] always succeeds
*/
static int
pm_list(const char *start, const char *end, const char c, int flags)
{
const char *p = start;
char rangeStart = '\0', nextRangeStart;
int match = 1, nomatch = 0;
/* This will be used soon... */
(void)flags; /* UNUSED */
/* If this is a negated class, return success for nomatch. */
if (*p == '!' && p < end) {
match = 0;
nomatch = 1;
++p;
}
while (p < end) {
nextRangeStart = '\0';
switch (*p) {
case '-':
/* Trailing or initial '-' is not special. */
if ((rangeStart == '\0') || (p == end - 1)) {
if (*p == c)
return (match);
} else {
char rangeEnd = *++p;
if (rangeEnd == '\\')
rangeEnd = *++p;
if ((rangeStart <= c) && (c <= rangeEnd))
return (match);
}
break;
case '\\':
++p;
/* Fall through */
default:
if (*p == c)
return (match);
nextRangeStart = *p; /* Possible start of range. */
}
rangeStart = nextRangeStart;
++p;
}
return (nomatch);
}
/*
* If s is pointing to "./", ".//", "./././" or the like, skip it.
*/
static const char *
pm_slashskip(const char *s) {
while (*s == '.' || *s == '/') {
if (s[0] != '/' && s[1] != '/')
break;
++s;
}
return (s);
}
static int
pm(const char *p, const char *s, int flags)
{
const char *end;
/*
* Ignore leading './', './/', '././', etc.
*/
if (s[0] == '.' && s[1] == '/')
s = pm_slashskip(s + 1);
if (p[0] == '.' && p[1] == '/')
p = pm_slashskip(p + 1);
for (;;) {
switch (*p) {
case '\0':
if (s[0] == '/') {
if (flags & PATHMATCH_NO_ANCHOR_END)
return (1);
/* "dir" == "dir/" == "dir/." */
s = pm_slashskip(s);
if (s[0] == '.' && s[1] == '\0')
return (1);
}
return (*s == '\0');
break;
case '?':
/* ? always succeds, unless we hit end of 's' */
if (*s == '\0')
return (0);
break;
case '*':
/* "*" == "**" == "***" ... */
while (*p == '*')
++p;
/* Trailing '*' always succeeds. */
if (*p == '\0')
return (1);
while (*s) {
if (pathmatch(p, s, flags))
return (1);
++s;
}
return (0);
break;
case '[':
/*
* Find the end of the [...] character class,
* ignoring \] that might occur within the class.
*/
end = p + 1;
while (*end != '\0' && *end != ']') {
if (*end == '\\' && end[1] != '\0')
++end;
++end;
}
if (*end == ']') {
/* We found [...], try to match it. */
if (!pm_list(p + 1, end, *s, flags))
return (0);
p = end; /* Jump to trailing ']' char. */
break;
} else
/* No final ']', so just match '['. */
if (*p != *s)
return (0);
break;
default:
if (*p == *s)
break;
if ((*s == '\0') && (*p == '/')) {
p = pm_slashskip(p);
if (*p == '\0')
return (1);
if (p[0] == '.' && p[1] == '\0')
return (1);
return (0);
}
return (0);
break;
case '\\':
/* Trailing '\\' matches itself. */
if (p[1] == '\0') {
if (*s != '\\')
return (0);
} else {
++p;
if (*p != *s)
return (0);
}
break;
}
/*
* TODO: pattern of "\/\.\/" should not match plain "/",
* it should only match explicit "/./".
*/
if (*p == '/')
p = pm_slashskip(p);
else
++p;
if (*s == '/')
s = pm_slashskip(s);
else
++s;
}
}
/* Main entry point. */
int
pathmatch(const char *p, const char *s, int flags)
{
/* Empty pattern only matches the empty string. */
if (p == NULL || *p == '\0')
return (s == NULL || *s == '\0');
/* Leading '^' anchors the start of the pattern. */
if (*p == '^') {
++p;
flags &= ~PATHMATCH_NO_ANCHOR_START;
}
/* Certain patterns anchor implicitly. */
if (*p == '*' || *p == '/')
return (pm(p, s, flags));
/* If start is unanchored, try to match start of each path element. */
if (flags & PATHMATCH_NO_ANCHOR_START) {
for ( ; p != NULL; p = strchr(p, '/')) {
if (*p == '/')
p++;
if (pm(p, s, flags))
return (1);
}
return (0);
}
/* Default: Match from beginning. */
return (pm(p, s, flags));
}

View File

@ -1,37 +0,0 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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
* in this position and unchanged.
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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.
*
* $FreeBSD$
*/
#ifndef PATHMATCH_H
#define PATHMATCH_H
#define PATHMATCH_NO_ANCHOR_START 1
#define PATHMATCH_NO_ANCHOR_END 2
int pathmatch(const char *p, const char *s, int flags);
#endif

View File

@ -1,54 +0,0 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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 "test.h"
__FBSDID("$FreeBSD$");
DEFINE_TEST(test_option_B)
{
struct stat st;
int r, fd;
/*
* Create a file on disk.
*/
fd = open("file", O_CREAT | O_WRONLY, 0644);
assert(fd >= 0);
close(fd);
/* Create an archive without -B; this should be 512 bytes. */
r = systemf("echo file | %s -o > small.cpio 2>small.err", testprog);
assertEqualInt(r, 0);
assertFileContents("1 block\n", 8, "small.err");
assertEqualInt(0, stat("small.cpio", &st));
assertEqualInt(512, st.st_size);
/* Create an archive with -B; this should be 5120 bytes. */
r = systemf("echo file | %s -oB > large.cpio 2>large.err", testprog);
assertEqualInt(r, 0);
assertFileContents("1 block\n", 8, "large.err");
assertEqualInt(0, stat("large.cpio", &st));
assertEqualInt(5120, st.st_size);
}

View File

@ -1,84 +0,0 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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 "test.h"
__FBSDID("$FreeBSD$");
DEFINE_TEST(test_option_L)
{
struct stat st;
int fd, filelist;
int r;
filelist = open("filelist", O_CREAT | O_WRONLY, 0644);
/* Create a file and a symlink to the file. */
fd = open("file", O_CREAT | O_WRONLY, 0644);
assert(fd >= 0);
assertEqualInt(10, write(fd, "123456789", 10));
close(fd);
write(filelist, "file\n", 5);
/* Symlink to above file. */
assertEqualInt(0, symlink("file", "symlink"));
write(filelist, "symlink\n", 8);
close(filelist);
r = systemf("cat filelist | %s -pd copy >copy.out 2>copy.err", testprog);
assertEqualInt(r, 0);
assertEqualInt(0, lstat("copy/symlink", &st));
failure("Regular -p without -L should preserve symlinks.");
assert(S_ISLNK(st.st_mode));
r = systemf("cat filelist | %s -pd -L copy-L >copy-L.out 2>copy-L.err", testprog);
assertEqualInt(r, 0);
assertEmptyFile("copy-L.out");
assertEmptyFile("copy-L.err");
assertEqualInt(0, lstat("copy-L/symlink", &st));
failure("-pdL should dereference symlinks and turn them into files.");
assert(!S_ISLNK(st.st_mode));
r = systemf("cat filelist | %s -o >archive.out 2>archive.err", testprog);
failure("Error invoking %s -o ", testprog);
assertEqualInt(r, 0);
assertEqualInt(0, mkdir("unpack", 0755));
r = systemf("cat archive.out | (cd unpack ; %s -i >unpack.out 2>unpack.err)", testprog);
failure("Error invoking %s -i", testprog);
assertEqualInt(r, 0);
assertEqualInt(0, lstat("unpack/symlink", &st));
assert(S_ISLNK(st.st_mode));
r = systemf("cat filelist | %s -oL >archive-L.out 2>archive-L.err", testprog);
failure("Error invoking %s -oL", testprog);
assertEqualInt(r, 0);
assertEqualInt(0, mkdir("unpack-L", 0755));
r = systemf("cat archive-L.out | (cd unpack-L ; %s -i >unpack-L.out 2>unpack-L.err)", testprog);
failure("Error invoking %s -i < archive-L.out", testprog);
assertEqualInt(r, 0);
assertEqualInt(0, lstat("unpack-L/symlink", &st));
assert(!S_ISLNK(st.st_mode));
}

View File

@ -1,66 +0,0 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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 "test.h"
__FBSDID("$FreeBSD$");
/*
* This is called "test_option_ell" instead of "test_option_l" to
* avoid any conflicts with "test_option_L" on case-insensitive
* filesystems.
*/
DEFINE_TEST(test_option_ell)
{
struct stat st, st2;
int fd;
int r;
/* Create a file. */
fd = open("f", O_CREAT | O_WRONLY, 0644);
assert(fd >= 0);
assertEqualInt(1, write(fd, "a", 1));
close(fd);
/* Stat it. */
assertEqualInt(0, stat("f", &st));
/* Copy the file to the "copy" dir. */
r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
testprog);
assertEqualInt(r, 0);
/* Check that the copy is a true copy and not a link. */
assertEqualInt(0, stat("copy/f", &st2));
assert(st2.st_ino != st.st_ino);
/* Copy the file to the "link" dir with the -l option. */
r = systemf("echo f | %s -pld link >link.out 2>link.err",
testprog);
assertEqualInt(r, 0);
/* Check that this is a link and not a copy. */
assertEqualInt(0, stat("link/f", &st2));
assert(st2.st_ino == st.st_ino);
}

View File

@ -22,23 +22,32 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/libarchive/archive_read.3,v 1.37 2008/05/26 17:00:22 kientzle Exp $
.\" $FreeBSD: head/lib/libarchive/archive_read.3 191595 2009-04-27 20:13:13Z kientzle $
.\"
.Dd August 19, 2006
.Dd April 13, 2009
.Dt archive_read 3
.Os
.Sh NAME
.Nm archive_read_new ,
.Nm archive_read_set_filter_options ,
.Nm archive_read_set_format_options ,
.Nm archive_read_set_options ,
.Nm archive_read_support_compression_all ,
.Nm archive_read_support_compression_bzip2 ,
.Nm archive_read_support_compression_compress ,
.Nm archive_read_support_compression_gzip ,
.Nm archive_read_support_compression_lzma ,
.Nm archive_read_support_compression_none ,
.Nm archive_read_support_compression_xz ,
.Nm archive_read_support_compression_program ,
.Nm archive_read_support_compression_program_signature ,
.Nm archive_read_support_format_all ,
.Nm archive_read_support_format_ar ,
.Nm archive_read_support_format_cpio ,
.Nm archive_read_support_format_empty ,
.Nm archive_read_support_format_iso9660 ,
.Nm archive_read_support_format_mtree,
.Nm archive_read_support_format_raw,
.Nm archive_read_support_format_tar ,
.Nm archive_read_support_format_zip ,
.Nm archive_read_open ,
@ -48,6 +57,7 @@
.Nm archive_read_open_filename ,
.Nm archive_read_open_memory ,
.Nm archive_read_next_header ,
.Nm archive_read_next_header2 ,
.Nm archive_read_data ,
.Nm archive_read_data_block ,
.Nm archive_read_data_skip ,
@ -74,25 +84,48 @@
.Ft int
.Fn archive_read_support_compression_gzip "struct archive *"
.Ft int
.Fn archive_read_support_compression_lzma "struct archive *"
.Ft int
.Fn archive_read_support_compression_none "struct archive *"
.Ft int
.Fn archive_read_support_compression_xz "struct archive *"
.Ft int
.Fo archive_read_support_compression_program
.Fa "struct archive *"
.Fa "const char *cmd"
.Fc
.Ft int
.Fo archive_read_support_compression_program_signature
.Fa "struct archive *"
.Fa "const char *cmd"
.Fa "const void *signature"
.Fa "size_t signature_length"
.Fc
.Ft int
.Fn archive_read_support_format_all "struct archive *"
.Ft int
.Fn archive_read_support_format_ar "struct archive *"
.Ft int
.Fn archive_read_support_format_cpio "struct archive *"
.Ft int
.Fn archive_read_support_format_empty "struct archive *"
.Ft int
.Fn archive_read_support_format_iso9660 "struct archive *"
.Ft int
.Fn archive_read_support_format_mtree "struct archive *"
.Ft int
.Fn archive_read_support_format_raw "struct archive *"
.Ft int
.Fn archive_read_support_format_tar "struct archive *"
.Ft int
.Fn archive_read_support_format_zip "struct archive *"
.Ft int
.Fn archive_read_set_filter_options "struct archive *" "const char *"
.Ft int
.Fn archive_read_set_format_options "struct archive *" "const char *"
.Ft int
.Fn archive_read_set_options "struct archive *" "const char *"
.Ft int
.Fo archive_read_open
.Fa "struct archive *"
.Fa "void *client_data"
@ -123,6 +156,8 @@
.Fn archive_read_open_memory "struct archive *" "void *buff" "size_t size"
.Ft int
.Fn archive_read_next_header "struct archive *" "struct archive_entry **"
.Ft int
.Fn archive_read_next_header2 "struct archive *" "struct archive_entry *"
.Ft ssize_t
.Fn archive_read_data "struct archive *" "void *buff" "size_t len"
.Ft int
@ -176,28 +211,41 @@ order they would be used:
Allocates and initializes a
.Tn struct archive
object suitable for reading from an archive.
.It Fn archive_read_support_compression_all , \
Fn archive_read_support_compression_bzip2 , \
.It Fn archive_read_support_compression_bzip2 , \
Fn archive_read_support_compression_compress , \
Fn archive_read_support_compression_gzip , \
Fn archive_read_support_compression_none
Fn archive_read_support_compression_lzma , \
Fn archive_read_support_compression_none , \
Fn archive_read_support_compression_xz
Enables auto-detection code and decompression support for the
specified compression.
Returns
.Cm ARCHIVE_OK
if the compression is fully supported, or
.Cm ARCHIVE_WARN
if the compression is supported only through an external program.
Note that decompression using an external program is usually slower than
decompression through built-in libraries.
Note that
.Dq none
is always enabled by default.
For convenience,
.Fn archive_read_support_compression_all
enables all available decompression code.
.It Fn archive_read_support_compression_all
Enables all available decompression filters.
.It Fn archive_read_support_compression_program
Data is fed through the specified external program before being dearchived.
Note that this disables automatic detection of the compression format,
so it makes no sense to specify this in conjunction with any other
decompression option.
.It Fn archive_read_support_compression_program_signature
This feeds data through the specified external program
but only if the initial bytes of the data match the specified
signature value.
.It Fn archive_read_support_format_all , \
Fn archive_read_support_format_ar , \
Fn archive_read_support_format_cpio , \
Fn archive_read_support_format_empty , \
Fn archive_read_support_format_iso9660 , \
Fn archive_read_support_format_mtree , \
Fn archive_read_support_format_tar , \
Fn archive_read_support_format_zip
Enables support---including auto-detection code---for the
@ -210,6 +258,57 @@ For convenience,
.Fn archive_read_support_format_all
enables support for all available formats.
Only empty archives are supported by default.
.It Fn archive_read_support_format_raw
The
.Dq raw
format handler allows libarchive to be used to read arbitrary data.
It treats any data stream as an archive with a single entry.
The pathname of this entry is
.Dq data ;
all other entry fields are unset.
This is not enabled by
.Fn archive_read_support_format_all
in order to avoid erroneous handling of damaged archives.
.It Fn archive_read_set_filter_options , \
Fn archive_read_set_format_options , \
Fn archive_read_set_options
Specifies options that will be passed to currently-registered
filters (including decompression filters) and/or format readers.
The argument is a comma-separated list of individual options.
Individual options have one of the following forms:
.Bl -tag -compact -width indent
.It Ar option=value
The option/value pair will be provided to every module.
Modules that do not accept an option with this name will ignore it.
.It Ar option
The option will be provided to every module with a value of
.Dq 1 .
.It Ar !option
The option will be provided to every module with a NULL value.
.It Ar module:option=value , Ar module:option , Ar module:!option
As above, but the corresponding option and value will be provided
only to modules whose name matches
.Ar module .
.El
The return value will be
.Cm ARCHIVE_OK
if any module accepts the option, or
.Cm ARCHIVE_WARN
if no module accepted the option, or
.Cm ARCHIVE_FATAL
if there was a fatal error while attempting to process the option.
.Pp
The currently supported options are:
.Bl -tag -compact -width indent
.It Format iso9660
.Bl -tag -compact -width indent
.It Cm joliet
Support Joliet extensions.
Defaults to enabled, use
.Cm !joliet
to disable.
.El
.El
.It Fn archive_read_open
The same as
.Fn archive_read_open2 ,
@ -262,6 +361,14 @@ memory containing the archive data.
Read the header for the next entry and return a pointer to
a
.Tn struct archive_entry .
This is a convenience wrapper around
.Fn archive_read_next_header2
that reuses an internal
.Tn struct archive_entry
object for each request.
.It Fn archive_read_next_header2
Read the header for the next entry and populate the provided
.Tn struct archive_entry .
.It Fn archive_read_data
Read data associated with the header just read.
Internally, this is a convenience function that calls

View File

@ -93,11 +93,9 @@ objects.
Allocates and initializes a
.Tn struct archive
object suitable for reading object information from disk.
.It Xo
.Fn archive_read_disk_set_symlink_logical ,
.Fn archive_read_disk_set_symlink_physical ,
.Fn archive_read_disk_set_symlink_hybrid
.Xc
.It Fn archive_read_disk_set_symlink_logical , \
Fn archive_read_disk_set_symlink_physical , \
Fn archive_read_disk_set_symlink_hybrid
This sets the mode used for handling symbolic links.
The
.Dq logical
@ -110,16 +108,12 @@ The
mode currently behaves identically to the
.Dq logical
mode.
.It Xo
.Fn archive_read_disk_gname ,
.Fn archive_read_disk_uname
.Xc
.It Fn archive_read_disk_gname , \
Fn archive_read_disk_uname
Returns a user or group name given a gid or uid value.
By default, these always return a NULL string.
.It Xo
.Fn archive_read_disk_set_gname_lookup ,
.Fn archive_read_disk_set_uname_lookup
.Xc
.It Fn archive_read_disk_set_gname_lookup , \
Fn archive_read_disk_set_uname_lookup
These allow you to override the functions used for
user and group name lookups.
You may also provide a

View File

@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/libarchive/archive_write.3,v 1.24 2008/05/26 17:00:23 kientzle Exp $
.\" $FreeBSD: head/lib/libarchive/archive_write.3 201110 2009-12-28 03:31:29Z kientzle $
.\"
.Dd May 11, 2008
.Dt archive_write 3
@ -43,6 +43,9 @@
.Nm archive_write_set_compression_gzip ,
.Nm archive_write_set_compression_none ,
.Nm archive_write_set_compression_program ,
.Nm archive_write_set_compressor_options ,
.Nm archive_write_set_format_options ,
.Nm archive_write_set_options ,
.Nm archive_write_open ,
.Nm archive_write_open_fd ,
.Nm archive_write_open_FILE ,
@ -73,10 +76,7 @@
.Ft int
.Fn archive_write_set_compression_none "struct archive *"
.Ft int
.Fo archive_write_set_compression_program
.Fa "struct archive *"
.Fa "const char * cmd"
.Fc
.Fn archive_write_set_compression_program "struct archive *" "const char * cmd"
.Ft int
.Fn archive_write_set_format_cpio "struct archive *"
.Ft int
@ -90,6 +90,12 @@
.Ft int
.Fn archive_write_set_format_ustar "struct archive *"
.Ft int
.Fn archive_write_set_format_options "struct archive *" "const char *"
.Ft int
.Fn archive_write_set_compressor_options "struct archive *" "const char *"
.Ft int
.Fn archive_write_set_options "struct archive *" "const char *"
.Ft int
.Fo archive_write_open
.Fa "struct archive *"
.Fa "void *client_data"
@ -206,6 +212,66 @@ Note that the compressed output is always properly blocked.
The archive will be fed into the specified compression program.
The output of that program is blocked and written to the client
write callbacks.
.It Fn archive_write_set_compressor_options , \
Fn archive_write_set_format_options , \
Fn archive_write_set_options
Specifies options that will be passed to the currently-enabled
compressor and/or format writer.
The argument is a comma-separated list of individual options.
Individual options have one of the following forms:
.Bl -tag -compact -width indent
.It Ar option=value
The option/value pair will be provided to every module.
Modules that do not accept an option with this name will ignore it.
.It Ar option
The option will be provided to every module with a value of
.Dq 1 .
.It Ar !option
The option will be provided to every module with a NULL value.
.It Ar module:option=value , Ar module:option , Ar module:!option
As above, but the corresponding option and value will be provided
only to modules whose name matches
.Ar module .
.El
The return value will be
.Cm ARCHIVE_OK
if any module accepts the option, or
.Cm ARCHIVE_WARN
if no module accepted the option, or
.Cm ARCHIVE_FATAL
if there was a fatal error while attempting to process the option.
.Pp
The currently supported options are:
.Bl -tag -compact -width indent
.It Compressor gzip
.Bl -tag -compact -width indent
.It Cm compression-level
The value is interpreted as a decimal integer specifying the
gzip compression level.
.El
.It Compressor xz
.Bl -tag -compact -width indent
.It Cm compression-level
The value is interpreted as a decimal integer specifying the
compression level.
.El
.It Format mtree
.Bl -tag -compact -width indent
.It Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent , Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 , Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname
Enable a particular keyword in the mtree output.
Prefix with an exclamation mark to disable the corresponding keyword.
The default is equivalent to
.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
.It Cm all
Enables all of the above keywords.
.It Cm use-set
Enables generation of
.Cm /set
lines that specify default values for the following files and/or directories.
.It Cm indent
XXX needs explanation XXX
.El
.El
.It Fn archive_write_open
Freeze the settings, open the archive, and prepare for writing entries.
This is the most generic form of this function, which accepts
@ -338,7 +404,7 @@ to register an error code and message and return
.Fo archive_write_callback
.Fa "struct archive *"
.Fa "void *client_data"
.Fa "void *buffer"
.Fa "const void *buffer"
.Fa "size_t length"
.Fc
.El
@ -381,6 +447,9 @@ and
.Xr close 2
system calls.
.Bd -literal -offset indent
#ifdef __linux__
#define _FILE_OFFSET_BITS 64
#endif
#include <sys/stat.h>
#include <archive.h>
#include <archive_entry.h>
@ -406,7 +475,7 @@ myopen(struct archive *a, void *client_data)
}
ssize_t
mywrite(struct archive *a, void *client_data, void *buff, size_t n)
mywrite(struct archive *a, void *client_data, const void *buff, size_t n)
{
struct mydata *mydata = client_data;

View File

@ -22,9 +22,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/libarchive/archive_write_disk.3,v 1.3 2008/05/26 17:00:23 kientzle Exp $
.\" $FreeBSD: src/lib/libarchive/archive_write_disk.3,v 1.4 2008/09/04 05:22:00 kientzle Exp $
.\"
.Dd March 2, 2007
.Dd August 5, 2008
.Dt archive_write_disk 3
.Os
.Sh NAME
@ -169,11 +169,11 @@ The default is to not refuse such paths.
Note that paths ending in
.Pa ..
always cause an error, regardless of this flag.
.El
.It Cm ARCHIVE_EXTRACT_SPARSE
Scan data for blocks of NUL bytes and try to recreate them with holes.
This results in sparse files, independent of whether the archive format
supports or uses them.
.El
.It Fn archive_write_disk_set_group_lookup , \
Fn archive_write_disk_set_user_lookup
The

View File

@ -1,120 +0,0 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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.
*
* $FreeBSD: src/lib/libarchive/config_freebsd.h,v 1.10 2008/06/15 05:12:47 kientzle Exp $
*/
/* FreeBSD 5.0 and later have ACL support. */
#if __FreeBSD__ > 4
#define HAVE_ACL_CREATE_ENTRY 1
#define HAVE_ACL_INIT 1
#define HAVE_ACL_SET_FD 1
#define HAVE_ACL_SET_FD_NP 1
#define HAVE_ACL_SET_FILE 1
#define HAVE_ACL_USER 1
#endif
#define HAVE_BZLIB_H 1
#define HAVE_CHFLAGS 1
#define HAVE_CHOWN 1
#define HAVE_DECL_INT64_MAX 1
#define HAVE_DECL_INT64_MIN 1
#define HAVE_DECL_SIZE_MAX 1
#define HAVE_DECL_STRERROR_R 1
#define HAVE_DECL_UINT32_MAX 1
#define HAVE_DECL_UINT64_MAX 1
#define HAVE_EFTYPE 1
#define HAVE_EILSEQ 1
#define HAVE_ERRNO_H 1
#define HAVE_FCHDIR 1
#define HAVE_FCHFLAGS 1
#define HAVE_FCHMOD 1
#define HAVE_FCHOWN 1
#define HAVE_FCNTL 1
#define HAVE_FCNTL_H 1
#define HAVE_FSEEKO 1
#define HAVE_FSTAT 1
#define HAVE_FUTIMES 1
#define HAVE_GETEUID 1
#define HAVE_GETPID 1
#define HAVE_GRP_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LCHFLAGS 1
#define HAVE_LCHMOD 1
#define HAVE_LCHOWN 1
#define HAVE_LIMITS_H 1
#define HAVE_LUTIMES 1
#define HAVE_MALLOC 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMSET 1
#define HAVE_MKDIR 1
#define HAVE_MKFIFO 1
#define HAVE_MKNOD 1
#define HAVE_PIPE 1
#define HAVE_POLL 1
#define HAVE_POLL_H 1
#define HAVE_PWD_H 1
#define HAVE_SELECT 1
#define HAVE_SETENV 1
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRCHR 1
#define HAVE_STRDUP 1
#define HAVE_STRERROR 1
#define HAVE_STRERROR_R 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_STRRCHR 1
#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
#define HAVE_SYS_ACL_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#undef HAVE_SYS_UTIME_H
#define HAVE_SYS_WAIT_H 1
#define HAVE_TIMEGM 1
#define HAVE_TZSET 1
#define HAVE_UNISTD_H 1
#define HAVE_UNSETENV 1
#define HAVE_UTIME 1
#define HAVE_UTIMES 1
#define HAVE_UTIME_H 1
#define HAVE_VFORK 1
#define HAVE_WCHAR_H 1
#define HAVE_WCSCPY 1
#define HAVE_WCSLEN 1
#define HAVE_WCTOMB 1
#define HAVE_WMEMCMP 1
#define HAVE_WMEMCPY 1
#define HAVE_ZLIB_H 1
#define STDC_HEADERS 1
#define TIME_WITH_SYS_TIME 1
/* FreeBSD 4 and earlier lack intmax_t/uintmax_t */
#if __FreeBSD__ < 5
#define intmax_t int64_t
#define uintmax_t uint64_t
#endif

View File

@ -1,682 +0,0 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
#ifndef CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED
///////////////////////////////////////////////////////////////////////////
// Check for Watcom and Microsoft Visual C compilers (WIN32 only) ///////
///////////////////////////////////////////////////////////////////////////
#if defined(__WIN32__) || defined(_WIN32) || defined(__WIN32)
#define IS_WIN32 1
#if defined(__TURBOC__) || defined(__BORLANDC__) /* Borland compilers */
#elif defined( __WATCOMC__ ) || defined(__WATCOMCPP__) /* Watcom compilers */
#define IS_WATCOM 1
/* Define to 1 if __INT64 is defined */
#define HAVE___INT64 1
/* Define to 1 if UID should be unsigned */
#define USE_UNSIGNED_UID 1
/* Define to 1 if UID should be unsigned */
#define USE_UNSIGNED_GID 1
#elif defined(__IBMC__) || defined(__IBMCPP__) /* IBM compilers */
#elif defined( __SC__ ) /* Symantec C++ compilers */
#elif defined( M_I86 ) && defined( MSDOS ) /* Microsoft DOS/Win 16 compilers */
#elif defined( _M_IX86 ) || defined( _68K_ ) /* Microsoft Win32 compilers */
#define IS_VISUALC 1
/* Define to 1 if __INT64 is defined */
#define HAVE___INT64 1
#else
#endif
#endif
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
/* Define to 1 if you have the `acl_create_entry' function. */
/* #undef HAVE_ACL_CREATE_ENTRY */
/* Define to 1 if you have the `acl_get_perm' function. */
/* #undef HAVE_ACL_GET_PERM */
/* Define to 1 if you have the `acl_get_perm_np' function. */
/* #undef HAVE_ACL_GET_PERM_NP */
/* Define to 1 if you have the `acl_init' function. */
/* #undef HAVE_ACL_INIT */
/* Define to 1 if the system has the type `acl_permset_t'. */
/* #undef HAVE_ACL_PERMSET_T */
/* Define to 1 if you have the `acl_set_fd' function. */
/* #undef HAVE_ACL_SET_FD */
/* Define to 1 if you have the `acl_set_fd_np' function. */
/* #undef HAVE_ACL_SET_FD_NP */
/* Define to 1 if you have the `acl_set_file' function. */
/* #undef HAVE_ACL_SET_FILE */
/* True for systems with POSIX ACL support */
/* #undef HAVE_ACL_USER */
/* Define to 1 if you have the <attr/xattr.h> header file. */
/* #undef HAVE_ATTR_XATTR_H */
/* Define to 1 if you have the <bzlib.h> header file. */
/* #undef HAVE_BZLIB_H */
/* Define to 1 if you have the `chflags' function. */
/* #undef HAVE_CHFLAGS */
/* Define to 1 if you have the `chown' function. */
/* #undef HAVE_CHOWN */
/* Define to 1 if you have the declaration of `INT64_MAX', and to 0 if you
don't. */
/* #undef HAVE_DECL_INT64_MAX */
/* Define to 1 if you have the declaration of `INT64_MIN', and to 0 if you
don't. */
/* #undef HAVE_DECL_INT64_MIN */
/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't.
*/
/* #undef HAVE_DECL_OPTARG */
/* Define to 1 if you have the declaration of `optind', and to 0 if you don't.
*/
/* #undef HAVE_DECL_OPTIND */
/* Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you
don't. */
/* #undef HAVE_DECL_SIZE_MAX */
#if defined(_MSC_VER) && _MSC_VER >= 1400
#define HAVE_DECL_SIZE_MAX 1
#endif
/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
don't. */
/* #undef HAVE_DECL_STRERROR_R */
/* Define to 1 if you have the declaration of `UINT32_MAX', and to 0 if you
don't. */
/* #undef HAVE_DECL_UINT32_MAX */
/* Define to 1 if you have the declaration of `UINT64_MAX', and to 0 if you
don't. */
/* #undef HAVE_DECL_UINT64_MAX */
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_DIRENT_H */
/* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H */
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
/* #undef HAVE_DOPRNT */
/* Define to 1 if nl_langinfo supports D_MD_ORDER */
/* #undef HAVE_D_MD_ORDER */
/* A possible errno value for invalid file format errors */
#if ((IS_WATCOM) || (IS_VISUALC))
#define HAVE_EFTYPE 0
#else
#define HAVE_EFTYPE 1
#endif
/* A possible errno value for invalid file format errors */
#define HAVE_EILSEQ 1
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the <ext2fs/ext2_fs.h> header file. */
/* #undef HAVE_EXT2FS_EXT2_FS_H */
/* Define to 1 if you have the `fchdir' function. */
/* #undef HAVE_FCHDIR */
/* Define to 1 if you have the `fchflags' function. */
/* #undef HAVE_FCHFLAGS */
/* Define to 1 if you have the `fchmod' function. */
/* #undef HAVE_FCHMOD */
/* Define to 1 if you have the `fchown' function. */
/* #undef HAVE_FCHOWN */
/* Define to 1 if you have the <fcntl.h> header file. */
/* #undef HAVE_FCNTL_H 1 */
/* Define to 1 if you have the fcntl() function. */
/* #undef HAVE_FCNTL_FN */
/* Define to 1 if your system has a working POSIX `fnmatch' function. */
/* #undef HAVE_FNMATCH */
/* Define to 1 if fnmatch(3) supports the FNM_LEADING_DIR flag */
/* #undef HAVE_FNM_LEADING_DIR */
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
/* #undef HAVE_FSEEKO */
/* Define to 1 if you have the `fsetxattr' function. */
/* #undef HAVE_FSETXATTR */
/* Define to 1 if you have the `ftruncate' function. */
/* #undef HAVE_FTRUNCATE */
/* Define to 1 if you have the `futimes' function. */
/* #undef HAVE_FUTIMES */
/* Define to 1 if you have the `geteuid' function. */
/* #undef HAVE_GETEUID */
/* Define to 1 if you have the `getopt_long' function. */
/* #undef HAVE_GETOPT_LONG */
/* Define to 1 if you have the `getxattr' function. */
/* #undef HAVE_GETXATTR */
/* Define to 1 if you have the <grp.h> header file. */
/* #undef HAVE_GRP_H */
/* Define to 1 if the system has the type `intmax_t'. */
/* #undef HAVE_INTMAX_T */
/* Define to 1 if you have the <inttypes.h> header file. */
/* #undef HAVE_INTTYPES_H */
/* Define to 1 if you have the <langinfo.h> header file. */
/* #undef HAVE_LANGINFO_H */
/* Define to 1 if you have the `lchflags' function. */
/* #undef HAVE_LCHFLAGS */
/* Define to 1 if you have the `lchmod' function. */
/* #undef HAVE_LCHMOD */
/* Define to 1 if you have the `lchown' function. */
/* #undef HAVE_LCHOWN */
/* Define to 1 if you have the `lgetxattr' function. */
/* #undef HAVE_LGETXATTR */
/* Define to 1 if you have the `acl' library (-lacl). */
/* #undef HAVE_LIBACL */
/* Define to 1 if you have the `attr' library (-lattr). */
/* #undef HAVE_LIBATTR */
/* Define to 1 if you have the `bz2' library (-lbz2). */
/* #undef HAVE_LIBBZ2 */
/* Define to 1 if you have the `z' library (-lz). */
/* #undef HAVE_LIBZ */
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define to 1 if you have the <linux/ext2_fs.h> header file. */
/* #undef HAVE_LINUX_EXT2_FS_H */
/* Define to 1 if you have the <linux/fs.h> header file. */
/* #undef HAVE_LINUX_FS_H */
/* Define to 1 if you have the `listxattr' function. */
/* #undef HAVE_LISTXATTR */
/* Define to 1 if you have the `llistxattr' function. */
/* #undef HAVE_LLISTXATTR */
/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1
/* Define to 1 if the system has the type `long long int'. */
#define HAVE_LONG_LONG_INT 1
/* Define to 1 if you have the `lsetxattr' function. */
/* #undef HAVE_LSETXATTR */
/* Define to 1 if `lstat' has the bug that it succeeds when given the
zero-length file name argument. */
/* #undef HAVE_LSTAT_EMPTY_STRING_BUG */
/* Define to 1 if you have the `lutimes' function. */
/* #undef HAVE_LUTIMES */
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have the `mkdir' function. */
#define HAVE_MKDIR 1
/* Define to 1 if you have the `mkfifo' function. */
/* #undef HAVE_MKFIFO */
/* Define to 1 if you have the `mknod' function. */
/* #undef HAVE_MKNOD */
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
/* Define to 1 if you have the `nl_langinfo' function. */
/* #undef HAVE_NL_LANGINFO */
/* Define to 1 if you have the <paths.h> header file. */
/* #undef HAVE_PATHS_H */
/* Define to 1 if you have the `poll' function. */
/* #undef HAVE_POLL */
/* Define to 1 if you have the <poll.h> header file. */
/* #undef HAVE_POLL_H */
/* Define to 1 if you have the <pwd.sh.h> header file. */
/* #undef HAVE_PWD_H */
/* Define to 1 if you have the `select' function. */
/* #undef HAVE_SELECT */
/* Define to 1 if you have the `setlocale' function. */
#define HAVE_SETLOCALE 1
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
/* #undef HAVE_STAT_EMPTY_STRING_BUG */
/* Define to 1 if you have the <stdarg.h> header file. */
#define HAVE_STDARG_H 1
/* Define to 1 if you have the <stdint.h> header file. */
/* #undef HAVE_STDINT_H */
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strchr' function. */
#define HAVE_STRCHR 1
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the `strerror_r' function. */
/* #undef HAVE_STRERROR_R */
/* Define to 1 if you have the `strftime' function. */
#define HAVE_STRFTIME 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strrchr' function. */
#define HAVE_STRRCHR 1
/* Define to 1 if `st_mtimespec.tv_nsec' is member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC */
/* Define to 1 if `st_mtim.tv_nsec' is member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC */
/* Define to 1 if you have the <sys/acl.h> header file. */
/* #undef HAVE_SYS_ACL_H */
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/ioctl.h> header file. */
/* #undef HAVE_SYS_IOCTL_H */
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
/* Define to 1 if you have the <sys/param.h> header file. */
/* #undef HAVE_SYS_PARAM_H */
/* Define to 1 if you have the <sys/poll.h> header file. */
/* #undef HAVE_SYS_POLL_H */
/* Define to 1 if you have the <sys/select.h> header file. */
/* #undef HAVE_SYS_SELECT_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
/* #undef HAVE_SYS_TIME_H */
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/utime.h> header file. */
#define HAVE_SYS_UTIME_H 1
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
/* #undef HAVE_SYS_WAIT_H */
/* Define to 1 if you have the `timegm' function. */
/* #undef HAVE_TIMEGM */
/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define to 1 if the system has the type `uintmax_t'. */
/* #undef HAVE_UINTMAX_T */
/* Define to 1 if you have the <unistd.h> header file. */
/* #undef HAVE_UNISTD_H */
/* Define to 1 if the system has the type `unsigned long long'. */
#define HAVE_UNSIGNED_LONG_LONG 1
/* Define to 1 if the system has the type `unsigned long long int'. */
#define HAVE_UNSIGNED_LONG_LONG_INT 1
/* Define to 1 if you have the `utime' function. */
#define HAVE_UTIME 1
/* Define to 1 if you have the `utimes' function. */
/* #undef HAVE_UTIMES */
/* Define to 1 if you have the <utime.h> header file. */
/* #undef HAVE_UTIME_H */
/* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1
/* Define to 1 if you have the <wchar.h> header file. */
#define HAVE_WCHAR_H 1
/* Define to 1 if you have the `wcscpy' function. */
#define HAVE_WCSCPY 1
/* Define to 1 if you have the `wcslen' function. */
#define HAVE_WCSLEN 1
/* Define to 1 if you have the `wmemcmp' function. */
/* #undef HAVE_WMEMCMP */
/* Define to 1 if you have the `wmemcpy' function. */
/* #undef HAVE_WMEMCPY */
/* Define to 1 if you have the <zlib.h> header file. */
#define HAVE_ZLIB_H 1
/* Version number of libarchive as a single integer */
#define LIBARCHIVE_VERSION_NUMBER "2005000"
/* Version number of libarchive */
#define LIBARCHIVE_VERSION_STRING "2.5.0b"
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */
/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
*/
/* #undef MAJOR_IN_MKDEV */
/* Define to 1 if `major', `minor', and `makedev' are declared in
<sysmacros.h>. */
/* #undef MAJOR_IN_SYSMACROS */
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Name of package */
#define PACKAGE "libarchive"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "kientzle@freebsd.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "libarchive"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libarchive 2.4.12"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libarchive"
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.4.12"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if strerror_r returns char *. */
/* #undef STRERROR_R_CHAR_P */
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Version number of package */
#define VERSION "2.4.12"
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
/* #undef _LARGEFILE_SOURCE */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
#define below would cause a syntax error. */
/* #undef _UINT64_T */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `int' if <sys/types.h> doesn't define. */
#if (USE_UNSIGNED_GID)
#define gid_t unsigned int
#else
#define gid_t int
#endif
/* Define to `unsigned long' if <sys/types.h> does not define. */
#define id_t int
/* Define to the type of a signed integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#if (HAVE___INT64)
typedef __int64 int64_t;
#else
#define int64_t long long
#endif
/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
not define. */
#if (HAVE___INT64)
typedef __int64 intmax_t;
#else
#define intmax_t long long
#endif
/* Define to `int' if <sys/types.h> does not define. */
#define mode_t unsigned short
/* Define to `long long' if <sys/types.h> does not define. */
/* #undef off_t */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
/* Define to `int' if <sys/types.h> doesn't define. */
#if (USE_UNSIGNED_UID)
#define uid_t unsigned int
#else
#define uid_t int
#endif
/* Define to the type of an unsigned integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#if (HAVE___INT64)
typedef unsigned __int64 uint64_t;
#else
#define uint64_t unsigned long long
#endif
/* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
do not define. */
#if (HAVE___INT64)
typedef unsigned __int64 uintmax_t;
#else
#define uintmax_t unsigned long long
#endif
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef uintptr_t */
/* Define to `unsigned int' if <sys/types.h> does not define. */
#define pid_t unsigned int
#define uint32_t unsigned long
#define uint16_t unsigned short
#define ssize_t long
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
#if (IS_VISUALC)
#include <io.h>
#include <stdlib.h> //brings in NULL
#include <sys/stat.h> //brings in S_IFMT(), etc...
#define HAVE_UINTPTR 0
#if !defined(STDIN_FILENO)
#define STDIN_FILENO 0
#endif
#if !defined(STDOUT_FILENO)
#define STDOUT_FILENO 1
#endif
#if !defined(STDERR_FILENO)
#define STDERR_FILENO 2
#endif
/* Define to 1 if ino_t is defined (possibly in sys/types.h) */
#define HAVE_INO_T 1
#define S_IFFIFO _S_IFIFO
#define S_ISBLK( m ) 0
#define S_ISFIFO( m ) (((m) & S_IFMT) == S_IFFIFO)
#define S_ISCHR( m ) (((m) & S_IFMT) == S_IFCHR)
#define S_ISDIR( m ) (((m) & S_IFMT) == S_IFDIR)
#define S_ISREG( m ) (((m) & S_IFMT) == S_IFREG)
#define S_ISUID 0004000
#define S_ISGID 0002000
#define S_ISVTX 0001000
//NOT SURE IF O_NONBLOCK is OK here but at least the 0x0004 flag is not used by anything else...
#define O_NONBLOCK 0x0004 /* Non-blocking I/O. */
//#define O_NDELAY O_NONBLOCK
#define lstat _stat
/* Symbolic constants for the access() function */
#if !defined(F_OK)
#define R_OK 4 /* Test for read permission */
#define W_OK 2 /* Test for write permission */
#define X_OK 1 /* Test for execute permission */
#define F_OK 0 /* Test for existence of file */
#endif
#endif
//////////////////////////////////////////////////////////////////////////
#if (IS_WATCOM)
#include <io.h> //brings in STDERR/OUT/IN_FILENO, dup(), dup2(), close(), write(), etc...
#include <process.h> //brings in execlp() and _exit()
#include <stdlib.h> //brings in NULL
#include <sys/stat.h>
/* Define to 1 if ino_t is defined (possibly in sys/types.h) */
#define HAVE_INO_T 1
//NOT SURE IF O_NONBLOCK is OK here but at least the 0x0004 flag is not used by anything else...
#define O_NONBLOCK 0x0004 /* Non-blocking I/O. */
//#define O_NDELAY O_NONBLOCK
//Prototypes for functions which we'll define in archive_windows.c
extern unsigned int sleep (unsigned int seconds);
#define lstat _stat
#endif
//////////////////////////////////////////////////////////////////////////
#if !(HAVE_UINTPTR)
typedef unsigned int *uintptr_t;
#if defined(HAVE_UINTPTR)
#undef HAVE_UINTPTR
#endif
#define HAVE_UINTPTR 1
#endif
#if !defined(SSIZE_MAX)
//#define _POSIX_SSIZE_MAX 32767
#if defined(_POSIX_SSIZE_MAX)
#define SSIZE_MAX _POSIX_SSIZE_MAX
#else
#define SSIZE_MAX ((ssize_t)((size_t)-1 >> 1))
#endif
#endif
#if !(HAVE_FCNTL_FN)
#define F_SETFL 4 /* Set file status flags. */
#if defined(HAVE_FCNTL_FN)
#undef HAVE_FCNTL_FN
#endif
#define HAVE_FCNTL_FN 1
#endif
#define _S_IFLNK 0xA000 /* symbolic link */
#if !defined(_S_IFMT)
#define _S_IFMT S_IFMT
#endif
#define _S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
#define S_ISLNK(m) _S_ISLNK(m)
/* Replacement for major/minor/makedev. */
#if !(MAJOR_IN_MKDEV) && !(MAJOR_IN_SYSMACROS)
#define major(x) ((int)(0x00ff & ((x) >> 8)))
#define minor(x) ((int)(0xffff00ff & (x)))
#define makedev(maj,min) ((0xff00 & ((maj)<<8))|(0xffff00ff & (min)))
#endif
#define set_errno(val) ((errno)=val)
#endif /* CONFIG_H_INCLUDED */

View File

@ -1,9 +0,0 @@
begin 644 test_compat_gtar_1.tgz
M'XL(`,N`6T<``^W62PZ",!`&X!YE3@`SI:6Z<R^7\(&*+Q+%>'W+PJB)43=4
MJO^W:1.Z:#KYATG2)!T5]7Y95/N-Z@:UF)ZO7B9"-TPD[%@4%1W=Y\'IV$P.
M1.I0U\VK<^=566Y#7"@LT9FQN1L,.>[=M]\Q5@%JHX0Y-Z;-NSC+]^LM\S[R
M.G?,XC(B+:Q949"B7O/?5+N7Y]Y]CU32U_[OZS_NZ#X/T/][T\/1_\/K;?XQ
M_P4QF<[FY6*YJM9Q[[[]CK$*4!O_CV%G[6?SGS9^_C/&:I]_'6(X_?/Y#P``
4````````````?L\%KFMT6@`H````
`
end

View File

@ -1,10 +0,0 @@
begin 644 test_pax_filename_encoding.tar.gz
M'XL(`)4;VT<``^V6STK#0!#&<\Y3[!/HS/Z-ASVHEQ1$BE[L<4T6$DP32:-$
MG\%'\Y%Z,*7$UEJLE"91NK_+P.P>OF'X^&9LZM":V):GYCYZ?YOFQ5W]\NH=
M%`"0G).FHA*P7I>@E`1!22E!`9,$4#"0'JD/*V,[3[/*E(V4*IW^^&_7^W(4
M\EG_"13)HZD2W6Y_WFS?IT"B9EZKD8(0+)"!6/3,EQZ5/BIR>QF.KB8GL7W6
M0>!3VC;2O-"<H>#\S,>@[>99FC]H](>>VM'2G>M7[/(_@-CP/V-4>`2Z$K3.
MD?L_M%E6#"W",1CC;_D_[SW_*;+-_!><N?SO@R;_D[B,$E/.;*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O-6_,_/]:YC;<A-%^UFF09U
MP`*D@;&4KUHN&1:F_D1:YM:J-EG8L%<+BF4W%"6TU:I68MIJ6"FVH>T9PR7J
MNU2C2G2>5**"XH4HD`PF+(*DTT&47'A+)B";NS-UH>(]7G^\/G_343KU\17<
M<*""-SM"%>BVIJL8SF]7L-1.-LSRP2%=KX&C56*FC&#C$XNMGL)]3X&^$V4Z
MY`()G`%`KUR!HU8Z'"HWNE&P6MI:KZ<F%H/X3DN/F&%#`.%8#!HTK295C.#[
M+^4C&90I^(::@`Y$=<OX=S3?,A#ZU'\'^+PYHV2PK?Q-,&8/Q$A3@$*X*=$A
MK;I2)&A^MSZ`*](@"[>^Q"H0L7.OV8ZJW409[QO=`&&D%=5&@RP`MO%R/J#Q
M-KJ*6D;EH7:DK0.48@8HF*IP(>*YMR$>!+A,)X+;`$94@@?U]B/=2T0CY-2=
M*_1FPF<-G\\@Z-_,Q>06='5:(B#3`W$8Y!:C-CE22SM9*S$00,XXJTIZ!GA(
LGTMN:F\J-,D9>?.38*!I7T>--*B_=T44HJ?#@``"1;7#_Q=R13A0D!M#:2D`
`
end

View File

@ -1,811 +0,0 @@
%{
/*
* March 2005: Further modified and simplified by Tim Kientzle:
* Eliminate minutes-based calculations (just do everything in
* seconds), have lexer only recognize unsigned integers (handle '+'
* and '-' characters in grammar), combine tables into one table with
* explicit abbreviation notes, do am/pm adjustments in the grammar
* (eliminate some state variables and post-processing). Among other
* things, these changes eliminated two shift/reduce conflicts. (Went
* from 10 to 8.)
* All of Tim Kientzle's changes to this file are public domain.
*/
/*
** Originally written by Steven M. Bellovin <smb@research.att.com> while
** at the University of North Carolina at Chapel Hill. Later tweaked by
** a couple of people on Usenet. Completely overhauled by Rich $alz
** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
**
** This grammar has 10 shift/reduce conflicts.
**
** This code is in the public domain and has no copyright.
*/
/* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */
/* SUPPRESS 288 on yyerrlab *//* Label unused */
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/usr.bin/tar/getdate.y,v 1.9 2007/07/20 01:27:50 kientzle Exp $");
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define yyparse getdate_yyparse
#define yylex getdate_yylex
#define yyerror getdate_yyerror
static int yyparse(void);
static int yylex(void);
static int yyerror(const char *);
time_t get_date(char *);
#define EPOCH 1970
#define HOUR(x) ((time_t)(x) * 60)
#define SECSPERDAY (24L * 60L * 60L)
/*
** Daylight-savings mode: on, off, or not yet known.
*/
typedef enum _DSTMODE {
DSTon, DSToff, DSTmaybe
} DSTMODE;
/*
** Meridian: am or pm.
*/
enum { tAM, tPM };
/*
** Global variables. We could get rid of most of these by using a good
** union as the yacc stack. (This routine was originally written before
** yacc had the %union construct.) Maybe someday; right now we only use
** the %union very rarely.
*/
static char *yyInput;
static DSTMODE yyDSTmode;
static time_t yyDayOrdinal;
static time_t yyDayNumber;
static int yyHaveDate;
static int yyHaveDay;
static int yyHaveRel;
static int yyHaveTime;
static int yyHaveZone;
static time_t yyTimezone;
static time_t yyDay;
static time_t yyHour;
static time_t yyMinutes;
static time_t yyMonth;
static time_t yySeconds;
static time_t yyYear;
static time_t yyRelMonth;
static time_t yyRelSeconds;
%}
%union {
time_t Number;
}
%token tAGO tDAY tDAYZONE tAMPM tMONTH tMONTH_UNIT tSEC_UNIT tUNUMBER
%token tZONE tDST
%type <Number> tDAY tDAYZONE tMONTH tMONTH_UNIT
%type <Number> tSEC_UNIT tUNUMBER tZONE tAMPM
%%
spec : /* NULL */
| spec item
;
item : time { yyHaveTime++; }
| zone { yyHaveZone++; }
| date { yyHaveDate++; }
| day { yyHaveDay++; }
| rel { yyHaveRel++; }
| number
;
time : tUNUMBER tAMPM {
/* "7am" */
yyHour = $1;
if (yyHour == 12)
yyHour = 0;
yyMinutes = 0;
yySeconds = 0;
if ($2 == tPM)
yyHour += 12;
}
| bare_time {
/* "7:12:18" "19:17" */
}
| bare_time tAMPM {
/* "7:12pm", "12:20:13am" */
if (yyHour == 12)
yyHour = 0;
if ($2 == tPM)
yyHour += 12;
}
| bare_time '+' tUNUMBER {
/* "7:14+0700" */
yyDSTmode = DSToff;
yyTimezone = - ($3 % 100 + ($3 / 100) * 60);
}
| bare_time '-' tUNUMBER {
/* "19:14:12-0530" */
yyDSTmode = DSToff;
yyTimezone = + ($3 % 100 + ($3 / 100) * 60);
}
;
bare_time : tUNUMBER ':' tUNUMBER {
yyHour = $1;
yyMinutes = $3;
yySeconds = 0;
}
| tUNUMBER ':' tUNUMBER ':' tUNUMBER {
yyHour = $1;
yyMinutes = $3;
yySeconds = $5;
}
;
zone : tZONE {
yyTimezone = $1;
yyDSTmode = DSToff;
}
| tDAYZONE {
yyTimezone = $1;
yyDSTmode = DSTon;
}
| tZONE tDST {
yyTimezone = $1;
yyDSTmode = DSTon;
}
;
day : tDAY {
yyDayOrdinal = 1;
yyDayNumber = $1;
}
| tDAY ',' {
/* "tue," "wednesday," */
yyDayOrdinal = 1;
yyDayNumber = $1;
}
| tUNUMBER tDAY {
/* "second tues" "3 wed" */
yyDayOrdinal = $1;
yyDayNumber = $2;
}
;
date : tUNUMBER '/' tUNUMBER {
/* "1/15" */
yyMonth = $1;
yyDay = $3;
}
| tUNUMBER '/' tUNUMBER '/' tUNUMBER {
if ($1 >= 13) {
/* First number is big: 2004/01/29, 99/02/17 */
yyYear = $1;
yyMonth = $3;
yyDay = $5;
} else if (($5 >= 13) || ($3 >= 13)) {
/* Last number is big: 01/07/98 */
/* Middle number is big: 01/29/04 */
yyMonth = $1;
yyDay = $3;
yyYear = $5;
} else {
/* No significant clues: 02/03/04 */
yyMonth = $1;
yyDay = $3;
yyYear = $5;
}
}
| tUNUMBER '-' tUNUMBER '-' tUNUMBER {
/* ISO 8601 format. yyyy-mm-dd. */
yyYear = $1;
yyMonth = $3;
yyDay = $5;
}
| tUNUMBER '-' tMONTH '-' tUNUMBER {
if ($1 > 31) {
/* e.g. 1992-Jun-17 */
yyYear = $1;
yyMonth = $3;
yyDay = $5;
} else {
/* e.g. 17-JUN-1992. */
yyDay = $1;
yyMonth = $3;
yyYear = $5;
}
}
| tMONTH tUNUMBER {
/* "May 3" */
yyMonth = $1;
yyDay = $2;
}
| tMONTH tUNUMBER ',' tUNUMBER {
/* "June 17, 2001" */
yyMonth = $1;
yyDay = $2;
yyYear = $4;
}
| tUNUMBER tMONTH {
/* "12 Sept" */
yyDay = $1;
yyMonth = $2;
}
| tUNUMBER tMONTH tUNUMBER {
/* "12 Sept 1997" */
yyDay = $1;
yyMonth = $2;
yyYear = $3;
}
;
rel : relunit tAGO {
yyRelSeconds = -yyRelSeconds;
yyRelMonth = -yyRelMonth;
}
| relunit
;
relunit : '-' tUNUMBER tSEC_UNIT {
/* "-3 hours" */
yyRelSeconds -= $2 * $3;
}
| '+' tUNUMBER tSEC_UNIT {
/* "+1 minute" */
yyRelSeconds += $2 * $3;
}
| tUNUMBER tSEC_UNIT {
/* "1 day" */
yyRelSeconds += $1 * $2;
}
| tSEC_UNIT {
/* "hour" */
yyRelSeconds += $1;
}
| '-' tUNUMBER tMONTH_UNIT {
/* "-3 months" */
yyRelMonth -= $2 * $3;
}
| '+' tUNUMBER tMONTH_UNIT {
/* "+5 years" */
yyRelMonth += $2 * $3;
}
| tUNUMBER tMONTH_UNIT {
/* "2 years" */
yyRelMonth += $1 * $2;
}
| tMONTH_UNIT {
/* "6 months" */
yyRelMonth += $1;
}
;
number : tUNUMBER {
if (yyHaveTime && yyHaveDate && !yyHaveRel)
yyYear = $1;
else {
if($1>10000) {
/* "20040301" */
yyHaveDate++;
yyDay= ($1)%100;
yyMonth= ($1/100)%100;
yyYear = $1/10000;
}
else {
/* "513" is same as "5:13" */
yyHaveTime++;
if ($1 < 100) {
yyHour = $1;
yyMinutes = 0;
}
else {
yyHour = $1 / 100;
yyMinutes = $1 % 100;
}
yySeconds = 0;
}
}
}
;
%%
static struct TABLE {
size_t abbrev;
const char *name;
int type;
time_t value;
} const TimeWords[] = {
/* am/pm */
{ 0, "am", tAMPM, tAM },
{ 0, "pm", tAMPM, tPM },
/* Month names. */
{ 3, "january", tMONTH, 1 },
{ 3, "february", tMONTH, 2 },
{ 3, "march", tMONTH, 3 },
{ 3, "april", tMONTH, 4 },
{ 3, "may", tMONTH, 5 },
{ 3, "june", tMONTH, 6 },
{ 3, "july", tMONTH, 7 },
{ 3, "august", tMONTH, 8 },
{ 3, "september", tMONTH, 9 },
{ 3, "october", tMONTH, 10 },
{ 3, "november", tMONTH, 11 },
{ 3, "december", tMONTH, 12 },
/* Days of the week. */
{ 2, "sunday", tDAY, 0 },
{ 3, "monday", tDAY, 1 },
{ 2, "tuesday", tDAY, 2 },
{ 3, "wednesday", tDAY, 3 },
{ 2, "thursday", tDAY, 4 },
{ 2, "friday", tDAY, 5 },
{ 2, "saturday", tDAY, 6 },
/* Timezones: Offsets are in minutes. */
{ 0, "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
{ 0, "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */
{ 0, "utc", tZONE, HOUR( 0) },
{ 0, "wet", tZONE, HOUR( 0) }, /* Western European */
{ 0, "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
{ 0, "wat", tZONE, HOUR( 1) }, /* West Africa */
{ 0, "at", tZONE, HOUR( 2) }, /* Azores */
/* { 0, "bst", tZONE, HOUR( 3) }, */ /* Brazil Standard: Conflict */
/* { 0, "gst", tZONE, HOUR( 3) }, */ /* Greenland Standard: Conflict*/
{ 0, "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */
{ 0, "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */
{ 0, "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */
{ 0, "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
{ 0, "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
{ 0, "est", tZONE, HOUR( 5) }, /* Eastern Standard */
{ 0, "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
{ 0, "cst", tZONE, HOUR( 6) }, /* Central Standard */
{ 0, "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
{ 0, "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
{ 0, "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
{ 0, "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
{ 0, "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
{ 0, "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
{ 0, "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
{ 0, "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
{ 0, "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */
{ 0, "cat", tZONE, HOUR(10) }, /* Central Alaska */
{ 0, "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */
{ 0, "nt", tZONE, HOUR(11) }, /* Nome */
{ 0, "idlw", tZONE, HOUR(12) }, /* Intl Date Line West */
{ 0, "cet", tZONE, -HOUR(1) }, /* Central European */
{ 0, "met", tZONE, -HOUR(1) }, /* Middle European */
{ 0, "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
{ 0, "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
{ 0, "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
{ 0, "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
{ 0, "fwt", tZONE, -HOUR(1) }, /* French Winter */
{ 0, "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
{ 0, "eet", tZONE, -HOUR(2) }, /* Eastern Eur, USSR Zone 1 */
{ 0, "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */
{ 0, "it", tZONE, -HOUR(3)-30 },/* Iran */
{ 0, "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
{ 0, "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
{ 0, "ist", tZONE, -HOUR(5)-30 },/* Indian Standard */
{ 0, "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
/* { 0, "nst", tZONE, -HOUR(6.5) }, */ /* North Sumatra: Conflict */
/* { 0, "sst", tZONE, -HOUR(7) }, */ /* So Sumatra, USSR 6: Conflict */
{ 0, "wast", tZONE, -HOUR(7) }, /* West Australian Standard */
{ 0, "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */
{ 0, "jt", tZONE, -HOUR(7)-30 },/* Java (3pm in Cronusland!)*/
{ 0, "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */
{ 0, "jst", tZONE, -HOUR(9) }, /* Japan Std, USSR Zone 8 */
{ 0, "cast", tZONE, -HOUR(9)-30 },/* Central Australian Std */
{ 0, "cadt", tDAYZONE, -HOUR(9)-30 },/* Central Australian Daylt */
{ 0, "east", tZONE, -HOUR(10) }, /* Eastern Australian Std */
{ 0, "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylt */
{ 0, "gst", tZONE, -HOUR(10) }, /* Guam Std, USSR Zone 9 */
{ 0, "nzt", tZONE, -HOUR(12) }, /* New Zealand */
{ 0, "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
{ 0, "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
{ 0, "idle", tZONE, -HOUR(12) }, /* Intl Date Line East */
{ 0, "dst", tDST, 0 },
/* Time units. */
{ 4, "years", tMONTH_UNIT, 12 },
{ 5, "months", tMONTH_UNIT, 1 },
{ 9, "fortnights", tSEC_UNIT, 14 * 24 * 60 * 60 },
{ 4, "weeks", tSEC_UNIT, 7 * 24 * 60 * 60 },
{ 3, "days", tSEC_UNIT, 1 * 24 * 60 * 60 },
{ 4, "hours", tSEC_UNIT, 60 * 60 },
{ 3, "minutes", tSEC_UNIT, 60 },
{ 3, "seconds", tSEC_UNIT, 1 },
/* Relative-time words. */
{ 0, "tomorrow", tSEC_UNIT, 1 * 24 * 60 * 60 },
{ 0, "yesterday", tSEC_UNIT, -1 * 24 * 60 * 60 },
{ 0, "today", tSEC_UNIT, 0 },
{ 0, "now", tSEC_UNIT, 0 },
{ 0, "last", tUNUMBER, -1 },
{ 0, "this", tSEC_UNIT, 0 },
{ 0, "next", tUNUMBER, 2 },
{ 0, "first", tUNUMBER, 1 },
{ 0, "1st", tUNUMBER, 1 },
/* { 0, "second", tUNUMBER, 2 }, */
{ 0, "2nd", tUNUMBER, 2 },
{ 0, "third", tUNUMBER, 3 },
{ 0, "3rd", tUNUMBER, 3 },
{ 0, "fourth", tUNUMBER, 4 },
{ 0, "4th", tUNUMBER, 4 },
{ 0, "fifth", tUNUMBER, 5 },
{ 0, "5th", tUNUMBER, 5 },
{ 0, "sixth", tUNUMBER, 6 },
{ 0, "seventh", tUNUMBER, 7 },
{ 0, "eighth", tUNUMBER, 8 },
{ 0, "ninth", tUNUMBER, 9 },
{ 0, "tenth", tUNUMBER, 10 },
{ 0, "eleventh", tUNUMBER, 11 },
{ 0, "twelfth", tUNUMBER, 12 },
{ 0, "ago", tAGO, 1 },
/* Military timezones. */
{ 0, "a", tZONE, HOUR( 1) },
{ 0, "b", tZONE, HOUR( 2) },
{ 0, "c", tZONE, HOUR( 3) },
{ 0, "d", tZONE, HOUR( 4) },
{ 0, "e", tZONE, HOUR( 5) },
{ 0, "f", tZONE, HOUR( 6) },
{ 0, "g", tZONE, HOUR( 7) },
{ 0, "h", tZONE, HOUR( 8) },
{ 0, "i", tZONE, HOUR( 9) },
{ 0, "k", tZONE, HOUR( 10) },
{ 0, "l", tZONE, HOUR( 11) },
{ 0, "m", tZONE, HOUR( 12) },
{ 0, "n", tZONE, HOUR(- 1) },
{ 0, "o", tZONE, HOUR(- 2) },
{ 0, "p", tZONE, HOUR(- 3) },
{ 0, "q", tZONE, HOUR(- 4) },
{ 0, "r", tZONE, HOUR(- 5) },
{ 0, "s", tZONE, HOUR(- 6) },
{ 0, "t", tZONE, HOUR(- 7) },
{ 0, "u", tZONE, HOUR(- 8) },
{ 0, "v", tZONE, HOUR(- 9) },
{ 0, "w", tZONE, HOUR(-10) },
{ 0, "x", tZONE, HOUR(-11) },
{ 0, "y", tZONE, HOUR(-12) },
{ 0, "z", tZONE, HOUR( 0) },
/* End of table. */
{ 0, NULL, 0, 0 }
};
/* ARGSUSED */
static int
yyerror(const char *s)
{
(void)s;
return 0;
}
static time_t
ToSeconds(time_t Hours, time_t Minutes, time_t Seconds)
{
if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59)
return -1;
if (Hours < 0 || Hours > 23)
return -1;
return (Hours * 60L + Minutes) * 60L + Seconds;
}
/* Year is either
* A number from 0 to 99, which means a year from 1970 to 2069, or
* The actual year (>=100). */
static time_t
Convert(time_t Month, time_t Day, time_t Year,
time_t Hours, time_t Minutes, time_t Seconds, DSTMODE DSTmode)
{
static int DaysInMonth[12] = {
31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
time_t tod;
time_t Julian;
int i;
if (Year < 69)
Year += 2000;
else if (Year < 100)
Year += 1900;
DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
? 29 : 28;
/* Checking for 2038 bogusly assumes that time_t is 32 bits. But
I'm too lazy to try to check for time_t overflow in another way. */
if (Year < EPOCH || Year > 2038
|| Month < 1 || Month > 12
/* Lint fluff: "conversion from long may lose accuracy" */
|| Day < 1 || Day > DaysInMonth[(int)--Month])
return -1;
Julian = Day - 1;
for (i = 0; i < Month; i++)
Julian += DaysInMonth[i];
for (i = EPOCH; i < Year; i++)
Julian += 365 + (i % 4 == 0);
Julian *= SECSPERDAY;
Julian += yyTimezone * 60L;
if ((tod = ToSeconds(Hours, Minutes, Seconds)) < 0)
return -1;
Julian += tod;
if (DSTmode == DSTon
|| (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst))
Julian -= 60 * 60;
return Julian;
}
static time_t
DSTcorrect(time_t Start, time_t Future)
{
time_t StartDay;
time_t FutureDay;
StartDay = (localtime(&Start)->tm_hour + 1) % 24;
FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
return (Future - Start) + (StartDay - FutureDay) * 60L * 60L;
}
static time_t
RelativeDate(time_t Start, time_t DayOrdinal, time_t DayNumber)
{
struct tm *tm;
time_t now;
now = Start;
tm = localtime(&now);
now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7);
now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1);
return DSTcorrect(Start, now);
}
static time_t
RelativeMonth(time_t Start, time_t RelMonth)
{
struct tm *tm;
time_t Month;
time_t Year;
if (RelMonth == 0)
return 0;
tm = localtime(&Start);
Month = 12 * (tm->tm_year + 1900) + tm->tm_mon + RelMonth;
Year = Month / 12;
Month = Month % 12 + 1;
return DSTcorrect(Start,
Convert(Month, (time_t)tm->tm_mday, Year,
(time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
DSTmaybe));
}
static int
yylex(void)
{
char c;
char buff[64];
for ( ; ; ) {
while (isspace((unsigned char)*yyInput))
yyInput++;
/* Skip parenthesized comments. */
if (*yyInput == '(') {
int Count = 0;
do {
c = *yyInput++;
if (c == '\0')
return c;
if (c == '(')
Count++;
else if (c == ')')
Count--;
} while (Count > 0);
continue;
}
/* Try the next token in the word table first. */
/* This allows us to match "2nd", for example. */
{
char *src = yyInput;
const struct TABLE *tp;
unsigned i = 0;
/* Force to lowercase and strip '.' characters. */
while (*src != '\0'
&& (isalnum((unsigned char)*src) || *src == '.')
&& i < sizeof(buff)-1) {
if (*src != '.') {
if (isupper((unsigned char)*src))
buff[i++] = tolower((unsigned char)*src);
else
buff[i++] = *src;
}
src++;
}
buff[i++] = '\0';
/*
* Find the first match. If the word can be
* abbreviated, make sure we match at least
* the minimum abbreviation.
*/
for (tp = TimeWords; tp->name; tp++) {
size_t abbrev = tp->abbrev;
if (abbrev == 0)
abbrev = strlen(tp->name);
if (strlen(buff) >= abbrev
&& strncmp(tp->name, buff, strlen(buff))
== 0) {
/* Skip over token. */
yyInput = src;
/* Return the match. */
yylval.Number = tp->value;
return tp->type;
}
}
}
/*
* Not in the word table, maybe it's a number. Note:
* Because '-' and '+' have other special meanings, I
* don't deal with signed numbers here.
*/
if (isdigit((unsigned char)(c = *yyInput))) {
for (yylval.Number = 0; isdigit((unsigned char)(c = *yyInput++)); )
yylval.Number = 10 * yylval.Number + c - '0';
yyInput--;
return (tUNUMBER);
}
return (*yyInput++);
}
}
#define TM_YEAR_ORIGIN 1900
/* Yield A - B, measured in seconds. */
static long
difftm (struct tm *a, struct tm *b)
{
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
int days = (
/* difference in day of year */
a->tm_yday - b->tm_yday
/* + intervening leap days */
+ ((ay >> 2) - (by >> 2))
- (ay/100 - by/100)
+ ((ay/100 >> 2) - (by/100 >> 2))
/* + difference in years * 365 */
+ (long)(ay-by) * 365
);
return (60*(60*(24*days + (a->tm_hour - b->tm_hour))
+ (a->tm_min - b->tm_min))
+ (a->tm_sec - b->tm_sec));
}
time_t
get_date(char *p)
{
struct tm *tm;
struct tm gmt, *gmt_ptr;
time_t Start;
time_t tod;
time_t nowtime;
long tzone;
memset(&gmt, 0, sizeof(gmt));
yyInput = p;
(void)time (&nowtime);
gmt_ptr = gmtime (&nowtime);
if (gmt_ptr != NULL) {
/* Copy, in case localtime and gmtime use the same buffer. */
gmt = *gmt_ptr;
}
if (! (tm = localtime (&nowtime)))
return -1;
if (gmt_ptr != NULL)
tzone = difftm (&gmt, tm) / 60;
else
/* This system doesn't understand timezones; fake it. */
tzone = 0;
if(tm->tm_isdst)
tzone += 60;
yyYear = tm->tm_year + 1900;
yyMonth = tm->tm_mon + 1;
yyDay = tm->tm_mday;
yyTimezone = tzone;
yyDSTmode = DSTmaybe;
yyHour = 0;
yyMinutes = 0;
yySeconds = 0;
yyRelSeconds = 0;
yyRelMonth = 0;
yyHaveDate = 0;
yyHaveDay = 0;
yyHaveRel = 0;
yyHaveTime = 0;
yyHaveZone = 0;
if (yyparse()
|| yyHaveTime > 1 || yyHaveZone > 1
|| yyHaveDate > 1 || yyHaveDay > 1)
return -1;
if (yyHaveDate || yyHaveTime || yyHaveDay) {
Start = Convert(yyMonth, yyDay, yyYear,
yyHour, yyMinutes, yySeconds, yyDSTmode);
if (Start < 0)
return -1;
} else {
Start = nowtime;
if (!yyHaveRel)
Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec;
}
Start += yyRelSeconds;
Start += RelativeMonth(Start, yyRelMonth);
if (yyHaveDay && !yyHaveDate) {
tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber);
Start += tod;
}
/* Have to do *something* with a legitimate -1 so it's
* distinguishable from the error return value. (Alternately
* could set errno on error.) */
return Start == -1 ? 0 : Start;
}
#if defined(TEST)
/* ARGSUSED */
int
main(int argc, char **argv)
{
time_t d;
while (*++argv != NULL) {
(void)printf("Input: %s\n", *argv);
d = get_date(*argv);
if (d == -1)
(void)printf("Bad format - couldn't convert.\n");
else
(void)printf("Output: %s\n", ctime(&d));
}
exit(0);
/* NOTREACHED */
}
#endif /* defined(TEST) */

View File

@ -1,444 +0,0 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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 "bsdtar_platform.h"
__FBSDID("$FreeBSD: src/usr.bin/tar/matching.c,v 1.13 2008/05/26 17:10:10 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "bsdtar.h"
struct match {
struct match *next;
int matches;
char pattern[1];
};
struct matching {
struct match *exclusions;
int exclusions_count;
struct match *inclusions;
int inclusions_count;
int inclusions_unmatched_count;
};
static void add_pattern(struct bsdtar *, struct match **list,
const char *pattern);
static int bsdtar_fnmatch(const char *p, const char *s);
static void initialize_matching(struct bsdtar *);
static int match_exclusion(struct match *, const char *pathname);
static int match_inclusion(struct match *, const char *pathname);
/*
* The matching logic here needs to be re-thought. I started out to
* try to mimic gtar's matching logic, but it's not entirely
* consistent. In particular 'tar -t' and 'tar -x' interpret patterns
* on the command line as anchored, but --exclude doesn't.
*/
/*
* Utility functions to manage exclusion/inclusion patterns
*/
int
exclude(struct bsdtar *bsdtar, const char *pattern)
{
struct matching *matching;
if (bsdtar->matching == NULL)
initialize_matching(bsdtar);
matching = bsdtar->matching;
add_pattern(bsdtar, &(matching->exclusions), pattern);
matching->exclusions_count++;
return (0);
}
int
exclude_from_file(struct bsdtar *bsdtar, const char *pathname)
{
return (process_lines(bsdtar, pathname, &exclude));
}
int
include(struct bsdtar *bsdtar, const char *pattern)
{
struct matching *matching;
if (bsdtar->matching == NULL)
initialize_matching(bsdtar);
matching = bsdtar->matching;
add_pattern(bsdtar, &(matching->inclusions), pattern);
matching->inclusions_count++;
matching->inclusions_unmatched_count++;
return (0);
}
int
include_from_file(struct bsdtar *bsdtar, const char *pathname)
{
return (process_lines(bsdtar, pathname, &include));
}
static void
add_pattern(struct bsdtar *bsdtar, struct match **list, const char *pattern)
{
struct match *match;
match = malloc(sizeof(*match) + strlen(pattern) + 1);
if (match == NULL)
bsdtar_errc(bsdtar, 1, errno, "Out of memory");
if (pattern[0] == '/')
pattern++;
strcpy(match->pattern, pattern);
/* Both "foo/" and "foo" should match "foo/bar". */
if (match->pattern[strlen(match->pattern)-1] == '/')
match->pattern[strlen(match->pattern)-1] = '\0';
match->next = *list;
*list = match;
match->matches = 0;
}
int
excluded(struct bsdtar *bsdtar, const char *pathname)
{
struct matching *matching;
struct match *match;
struct match *matched;
matching = bsdtar->matching;
if (matching == NULL)
return (0);
/* Exclusions take priority */
for (match = matching->exclusions; match != NULL; match = match->next){
if (match_exclusion(match, pathname))
return (1);
}
/* Then check for inclusions */
matched = NULL;
for (match = matching->inclusions; match != NULL; match = match->next){
if (match_inclusion(match, pathname)) {
/*
* If this pattern has never been matched,
* then we're done.
*/
if (match->matches == 0) {
match->matches++;
matching->inclusions_unmatched_count--;
return (0);
}
/*
* Otherwise, remember the match but keep checking
* in case we can tick off an unmatched pattern.
*/
matched = match;
}
}
/*
* We didn't find a pattern that had never been matched, but
* we did find a match, so count it and exit.
*/
if (matched != NULL) {
matched->matches++;
return (0);
}
/* If there were inclusions, default is to exclude. */
if (matching->inclusions != NULL)
return (1);
/* No explicit inclusions, default is to match. */
return (0);
}
/*
* This is a little odd, but it matches the default behavior of
* gtar. In particular, 'a*b' will match 'foo/a1111/222b/bar'
*
*/
int
match_exclusion(struct match *match, const char *pathname)
{
const char *p;
if (*match->pattern == '*' || *match->pattern == '/')
return (bsdtar_fnmatch(match->pattern, pathname) == 0);
for (p = pathname; p != NULL; p = strchr(p, '/')) {
if (*p == '/')
p++;
if (bsdtar_fnmatch(match->pattern, p) == 0)
return (1);
}
return (0);
}
/*
* Again, mimic gtar: inclusions are always anchored (have to match
* the beginning of the path) even though exclusions are not anchored.
*/
int
match_inclusion(struct match *match, const char *pathname)
{
return (bsdtar_fnmatch(match->pattern, pathname) == 0);
}
void
cleanup_exclusions(struct bsdtar *bsdtar)
{
struct match *p, *q;
if (bsdtar->matching) {
p = bsdtar->matching->inclusions;
while (p != NULL) {
q = p;
p = p->next;
free(q);
}
p = bsdtar->matching->exclusions;
while (p != NULL) {
q = p;
p = p->next;
free(q);
}
free(bsdtar->matching);
}
}
static void
initialize_matching(struct bsdtar *bsdtar)
{
bsdtar->matching = malloc(sizeof(*bsdtar->matching));
if (bsdtar->matching == NULL)
bsdtar_errc(bsdtar, 1, errno, "No memory");
memset(bsdtar->matching, 0, sizeof(*bsdtar->matching));
}
int
unmatched_inclusions(struct bsdtar *bsdtar)
{
struct matching *matching;
matching = bsdtar->matching;
if (matching == NULL)
return (0);
return (matching->inclusions_unmatched_count);
}
int
unmatched_inclusions_warn(struct bsdtar *bsdtar, const char *msg)
{
struct matching *matching;
struct match *p;
matching = bsdtar->matching;
if (matching == NULL)
return (0);
p = matching->inclusions;
while (p != NULL) {
if (p->matches == 0) {
bsdtar->return_value = 1;
bsdtar_warnc(bsdtar, 0, "%s: %s",
p->pattern, msg);
}
p = p->next;
}
return (matching->inclusions_unmatched_count);
}
#if defined(HAVE_FNMATCH) && defined(HAVE_FNM_LEADING_DIR)
/* Use system fnmatch() if it suits our needs. */
/* On Linux, _GNU_SOURCE must be defined to get FNM_LEADING_DIR. */
#define _GNU_SOURCE
#include <fnmatch.h>
static int
bsdtar_fnmatch(const char *pattern, const char *string)
{
return (fnmatch(pattern, string, FNM_LEADING_DIR));
}
#else
/*
* The following was hacked from BSD C library
* code: src/lib/libc/gen/fnmatch.c,v 1.15 2002/02/01
*
* In particular, most of the flags were ripped out: this always
* behaves like FNM_LEADING_DIR is set and other flags specified
* by POSIX are unset.
*
* Normally, I would not conditionally compile something like this: If
* I have to support it anyway, everyone may as well use it. ;-)
* However, the full POSIX spec for fnmatch() includes a lot of
* advanced character handling that I'm not ready to put in here, so
* it's probably best if people use a local version when it's available.
*/
/*
* Copyright (c) 1989, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Guido van Rossum.
*
* 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.
* 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.
*/
static int
bsdtar_fnmatch(const char *pattern, const char *string)
{
const char *saved_pattern;
int negate, matched;
char c;
for (;;) {
switch (c = *pattern++) {
case '\0':
if (*string == '/' || *string == '\0')
return (0);
return (1);
case '?':
if (*string == '\0')
return (1);
++string;
break;
case '*':
c = *pattern;
/* Collapse multiple stars. */
while (c == '*')
c = *++pattern;
/* Optimize for pattern with * at end. */
if (c == '\0')
return (0);
/* General case, use recursion. */
while (*string != '\0') {
if (!bsdtar_fnmatch(pattern, string))
return (0);
++string;
}
return (1);
case '[':
if (*string == '\0')
return (1);
saved_pattern = pattern;
if (*pattern == '!' || *pattern == '^') {
negate = 1;
++pattern;
} else
negate = 0;
matched = 0;
c = *pattern++;
do {
if (c == '\\')
c = *pattern++;
if (c == '\0') {
pattern = saved_pattern;
c = '[';
goto norm;
}
if (*pattern == '-') {
char c2 = *(pattern + 1);
if (c2 == '\0') {
pattern = saved_pattern;
c = '[';
goto norm;
}
if (c2 == ']') {
/* [a-] is not a range. */
if (c == *string
|| '-' == *string)
matched = 1;
pattern ++;
} else {
if (c <= *string
&& *string <= c2)
matched = 1;
pattern += 2;
}
} else if (c == *string)
matched = 1;
c = *pattern++;
} while (c != ']');
if (matched == negate)
return (1);
++string;
break;
case '\\':
if ((c = *pattern++) == '\0') {
c = '\\';
--pattern;
}
/* FALLTHROUGH */
default:
norm:
if (c != *string)
return (1);
string++;
break;
}
}
/* NOTREACHED */
}
#endif

View File

@ -1,147 +0,0 @@
/*-
* Copyright 2008 Colin Percival
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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 "bsdtar_platform.h"
__FBSDID("$FreeBSD: src/usr.bin/tar/siginfo.c,v 1.2 2008/05/22 21:08:36 cperciva Exp $");
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bsdtar.h"
/* Is there a pending SIGINFO or SIGUSR1? */
static volatile sig_atomic_t siginfo_received = 0;
struct siginfo_data {
/* What sort of operation are we doing? */
char * oper;
/* What path are we handling? */
char * path;
/* How large is the archive entry? */
int64_t size;
/* Old signal handlers. */
#ifdef SIGINFO
void (*siginfo_old)(int);
#endif
void (*sigusr1_old)(int);
};
static void siginfo_handler(int sig);
/* Handler for SIGINFO / SIGUSR1. */
static void
siginfo_handler(int sig)
{
(void)sig; /* UNUSED */
/* Record that SIGINFO or SIGUSR1 has been received. */
siginfo_received = 1;
}
void
siginfo_init(struct bsdtar *bsdtar)
{
/* Allocate space for internal structure. */
if ((bsdtar->siginfo = malloc(sizeof(struct siginfo_data))) == NULL)
bsdtar_errc(bsdtar, 1, errno, "malloc failed");
/* Set the strings to NULL so that free() is safe. */
bsdtar->siginfo->path = bsdtar->siginfo->oper = NULL;
#ifdef SIGINFO
/* We want to catch SIGINFO, if it exists. */
bsdtar->siginfo->siginfo_old = signal(SIGINFO, siginfo_handler);
#endif
/* ... and treat SIGUSR1 the same way as SIGINFO. */
bsdtar->siginfo->sigusr1_old = signal(SIGUSR1, siginfo_handler);
}
void
siginfo_setinfo(struct bsdtar *bsdtar, const char * oper, const char * path,
int64_t size)
{
/* Free old operation and path strings. */
free(bsdtar->siginfo->oper);
free(bsdtar->siginfo->path);
/* Duplicate strings and store entry size. */
if ((bsdtar->siginfo->oper = strdup(oper)) == NULL)
bsdtar_errc(bsdtar, 1, errno, "Cannot strdup");
if ((bsdtar->siginfo->path = strdup(path)) == NULL)
bsdtar_errc(bsdtar, 1, errno, "Cannot strdup");
bsdtar->siginfo->size = size;
}
void
siginfo_printinfo(struct bsdtar *bsdtar, off_t progress)
{
/* If there's a signal to handle and we know what we're doing... */
if ((siginfo_received == 1) &&
(bsdtar->siginfo->path != NULL) &&
(bsdtar->siginfo->oper != NULL)) {
if (bsdtar->verbose)
fprintf(stderr, "\n");
if (bsdtar->siginfo->size > 0) {
safe_fprintf(stderr, "%s %s (%ju / %" PRId64 ")",
bsdtar->siginfo->oper, bsdtar->siginfo->path,
(uintmax_t)progress, bsdtar->siginfo->size);
} else {
safe_fprintf(stderr, "%s %s",
bsdtar->siginfo->oper, bsdtar->siginfo->path);
}
if (!bsdtar->verbose)
fprintf(stderr, "\n");
siginfo_received = 0;
}
}
void
siginfo_done(struct bsdtar *bsdtar)
{
#ifdef SIGINFO
/* Restore old SIGINFO handler. */
signal(SIGINFO, bsdtar->siginfo->siginfo_old);
#endif
/* And the old SIGUSR1 handler, too. */
signal(SIGUSR1, bsdtar->siginfo->sigusr1_old);
/* Free strings. */
free(bsdtar->siginfo->path);
free(bsdtar->siginfo->oper);
/* Free internal data structure. */
free(bsdtar->siginfo);
}

View File

@ -1,142 +0,0 @@
/*-
* Copyright (c) 2003-2008 Tim Kientzle
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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 "test.h"
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_option_T.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
static int
touch(const char *fn)
{
int fd = open(fn, O_RDWR | O_CREAT);
failure("Couldn't create file '%s', fd=%d, errno=%d (%s)\n",
fn, fd, errno, strerror(errno));
if (!assert(fd > 0))
return (0); /* Failure. */
close(fd);
return (1); /* Success */
}
DEFINE_TEST(test_option_T)
{
FILE *f;
/* Create a simple dir heirarchy; bail if anything fails. */
if (!assertEqualInt(0, mkdir("d1", 0755))) return;
if (!assertEqualInt(0, mkdir("d1/d2", 0755))) return;
if (!touch("d1/f1")) return;
if (!touch("d1/f2")) return;
if (!touch("d1/d2/f3")) return;
if (!touch("d1/d2/f4")) return;
if (!touch("d1/d2/f5")) return;
/* Populate a file list */
f = fopen("filelist", "w+");
if (!assert(f != NULL))
return;
fprintf(f, "d1/f1\n");
fprintf(f, "d1/d2/f4\n");
fclose(f);
/* Populate a second file list */
f = fopen("filelist2", "w+");
if (!assert(f != NULL))
return;
fprintf(f, "d1/d2/f3\n");
fprintf(f, "d1/d2/f5\n");
fclose(f);
/* Use -c -T to archive up the files. */
systemf("%s -c -f test1.tar -T filelist > test1.out 2> test1.err",
testprog);
assertEmptyFile("test1.out");
assertEmptyFile("test1.err");
/* Use -x -T to dearchive the files */
if (!assertEqualInt(0, mkdir("test1", 0755))) return;
systemf("%s -x -f test1.tar -T filelist -C test1"
" > test1b.out 2> test1b.err", testprog);
assertEmptyFile("test1b.out");
assertEmptyFile("test1b.err");
/* Verify the files were extracted. */
assertFileExists("test1/d1/f1");
assertFileNotExists("test1/d1/f2");
assertFileNotExists("test1/d1/d2/f3");
assertFileExists("test1/d1/d2/f4");
assertFileNotExists("test1/d1/d2/f5");
/* Use -r -T to add more files to the archive. */
systemf("%s -r -f test1.tar -T filelist2 > test2.out 2> test2.err",
testprog);
assertEmptyFile("test2.out");
assertEmptyFile("test2.err");
/* Use -x without -T to dearchive the files (ensure -r worked) */
if (!assertEqualInt(0, mkdir("test3", 0755))) return;
systemf("%s -x -f test1.tar -C test3"
" > test3.out 2> test3.err", testprog);
assertEmptyFile("test3.out");
assertEmptyFile("test3.err");
/* Verify the files were extracted.*/
assertFileExists("test3/d1/f1");
assertFileNotExists("test3/d1/f2");
assertFileExists("test3/d1/d2/f3");
assertFileExists("test3/d1/d2/f4");
assertFileExists("test3/d1/d2/f5");
/* Use -x -T to dearchive the files (verify -x -T together) */
if (!assertEqualInt(0, mkdir("test2", 0755))) return;
systemf("%s -x -f test1.tar -T filelist -C test2"
" > test2b.out 2> test2b.err", testprog);
assertEmptyFile("test2b.out");
assertEmptyFile("test2b.err");
/* Verify the files were extracted.*/
assertFileExists("test2/d1/f1");
assertFileNotExists("test2/d1/f2");
assertFileNotExists("test2/d1/d2/f3");
assertFileExists("test2/d1/d2/f4");
assertFileNotExists("test2/d1/d2/f5");
assertEqualInt(0, mkdir("test4", 0755));
assertEqualInt(0, mkdir("test4_out", 0755));
assertEqualInt(0, mkdir("test4_out2", 0755));
assertEqualInt(0, mkdir("test4/d1", 0755));
assertEqualInt(1, touch("test4/d1/foo"));
systemf("%s -cf - -s /foo/bar/ test4/d1/foo | %s -xf - -C test4_out",
testprog, testprog);
assertEmptyFile("test4_out/test4/d1/bar");
systemf("%s -cf - -s /d1/d2/ test4/d1/foo | %s -xf - -C test4_out",
testprog, testprog);
assertEmptyFile("test4_out/test4/d2/foo");
systemf("%s -cf - -s ,test4/d1/foo,, test4/d1/foo | %s -tvf - > test4.lst",
testprog, testprog);
assertEmptyFile("test4.lst");
systemf("%s -cf - test4/d1/foo | %s -xf - -s /foo/bar/ -C test4_out2",
testprog, testprog);
assertEmptyFile("test4_out2/test4/d1/bar");
/* TODO: Include some use of -C directory-changing within the filelist. */
/* I'm pretty sure -C within the filelist is broken on extract. */
}