diff options
author | mm <mm@FreeBSD.org> | 2011-12-21 11:18:49 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2011-12-21 11:18:49 +0000 |
commit | 89ab30c75fb39b787137083c605fcb09563c2920 (patch) | |
tree | 61643326e8c3ea242090f87364bc9e05a889155f /contrib/libarchive/tar | |
parent | 5fa2c01e289ce67d0d55ac9021d72da163545ae4 (diff) | |
download | FreeBSD-src-89ab30c75fb39b787137083c605fcb09563c2920.zip FreeBSD-src-89ab30c75fb39b787137083c605fcb09563c2920.tar.gz |
Strip unnecessary files and directories from contrib/libarchive
according to FREEBSD-Xlist
MFC after: 2 weeks
Diffstat (limited to 'contrib/libarchive/tar')
-rw-r--r-- | contrib/libarchive/tar/CMakeLists.txt | 55 | ||||
-rw-r--r-- | contrib/libarchive/tar/bsdtar_windows.c | 298 | ||||
-rw-r--r-- | contrib/libarchive/tar/bsdtar_windows.h | 60 | ||||
-rw-r--r-- | contrib/libarchive/tar/test/CMakeLists.txt | 67 | ||||
-rw-r--r-- | contrib/libarchive/tar/test/test_windows.c | 323 |
5 files changed, 0 insertions, 803 deletions
diff --git a/contrib/libarchive/tar/CMakeLists.txt b/contrib/libarchive/tar/CMakeLists.txt deleted file mode 100644 index 2ed8161..0000000 --- a/contrib/libarchive/tar/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -############################################ -# -# How to build bsdtar -# -############################################ -IF (ENABLE_TAR) - - SET(bsdtar_SOURCES - bsdtar.c - bsdtar.h - bsdtar_platform.h - cmdline.c - getdate.c - read.c - subst.c - tree.c - tree.h - util.c - write.c - ../libarchive_fe/err.c - ../libarchive_fe/err.h - ../libarchive_fe/lafe_platform.h - ../libarchive_fe/line_reader.c - ../libarchive_fe/line_reader.h - ../libarchive_fe/matching.c - ../libarchive_fe/matching.h - ../libarchive_fe/pathmatch.c - ../libarchive_fe/pathmatch.h - ) - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libarchive_fe) - IF(WIN32 AND NOT CYGWIN) - LIST(APPEND bsdtar_SOURCES bsdtar_windows.c) - LIST(APPEND bsdtar_SOURCES bsdtar_windows.h) - ENDIF(WIN32 AND NOT CYGWIN) - - # bsdtar documentation - SET(bsdtar_MANS bsdtar.1) - - # How to build bsdtar - ADD_EXECUTABLE(bsdtar ${bsdtar_SOURCES}) - IF(ENABLE_TAR_SHARED) - TARGET_LINK_LIBRARIES(bsdtar archive ${ADDITIONAL_LIBS}) - ELSE(ENABLE_TAR_SHARED) - TARGET_LINK_LIBRARIES(bsdtar archive_static ${ADDITIONAL_LIBS}) - SET_TARGET_PROPERTIES(bsdtar PROPERTIES COMPILE_DEFINITIONS - LIBARCHIVE_STATIC) - ENDIF(ENABLE_TAR_SHARED) - GET_TARGET_PROPERTY(BSDTAR bsdtar LOCATION) - - # Installation rules - INSTALL(TARGETS bsdtar RUNTIME DESTINATION bin) - INSTALL_MAN(${bsdtar_MANS}) -ENDIF(ENABLE_TAR) - -add_subdirectory(test) diff --git a/contrib/libarchive/tar/bsdtar_windows.c b/contrib/libarchive/tar/bsdtar_windows.c deleted file mode 100644 index 4d12050..0000000 --- a/contrib/libarchive/tar/bsdtar_windows.c +++ /dev/null @@ -1,298 +0,0 @@ -/*- - * Copyright (c) 2009 Michihiro NAKAJIMA - * 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$ - */ - -#if defined(_WIN32) && !defined(__CYGWIN__) - -#include "bsdtar_platform.h" -#include <ctype.h> -#include <errno.h> -#include <fcntl.h> -#include <io.h> -#include <stddef.h> -#ifdef HAVE_SYS_UTIME_H -#include <sys/utime.h> -#endif -#include <sys/stat.h> -#include <process.h> -#include <stdlib.h> -#include <wchar.h> -#include <windows.h> -#include <sddl.h> - -#include "bsdtar.h" -#include "err.h" - -/* This may actually not be needed anymore. - * TODO: Review the error handling for chdir() failures and - * simply dump this if it's not really needed. */ -static void __tar_dosmaperr(unsigned long); - -/* - * Prepend "\\?\" to the path name and convert it to unicode to permit - * an extended-length path for a maximum total path length of 32767 - * characters. - * see also http://msdn.microsoft.com/en-us/library/aa365247.aspx - */ -static wchar_t * -permissive_name(const char *name) -{ - wchar_t *wn, *wnp; - wchar_t *ws, *wsp; - DWORD l, len, slen, alloclen; - int unc; - - len = (DWORD)strlen(name); - wn = malloc((len + 1) * sizeof(wchar_t)); - if (wn == NULL) - return (NULL); - l = MultiByteToWideChar(CP_ACP, 0, name, len, wn, len); - if (l == 0) { - free(wn); - return (NULL); - } - wn[l] = L'\0'; - - /* Get a full path names */ - l = GetFullPathNameW(wn, 0, NULL, NULL); - if (l == 0) { - free(wn); - return (NULL); - } - wnp = malloc(l * sizeof(wchar_t)); - if (wnp == NULL) { - free(wn); - return (NULL); - } - len = GetFullPathNameW(wn, l, wnp, NULL); - free(wn); - wn = wnp; - - if (wnp[0] == L'\\' && wnp[1] == L'\\' && - wnp[2] == L'?' && wnp[3] == L'\\') - /* We have already permissive names. */ - return (wn); - - if (wnp[0] == L'\\' && wnp[1] == L'\\' && - wnp[2] == L'.' && wnp[3] == L'\\') { - /* Device names */ - if (((wnp[4] >= L'a' && wnp[4] <= L'z') || - (wnp[4] >= L'A' && wnp[4] <= L'Z')) && - wnp[5] == L':' && wnp[6] == L'\\') - wnp[2] = L'?';/* Not device names. */ - return (wn); - } - - unc = 0; - if (wnp[0] == L'\\' && wnp[1] == L'\\' && wnp[2] != L'\\') { - wchar_t *p = &wnp[2]; - - /* Skip server-name letters. */ - while (*p != L'\\' && *p != L'\0') - ++p; - if (*p == L'\\') { - wchar_t *rp = ++p; - /* Skip share-name letters. */ - while (*p != L'\\' && *p != L'\0') - ++p; - if (*p == L'\\' && p != rp) { - /* Now, match patterns such as - * "\\server-name\share-name\" */ - wnp += 2; - len -= 2; - unc = 1; - } - } - } - - alloclen = slen = 4 + (unc * 4) + len + 1; - ws = wsp = malloc(slen * sizeof(wchar_t)); - if (ws == NULL) { - free(wn); - return (NULL); - } - /* prepend "\\?\" */ - wcsncpy(wsp, L"\\\\?\\", 4); - wsp += 4; - slen -= 4; - if (unc) { - /* append "UNC\" ---> "\\?\UNC\" */ - wcsncpy(wsp, L"UNC\\", 4); - wsp += 4; - slen -= 4; - } - wcsncpy(wsp, wnp, slen); - free(wn); - ws[alloclen - 1] = L'\0'; - return (ws); -} - -int -__tar_chdir(const char *path) -{ - wchar_t *ws; - int r; - - r = SetCurrentDirectoryA(path); - if (r == 0) { - if (GetLastError() != ERROR_FILE_NOT_FOUND) { - __tar_dosmaperr(GetLastError()); - return (-1); - } - } else - return (0); - ws = permissive_name(path); - if (ws == NULL) { - errno = EINVAL; - return (-1); - } - r = SetCurrentDirectoryW(ws); - free(ws); - if (r == 0) { - __tar_dosmaperr(GetLastError()); - return (-1); - } - return (0); -} - -/* - * The following function was modified from PostgreSQL sources and is - * subject to the copyright below. - */ -/*------------------------------------------------------------------------- - * - * win32error.c - * Map win32 error codes to errno values - * - * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group - * - * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/win32error.c,v 1.4 2008/01/01 19:46:00 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -/* -PostgreSQL Database Management System -(formerly known as Postgres, then as Postgres95) - -Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group - -Portions Copyright (c) 1994, The Regents of the University of California - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose, without fee, and without a written agreement -is hereby granted, provided that the above copyright notice and this -paragraph and the following two paragraphs appear in all copies. - -IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR -DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING -LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS -DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS -ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO -PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -*/ - -static const struct { - DWORD winerr; - int doserr; -} doserrors[] = -{ - { ERROR_INVALID_FUNCTION, EINVAL }, - { ERROR_FILE_NOT_FOUND, ENOENT }, - { ERROR_PATH_NOT_FOUND, ENOENT }, - { ERROR_TOO_MANY_OPEN_FILES, EMFILE }, - { ERROR_ACCESS_DENIED, EACCES }, - { ERROR_INVALID_HANDLE, EBADF }, - { ERROR_ARENA_TRASHED, ENOMEM }, - { ERROR_NOT_ENOUGH_MEMORY, ENOMEM }, - { ERROR_INVALID_BLOCK, ENOMEM }, - { ERROR_BAD_ENVIRONMENT, E2BIG }, - { ERROR_BAD_FORMAT, ENOEXEC }, - { ERROR_INVALID_ACCESS, EINVAL }, - { ERROR_INVALID_DATA, EINVAL }, - { ERROR_INVALID_DRIVE, ENOENT }, - { ERROR_CURRENT_DIRECTORY, EACCES }, - { ERROR_NOT_SAME_DEVICE, EXDEV }, - { ERROR_NO_MORE_FILES, ENOENT }, - { ERROR_LOCK_VIOLATION, EACCES }, - { ERROR_SHARING_VIOLATION, EACCES }, - { ERROR_BAD_NETPATH, ENOENT }, - { ERROR_NETWORK_ACCESS_DENIED, EACCES }, - { ERROR_BAD_NET_NAME, ENOENT }, - { ERROR_FILE_EXISTS, EEXIST }, - { ERROR_CANNOT_MAKE, EACCES }, - { ERROR_FAIL_I24, EACCES }, - { ERROR_INVALID_PARAMETER, EINVAL }, - { ERROR_NO_PROC_SLOTS, EAGAIN }, - { ERROR_DRIVE_LOCKED, EACCES }, - { ERROR_BROKEN_PIPE, EPIPE }, - { ERROR_DISK_FULL, ENOSPC }, - { ERROR_INVALID_TARGET_HANDLE, EBADF }, - { ERROR_INVALID_HANDLE, EINVAL }, - { ERROR_WAIT_NO_CHILDREN, ECHILD }, - { ERROR_CHILD_NOT_COMPLETE, ECHILD }, - { ERROR_DIRECT_ACCESS_HANDLE, EBADF }, - { ERROR_NEGATIVE_SEEK, EINVAL }, - { ERROR_SEEK_ON_DEVICE, EACCES }, - { ERROR_DIR_NOT_EMPTY, ENOTEMPTY }, - { ERROR_NOT_LOCKED, EACCES }, - { ERROR_BAD_PATHNAME, ENOENT }, - { ERROR_MAX_THRDS_REACHED, EAGAIN }, - { ERROR_LOCK_FAILED, EACCES }, - { ERROR_ALREADY_EXISTS, EEXIST }, - { ERROR_FILENAME_EXCED_RANGE, ENOENT }, - { ERROR_NESTING_NOT_ALLOWED, EAGAIN }, - { ERROR_NOT_ENOUGH_QUOTA, ENOMEM } -}; - -static void -__tar_dosmaperr(unsigned long e) -{ - int i; - - if (e == 0) { - errno = 0; - return; - } - - for (i = 0; i < sizeof(doserrors); i++) { - if (doserrors[i].winerr == e) { - errno = doserrors[i].doserr; - return; - } - } - - /* fprintf(stderr, "unrecognized win32 error code: %lu", e); */ - errno = EINVAL; - return; -} - -#endif diff --git a/contrib/libarchive/tar/bsdtar_windows.h b/contrib/libarchive/tar/bsdtar_windows.h deleted file mode 100644 index 092ea69..0000000 --- a/contrib/libarchive/tar/bsdtar_windows.h +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 2009 Michihiro NAKAJIMA - * 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$ - */ - -#ifndef BSDTAR_WINDOWS_H -#define BSDTAR_WINDOWS_H 1 -#include <direct.h> -#include <windows.h> - -#ifndef PRId64 -#define PRId64 "I64" -#endif -#define geteuid() 0 - -#ifndef S_IFIFO -#define S_IFIFO 0010000 /* pipe */ -#endif - -#include <string.h> /* Must include before redefining 'strdup' */ -#if !defined(__BORLANDC__) -#define strdup _strdup -#endif -#if !defined(__BORLANDC__) -#define getcwd _getcwd -#endif - -#define chdir __tar_chdir -int __tar_chdir(const char *); - -#ifndef S_ISREG -#define S_ISREG(a) (a & _S_IFREG) -#endif -#ifndef S_ISBLK -#define S_ISBLK(a) (0) -#endif - -#endif /* BSDTAR_WINDOWS_H */ diff --git a/contrib/libarchive/tar/test/CMakeLists.txt b/contrib/libarchive/tar/test/CMakeLists.txt deleted file mode 100644 index 6064e14..0000000 --- a/contrib/libarchive/tar/test/CMakeLists.txt +++ /dev/null @@ -1,67 +0,0 @@ -############################################ -# -# How to build bsdtar_test -# -############################################ -IF(ENABLE_TAR AND ENABLE_TEST) - SET(bsdtar_test_SOURCES - ../getdate.c - main.c - test.h - test_0.c - test_basic.c - test_copy.c - test_empty_mtree.c - test_getdate.c - test_help.c - test_option_T_upper.c - test_option_q.c - test_option_r.c - test_option_s.c - test_patterns.c - test_stdio.c - test_strip_components.c - test_symlink_dir.c - test_version.c - test_windows.c - ) - IF(WIN32 AND NOT CYGWIN) - LIST(APPEND bsdtar_test_SOURCES ../bsdtar_windows.c) - LIST(APPEND bsdtar_test_SOURCES ../bsdtar_windows.h) - ENDIF(WIN32 AND NOT CYGWIN) - - # - # Register target - # - ADD_EXECUTABLE(bsdtar_test ${bsdtar_test_SOURCES}) - SET_PROPERTY(TARGET bsdtar_test PROPERTY COMPILE_DEFINITIONS LIST_H) - - # - # Generate list.h by grepping DEFINE_TEST() lines out of the C sources. - # - GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h - ${CMAKE_CURRENT_LIST_FILE} ${bsdtar_test_SOURCES}) - SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_BINARY_DIR}) - - # list.h has a line DEFINE_TEST(testname) for every - # test. We can use that to define the tests for cmake by - # defining a DEFINE_TEST macro and reading list.h in. - MACRO (DEFINE_TEST _testname) - ADD_TEST_28( - NAME bsdtar_${_testname} - COMMAND bsdtar_test -vv - -p $<TARGET_FILE:bsdtar> - -r ${CMAKE_CURRENT_SOURCE_DIR} - ${_testname}) - ENDMACRO (DEFINE_TEST _testname) - - INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h) - - # Experimental new test handling - ADD_CUSTOM_TARGET(run_bsdtar_test - COMMAND bsdtar_test -p ${BSDTAR} -r ${CMAKE_CURRENT_SOURCE_DIR}) - ADD_DEPENDENCIES(run_bsdtar_test bsdtar) - ADD_DEPENDENCIES(run_all_tests run_bsdtar_test) - -ENDIF (ENABLE_TAR AND ENABLE_TEST) diff --git a/contrib/libarchive/tar/test/test_windows.c b/contrib/libarchive/tar/test/test_windows.c deleted file mode 100644 index a2d0c21..0000000 --- a/contrib/libarchive/tar/test/test_windows.c +++ /dev/null @@ -1,323 +0,0 @@ -/*- - * Copyright (c) 2009 Michihiro NAKAJIMA - * 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" - -#if defined(_WIN32) && !defined(__CYGWIN__) -#include <windows.h> - -static void -mkfile(const char *name) -{ - FILE *f; - - f = fopen(name, "wb"); - assert(f != NULL); - assertEqualInt(5, fwrite("01234", 1, 5, f)); - fclose(f); -} - -static void -mkfullpath(char **path1, char **path2, const char *tpath, int type) -{ - char *fp1 = NULL, *fp2 = NULL, *p1 = NULL, *p2 = NULL; - size_t l; - - /* - * Get full path name of "tpath" - */ - l = GetFullPathNameA(tpath, 0, NULL, NULL); - assert(0 != l); - fp1 = malloc(l); - assert(NULL != fp1); - fp2 = malloc(l*2); - assert(NULL != fp2); - l = GetFullPathNameA(tpath, l, fp1, NULL); - if ((type & 0x01) == 0) { - for (p1 = fp1; *p1 != '\0'; p1++) - if (*p1 == '\\') - *p1 = '/'; - } - - switch(type) { - case 0: /* start with "/" */ - case 1: /* start with "\" */ - /* strip "c:" */ - memmove(fp1, fp1 + 2, l - 2); - fp1[l -2] = '\0'; - p1 = fp1 + 1; - break; - case 2: /* start with "c:/" */ - case 3: /* start with "c:\" */ - p1 = fp1 + 3; - break; - case 4: /* start with "//./c:/" */ - case 5: /* start with "\\.\c:\" */ - case 6: /* start with "//?/c:/" */ - case 7: /* start with "\\?\c:\" */ - p1 = malloc(l + 4 + 1); - assert(NULL != p1); - if (type & 0x1) - memcpy(p1, "\\\\.\\", 4); - else - memcpy(p1, "//./", 4); - if (type == 6 || type == 7) - p1[2] = '?'; - memcpy(p1 + 4, fp1, l); - p1[l + 4] = '\0'; - free(fp1); - fp1 = p1; - p1 = fp1 + 7; - break; - } - - /* - * Strip leading drive names and converting "\" to "\\" - */ - p2 = fp2; - while (*p1 != '\0') { - if (*p1 == '\\') - *p2 = '/'; - else - *p2 = *p1; - ++p1; - ++p2; - } - *p2++ = '\r'; - *p2++ = '\n'; - *p2 = '\0'; - - *path1 = fp1; - *path2 = fp2; -} - -static const char *list1[] = {"aaa/", "aaa/file1", "aaa/xxa/", "aaa/xxb/", - "aaa/zzc/", "aaa/zzc/file1", "aaa/xxb/file1", "aaa/xxa/file1", - "aab/", "aac/", "abb/", "abc/", "abd/", NULL}; -static const char *list2[] = {"bbb/", "bbb/file1", "bbb/xxa/", "bbb/xxb/", - "bbb/zzc/", "bbb/zzc/file1", "bbb/xxb/file1", "bbb/xxa/file1", "bbc/", - "bbd/", "bcc/", "bcd/", "bce/", NULL}; -static const char *list3[] = {"aac/", "abc/", "bbc/", "bcc/", "ccc/", NULL}; -static const char *list4[] = {"fff/abca", "fff/acca", NULL}; -static const char *list5[] = {"aaa/file1", "aaa/xxa/", "aaa/xxa/file1", - "aaa/xxb/", "aaa/xxb/file1", "aaa/zzc/", "aaa/zzc/file1", NULL}; -static const char *list6[] = {"fff/abca", "fff/acca", "aaa/xxa/", - "aaa/xxa/file1", "aaa/xxb/", "aaa/xxb/file1", NULL}; -#endif /* _WIN32 && !__CYGWIN__ */ - -DEFINE_TEST(test_windows) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - char *fp1, *fp2; - - /* - * Preparre tests. - * Create directories and files. - */ - assertMakeDir("tmp", 0775); - assertChdir("tmp"); - - assertMakeDir("aaa", 0775); - assertMakeDir("aaa/xxa", 0775); - assertMakeDir("aaa/xxb", 0775); - assertMakeDir("aaa/zzc", 0775); - mkfile("aaa/file1"); - mkfile("aaa/xxa/file1"); - mkfile("aaa/xxb/file1"); - mkfile("aaa/zzc/file1"); - assertMakeDir("aab", 0775); - assertMakeDir("aac", 0775); - assertMakeDir("abb", 0775); - assertMakeDir("abc", 0775); - assertMakeDir("abd", 0775); - assertMakeDir("bbb", 0775); - assertMakeDir("bbb/xxa", 0775); - assertMakeDir("bbb/xxb", 0775); - assertMakeDir("bbb/zzc", 0775); - mkfile("bbb/file1"); - mkfile("bbb/xxa/file1"); - mkfile("bbb/xxb/file1"); - mkfile("bbb/zzc/file1"); - assertMakeDir("bbc", 0775); - assertMakeDir("bbd", 0775); - assertMakeDir("bcc", 0775); - assertMakeDir("bcd", 0775); - assertEqualInt(0, _mkdir("bce")); - assertEqualInt(0, _mkdir("ccc")); - assertEqualInt(0, _mkdir("fff")); - mkfile("fff/aaaa"); - mkfile("fff/abba"); - mkfile("fff/abca"); - mkfile("fff/acba"); - mkfile("fff/acca"); - - /* - * Test1: Command line pattern matching. - */ - assertEqualInt(0, - systemf("%s -cf ../archive1.tar a*", testprog)); - assertEqualInt(0, - systemf("%s -tf ../archive1.tar > ../list1", testprog)); - assertFileContainsLinesAnyOrder("../list1", list1); - - assertEqualInt(0, - systemf("%s -cf ../archive2.tar b*", testprog)); - assertEqualInt(0, - systemf("%s -tf ../archive2.tar > ../list2", testprog)); - assertFileContainsLinesAnyOrder("../list2", list2); - - assertEqualInt(0, - systemf("%s -cf ../archive3.tar ??c", testprog)); - assertEqualInt(0, - systemf("%s -tf ../archive3.tar > ../list3", testprog)); - assertFileContainsLinesAnyOrder("../list3", list3); - - assertEqualInt(0, - systemf("%s -cf ../archive3b.tar *c", testprog)); - assertEqualInt(0, - systemf("%s -tf ../archive3b.tar > ../list3b", testprog)); - assertFileContainsLinesAnyOrder("../list3b", list3); - - assertEqualInt(0, - systemf("%s -cf ../archive4.tar fff/a?ca", testprog)); - assertEqualInt(0, - systemf("%s -tf ../archive4.tar > ../list4", testprog)); - assertFileContainsLinesAnyOrder("../list4", list4); - - assertEqualInt(0, - systemf("%s -cf ../archive5.tar aaa\\*", testprog)); - assertEqualInt(0, - systemf("%s -tf ../archive5.tar > ../list5", testprog)); - assertFileContainsLinesAnyOrder("../list5", list5); - - assertEqualInt(0, - systemf("%s -cf ../archive6.tar fff\\a?ca aaa\\xx*", testprog)); - assertEqualInt(0, - systemf("%s -tf ../archive6.tar > ../list6", testprog)); - assertFileContainsLinesAnyOrder("../list6", list6); - - /* - * Test2: Archive the file start with drive letters. - */ - /* Test2a: start with "/" */ - mkfullpath(&fp1, &fp2, "aaa/file1", 0); - assertEqualInt(0, - systemf("%s -cf ../archive10.tar %s > ../out10 2> ../err10", - testprog, fp1)); - assertEqualInt(0, - systemf("%s -tf ../archive10.tar > ../list10", testprog)); - /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list10"); - free(fp1); - free(fp2); - - /* Test2b: start with "\" */ - mkfullpath(&fp1, &fp2, "aaa/file1", 1); - assertEqualInt(0, - systemf("%s -cf ../archive11.tar %s > ../out11 2> ../err11", - testprog, fp1)); - assertEqualInt(0, - systemf("%s -tf ../archive11.tar > ../list11", testprog)); - /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list11"); - free(fp1); - free(fp2); - - /* Test2c: start with "c:/" */ - mkfullpath(&fp1, &fp2, "aaa/file1", 2); - assertEqualInt(0, - systemf("%s -cf ../archive12.tar %s > ../out12 2> ../err12", - testprog, fp1)); - assertEqualInt(0, - systemf("%s -tf ../archive12.tar > ../list12", testprog)); - /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list12"); - free(fp1); - free(fp2); - - /* Test2d: start with "c:\" */ - mkfullpath(&fp1, &fp2, "aaa/file1", 3); - assertEqualInt(0, - systemf("%s -cf ../archive13.tar %s > ../out13 2> ../err13", - testprog, fp1)); - assertEqualInt(0, - systemf("%s -tf ../archive13.tar > ../list13", testprog)); - /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list13"); - free(fp1); - free(fp2); - - /* Test2e: start with "//./c:/" */ - mkfullpath(&fp1, &fp2, "aaa/file1", 4); - assertEqualInt(0, - systemf("%s -cf ../archive14.tar %s > ../out14 2> ../err14", - testprog, fp1)); - assertEqualInt(0, - systemf("%s -tf ../archive14.tar > ../list14", testprog)); - /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list14"); - free(fp1); - free(fp2); - - /* Test2f: start with "\\.\c:\" */ - mkfullpath(&fp1, &fp2, "aaa/file1", 5); - assertEqualInt(0, - systemf("%s -cf ../archive15.tar %s > ../out15 2> ../err15", - testprog, fp1)); - assertEqualInt(0, - systemf("%s -tf ../archive15.tar > ../list15", testprog)); - /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list15"); - free(fp1); - free(fp2); - - /* Test2g: start with "//?/c:/" */ - mkfullpath(&fp1, &fp2, "aaa/file1", 6); - failure("fp1=%s, fp2=%s", fp1, fp2); - assertEqualInt(0, - systemf("%s -cf ../archive16.tar %s > ../out16 2> ../err16", - testprog, fp1)); - assertEqualInt(0, - systemf("%s -tf ../archive16.tar > ../list16", testprog)); - /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list16"); - free(fp1); - free(fp2); - - /* Test2h: start with "\\?\c:\" */ - mkfullpath(&fp1, &fp2, "aaa/file1", 7); - failure("fp1=%s, fp2=%s", fp1, fp2); - assertEqualInt(0, - systemf("%s -cf ../archive17.tar %s > ../out17 2> ../err17", - testprog, fp1)); - assertEqualInt(0, - systemf("%s -tf ../archive17.tar > ../list17", testprog)); - /* Check drive letters have been stripped. */ - assertFileContents(fp2, strlen(fp2), "../list17"); - free(fp1); - free(fp2); -#else - skipping("Windows specific test"); -#endif /* _WIN32 && !__CYGWIN__ */ -} |