From: Michihiro NAKAJIMA Date: Sun, 12 Oct 2014 01:50:09 +0000 (+0900) Subject: Fix build failure on Windows. X-Git-Tag: v3.1.900a~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f875fa28da77dbf9565306ffb7e005238a54575;p=thirdparty%2Flibarchive.git Fix build failure on Windows. --- diff --git a/libarchive/archive_cryptor_private.h b/libarchive/archive_cryptor_private.h index 7e2033b19..35b3385e0 100644 --- a/libarchive/archive_cryptor_private.h +++ b/libarchive/archive_cryptor_private.h @@ -45,6 +45,19 @@ typedef struct { unsigned encr_pos; } archive_crypto_ctx; +#elif defined(_WIN32) && !defined(__CYGWIN__) + +#define AES_MAX_KEY_SIZE 32 +#define AES_BLOCK_SIZE 16 +typedef struct { + int ctx; + uint8_t key[AES_MAX_KEY_SIZE]; + unsigned key_len; + uint8_t nonce[AES_BLOCK_SIZE]; + uint8_t encr_buf[AES_BLOCK_SIZE]; + unsigned encr_pos; +} archive_crypto_ctx; + #elif defined(HAVE_LIBNETTLE) #if defined(HAVE_NETTLE_PBKDF2_H) #include diff --git a/libarchive/archive_hmac.c b/libarchive/archive_hmac.c index 34ce7d49b..9e6834ec9 100644 --- a/libarchive/archive_hmac.c +++ b/libarchive/archive_hmac.c @@ -142,10 +142,11 @@ __hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data, } static void -__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out) +__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len) { (void)ctx;/* UNUSED */ (void)out;/* UNUSED */ + (void)out_len;/* UNUSED */ } static void diff --git a/libarchive/archive_hmac_private.h b/libarchive/archive_hmac_private.h index 324deb6f3..223e7ca66 100644 --- a/libarchive/archive_hmac_private.h +++ b/libarchive/archive_hmac_private.h @@ -35,6 +35,10 @@ typedef CCHmacContext archive_hmac_sha1_ctx; +#elif defined(_WIN32) && !defined(__CYGWIN__) + +typedef int archive_hmac_sha1_ctx; + #elif defined(HAVE_LIBNETTLE) #include diff --git a/libarchive/archive_random.c b/libarchive/archive_random.c index 7786323dc..57c49d5ab 100644 --- a/libarchive/archive_random.c +++ b/libarchive/archive_random.c @@ -51,10 +51,6 @@ __FBSDID("$FreeBSD$"); #include #endif -#if defined(HAVE_WINCRYPT_H) && !defined(__CYGWIN__) -#include -#endif - static void arc4random_buf(void *, size_t); #endif /* HAVE_ARC4RANDOM_BUF */ @@ -62,6 +58,10 @@ static void arc4random_buf(void *, size_t); #include "archive.h" #include "archive_random_private.h" +#if defined(HAVE_WINCRYPT_H) && !defined(__CYGWIN__) +#include +#endif + /* * Random number generator function. * This simply calls arc4random_buf function if the platform provides it. @@ -81,7 +81,7 @@ archive_random(void *buf, size_t nbytes) PROV_RSA_FULL, CRYPT_NEWKEYSET); } if (success) { - success = CryptGenRandom(hProv, (DWORD)nbytes, (BYTE*)buf)) + success = CryptGenRandom(hProv, (DWORD)nbytes, (BYTE*)buf); CryptReleaseContext(hProv, 0); if (success) return ARCHIVE_OK; diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c index 953a16c92..572686ab8 100644 --- a/libarchive/archive_read_support_format_lha.c +++ b/libarchive/archive_read_support_format_lha.c @@ -1492,7 +1492,7 @@ lha_read_data_lzh(struct archive_read *a, const void **buff, if (bytes_avail > lha->entry_bytes_remaining) bytes_avail = (ssize_t)lha->entry_bytes_remaining; - lha->strm.avail_in = bytes_avail; + lha->strm.avail_in = (int)bytes_avail; lha->strm.total_in = 0; lha->strm.avail_out = 0; @@ -2001,7 +2001,7 @@ static void lzh_emit_window(struct lzh_stream *strm, size_t s) { strm->ref_ptr = strm->ds->w_buff; - strm->avail_out = s; + strm->avail_out = (int)s; strm->total_out += s; } diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c index 62902206a..b58f592a3 100644 --- a/libarchive/archive_read_support_format_mtree.c +++ b/libarchive/archive_read_support_format_mtree.c @@ -1377,7 +1377,7 @@ parse_device(dev_t *pdev, struct archive *a, char *val) "Missing number"); return ARCHIVE_WARN; } - numbers[argc++] = mtree_atol(&p); + numbers[argc++] = (unsigned long)mtree_atol(&p); if (argc > MAX_PACK_ARGS) { archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT, "Too many arguments"); diff --git a/libarchive/test/test_archive_string.c b/libarchive/test/test_archive_string.c index 7303be84d..9e3f90702 100644 --- a/libarchive/test/test_archive_string.c +++ b/libarchive/test/test_archive_string.c @@ -380,7 +380,7 @@ DEFINE_TEST(test_archive_string_sort) unsigned int i, j, size; char **test_strings, *tmp; - srand(time(NULL)); + srand((unsigned int)time(NULL)); size = sizeof(strings) / sizeof(char *); assert((test_strings = (char **)calloc(1, sizeof(strings))) != NULL); for (i = 0; i < (size - 1); i++) diff --git a/libarchive/test/test_read_format_7zip.c b/libarchive/test/test_read_format_7zip.c index ea9035aa7..14447def8 100644 --- a/libarchive/test/test_read_format_7zip.c +++ b/libarchive/test/test_read_format_7zip.c @@ -25,6 +25,11 @@ #include "test.h" __FBSDID("$FreeBSD"); +#if defined(_WIN32) && !defined(__CYGWIN__) +#define close _close +#define open _open +#endif + /* * Extract a non-encoded file. * The header of the 7z archive files is not encoded. diff --git a/libarchive/test/test_write_format_zip_large.c b/libarchive/test/test_write_format_zip_large.c index 12cd1059d..06045525e 100644 --- a/libarchive/test/test_write_format_zip_large.c +++ b/libarchive/test/test_write_format_zip_large.c @@ -84,7 +84,7 @@ memory_write(struct archive *a, void *_private, const void *buff, size_t size) /* It's header or metadata, copy and save it. */ block = (struct fileblock *)malloc(sizeof(*block)); memset(block, 0, sizeof(*block)); - block->size = size; + block->size = (int)size; block->buff = malloc(size); memcpy(block->buff, buff, size); if (private->last == NULL) {