From 2cffae8dcd70e9a8f95c790d46d40ea931ffc8ae Mon Sep 17 00:00:00 2001 From: Rich Young <916491+richnetdesign@users.noreply.github.com> Date: Mon, 15 Nov 2021 21:48:15 -0500 Subject: [PATCH 01/91] symlink --- libarchive/_libarchive.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libarchive/_libarchive.py b/libarchive/_libarchive.py index a2cb2cc..0df844c 100644 --- a/libarchive/_libarchive.py +++ b/libarchive/_libarchive.py @@ -368,6 +368,10 @@ def archive_entry_mtime(*args): return __libarchive.archive_entry_mtime(*args) archive_entry_mtime = __libarchive.archive_entry_mtime +def archive_entry_symlink(*args): + return __libarchive.archive_entry_symlink(*args) +archive_entry_symlink = __libarchive.archive_entry_symlink + def archive_entry_filetype(*args): return __libarchive.archive_entry_filetype(*args) archive_entry_filetype = __libarchive.archive_entry_filetype @@ -388,6 +392,10 @@ def archive_entry_set_mtime(*args): return __libarchive.archive_entry_set_mtime(*args) archive_entry_set_mtime = __libarchive.archive_entry_set_mtime +def archive_entry_set_symlink(*args): + return __libarchive.archive_entry_set_symlink (*args) +archive_entry_set_symlink = __libarchive.archive_entry_set_symlink + def archive_entry_set_filetype(*args): return __libarchive.archive_entry_set_filetype(*args) archive_entry_set_filetype = __libarchive.archive_entry_set_filetype From e9597eaa2afd998fdf8735e97baef298fe448179 Mon Sep 17 00:00:00 2001 From: Richard Young Date: Mon, 15 Nov 2021 22:35:44 -0500 Subject: [PATCH 02/91] additional api --- libarchive/_libarchive.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libarchive/_libarchive.py b/libarchive/_libarchive.py index 0df844c..3938902 100644 --- a/libarchive/_libarchive.py +++ b/libarchive/_libarchive.py @@ -396,6 +396,10 @@ def archive_entry_set_symlink(*args): return __libarchive.archive_entry_set_symlink (*args) archive_entry_set_symlink = __libarchive.archive_entry_set_symlink +def archive_entry_set_link(*args): + return __libarchive.archive_entry_set_link (*args) +archive_entry_set_link = __libarchive.archive_entry_set_link + def archive_entry_set_filetype(*args): return __libarchive.archive_entry_set_filetype(*args) archive_entry_set_filetype = __libarchive.archive_entry_set_filetype From 1d1a212df11e079c94b5f92ec756e8f8ce8e71ca Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 01:34:33 -0500 Subject: [PATCH 03/91] hacking in some more api --- libarchive/_libarchive.i | 31 +- libarchive/_libarchive.py | 560 +++---- libarchive/_libarchive_wrap.c | 2681 ++++++++++++++++++--------------- 3 files changed, 1700 insertions(+), 1572 deletions(-) diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index 13b2474..5c2645c 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -72,8 +72,6 @@ typedef unsigned short mode_t; -# Everything below is from the archive.h and archive_entry.h files. -# I excluded functions declarations that are not needed. /* CONFIGURATION */ @@ -276,6 +274,33 @@ extern __LA_INT64_T archive_entry_size(struct archive_entry *); extern time_t archive_entry_mtime(struct archive_entry *); extern __LA_MODE_T archive_entry_filetype(struct archive_entry *); extern __LA_MODE_T archive_entry_perm(struct archive_entry *); +extern const char *archive_entry_symlink(struct archive_entry *); +//extern const char *archive_entry_symlink_utf8(struct archive_entry *); + +extern void archive_entry_set_link(struct archive_entry *, const char *); +//extern void archive_entry_set_link_utf8(struct archive_entry *, const char *); +//extern int archive_entry_symlink_type(struct archive_entry *); +extern const wchar_t *archive_entry_symlink_w(struct archive_entry *); + +//__LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *); +//__LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *); + +/* The names for symlink modes here correspond to an old BSD + * command-line argument convention: -L, -P, -H */ +/* Follow all symlinks. */ +extern int archive_read_disk_set_symlink_logical(struct archive *); +/* Follow no symlinks. */ +extern int archive_read_disk_set_symlink_physical(struct archive *); +/* Follow symlink initially, then not. */ +extern int archive_read_disk_set_symlink_hybrid(struct archive *); + + +extern void archive_entry_set_symlink(struct archive_entry *, const char *); +//extern void archive_entry_set_symlink_type(struct archive_entry *, int); +//extern void archive_entry_set_symlink_utf8(struct archive_entry *, const char *); +extern void archive_entry_copy_symlink(struct archive_entry *, const char *); +extern void archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *); +//extern int archive_entry_update_symlink_utf8(struct archive_entry *, const char *); /* writing */ extern void archive_entry_set_pathname(struct archive_entry *, const char *); @@ -283,6 +308,8 @@ extern void archive_entry_set_size(struct archive_entry *, __LA_INT64_T); extern void archive_entry_set_mtime(struct archive_entry *, time_t, long); extern void archive_entry_set_filetype(struct archive_entry *, unsigned int); extern void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T); +//extern void archive_entry_set_link(struct archive_entry *, __LA_MODE_T); +//extern void archive_entry_set_symlink(struct archive_entry *, __LA_MODE_T); /* ERROR HANDLING */ diff --git a/libarchive/_libarchive.py b/libarchive/_libarchive.py index 3938902..bff869a 100644 --- a/libarchive/_libarchive.py +++ b/libarchive/_libarchive.py @@ -1,420 +1,345 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 2.0.4 +# Version 4.0.2 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. +from sys import version_info as _swig_python_version_info +if _swig_python_version_info < (2, 7, 0): + raise RuntimeError("Python 2.7 or later required") - -from sys import version_info -if version_info >= (2,6,0): - def swig_import_helper(): - from os.path import dirname - import imp - fp = None - try: - fp, pathname, description = imp.find_module('__libarchive', [dirname(__file__)]) - except ImportError: - import __libarchive - return __libarchive - if fp is not None: - try: - _mod = imp.load_module('__libarchive', fp, pathname, description) - finally: - fp.close() - return _mod - __libarchive = swig_import_helper() - del swig_import_helper +# Import the low-level C/C++ module +if __package__ or "." in __name__: + from . import __libarchive else: import __libarchive -del version_info + try: - _swig_property = property -except NameError: - pass # Python < 2.2 doesn't have 'property'. -def _swig_setattr_nondynamic(self,class_type,name,value,static=1): - if (name == "thisown"): return self.this.own(value) - if (name == "this"): - if type(value).__name__ == 'SwigPyObject': - self.__dict__[name] = value - return - method = class_type.__swig_setmethods__.get(name,None) - if method: return method(self,value) - if (not static): - self.__dict__[name] = value - else: - raise AttributeError("You cannot add attributes to %s" % self) - -def _swig_setattr(self,class_type,name,value): - return _swig_setattr_nondynamic(self,class_type,name,value,0) - -def _swig_getattr(self,class_type,name): - if (name == "thisown"): return self.this.own() - method = class_type.__swig_getmethods__.get(name,None) - if method: return method(self) - raise AttributeError(name) + import builtins as __builtin__ +except ImportError: + import __builtin__ def _swig_repr(self): - try: strthis = "proxy of " + self.this.__repr__() - except: strthis = "" + try: + strthis = "proxy of " + self.this.__repr__() + except __builtin__.Exception: + strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) -try: - _object = object - _newclass = 1 -except AttributeError: - class _object : pass - _newclass = 0 + +def _swig_setattr_nondynamic_instance_variable(set): + def set_instance_attr(self, name, value): + if name == "thisown": + self.this.own(value) + elif name == "this": + set(self, name, value) + elif hasattr(self, name) and isinstance(getattr(type(self), name), property): + set(self, name, value) + else: + raise AttributeError("You cannot add instance attributes to %s" % self) + return set_instance_attr + + +def _swig_setattr_nondynamic_class_variable(set): + def set_class_attr(cls, name, value): + if hasattr(cls, name) and not isinstance(getattr(cls, name), property): + set(cls, name, value) + else: + raise AttributeError("You cannot add class attributes to %s" % cls) + return set_class_attr + + +def _swig_add_metaclass(metaclass): + """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" + def wrapper(cls): + return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) + return wrapper + + +class _SwigNonDynamicMeta(type): + """Meta class to enforce nondynamic attributes (no new attributes) for a class""" + __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) def archive_read_new(): - return __libarchive.archive_read_new() -archive_read_new = __libarchive.archive_read_new + return __libarchive.archive_read_new() -def archive_read_free(*args): - return __libarchive.archive_read_free(*args) -archive_read_free = __libarchive.archive_read_free +def archive_read_free(arg1): + return __libarchive.archive_read_free(arg1) -def archive_read_open_filename(*args): - return __libarchive.archive_read_open_filename(*args) -archive_read_open_filename = __libarchive.archive_read_open_filename +def archive_read_open_filename(arg1, _filename, _block_size): + return __libarchive.archive_read_open_filename(arg1, _filename, _block_size) -def archive_read_open_memory(*args): - return __libarchive.archive_read_open_memory(*args) -archive_read_open_memory = __libarchive.archive_read_open_memory +def archive_read_open_memory(arg1, buff, size): + return __libarchive.archive_read_open_memory(arg1, buff, size) -def archive_read_open_memory2(*args): - return __libarchive.archive_read_open_memory2(*args) -archive_read_open_memory2 = __libarchive.archive_read_open_memory2 +def archive_read_open_memory2(a, buff, size, read_size): + return __libarchive.archive_read_open_memory2(a, buff, size, read_size) -def archive_read_open_fd(*args): - return __libarchive.archive_read_open_fd(*args) -archive_read_open_fd = __libarchive.archive_read_open_fd +def archive_read_open_fd(arg1, _fd, _block_size): + return __libarchive.archive_read_open_fd(arg1, _fd, _block_size) -def archive_read_close(*args): - return __libarchive.archive_read_close(*args) -archive_read_close = __libarchive.archive_read_close +def archive_read_close(arg1): + return __libarchive.archive_read_close(arg1) -def archive_format(*args): - return __libarchive.archive_format(*args) -archive_format = __libarchive.archive_format +def archive_format(arg1): + return __libarchive.archive_format(arg1) -def archive_read_next_header2(*args): - return __libarchive.archive_read_next_header2(*args) -archive_read_next_header2 = __libarchive.archive_read_next_header2 +def archive_read_next_header2(arg1, arg2): + return __libarchive.archive_read_next_header2(arg1, arg2) -def archive_entry_stat(*args): - return __libarchive.archive_entry_stat(*args) -archive_entry_stat = __libarchive.archive_entry_stat +def archive_entry_stat(arg1): + return __libarchive.archive_entry_stat(arg1) -def archive_read_header_position(*args): - return __libarchive.archive_read_header_position(*args) -archive_read_header_position = __libarchive.archive_read_header_position +def archive_read_header_position(arg1): + return __libarchive.archive_read_header_position(arg1) -def archive_read_data_skip(*args): - return __libarchive.archive_read_data_skip(*args) -archive_read_data_skip = __libarchive.archive_read_data_skip +def archive_read_data_skip(arg1): + return __libarchive.archive_read_data_skip(arg1) -def archive_read_data_into_fd(*args): - return __libarchive.archive_read_data_into_fd(*args) -archive_read_data_into_fd = __libarchive.archive_read_data_into_fd +def archive_read_data_into_fd(arg1, fd): + return __libarchive.archive_read_data_into_fd(arg1, fd) -def archive_read_support_filter_all(*args): - return __libarchive.archive_read_support_filter_all(*args) -archive_read_support_filter_all = __libarchive.archive_read_support_filter_all +def archive_read_support_filter_all(arg1): + return __libarchive.archive_read_support_filter_all(arg1) -def archive_read_support_filter_bzip2(*args): - return __libarchive.archive_read_support_filter_bzip2(*args) -archive_read_support_filter_bzip2 = __libarchive.archive_read_support_filter_bzip2 +def archive_read_support_filter_bzip2(arg1): + return __libarchive.archive_read_support_filter_bzip2(arg1) -def archive_read_support_filter_compress(*args): - return __libarchive.archive_read_support_filter_compress(*args) -archive_read_support_filter_compress = __libarchive.archive_read_support_filter_compress +def archive_read_support_filter_compress(arg1): + return __libarchive.archive_read_support_filter_compress(arg1) -def archive_read_support_filter_gzip(*args): - return __libarchive.archive_read_support_filter_gzip(*args) -archive_read_support_filter_gzip = __libarchive.archive_read_support_filter_gzip +def archive_read_support_filter_gzip(arg1): + return __libarchive.archive_read_support_filter_gzip(arg1) -def archive_read_support_filter_lzip(*args): - return __libarchive.archive_read_support_filter_lzip(*args) -archive_read_support_filter_lzip = __libarchive.archive_read_support_filter_lzip +def archive_read_support_filter_lzip(arg1): + return __libarchive.archive_read_support_filter_lzip(arg1) -def archive_read_support_filter_lzma(*args): - return __libarchive.archive_read_support_filter_lzma(*args) -archive_read_support_filter_lzma = __libarchive.archive_read_support_filter_lzma +def archive_read_support_filter_lzma(arg1): + return __libarchive.archive_read_support_filter_lzma(arg1) -def archive_read_support_filter_none(*args): - return __libarchive.archive_read_support_filter_none(*args) -archive_read_support_filter_none = __libarchive.archive_read_support_filter_none +def archive_read_support_filter_none(arg1): + return __libarchive.archive_read_support_filter_none(arg1) -def archive_read_support_filter_rpm(*args): - return __libarchive.archive_read_support_filter_rpm(*args) -archive_read_support_filter_rpm = __libarchive.archive_read_support_filter_rpm +def archive_read_support_filter_rpm(arg1): + return __libarchive.archive_read_support_filter_rpm(arg1) -def archive_read_support_filter_uu(*args): - return __libarchive.archive_read_support_filter_uu(*args) -archive_read_support_filter_uu = __libarchive.archive_read_support_filter_uu +def archive_read_support_filter_uu(arg1): + return __libarchive.archive_read_support_filter_uu(arg1) -def archive_read_support_filter_xz(*args): - return __libarchive.archive_read_support_filter_xz(*args) -archive_read_support_filter_xz = __libarchive.archive_read_support_filter_xz +def archive_read_support_filter_xz(arg1): + return __libarchive.archive_read_support_filter_xz(arg1) -def archive_read_support_format_all(*args): - return __libarchive.archive_read_support_format_all(*args) -archive_read_support_format_all = __libarchive.archive_read_support_format_all +def archive_read_support_format_all(arg1): + return __libarchive.archive_read_support_format_all(arg1) -def archive_read_support_format_7zip(*args): - return __libarchive.archive_read_support_format_7zip(*args) -archive_read_support_format_7zip = __libarchive.archive_read_support_format_7zip +def archive_read_support_format_7zip(arg1): + return __libarchive.archive_read_support_format_7zip(arg1) -def archive_read_support_format_ar(*args): - return __libarchive.archive_read_support_format_ar(*args) -archive_read_support_format_ar = __libarchive.archive_read_support_format_ar +def archive_read_support_format_ar(arg1): + return __libarchive.archive_read_support_format_ar(arg1) -def archive_read_support_format_cab(*args): - return __libarchive.archive_read_support_format_cab(*args) -archive_read_support_format_cab = __libarchive.archive_read_support_format_cab +def archive_read_support_format_cab(arg1): + return __libarchive.archive_read_support_format_cab(arg1) -def archive_read_support_format_cpio(*args): - return __libarchive.archive_read_support_format_cpio(*args) -archive_read_support_format_cpio = __libarchive.archive_read_support_format_cpio +def archive_read_support_format_cpio(arg1): + return __libarchive.archive_read_support_format_cpio(arg1) -def archive_read_support_format_empty(*args): - return __libarchive.archive_read_support_format_empty(*args) -archive_read_support_format_empty = __libarchive.archive_read_support_format_empty +def archive_read_support_format_empty(arg1): + return __libarchive.archive_read_support_format_empty(arg1) -def archive_read_support_format_gnutar(*args): - return __libarchive.archive_read_support_format_gnutar(*args) -archive_read_support_format_gnutar = __libarchive.archive_read_support_format_gnutar +def archive_read_support_format_gnutar(arg1): + return __libarchive.archive_read_support_format_gnutar(arg1) -def archive_read_support_format_iso9660(*args): - return __libarchive.archive_read_support_format_iso9660(*args) -archive_read_support_format_iso9660 = __libarchive.archive_read_support_format_iso9660 +def archive_read_support_format_iso9660(arg1): + return __libarchive.archive_read_support_format_iso9660(arg1) -def archive_read_support_format_lha(*args): - return __libarchive.archive_read_support_format_lha(*args) -archive_read_support_format_lha = __libarchive.archive_read_support_format_lha +def archive_read_support_format_lha(arg1): + return __libarchive.archive_read_support_format_lha(arg1) -def archive_read_support_format_rar(*args): - return __libarchive.archive_read_support_format_rar(*args) -archive_read_support_format_rar = __libarchive.archive_read_support_format_rar +def archive_read_support_format_rar(arg1): + return __libarchive.archive_read_support_format_rar(arg1) -def archive_read_support_format_raw(*args): - return __libarchive.archive_read_support_format_raw(*args) -archive_read_support_format_raw = __libarchive.archive_read_support_format_raw +def archive_read_support_format_raw(arg1): + return __libarchive.archive_read_support_format_raw(arg1) -def archive_read_support_format_tar(*args): - return __libarchive.archive_read_support_format_tar(*args) -archive_read_support_format_tar = __libarchive.archive_read_support_format_tar +def archive_read_support_format_tar(arg1): + return __libarchive.archive_read_support_format_tar(arg1) -def archive_read_support_format_xar(*args): - return __libarchive.archive_read_support_format_xar(*args) -archive_read_support_format_xar = __libarchive.archive_read_support_format_xar +def archive_read_support_format_xar(arg1): + return __libarchive.archive_read_support_format_xar(arg1) -def archive_read_support_format_zip(*args): - return __libarchive.archive_read_support_format_zip(*args) -archive_read_support_format_zip = __libarchive.archive_read_support_format_zip +def archive_read_support_format_zip(arg1): + return __libarchive.archive_read_support_format_zip(arg1) def archive_write_new(): - return __libarchive.archive_write_new() -archive_write_new = __libarchive.archive_write_new + return __libarchive.archive_write_new() -def archive_write_free(*args): - return __libarchive.archive_write_free(*args) -archive_write_free = __libarchive.archive_write_free +def archive_write_free(arg1): + return __libarchive.archive_write_free(arg1) -def archive_write_open(*args): - return __libarchive.archive_write_open(*args) -archive_write_open = __libarchive.archive_write_open +def archive_write_open(arg1, arg2, arg3, arg4, arg5): + return __libarchive.archive_write_open(arg1, arg2, arg3, arg4, arg5) -def archive_write_open_fd(*args): - return __libarchive.archive_write_open_fd(*args) -archive_write_open_fd = __libarchive.archive_write_open_fd +def archive_write_open_fd(arg1, _fd): + return __libarchive.archive_write_open_fd(arg1, _fd) -def archive_write_open_filename(*args): - return __libarchive.archive_write_open_filename(*args) -archive_write_open_filename = __libarchive.archive_write_open_filename +def archive_write_open_filename(arg1, _file): + return __libarchive.archive_write_open_filename(arg1, _file) -def archive_write_open_filename_w(*args): - return __libarchive.archive_write_open_filename_w(*args) -archive_write_open_filename_w = __libarchive.archive_write_open_filename_w +def archive_write_open_filename_w(arg1, _file): + return __libarchive.archive_write_open_filename_w(arg1, _file) -def archive_write_open_memory(*args): - return __libarchive.archive_write_open_memory(*args) -archive_write_open_memory = __libarchive.archive_write_open_memory +def archive_write_open_memory(arg1, _buffer, _buffSize, _used): + return __libarchive.archive_write_open_memory(arg1, _buffer, _buffSize, _used) -def archive_write_close(*args): - return __libarchive.archive_write_close(*args) -archive_write_close = __libarchive.archive_write_close +def archive_write_close(arg1): + return __libarchive.archive_write_close(arg1) -def archive_write_header(*args): - return __libarchive.archive_write_header(*args) -archive_write_header = __libarchive.archive_write_header +def archive_write_header(arg1, arg2): + return __libarchive.archive_write_header(arg1, arg2) -def archive_write_finish_entry(*args): - return __libarchive.archive_write_finish_entry(*args) -archive_write_finish_entry = __libarchive.archive_write_finish_entry +def archive_write_finish_entry(arg1): + return __libarchive.archive_write_finish_entry(arg1) -def archive_write_add_filter_bzip2(*args): - return __libarchive.archive_write_add_filter_bzip2(*args) -archive_write_add_filter_bzip2 = __libarchive.archive_write_add_filter_bzip2 +def archive_write_add_filter_bzip2(arg1): + return __libarchive.archive_write_add_filter_bzip2(arg1) -def archive_write_add_filter_compress(*args): - return __libarchive.archive_write_add_filter_compress(*args) -archive_write_add_filter_compress = __libarchive.archive_write_add_filter_compress +def archive_write_add_filter_compress(arg1): + return __libarchive.archive_write_add_filter_compress(arg1) -def archive_write_add_filter_gzip(*args): - return __libarchive.archive_write_add_filter_gzip(*args) -archive_write_add_filter_gzip = __libarchive.archive_write_add_filter_gzip +def archive_write_add_filter_gzip(arg1): + return __libarchive.archive_write_add_filter_gzip(arg1) -def archive_write_add_filter_lzip(*args): - return __libarchive.archive_write_add_filter_lzip(*args) -archive_write_add_filter_lzip = __libarchive.archive_write_add_filter_lzip +def archive_write_add_filter_lzip(arg1): + return __libarchive.archive_write_add_filter_lzip(arg1) -def archive_write_add_filter_lzma(*args): - return __libarchive.archive_write_add_filter_lzma(*args) -archive_write_add_filter_lzma = __libarchive.archive_write_add_filter_lzma +def archive_write_add_filter_lzma(arg1): + return __libarchive.archive_write_add_filter_lzma(arg1) -def archive_write_add_filter_none(*args): - return __libarchive.archive_write_add_filter_none(*args) -archive_write_add_filter_none = __libarchive.archive_write_add_filter_none +def archive_write_add_filter_none(arg1): + return __libarchive.archive_write_add_filter_none(arg1) -def archive_write_add_filter_xz(*args): - return __libarchive.archive_write_add_filter_xz(*args) -archive_write_add_filter_xz = __libarchive.archive_write_add_filter_xz +def archive_write_add_filter_xz(arg1): + return __libarchive.archive_write_add_filter_xz(arg1) -def archive_write_set_format(*args): - return __libarchive.archive_write_set_format(*args) -archive_write_set_format = __libarchive.archive_write_set_format +def archive_write_set_format(arg1, format_code): + return __libarchive.archive_write_set_format(arg1, format_code) -def archive_write_set_format_by_name(*args): - return __libarchive.archive_write_set_format_by_name(*args) -archive_write_set_format_by_name = __libarchive.archive_write_set_format_by_name +def archive_write_set_format_by_name(arg1, name): + return __libarchive.archive_write_set_format_by_name(arg1, name) -def archive_write_set_format_ar_bsd(*args): - return __libarchive.archive_write_set_format_ar_bsd(*args) -archive_write_set_format_ar_bsd = __libarchive.archive_write_set_format_ar_bsd +def archive_write_set_format_ar_bsd(arg1): + return __libarchive.archive_write_set_format_ar_bsd(arg1) -def archive_write_set_format_ar_svr4(*args): - return __libarchive.archive_write_set_format_ar_svr4(*args) -archive_write_set_format_ar_svr4 = __libarchive.archive_write_set_format_ar_svr4 +def archive_write_set_format_ar_svr4(arg1): + return __libarchive.archive_write_set_format_ar_svr4(arg1) -def archive_write_set_format_cpio(*args): - return __libarchive.archive_write_set_format_cpio(*args) -archive_write_set_format_cpio = __libarchive.archive_write_set_format_cpio +def archive_write_set_format_cpio(arg1): + return __libarchive.archive_write_set_format_cpio(arg1) -def archive_write_set_format_cpio_newc(*args): - return __libarchive.archive_write_set_format_cpio_newc(*args) -archive_write_set_format_cpio_newc = __libarchive.archive_write_set_format_cpio_newc +def archive_write_set_format_cpio_newc(arg1): + return __libarchive.archive_write_set_format_cpio_newc(arg1) -def archive_write_set_format_gnutar(*args): - return __libarchive.archive_write_set_format_gnutar(*args) -archive_write_set_format_gnutar = __libarchive.archive_write_set_format_gnutar +def archive_write_set_format_gnutar(arg1): + return __libarchive.archive_write_set_format_gnutar(arg1) -def archive_write_set_format_iso9660(*args): - return __libarchive.archive_write_set_format_iso9660(*args) -archive_write_set_format_iso9660 = __libarchive.archive_write_set_format_iso9660 +def archive_write_set_format_iso9660(arg1): + return __libarchive.archive_write_set_format_iso9660(arg1) -def archive_write_set_format_pax(*args): - return __libarchive.archive_write_set_format_pax(*args) -archive_write_set_format_pax = __libarchive.archive_write_set_format_pax +def archive_write_set_format_pax(arg1): + return __libarchive.archive_write_set_format_pax(arg1) -def archive_write_set_format_pax_restricted(*args): - return __libarchive.archive_write_set_format_pax_restricted(*args) -archive_write_set_format_pax_restricted = __libarchive.archive_write_set_format_pax_restricted +def archive_write_set_format_pax_restricted(arg1): + return __libarchive.archive_write_set_format_pax_restricted(arg1) -def archive_write_set_format_shar(*args): - return __libarchive.archive_write_set_format_shar(*args) -archive_write_set_format_shar = __libarchive.archive_write_set_format_shar +def archive_write_set_format_shar(arg1): + return __libarchive.archive_write_set_format_shar(arg1) -def archive_write_set_format_shar_dump(*args): - return __libarchive.archive_write_set_format_shar_dump(*args) -archive_write_set_format_shar_dump = __libarchive.archive_write_set_format_shar_dump +def archive_write_set_format_shar_dump(arg1): + return __libarchive.archive_write_set_format_shar_dump(arg1) -def archive_write_set_format_ustar(*args): - return __libarchive.archive_write_set_format_ustar(*args) -archive_write_set_format_ustar = __libarchive.archive_write_set_format_ustar +def archive_write_set_format_ustar(arg1): + return __libarchive.archive_write_set_format_ustar(arg1) -def archive_write_set_format_xar(*args): - return __libarchive.archive_write_set_format_xar(*args) -archive_write_set_format_xar = __libarchive.archive_write_set_format_xar +def archive_write_set_format_xar(arg1): + return __libarchive.archive_write_set_format_xar(arg1) -def archive_write_set_format_zip(*args): - return __libarchive.archive_write_set_format_zip(*args) -archive_write_set_format_zip = __libarchive.archive_write_set_format_zip +def archive_write_set_format_zip(arg1): + return __libarchive.archive_write_set_format_zip(arg1) def archive_entry_new(): - return __libarchive.archive_entry_new() -archive_entry_new = __libarchive.archive_entry_new + return __libarchive.archive_entry_new() + +def archive_entry_free(arg1): + return __libarchive.archive_entry_free(arg1) + +def archive_entry_pathname(arg1): + return __libarchive.archive_entry_pathname(arg1) + +def archive_entry_pathname_w(arg1): + return __libarchive.archive_entry_pathname_w(arg1) + +def archive_entry_size(arg1): + return __libarchive.archive_entry_size(arg1) + +def archive_entry_mtime(arg1): + return __libarchive.archive_entry_mtime(arg1) + +def archive_entry_filetype(arg1): + return __libarchive.archive_entry_filetype(arg1) -def archive_entry_free(*args): - return __libarchive.archive_entry_free(*args) -archive_entry_free = __libarchive.archive_entry_free +def archive_entry_perm(arg1): + return __libarchive.archive_entry_perm(arg1) -def archive_entry_pathname(*args): - return __libarchive.archive_entry_pathname(*args) -archive_entry_pathname = __libarchive.archive_entry_pathname +def archive_entry_symlink(arg1): + return __libarchive.archive_entry_symlink(arg1) -def archive_entry_pathname_w(*args): - return __libarchive.archive_entry_pathname_w(*args) -archive_entry_pathname_w = __libarchive.archive_entry_pathname_w +def archive_entry_set_link(arg1, arg2): + return __libarchive.archive_entry_set_link(arg1, arg2) -def archive_entry_size(*args): - return __libarchive.archive_entry_size(*args) -archive_entry_size = __libarchive.archive_entry_size +def archive_entry_symlink_w(arg1): + return __libarchive.archive_entry_symlink_w(arg1) -def archive_entry_mtime(*args): - return __libarchive.archive_entry_mtime(*args) -archive_entry_mtime = __libarchive.archive_entry_mtime +def archive_read_disk_set_symlink_logical(arg1): + return __libarchive.archive_read_disk_set_symlink_logical(arg1) -def archive_entry_symlink(*args): - return __libarchive.archive_entry_symlink(*args) -archive_entry_symlink = __libarchive.archive_entry_symlink +def archive_read_disk_set_symlink_physical(arg1): + return __libarchive.archive_read_disk_set_symlink_physical(arg1) -def archive_entry_filetype(*args): - return __libarchive.archive_entry_filetype(*args) -archive_entry_filetype = __libarchive.archive_entry_filetype +def archive_read_disk_set_symlink_hybrid(arg1): + return __libarchive.archive_read_disk_set_symlink_hybrid(arg1) -def archive_entry_perm(*args): - return __libarchive.archive_entry_perm(*args) -archive_entry_perm = __libarchive.archive_entry_perm +def archive_entry_set_symlink(arg1, arg2): + return __libarchive.archive_entry_set_symlink(arg1, arg2) -def archive_entry_set_pathname(*args): - return __libarchive.archive_entry_set_pathname(*args) -archive_entry_set_pathname = __libarchive.archive_entry_set_pathname +def archive_entry_copy_symlink(arg1, arg2): + return __libarchive.archive_entry_copy_symlink(arg1, arg2) -def archive_entry_set_size(*args): - return __libarchive.archive_entry_set_size(*args) -archive_entry_set_size = __libarchive.archive_entry_set_size +def archive_entry_copy_symlink_w(arg1, arg2): + return __libarchive.archive_entry_copy_symlink_w(arg1, arg2) -def archive_entry_set_mtime(*args): - return __libarchive.archive_entry_set_mtime(*args) -archive_entry_set_mtime = __libarchive.archive_entry_set_mtime +def archive_entry_set_pathname(arg1, arg2): + return __libarchive.archive_entry_set_pathname(arg1, arg2) -def archive_entry_set_symlink(*args): - return __libarchive.archive_entry_set_symlink (*args) -archive_entry_set_symlink = __libarchive.archive_entry_set_symlink +def archive_entry_set_size(arg1, arg2): + return __libarchive.archive_entry_set_size(arg1, arg2) -def archive_entry_set_link(*args): - return __libarchive.archive_entry_set_link (*args) -archive_entry_set_link = __libarchive.archive_entry_set_link +def archive_entry_set_mtime(arg1, arg2, arg3): + return __libarchive.archive_entry_set_mtime(arg1, arg2, arg3) -def archive_entry_set_filetype(*args): - return __libarchive.archive_entry_set_filetype(*args) -archive_entry_set_filetype = __libarchive.archive_entry_set_filetype +def archive_entry_set_filetype(arg1, arg2): + return __libarchive.archive_entry_set_filetype(arg1, arg2) -def archive_entry_set_perm(*args): - return __libarchive.archive_entry_set_perm(*args) -archive_entry_set_perm = __libarchive.archive_entry_set_perm +def archive_entry_set_perm(arg1, arg2): + return __libarchive.archive_entry_set_perm(arg1, arg2) -def archive_errno(*args): - return __libarchive.archive_errno(*args) -archive_errno = __libarchive.archive_errno +def archive_errno(arg1): + return __libarchive.archive_errno(arg1) -def archive_error_string(*args): - return __libarchive.archive_error_string(*args) -archive_error_string = __libarchive.archive_error_string +def archive_error_string(arg1): + return __libarchive.archive_error_string(arg1) ARCHIVE_VERSION_NUMBER = __libarchive.ARCHIVE_VERSION_NUMBER ARCHIVE_VERSION_STRING = __libarchive.ARCHIVE_VERSION_STRING ARCHIVE_EOF = __libarchive.ARCHIVE_EOF @@ -478,13 +403,10 @@ ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER = __libarchive.ARCHIVE_EXTRACT_NO_OVERWRITE_N ARCHIVE_EXTRACT_SPARSE = __libarchive.ARCHIVE_EXTRACT_SPARSE ARCHIVE_EXTRACT_MAC_METADATA = __libarchive.ARCHIVE_EXTRACT_MAC_METADATA -def archive_read_data_into_str(*args): - return __libarchive.archive_read_data_into_str(*args) -archive_read_data_into_str = __libarchive.archive_read_data_into_str +def archive_read_data_into_str(archive, len): + return __libarchive.archive_read_data_into_str(archive, len) -def archive_write_data_from_str(*args): - return __libarchive.archive_write_data_from_str(*args) -archive_write_data_from_str = __libarchive.archive_write_data_from_str -# This file is compatible with both classic and new-style classes. +def archive_write_data_from_str(archive, str): + return __libarchive.archive_write_data_from_str(archive, str) diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index 1c4c9e0..bd56746 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -1,14 +1,18 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 - * - * This file is not intended to be easily readable and contains a number of + * Version 4.0.2 + * + * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. * ----------------------------------------------------------------------------- */ + +#ifndef SWIGPYTHON #define SWIGPYTHON +#endif + #define SWIG_PYTHON_DIRECTOR_NO_VTABLE /* ----------------------------------------------------------------------------- @@ -42,28 +46,28 @@ #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else -# define SWIGUNUSED +# define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif +# endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif @@ -78,9 +82,11 @@ #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -106,7 +112,7 @@ # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL -# endif +# endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ @@ -119,10 +125,34 @@ # define _SCL_SECURE_NO_DEPRECATE #endif +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif -/* Python.h has to appear first */ -#include +#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) +/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ +# include +#endif + +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include +# define _DEBUG 1 +#else +# include +#endif /* ----------------------------------------------------------------------------- * swigrun.swg @@ -148,7 +178,7 @@ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. - + But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ @@ -169,21 +199,22 @@ /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 -/* +/* Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return an integer + + The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). - + Use the following macros/flags to set or process the returning states. - + In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { @@ -216,23 +247,23 @@ } else { // fail code } - + I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be @@ -246,17 +277,17 @@ int fooi(int); and you call - + food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ -#define SWIG_OK (0) +#define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) @@ -287,14 +318,14 @@ # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { +SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCast +# define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif @@ -338,7 +369,7 @@ typedef struct swig_module_info { void *clientdata; /* Language specific module data */ } swig_module_info; -/* +/* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. @@ -358,18 +389,18 @@ SWIG_TypeNameComp(const char *f1, const char *l1, /* Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal + Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; const char* te = tb + strlen(tb); const char* ne = nb; - while (!equiv && *ne) { + while (equiv != 0 && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + equiv = SWIG_TypeNameComp(nb, ne, tb, te); if (*ne) ++ne; } return equiv; @@ -377,24 +408,13 @@ SWIG_TypeEquiv(const char *nb, const char *tb) { /* Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb + Return 0 if not equal, 1 if equal */ SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } - /* Check the typename */ @@ -422,7 +442,7 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) { return 0; } -/* +/* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * @@ -457,7 +477,7 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } -/* +/* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * @@ -501,7 +521,7 @@ SWIG_TypePrettyName(const swig_type_info *type) { return type->name; } -/* +/* Set the clientdata field for a type */ SWIGRUNTIME void @@ -509,14 +529,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; - + while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } - } + } cast = cast->next; } } @@ -525,31 +545,31 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } - + /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { swig_module_info *iter = start; do { if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; + size_t l = 0; + size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; + size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { + int compare = strcmp(name, iname); + if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { @@ -574,14 +594,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); @@ -592,7 +612,7 @@ SWIG_TypeQueryModule(swig_module_info *start, of the str field (the human readable name) */ swig_module_info *iter = start; do { - register size_t i = 0; + size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; @@ -600,56 +620,56 @@ SWIG_TypeQueryModule(swig_module_info *start, iter = iter->next; } while (iter != end); } - + /* neither found a match */ return 0; } -/* +/* Pack binary data into a string */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register unsigned char uu = *u; + unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } -/* +/* Unpack binary data from a string */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; + char d = *(c++); + unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else + uu = (unsigned char)((d - ('a'-10)) << 4); + else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else + uu |= (unsigned char)(d - ('a'-10)); + else return (char *) 0; *u = uu; } return c; } -/* +/* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * @@ -709,18 +729,18 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #endif /* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 +#define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 @@ -732,6 +752,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #define PyInt_Check(x) PyLong_Check(x) #define PyInt_AsLong(x) PyLong_AsLong(x) #define PyInt_FromLong(x) PyLong_FromLong(x) +#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) #define PyString_Check(name) PyBytes_Check(name) #define PyString_FromString(x) PyUnicode_FromString(x) #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) @@ -739,7 +760,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #define PyString_Size(str) PyBytes_Size(str) #define PyString_InternFromString(key) PyUnicode_InternFromString(key) #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE -#define PyString_AS_STRING(x) PyBytes_AsString(x) +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) #endif @@ -763,25 +784,31 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { -#if PY_VERSION_HEX >= 0x03000000 - char *cstr; - char *newstr; - Py_ssize_t len; +#if PY_VERSION_HEX >= 0x03030000 + return (char *)PyUnicode_AsUTF8(str); +#elif PY_VERSION_HEX >= 0x03000000 + char *newstr = 0; str = PyUnicode_AsUTF8String(str); - PyBytes_AsStringAndSize(str, &cstr, &len); - newstr = (char *) malloc(len+1); - memcpy(newstr, cstr, len+1); - Py_XDECREF(str); + if (str) { + char *cstr; + Py_ssize_t len; + if (PyBytes_AsStringAndSize(str, &cstr, &len) != -1) { + newstr = (char *) malloc(len+1); + if (newstr) + memcpy(newstr, cstr, len+1); + } + Py_XDECREF(str); + } return newstr; #else return PyString_AsString(str); #endif } -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#if PY_VERSION_HEX >= 0x03030000 || PY_VERSION_HEX < 0x03000000 +# define SWIG_Python_str_DelForPy3(x) #else -# define SWIG_Python_str_DelForPy3(x) +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) #endif @@ -795,148 +822,19 @@ SWIG_Python_str_FromChar(const char *c) #endif } -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf -# else -# define PyOS_snprintf snprintf -# endif -#endif - -/* A crude PyString_FromFormat implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 - -#ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 -#endif - -static PyObject * -PyString_FromFormat(const char *fmt, ...) { - va_list ap; - char buf[SWIG_PYBUFFER_SIZE * 2]; - int res; - va_start(ap, fmt); - res = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); -} -#endif - -/* Add PyObject_Del for old Pythons */ -#if PY_VERSION_HEX < 0x01060000 -# define PyObject_Del(op) PyMem_DEL((op)) -#endif #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif -/* A crude PyExc_StopIteration exception for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif -#endif - -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif - -/* A crude PyString_AsStringAndSize implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif -#endif - -/* PySequence_Size for old Pythons */ -#if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif -#endif - -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - -/* Py_ssize_t for old Pythons */ -/* This code is as recommended by: */ -/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -# define PY_SSIZE_T_MAX INT_MAX -# define PY_SSIZE_T_MIN INT_MIN -typedef inquiry lenfunc; -typedef intargfunc ssizeargfunc; -typedef intintargfunc ssizessizeargfunc; -typedef intobjargproc ssizeobjargproc; -typedef intintobjargproc ssizessizeobjargproc; -typedef getreadbufferproc readbufferproc; -typedef getwritebufferproc writebufferproc; -typedef getsegcountproc segcountproc; -typedef getcharbufferproc charbufferproc; -static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) -{ - long result = 0; - PyObject *i = PyNumber_Int(x); - if (i) { - result = PyInt_AsLong(i); - Py_DECREF(i); - } - return result; -} -#endif - -#if PY_VERSION_HEX < 0x02040000 -#define Py_VISIT(op) \ - do { \ - if (op) { \ - int vret = visit((op), arg); \ - if (vret) \ - return vret; \ - } \ - } while (0) -#endif - -#if PY_VERSION_HEX < 0x02030000 -typedef struct { - PyTypeObject type; - PyNumberMethods as_number; - PyMappingMethods as_mapping; - PySequenceMethods as_sequence; - PyBufferProcs as_buffer; - PyObject *name, *slots; -} PyHeapTypeObject; -#endif - -#if PY_VERSION_HEX < 0x02030000 -typedef destructor freefunc; -#endif - -#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ - (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ - (PY_MAJOR_VERSION > 3)) +// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user +// interface files check for it. # define SWIGPY_USE_CAPSULE -# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) -#endif +# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) #if PY_VERSION_HEX < 0x03020000 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) +#define Py_hash_t long #endif /* ----------------------------------------------------------------------------- @@ -994,14 +892,17 @@ SWIG_Python_AddErrorMsg(const char* mesg) PyObject *value = 0; PyObject *traceback = 0; - if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); + if (PyErr_Occurred()) + PyErr_Fetch(&type, &value, &traceback); if (value) { - char *tmp; PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); PyErr_Clear(); Py_XINCREF(type); - - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + if (tmp) + PyErr_Format(type, "%s %s", tmp, mesg); + else + PyErr_Format(type, "%s", mesg); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); Py_DECREF(value); @@ -1010,6 +911,37 @@ SWIG_Python_AddErrorMsg(const char* mesg) } } +SWIGRUNTIME int +SWIG_Python_TypeErrorOccurred(PyObject *obj) +{ + PyObject *error; + if (obj) + return 0; + error = PyErr_Occurred(); + return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); +} + +SWIGRUNTIME void +SWIG_Python_RaiseOrModifyTypeError(const char *message) +{ + if (SWIG_Python_TypeErrorOccurred(NULL)) { + /* Use existing TypeError to preserve stacktrace and enhance with given message */ + PyObject *newvalue; + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); +#if PY_VERSION_HEX >= 0x03000000 + newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); +#else + newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); +#endif + Py_XDECREF(value); + PyErr_Restore(type, newvalue, traceback); + } else { + /* Raise TypeError using given message */ + PyErr_SetString(PyExc_TypeError, message); + } +} + #if defined(SWIG_PYTHON_NO_THREADS) # if defined(SWIG_PYTHON_THREADS) # undef SWIG_PYTHON_THREADS @@ -1017,9 +949,7 @@ SWIG_Python_AddErrorMsg(const char* mesg) #endif #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ -# define SWIG_PYTHON_USE_GIL -# endif +# define SWIG_PYTHON_USE_GIL # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # ifndef SWIG_PYTHON_INITIALIZE_THREADS @@ -1096,30 +1026,13 @@ extern "C" { /* Constant information structure */ typedef struct swig_const_info { int type; - char *name; + const char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; - -/* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ -#if PY_VERSION_HEX >= 0x03000000 -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) -{ - return PyInstanceMethod_New(func); -} -#else -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) -{ - return NULL; -} -#endif - #ifdef __cplusplus } #endif @@ -1134,6 +1047,14 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), * * ----------------------------------------------------------------------------- */ +#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ +# error "This version of SWIG only supports Python >= 2.7" +#endif + +#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000 +# error "This version of SWIG only supports Python 3 >= 3.2" +#endif + /* Common SWIG API */ /* for raw pointers */ @@ -1172,7 +1093,7 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), /* Runtime API */ -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) #define SWIG_NewClientData(obj) SwigPyClientData_New(obj) @@ -1198,7 +1119,7 @@ SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { SWIGINTERN void SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, (char *) msg); + PyErr_SetString(errtype, msg); SWIG_PYTHON_THREAD_END_BLOCK; } @@ -1217,7 +1138,7 @@ SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { - PyDict_SetItemString(d, (char *)name, obj); + PyDict_SetItemString(d, name, obj); Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); @@ -1227,7 +1148,7 @@ SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *nam SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - PyDict_SetItemString(d, (char *)name, obj); + PyDict_SetItemString(d, name, obj); Py_DECREF(obj); } @@ -1237,7 +1158,6 @@ SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { -#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { @@ -1253,34 +1173,11 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { Py_DECREF(obj); } return result; -#else - PyObject* o2; - PyObject* o3; - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyTuple_Check(result)) { - o2 = result; - result = PyTuple_New(1); - PyTuple_SET_ITEM(result, 0, o2); - } - o3 = PyTuple_New(1); - PyTuple_SET_ITEM(o3, 0, obj); - o2 = result; - result = PySequence_Concat(o2, o3); - Py_DECREF(o2); - Py_DECREF(o3); - } - return result; -#endif } /* Unpack the argument tuple */ -SWIGINTERN int +SWIGINTERN Py_ssize_t SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { @@ -1294,7 +1191,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } if (!PyTuple_Check(args)) { if (min <= 1 && max >= 1) { - register int i; + Py_ssize_t i; objs[0] = args; for (i = 1; i < max; ++i) { objs[i] = 0; @@ -1304,7 +1201,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { - register Py_ssize_t l = PyTuple_GET_SIZE(args); + Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), (int)min, (int)l); @@ -1314,7 +1211,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { - register int i; + Py_ssize_t i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } @@ -1326,12 +1223,21 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } } +SWIGINTERN int +SWIG_Python_CheckNoKeywords(PyObject *kwargs, const char *name) { + int no_kwargs = 1; + if (kwargs) { + assert(PyDict_Check(kwargs)); + if (PyDict_Size(kwargs) > 0) { + PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name); + no_kwargs = 0; + } + } + return no_kwargs; +} + /* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif /* Helper for static pointer initialization for both C and C++ code, for example @@ -1360,35 +1266,6 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi extern "C" { #endif -/* How to access Py_None */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_BUILD_NONE -# ifndef SWIG_PYTHON_BUILD_NONE -# define SWIG_PYTHON_BUILD_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_BUILD_NONE -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue((char*)""); - Py_DECREF(none); - return none; -} -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; -} -#endif - /* The python void return value */ SWIGRUNTIMEINLINE PyObject * @@ -1415,7 +1292,10 @@ SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; - return data ? data->implicitconv : 0; + int fail = data ? data->implicitconv : 0; + if (fail) + PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); + return fail; } SWIGRUNTIMEINLINE PyObject * @@ -1442,11 +1322,7 @@ SwigPyClientData_New(PyObject* obj) data->newargs = obj; Py_INCREF(obj); } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; -#else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif + data->newraw = PyObject_GetAttrString(data->klass, "__new__"); if (data->newraw) { Py_INCREF(data->newraw); data->newargs = PyTuple_New(1); @@ -1457,7 +1333,7 @@ SwigPyClientData_New(PyObject* obj) Py_INCREF(data->newargs); } /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); + data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; @@ -1466,11 +1342,7 @@ SwigPyClientData_New(PyObject* obj) int flags; Py_INCREF(data->destroy); flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif } else { data->delargs = 0; } @@ -1500,6 +1372,23 @@ typedef struct { #endif } SwigPyObject; + +#ifdef SWIGPYTHON_BUILTIN + +SWIGRUNTIME PyObject * +SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + + if (!sobj->dict) + sobj->dict = PyDict_New(); + + Py_INCREF(sobj->dict); + return sobj->dict; +} + +#endif + SWIGRUNTIME PyObject * SwigPyObject_long(SwigPyObject *v) { @@ -1541,20 +1430,12 @@ SwigPyObject_hex(SwigPyObject *v) } SWIGRUNTIME PyObject * -#ifdef METH_NOARGS SwigPyObject_repr(SwigPyObject *v) -#else -SwigPyObject_repr(SwigPyObject *v, PyObject *args) -#endif { const char *name = SWIG_TypePrettyName(v->ty); - PyObject *repr = SWIG_Python_str_FromFormat("", name, (void *)v); + PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); if (v->next) { -# ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); -# else - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); -# endif # if PY_VERSION_HEX >= 0x03000000 PyObject *joined = PyUnicode_Concat(repr, nrep); Py_DecRef(repr); @@ -1567,32 +1448,12 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args) return repr; } -SWIGRUNTIME int -SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char *str; -#ifdef METH_NOARGS - PyObject *repr = SwigPyObject_repr(v); -#else - PyObject *repr = SwigPyObject_repr(v, NULL); -#endif - if (repr) { - str = SWIG_Python_str_AsChar(repr); - fputs(str, fp); - SWIG_Python_str_DelForPy3(str); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - +/* We need a version taking two PyObject* parameters so it's a valid + * PyCFunction to use in swigobject_methods[]. */ SWIGRUNTIME PyObject * -SwigPyObject_str(SwigPyObject *v) +SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) { - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - SWIG_Python_str_FromChar(result) : 0; + return SwigPyObject_repr((SwigPyObject*)v); } SWIGRUNTIME int @@ -1666,16 +1527,32 @@ SwigPyObject_dealloc(PyObject *v) if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; + + /* PyObject_CallFunction() has the potential to silently drop + the active exception. In cases of unnamed temporary + variable or where we just finished iterating over a generator + StopIteration will be active right now, and this needs to + remain true upon return from SwigPyObject_dealloc. So save + and restore. */ + + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); + if (data->delargs) { - /* we need to create a temporary object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); } + if (!res) + PyErr_WriteUnraisable(destroy); + + PyErr_Restore(type, value, traceback); + Py_XDECREF(res); } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) @@ -1693,12 +1570,8 @@ SWIGRUNTIME PyObject* SwigPyObject_append(PyObject* v, PyObject* next) { SwigPyObject *sobj = (SwigPyObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif if (!SwigPyObject_Check(next)) { + PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); return NULL; } sobj->next = next; @@ -1707,11 +1580,7 @@ SwigPyObject_append(PyObject* v, PyObject* next) } SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -SwigPyObject_next(PyObject* v) -#else SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif { SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { @@ -1723,11 +1592,7 @@ SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) } SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_disown(PyObject *v) -#else SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; @@ -1735,11 +1600,7 @@ SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) } SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_acquire(PyObject *v) -#else SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = SWIG_POINTER_OWN; @@ -1750,68 +1611,32 @@ SWIGINTERN PyObject* SwigPyObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#else - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#endif - { - return NULL; + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { + return NULL; + } else { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } } - else - { - SwigPyObject *sobj = (SwigPyObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v); - } else { - SwigPyObject_disown(v); - } -#else - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v,args); - } else { - SwigPyObject_disown(v,args); - } -#endif - } - return obj; - } + return obj; + } } -#ifdef METH_O -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#else static PyMethodDef swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, + {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, + {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, + {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, + {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, + {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, + {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, {0, 0, 0, 0} }; -#endif - -#if PY_VERSION_HEX < 0x02020000 -SWIGINTERN PyObject * -SwigPyObject_getattr(SwigPyObject *sobj,char *name) -{ - return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); -} -#endif SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void) { @@ -1852,14 +1677,12 @@ SwigPyObject_TypeOnce(void) { (unaryfunc)SwigPyObject_oct, /*nb_oct*/ (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif -#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ +#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ +#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ -#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ +#else 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ -#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; @@ -1867,26 +1690,21 @@ SwigPyObject_TypeOnce(void) { static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { - /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"SwigPyObject", /* tp_name */ + "SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ - (printfunc)SwigPyObject_print, /* tp_print */ -#if PY_VERSION_HEX < 0x02020000 - (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ -#else + 0, /* tp_print */ (getattrfunc)0, /* tp_getattr */ -#endif (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ #else (cmpfunc)SwigPyObject_compare, /* tp_compare */ #endif @@ -1896,7 +1714,7 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyObject_str, /* tp_str */ + 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -1906,7 +1724,6 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_clear */ (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ swigobject_methods, /* tp_methods */ @@ -1927,25 +1744,29 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ #endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ #endif }; swigpyobject_type = tmp; type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - swigpyobject_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&swigpyobject_type) < 0) return NULL; -#endif } return &swigpyobject_type; } @@ -1974,20 +1795,6 @@ typedef struct { size_t size; } SwigPyPacked; -SWIGRUNTIME int -SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - SWIGRUNTIME PyObject * SwigPyPacked_repr(SwigPyPacked *v) { @@ -2016,7 +1823,7 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) size_t i = v->size; size_t j = w->size; int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); + return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); @@ -2050,18 +1857,17 @@ SwigPyPacked_TypeOnce(void) { static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { - /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX>=0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"SwigPyPacked", /* tp_name */ + "SwigPyPacked", /* tp_name */ sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ - (printfunc)SwigPyPacked_print, /* tp_print */ + 0, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX>=0x03000000 @@ -2085,7 +1891,6 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ @@ -2106,25 +1911,29 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ #endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ #endif }; swigpypacked_type = tmp; type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - swigpypacked_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&swigpypacked_type) < 0) return NULL; -#endif } return &swigpypacked_type; } @@ -2165,20 +1974,14 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) * pointers/data manipulation * ----------------------------------------------------------------------------- */ -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return SWIG_Python_str_FromChar("this"); -} - -static PyObject *swig_this = NULL; +static PyObject *Swig_This_global = NULL; SWIGRUNTIME PyObject * SWIG_This(void) { - if (swig_this == NULL) - swig_this = _SWIG_This(); - return swig_this; + if (Swig_This_global == NULL) + Swig_This_global = SWIG_Python_str_FromChar("this"); + return Swig_This_global; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ @@ -2210,7 +2013,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) obj = 0; -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) if (PyInstance_Check(pyobj)) { obj = _PyInstance_Lookup(pyobj, SWIG_This()); } else { @@ -2273,13 +2076,14 @@ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { int res; SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; if (!obj) return SWIG_ERROR; - if (obj == Py_None) { + if (obj == Py_None && !implicit_conv) { if (ptr) *ptr = 0; - return SWIG_OK; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } res = SWIG_ERROR; @@ -2325,7 +2129,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } res = SWIG_OK; } else { - if (flags & SWIG_POINTER_IMPLICIT_CONV) { + if (implicit_conv) { SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; @@ -2359,6 +2163,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } } } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } } } return res; @@ -2372,31 +2183,28 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { return SWIG_ConvertPtr(obj, ptr, ty, 0); } else { void *vptr = 0; - + swig_cast_info *tc; + /* here we get the method pointer for callbacks */ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) + if (!desc) return SWIG_ERROR; - if (ty) { - swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (tc) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } else { - return SWIG_ERROR; - } + tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ } else { - *ptr = vptr; + return SWIG_ERROR; } return SWIG_OK; } } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { @@ -2424,7 +2232,6 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t SWIGRUNTIME PyObject* SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { -#if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; PyObject *newraw = data->newraw; if (newraw) { @@ -2441,88 +2248,73 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) } } #else - PyObject *key = SWIG_This(); - PyObject_SetAttr(inst, key, swig_this); + if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { + Py_DECREF(inst); + inst = 0; + } #endif } } else { #if PY_VERSION_HEX >= 0x03000000 - inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + PyObject *empty_args = PyTuple_New(0); + if (empty_args) { + PyObject *empty_kwargs = PyDict_New(); + if (empty_kwargs) { + inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); + Py_DECREF(empty_kwargs); + if (inst) { + if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { + Py_DECREF(inst); + inst = 0; + } else { + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } + } + } + Py_DECREF(empty_args); + } #else PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } #endif } return inst; -#else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst; - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - return (PyObject *) inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -#endif } -SWIGRUNTIME void +SWIGRUNTIME int SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { - PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; - } +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + return PyDict_SetItem(dict, SWIG_This(), swig_this); + } #endif - dict = PyObject_GetAttrString(inst, (char*)"__dict__"); - PyDict_SetItem(dict, SWIG_This(), swig_this); - Py_DECREF(dict); + return PyObject_SetAttr(inst, SWIG_This(), swig_this); } SWIGINTERN PyObject * SWIG_Python_InitShadowInstance(PyObject *args) { PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { return NULL; } else { SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); if (sthis) { SwigPyObject_append((PyObject*) sthis, obj[1]); } else { - SWIG_Python_SetSwigThis(obj[0], obj[1]); + if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0) + return NULL; } return SWIG_Py_Void(); } @@ -2551,18 +2343,21 @@ SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int f newobj = (SwigPyObject *) newobj->next; newobj->next = next_self; newobj = (SwigPyObject *)next_self; +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif } } else { newobj = PyObject_New(SwigPyObject, clientdata->pytype); +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif } if (newobj) { newobj->ptr = ptr; newobj->ty = type; newobj->own = own; newobj->next = 0; -#ifdef SWIGPYTHON_BUILTIN - newobj->dict = 0; -#endif return (PyObject*) newobj; } return SWIG_Py_Void(); @@ -2571,12 +2366,10 @@ SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int f assert(!(flags & SWIG_BUILTIN_TP_INIT)); robj = SwigPyObject_New(ptr, type, own); - if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - if (inst) { - Py_DECREF(robj); - robj = inst; - } + Py_DECREF(robj); + robj = inst; } return robj; } @@ -2597,19 +2390,14 @@ void *SWIG_ReturnGlobalTypeList(void *); #endif SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void) { +SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { static void *type_pointer = (void *)0; /* first check if module already created */ if (!type_pointer) { #ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); #else -# ifdef SWIGPY_USE_CAPSULE type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); -# else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); -# endif if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; @@ -2619,50 +2407,10 @@ SWIG_Python_GetModule(void) { return (swig_module_info *) type_pointer; } -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - SWIGRUNTIME void -#ifdef SWIGPY_USE_CAPSULE SWIG_Python_DestroyModule(PyObject *obj) -#else -SWIG_Python_DestroyModule(void *vptr) -#endif { -#ifdef SWIGPY_USE_CAPSULE swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); -#else - swig_module_info *swig_module = (swig_module_info *) vptr; -#endif swig_type_info **types = swig_module->types; size_t i; for (i =0; i < swig_module->size; ++i) { @@ -2673,33 +2421,24 @@ SWIG_Python_DestroyModule(void *vptr) } } Py_DECREF(SWIG_This()); - swig_this = NULL; + Swig_This_global = NULL; } SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { #if PY_VERSION_HEX >= 0x03000000 /* Add a dummy module object into sys.modules */ - PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); + PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); #else static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); + PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif -#ifdef SWIGPY_USE_CAPSULE PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } -#else - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -#endif } /* The python cached type query */ @@ -2717,20 +2456,12 @@ SWIG_Python_TypeQuery(const char *type) PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { -#ifdef SWIGPY_USE_CAPSULE descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); -#else - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); -#endif } else { - swig_module_info *swig_module = SWIG_Python_GetModule(); + swig_module_info *swig_module = SWIG_GetModule(0); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { -#ifdef SWIGPY_USE_CAPSULE obj = PyCapsule_New((void*) descriptor, NULL, NULL); -#else - obj = PyCObject_FromVoidPtr(descriptor, NULL); -#endif PyDict_SetItem(cache, key, obj); Py_DECREF(obj); } @@ -2755,14 +2486,15 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront) PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { - char *tmp; PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + const char *errmesg = tmp ? tmp : "Invalid error message"; Py_XINCREF(type); PyErr_Clear(); if (infront) { - PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); + PyErr_Format(type, "%s %s", mesg, errmesg); } else { - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + PyErr_Format(type, "%s %s", errmesg, mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); @@ -2791,7 +2523,7 @@ SwigPyObject_GetDesc(PyObject *self) { SwigPyObject *v = (SwigPyObject *)self; swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : (char*)""; + return ty ? ty->str : ""; } SWIGRUNTIME void @@ -2848,23 +2580,24 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(arg return result; } +#ifdef SWIGPYTHON_BUILTIN SWIGRUNTIME int SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { PyTypeObject *tp = obj->ob_type; PyObject *descr; PyObject *encoded_name; descrsetfunc f; - int res; + int res = -1; -#ifdef Py_USING_UNICODE +# ifdef Py_USING_UNICODE if (PyString_Check(name)) { name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); if (!name) return -1; } else if (!PyUnicode_Check(name)) -#else +# else if (!PyString_Check(name)) -#endif +# endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); return -1; @@ -2877,7 +2610,6 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { goto done; } - res = -1; descr = _PyType_Lookup(tp, name); f = NULL; if (descr != NULL) @@ -2888,6 +2620,8 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { Py_INCREF(name); } else { encoded_name = PyUnicode_AsUTF8String(name); + if (!encoded_name) + return -1; } PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); Py_DECREF(encoded_name); @@ -2899,6 +2633,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { Py_DECREF(name); return res; } +#endif #ifdef __cplusplus @@ -2913,6 +2648,21 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { +#ifdef __cplusplus +extern "C" { +#endif + +/* Method creation and docstring support functions */ + +SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); +SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); +SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); + +#ifdef __cplusplus +} +#endif + + /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_archive swig_types[0] @@ -2934,11 +2684,10 @@ static swig_module_info swig_module = {swig_types, 12, 0, 0, 0, 0}; /* -------- TYPES TABLE (END) -------- */ -#if (PY_VERSION_HEX <= 0x02000000) -# if !defined(SWIG_PYTHON_CLASSIC) -# error "This python version requires swig to be run with the '-classic' option" -# endif +#ifdef SWIG_TypeQuery +# undef SWIG_TypeQuery #endif +#define SWIG_TypeQuery SWIG_Python_TypeQuery /*----------------------------------------------- @(target):= __libarchive.so @@ -2952,7 +2701,7 @@ static swig_module_info swig_module = {swig_types, 12, 0, 0, 0, 0}; #endif #define SWIG_name "__libarchive" -#define SWIGVERSION 0x020004 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -2964,13 +2713,10 @@ static swig_module_info swig_module = {swig_types, 12, 0, 0, 0, 0}; #include - #define SWIG_From_long PyInt_FromLong - - -SWIGINTERNINLINE PyObject * -SWIG_From_int (int value) -{ - return SWIG_From_long (value); +SWIGINTERNINLINE PyObject* + SWIG_From_int (int value) +{ + return PyInt_FromLong((long) value); } @@ -2991,13 +2737,19 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { #if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (PyBytes_Check(obj)) +#else if (PyUnicode_Check(obj)) +#endif #else if (PyString_Check(obj)) #endif { char *cstr; Py_ssize_t len; + int ret = SWIG_OK; #if PY_VERSION_HEX>=0x03000000 +#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) if (!alloc && cptr) { /* We can't allow converting without allocation, since the internal representation of string in Python 3 is UCS-2/UCS-4 but we require @@ -3006,48 +2758,75 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); - PyBytes_AsStringAndSize(obj, &cstr, &len); - if(alloc) *alloc = SWIG_NEWOBJ; + if (!obj) + return SWIG_TypeError; + if (alloc) + *alloc = SWIG_NEWOBJ; +#endif + if (PyBytes_AsStringAndSize(obj, &cstr, &len) == -1) + return SWIG_TypeError; #else - PyString_AsStringAndSize(obj, &cstr, &len); + if (PyString_AsStringAndSize(obj, &cstr, &len) == -1) + return SWIG_TypeError; #endif if (cptr) { if (alloc) { - /* - In python the user should not be able to modify the inner - string representation. To warranty that, if you define - SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string - buffer is always returned. - - The default behavior is just to return the pointer value, - so, be careful. - */ -#if defined(SWIG_PYTHON_SAFE_CSTRINGS) - if (*alloc != SWIG_OLDOBJ) -#else - if (*alloc == SWIG_NEWOBJ) -#endif - { - *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); - *alloc = SWIG_NEWOBJ; - } - else { + if (*alloc == SWIG_NEWOBJ) { + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + *alloc = SWIG_NEWOBJ; + } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } else { - #if PY_VERSION_HEX>=0x03000000 - assert(0); /* Should never reach here in Python 3 */ - #endif +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + *cptr = PyBytes_AsString(obj); +#else + assert(0); /* Should never reach here with Unicode strings in Python 3 */ +#endif +#else *cptr = SWIG_Python_str_AsChar(obj); + if (!*cptr) + ret = SWIG_TypeError; +#endif } } if (psize) *psize = len + 1; -#if PY_VERSION_HEX>=0x03000000 +#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) Py_XDECREF(obj); #endif - return SWIG_OK; + return ret; } else { +#if defined(SWIG_PYTHON_2_UNICODE) +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) +#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" +#endif +#if PY_VERSION_HEX<0x03000000 + if (PyUnicode_Check(obj)) { + char *cstr; Py_ssize_t len; + if (!alloc && cptr) { + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { + if (cptr) { + if (alloc) *alloc = SWIG_NEWOBJ; + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + } + if (psize) *psize = len + 1; + + Py_XDECREF(obj); + return SWIG_OK; + } else { + Py_XDECREF(obj); + } + } +#endif +#endif + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; @@ -3073,9 +2852,11 @@ SWIG_AsVal_double (PyObject *obj, double *val) if (PyFloat_Check(obj)) { if (val) *val = PyFloat_AsDouble(obj); return SWIG_OK; +#if PY_VERSION_HEX < 0x03000000 } else if (PyInt_Check(obj)) { - if (val) *val = PyInt_AsLong(obj); + if (val) *val = (double) PyInt_AsLong(obj); return SWIG_OK; +#endif } else if (PyLong_Check(obj)) { double v = PyLong_AsDouble(obj); if (!PyErr_Occurred()) { @@ -3149,6 +2930,7 @@ SWIG_CanCastAsInteger(double *d, double min, double max) { SWIGINTERN int SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) { +#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) { long v = PyInt_AsLong(obj); if (v >= 0) { @@ -3157,13 +2939,16 @@ SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) } else { return SWIG_OverflowError; } - } else if (PyLong_Check(obj)) { + } else +#endif + if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); + return SWIG_OverflowError; } } #ifdef SWIG_PYTHON_CAST_MODE @@ -3186,43 +2971,104 @@ SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) } } #endif - return SWIG_TypeError; + return SWIG_TypeError; +} + + +#include +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE) +# define SWIG_LONG_LONG_AVAILABLE +#endif + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + unsigned long long v = PyLong_AsUnsignedLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + res = SWIG_OverflowError; + } + } else { + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + double d; + res = SWIG_AsVal_double (obj,&d); + if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max)) + return SWIG_OverflowError; + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { + if (val) *val = (unsigned long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +#endif + return res; } +#endif SWIGINTERNINLINE int SWIG_AsVal_size_t (PyObject * obj, size_t *val) { - unsigned long v; - int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); - if (SWIG_IsOK(res) && val) *val = (size_t)(v); + int res = SWIG_TypeError; +#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +#endif + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); +#ifdef SWIG_LONG_LONG_AVAILABLE + } else if (sizeof(size_t) <= sizeof(unsigned long long)) { + unsigned long long v; + res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); + } +#endif return res; } -#include -#if !defined(SWIG_NO_LLONG_MAX) -# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) -# define LLONG_MAX __LONG_LONG_MAX__ -# define LLONG_MIN (-LLONG_MAX - 1LL) -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) -# endif -#endif - - SWIGINTERN int SWIG_AsVal_long (PyObject *obj, long* val) { +#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; - } else if (PyLong_Check(obj)) { + } else +#endif + if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); + return SWIG_OverflowError; } } #ifdef SWIG_PYTHON_CAST_MODE @@ -3275,9 +3121,13 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); } else { #if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromStringAndSize(carray, (int)(size)); +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + return PyBytes_FromStringAndSize(carray, (Py_ssize_t)(size)); +#else + return PyUnicode_DecodeUTF8(carray, (Py_ssize_t)(size), "surrogateescape"); +#endif #else - return PyString_FromStringAndSize(carray, (int)(size)); + return PyString_FromStringAndSize(carray, (Py_ssize_t)(size)); #endif } } else { @@ -3293,11 +3143,14 @@ SWIG_FromCharPtr(const char *cptr) } + #define SWIG_From_long PyInt_FromLong + + SWIGINTERNINLINE PyObject* SWIG_From_unsigned_SS_long (unsigned long value) { return (value > LONG_MAX) ? - PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); + PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); } @@ -3342,17 +3195,10 @@ SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *str = NULL; -#if PY_VERSION_HEX >= 0x03000000 - if (!(str = PyBytes_FromStringAndSize(NULL, len))) { + if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } -#else - if (!(str = PyString_FromStringAndSize(NULL, len))) { - PyErr_SetString(PyExc_MemoryError, "could not allocate string."); - return NULL; - } -#endif if (len != archive_read_data(archive, PyString_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); return NULL; @@ -3376,7 +3222,7 @@ SWIGINTERN PyObject *_wrap_archive_read_new(PyObject *SWIGUNUSEDPARM(self), PyOb PyObject *resultobj = 0; struct archive *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)":archive_read_new")) SWIG_fail; + if (!SWIG_Python_UnpackTuple(args, "archive_read_new", 0, 0, 0)) SWIG_fail; result = (struct archive *)archive_read_new(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_archive, 0 | 0 ); return resultobj; @@ -3390,11 +3236,12 @@ SWIGINTERN PyObject *_wrap_archive_read_free(PyObject *SWIGUNUSEDPARM(self), PyO struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_free",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_free" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3419,23 +3266,21 @@ SWIGINTERN PyObject *_wrap_archive_read_open_filename(PyObject *SWIGUNUSEDPARM(s int alloc2 = 0 ; size_t val3 ; int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; + PyObject *swig_obj[3] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OOO:archive_read_open_filename",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_read_open_filename", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_open_filename" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_open_filename" "', argument " "2"" of type '" "char const *""'"); } arg2 = (char *)(buf2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); + ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "archive_read_open_filename" "', argument " "3"" of type '" "size_t""'"); } @@ -3460,22 +3305,20 @@ SWIGINTERN PyObject *_wrap_archive_read_open_memory(PyObject *SWIGUNUSEDPARM(sel int res2 ; size_t val3 ; int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; + PyObject *swig_obj[3] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OOO:archive_read_open_memory",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_read_open_memory", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_open_memory" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_open_memory" "', argument " "2"" of type '" "void *""'"); } - ecode3 = SWIG_AsVal_size_t(obj2, &val3); + ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "archive_read_open_memory" "', argument " "3"" of type '" "size_t""'"); } @@ -3501,28 +3344,25 @@ SWIGINTERN PyObject *_wrap_archive_read_open_memory2(PyObject *SWIGUNUSEDPARM(se int ecode3 = 0 ; size_t val4 ; int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; + PyObject *swig_obj[4] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OOOO:archive_read_open_memory2",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_read_open_memory2", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_open_memory2" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_open_memory2" "', argument " "2"" of type '" "void *""'"); } - ecode3 = SWIG_AsVal_size_t(obj2, &val3); + ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "archive_read_open_memory2" "', argument " "3"" of type '" "size_t""'"); } arg3 = (size_t)(val3); - ecode4 = SWIG_AsVal_size_t(obj3, &val4); + ecode4 = SWIG_AsVal_size_t(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "archive_read_open_memory2" "', argument " "4"" of type '" "size_t""'"); } @@ -3546,23 +3386,21 @@ SWIGINTERN PyObject *_wrap_archive_read_open_fd(PyObject *SWIGUNUSEDPARM(self), int ecode2 = 0 ; size_t val3 ; int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; + PyObject *swig_obj[3] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OOO:archive_read_open_fd",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_read_open_fd", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_open_fd" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_read_open_fd" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); + ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "archive_read_open_fd" "', argument " "3"" of type '" "size_t""'"); } @@ -3580,11 +3418,12 @@ SWIGINTERN PyObject *_wrap_archive_read_close(PyObject *SWIGUNUSEDPARM(self), Py struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_close",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_close" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3602,11 +3441,12 @@ SWIGINTERN PyObject *_wrap_archive_format(PyObject *SWIGUNUSEDPARM(self), PyObje struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_format",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_format" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3627,17 +3467,16 @@ SWIGINTERN PyObject *_wrap_archive_read_next_header2(PyObject *SWIGUNUSEDPARM(se int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_read_next_header2",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_read_next_header2", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_next_header2" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_archive_entry, 0 | 0 ); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_next_header2" "', argument " "2"" of type '" "struct archive_entry *""'"); } @@ -3655,11 +3494,12 @@ SWIGINTERN PyObject *_wrap_archive_entry_stat(PyObject *SWIGUNUSEDPARM(self), Py struct archive_entry *arg1 = (struct archive_entry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; struct stat *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)"O:archive_entry_stat",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_stat" "', argument " "1"" of type '" "struct archive_entry *""'"); } @@ -3677,11 +3517,12 @@ SWIGINTERN PyObject *_wrap_archive_read_header_position(PyObject *SWIGUNUSEDPARM struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int64_t result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_header_position",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_header_position" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3701,11 +3542,12 @@ SWIGINTERN PyObject *_wrap_archive_read_data_skip(PyObject *SWIGUNUSEDPARM(self) struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_data_skip",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_data_skip" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3726,17 +3568,16 @@ SWIGINTERN PyObject *_wrap_archive_read_data_into_fd(PyObject *SWIGUNUSEDPARM(se int res1 = 0 ; int val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_read_data_into_fd",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_read_data_into_fd", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_data_into_fd" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_read_data_into_fd" "', argument " "2"" of type '" "int""'"); } @@ -3754,11 +3595,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_all(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_filter_all",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_all" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3776,11 +3618,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_bzip2(PyObject *SWIGUNUSE struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_filter_bzip2",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_bzip2" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3798,11 +3641,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_compress(PyObject *SWIGUN struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_filter_compress",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_compress" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3820,11 +3664,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_gzip(PyObject *SWIGUNUSED struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_filter_gzip",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_gzip" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3842,11 +3687,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_lzip(PyObject *SWIGUNUSED struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_filter_lzip",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_lzip" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3864,11 +3710,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_lzma(PyObject *SWIGUNUSED struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_filter_lzma",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_lzma" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3886,11 +3733,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_none(PyObject *SWIGUNUSED struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_filter_none",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_none" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3908,11 +3756,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_rpm(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_filter_rpm",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_rpm" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3930,11 +3779,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_uu(PyObject *SWIGUNUSEDPA struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_filter_uu",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_uu" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3952,11 +3802,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_xz(PyObject *SWIGUNUSEDPA struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_filter_xz",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_xz" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3974,11 +3825,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_all(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_all",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_all" "', argument " "1"" of type '" "struct archive *""'"); } @@ -3996,11 +3848,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_7zip(PyObject *SWIGUNUSED struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_7zip",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_7zip" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4018,11 +3871,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_ar(PyObject *SWIGUNUSEDPA struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_ar",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_ar" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4040,11 +3894,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_cab(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_cab",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_cab" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4062,11 +3917,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_cpio(PyObject *SWIGUNUSED struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_cpio",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_cpio" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4084,11 +3940,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_empty(PyObject *SWIGUNUSE struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_empty",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_empty" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4106,11 +3963,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_gnutar(PyObject *SWIGUNUS struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_gnutar",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_gnutar" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4128,11 +3986,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_iso9660(PyObject *SWIGUNU struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_iso9660",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_iso9660" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4150,11 +4009,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_lha(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_lha",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_lha" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4172,11 +4032,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_rar(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_rar",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_rar" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4194,11 +4055,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_raw(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_raw",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_raw" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4216,11 +4078,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_tar(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_tar",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_tar" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4238,11 +4101,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_xar(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_xar",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_xar" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4260,11 +4124,12 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_zip(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_read_support_format_zip",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_zip" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4281,7 +4146,7 @@ SWIGINTERN PyObject *_wrap_archive_write_new(PyObject *SWIGUNUSEDPARM(self), PyO PyObject *resultobj = 0; struct archive *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)":archive_write_new")) SWIG_fail; + if (!SWIG_Python_UnpackTuple(args, "archive_write_new", 0, 0, 0)) SWIG_fail; result = (struct archive *)archive_write_new(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_archive, 0 | 0 ); return resultobj; @@ -4295,11 +4160,12 @@ SWIGINTERN PyObject *_wrap_archive_write_free(PyObject *SWIGUNUSEDPARM(self), Py struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_free",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_free" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4328,34 +4194,30 @@ SWIGINTERN PyObject *_wrap_archive_write_open(PyObject *SWIGUNUSEDPARM(self), Py int res4 = 0 ; void *argp5 = 0 ; int res5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; + PyObject *swig_obj[5] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OOOOO:archive_write_open",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_write_open", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_open" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_open" "', argument " "2"" of type '" "void *""'"); } - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_archive_open_callback, 0 | 0 ); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_archive_open_callback, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_write_open" "', argument " "3"" of type '" "archive_open_callback *""'"); } arg3 = (archive_open_callback *)(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_archive_write_callback, 0 | 0 ); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_archive_write_callback, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "archive_write_open" "', argument " "4"" of type '" "archive_write_callback *""'"); } arg4 = (archive_write_callback *)(argp4); - res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_archive_close_callback, 0 | 0 ); + res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_archive_close_callback, 0 | 0 ); if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "archive_write_open" "', argument " "5"" of type '" "archive_close_callback *""'"); } @@ -4376,17 +4238,16 @@ SWIGINTERN PyObject *_wrap_archive_write_open_fd(PyObject *SWIGUNUSEDPARM(self), int res1 = 0 ; int val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_write_open_fd",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_write_open_fd", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_open_fd" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_write_open_fd" "', argument " "2"" of type '" "int""'"); } @@ -4408,17 +4269,16 @@ SWIGINTERN PyObject *_wrap_archive_write_open_filename(PyObject *SWIGUNUSEDPARM( int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_write_open_filename",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_write_open_filename", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_open_filename" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_open_filename" "', argument " "2"" of type '" "char const *""'"); } @@ -4441,17 +4301,16 @@ SWIGINTERN PyObject *_wrap_archive_write_open_filename_w(PyObject *SWIGUNUSEDPAR int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_write_open_filename_w",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_write_open_filename_w", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_open_filename_w" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_wchar_t, 0 | 0 ); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_wchar_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_open_filename_w" "', argument " "2"" of type '" "wchar_t const *""'"); } @@ -4477,28 +4336,25 @@ SWIGINTERN PyObject *_wrap_archive_write_open_memory(PyObject *SWIGUNUSEDPARM(se int ecode3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; + PyObject *swig_obj[4] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OOOO:archive_write_open_memory",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_write_open_memory", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_open_memory" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_open_memory" "', argument " "2"" of type '" "void *""'"); } - ecode3 = SWIG_AsVal_size_t(obj2, &val3); + ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "archive_write_open_memory" "', argument " "3"" of type '" "size_t""'"); } arg3 = (size_t)(val3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_size_t, 0 | 0 ); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_size_t, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "archive_write_open_memory" "', argument " "4"" of type '" "size_t *""'"); } @@ -4516,11 +4372,12 @@ SWIGINTERN PyObject *_wrap_archive_write_close(PyObject *SWIGUNUSEDPARM(self), P struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_close",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_close" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4541,17 +4398,16 @@ SWIGINTERN PyObject *_wrap_archive_write_header(PyObject *SWIGUNUSEDPARM(self), int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_write_header",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_write_header", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_header" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_archive_entry, 0 | 0 ); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_header" "', argument " "2"" of type '" "struct archive_entry *""'"); } @@ -4569,11 +4425,12 @@ SWIGINTERN PyObject *_wrap_archive_write_finish_entry(PyObject *SWIGUNUSEDPARM(s struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_finish_entry",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_finish_entry" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4591,11 +4448,12 @@ SWIGINTERN PyObject *_wrap_archive_write_add_filter_bzip2(PyObject *SWIGUNUSEDPA struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_add_filter_bzip2",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_bzip2" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4613,11 +4471,12 @@ SWIGINTERN PyObject *_wrap_archive_write_add_filter_compress(PyObject *SWIGUNUSE struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_add_filter_compress",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_compress" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4635,11 +4494,12 @@ SWIGINTERN PyObject *_wrap_archive_write_add_filter_gzip(PyObject *SWIGUNUSEDPAR struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_add_filter_gzip",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_gzip" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4657,11 +4517,12 @@ SWIGINTERN PyObject *_wrap_archive_write_add_filter_lzip(PyObject *SWIGUNUSEDPAR struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_add_filter_lzip",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_lzip" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4679,11 +4540,12 @@ SWIGINTERN PyObject *_wrap_archive_write_add_filter_lzma(PyObject *SWIGUNUSEDPAR struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_add_filter_lzma",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_lzma" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4701,11 +4563,12 @@ SWIGINTERN PyObject *_wrap_archive_write_add_filter_none(PyObject *SWIGUNUSEDPAR struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_add_filter_none",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_none" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4723,11 +4586,12 @@ SWIGINTERN PyObject *_wrap_archive_write_add_filter_xz(PyObject *SWIGUNUSEDPARM( struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_add_filter_xz",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_xz" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4748,17 +4612,16 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format(PyObject *SWIGUNUSEDPARM(sel int res1 = 0 ; int val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_write_set_format",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_write_set_format", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_write_set_format" "', argument " "2"" of type '" "int""'"); } @@ -4780,17 +4643,16 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_by_name(PyObject *SWIGUNUSED int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_write_set_format_by_name",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_write_set_format_by_name", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_by_name" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_set_format_by_name" "', argument " "2"" of type '" "char const *""'"); } @@ -4810,11 +4672,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_ar_bsd(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_ar_bsd",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_ar_bsd" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4832,11 +4695,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_ar_svr4(PyObject *SWIGUNUSED struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_ar_svr4",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_ar_svr4" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4854,11 +4718,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_cpio(PyObject *SWIGUNUSEDPAR struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_cpio",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_cpio" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4876,11 +4741,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_cpio_newc(PyObject *SWIGUNUS struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_cpio_newc",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_cpio_newc" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4898,11 +4764,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_gnutar(PyObject *SWIGUNUSEDP struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_gnutar",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_gnutar" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4920,11 +4787,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_iso9660(PyObject *SWIGUNUSED struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_iso9660",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_iso9660" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4942,11 +4810,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_pax(PyObject *SWIGUNUSEDPARM struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_pax",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_pax" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4964,11 +4833,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_pax_restricted(PyObject *SWI struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_pax_restricted",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_pax_restricted" "', argument " "1"" of type '" "struct archive *""'"); } @@ -4986,11 +4856,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_shar(PyObject *SWIGUNUSEDPAR struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_shar",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_shar" "', argument " "1"" of type '" "struct archive *""'"); } @@ -5008,11 +4879,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_shar_dump(PyObject *SWIGUNUS struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_shar_dump",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_shar_dump" "', argument " "1"" of type '" "struct archive *""'"); } @@ -5030,11 +4902,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_ustar(PyObject *SWIGUNUSEDPA struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_ustar",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_ustar" "', argument " "1"" of type '" "struct archive *""'"); } @@ -5052,11 +4925,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_xar(PyObject *SWIGUNUSEDPARM struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_xar",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_xar" "', argument " "1"" of type '" "struct archive *""'"); } @@ -5074,11 +4948,12 @@ SWIGINTERN PyObject *_wrap_archive_write_set_format_zip(PyObject *SWIGUNUSEDPARM struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_write_set_format_zip",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_zip" "', argument " "1"" of type '" "struct archive *""'"); } @@ -5095,7 +4970,7 @@ SWIGINTERN PyObject *_wrap_archive_entry_new(PyObject *SWIGUNUSEDPARM(self), PyO PyObject *resultobj = 0; struct archive_entry *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)":archive_entry_new")) SWIG_fail; + if (!SWIG_Python_UnpackTuple(args, "archive_entry_new", 0, 0, 0)) SWIG_fail; result = (struct archive_entry *)archive_entry_new(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_archive_entry, 0 | 0 ); return resultobj; @@ -5109,10 +4984,11 @@ SWIGINTERN PyObject *_wrap_archive_entry_free(PyObject *SWIGUNUSEDPARM(self), Py struct archive_entry *arg1 = (struct archive_entry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; - if (!PyArg_ParseTuple(args,(char *)"O:archive_entry_free",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_free" "', argument " "1"" of type '" "struct archive_entry *""'"); } @@ -5130,11 +5006,12 @@ SWIGINTERN PyObject *_wrap_archive_entry_pathname(PyObject *SWIGUNUSEDPARM(self) struct archive_entry *arg1 = (struct archive_entry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; char *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)"O:archive_entry_pathname",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_pathname" "', argument " "1"" of type '" "struct archive_entry *""'"); } @@ -5152,11 +5029,12 @@ SWIGINTERN PyObject *_wrap_archive_entry_pathname_w(PyObject *SWIGUNUSEDPARM(sel struct archive_entry *arg1 = (struct archive_entry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; wchar_t *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)"O:archive_entry_pathname_w",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_pathname_w" "', argument " "1"" of type '" "struct archive_entry *""'"); } @@ -5174,11 +5052,12 @@ SWIGINTERN PyObject *_wrap_archive_entry_size(PyObject *SWIGUNUSEDPARM(self), Py struct archive_entry *arg1 = (struct archive_entry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int64_t result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_entry_size",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_size" "', argument " "1"" of type '" "struct archive_entry *""'"); } @@ -5198,11 +5077,12 @@ SWIGINTERN PyObject *_wrap_archive_entry_mtime(PyObject *SWIGUNUSEDPARM(self), P struct archive_entry *arg1 = (struct archive_entry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; time_t result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_entry_mtime",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_mtime" "', argument " "1"" of type '" "struct archive_entry *""'"); } @@ -5222,11 +5102,12 @@ SWIGINTERN PyObject *_wrap_archive_entry_filetype(PyObject *SWIGUNUSEDPARM(self) struct archive_entry *arg1 = (struct archive_entry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; mode_t result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_entry_filetype",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_filetype" "', argument " "1"" of type '" "struct archive_entry *""'"); } @@ -5244,11 +5125,12 @@ SWIGINTERN PyObject *_wrap_archive_entry_perm(PyObject *SWIGUNUSEDPARM(self), Py struct archive_entry *arg1 = (struct archive_entry *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; mode_t result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_entry_perm",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_perm" "', argument " "1"" of type '" "struct archive_entry *""'"); } @@ -5261,6 +5143,246 @@ fail: } +SWIGINTERN PyObject *_wrap_archive_entry_symlink(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive_entry *arg1 = (struct archive_entry *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_symlink" "', argument " "1"" of type '" "struct archive_entry *""'"); + } + arg1 = (struct archive_entry *)(argp1); + result = (char *)archive_entry_symlink(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_entry_set_link(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive_entry *arg1 = (struct archive_entry *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "archive_entry_set_link", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_set_link" "', argument " "1"" of type '" "struct archive_entry *""'"); + } + arg1 = (struct archive_entry *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_entry_set_link" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + archive_entry_set_link(arg1,(char const *)arg2); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_entry_symlink_w(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive_entry *arg1 = (struct archive_entry *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + wchar_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_symlink_w" "', argument " "1"" of type '" "struct archive_entry *""'"); + } + arg1 = (struct archive_entry *)(argp1); + result = (wchar_t *)archive_entry_symlink_w(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_wchar_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_disk_set_symlink_logical(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_disk_set_symlink_logical" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_disk_set_symlink_logical(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_disk_set_symlink_physical(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_disk_set_symlink_physical" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_disk_set_symlink_physical(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_disk_set_symlink_hybrid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_disk_set_symlink_hybrid" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_disk_set_symlink_hybrid(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_entry_set_symlink(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive_entry *arg1 = (struct archive_entry *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "archive_entry_set_symlink", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_set_symlink" "', argument " "1"" of type '" "struct archive_entry *""'"); + } + arg1 = (struct archive_entry *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_entry_set_symlink" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + archive_entry_set_symlink(arg1,(char const *)arg2); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_entry_copy_symlink(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive_entry *arg1 = (struct archive_entry *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "archive_entry_copy_symlink", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_copy_symlink" "', argument " "1"" of type '" "struct archive_entry *""'"); + } + arg1 = (struct archive_entry *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_entry_copy_symlink" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + archive_entry_copy_symlink(arg1,(char const *)arg2); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_entry_copy_symlink_w(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive_entry *arg1 = (struct archive_entry *) 0 ; + wchar_t *arg2 = (wchar_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "archive_entry_copy_symlink_w", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_copy_symlink_w" "', argument " "1"" of type '" "struct archive_entry *""'"); + } + arg1 = (struct archive_entry *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_wchar_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_entry_copy_symlink_w" "', argument " "2"" of type '" "wchar_t const *""'"); + } + arg2 = (wchar_t *)(argp2); + archive_entry_copy_symlink_w(arg1,(wchar_t const *)arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_archive_entry_set_pathname(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive_entry *arg1 = (struct archive_entry *) 0 ; @@ -5270,16 +5392,15 @@ SWIGINTERN PyObject *_wrap_archive_entry_set_pathname(PyObject *SWIGUNUSEDPARM(s int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_entry_set_pathname",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_entry_set_pathname", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_set_pathname" "', argument " "1"" of type '" "struct archive_entry *""'"); } arg1 = (struct archive_entry *)(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_entry_set_pathname" "', argument " "2"" of type '" "char const *""'"); } @@ -5300,22 +5421,21 @@ SWIGINTERN PyObject *_wrap_archive_entry_set_size(PyObject *SWIGUNUSEDPARM(self) int64_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_entry_set_size",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_entry_set_size", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_set_size" "', argument " "1"" of type '" "struct archive_entry *""'"); } arg1 = (struct archive_entry *)(argp1); { - if (PyLong_Check(obj1)) - arg2 = (int64_t) PyLong_AsLong(obj1); - else if (PyInt_Check(obj1)) - arg2 = (int64_t) PyInt_AsLong(obj1); - else if (PyFloat_Check(obj1)) - arg2 = (int64_t) PyFloat_AsDouble(obj1); + if (PyLong_Check(swig_obj[1])) + arg2 = (int64_t) PyLong_AsLong(swig_obj[1]); + else if (PyInt_Check(swig_obj[1])) + arg2 = (int64_t) PyInt_AsLong(swig_obj[1]); + else if (PyFloat_Check(swig_obj[1])) + arg2 = (int64_t) PyFloat_AsDouble(swig_obj[1]); else { PyErr_SetString(PyExc_TypeError,"Expected a large number"); return NULL; @@ -5338,29 +5458,27 @@ SWIGINTERN PyObject *_wrap_archive_entry_set_mtime(PyObject *SWIGUNUSEDPARM(self int res1 = 0 ; long val3 ; int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; + PyObject *swig_obj[3] ; - if (!PyArg_ParseTuple(args,(char *)"OOO:archive_entry_set_mtime",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_entry_set_mtime", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_set_mtime" "', argument " "1"" of type '" "struct archive_entry *""'"); } arg1 = (struct archive_entry *)(argp1); { - if (PyLong_Check(obj1)) - arg2 = (time_t) PyLong_AsLong(obj1); - else if (PyInt_Check(obj1)) - arg2 = (time_t) PyInt_AsLong(obj1); - else if (PyFloat_Check(obj1)) - arg2 = (time_t) PyFloat_AsDouble(obj1); + if (PyLong_Check(swig_obj[1])) + arg2 = (time_t) PyLong_AsLong(swig_obj[1]); + else if (PyInt_Check(swig_obj[1])) + arg2 = (time_t) PyInt_AsLong(swig_obj[1]); + else if (PyFloat_Check(swig_obj[1])) + arg2 = (time_t) PyFloat_AsDouble(swig_obj[1]); else { PyErr_SetString(PyExc_TypeError,"Expected a large number"); return NULL; } } - ecode3 = SWIG_AsVal_long(obj2, &val3); + ecode3 = SWIG_AsVal_long(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "archive_entry_set_mtime" "', argument " "3"" of type '" "long""'"); } @@ -5381,16 +5499,15 @@ SWIGINTERN PyObject *_wrap_archive_entry_set_filetype(PyObject *SWIGUNUSEDPARM(s int res1 = 0 ; unsigned int val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_entry_set_filetype",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_entry_set_filetype", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_set_filetype" "', argument " "1"" of type '" "struct archive_entry *""'"); } arg1 = (struct archive_entry *)(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2); + ecode2 = SWIG_AsVal_unsigned_SS_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_entry_set_filetype" "', argument " "2"" of type '" "unsigned int""'"); } @@ -5411,16 +5528,15 @@ SWIGINTERN PyObject *_wrap_archive_entry_set_perm(PyObject *SWIGUNUSEDPARM(self) int res1 = 0 ; unsigned short val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_entry_set_perm",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_entry_set_perm", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive_entry, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_entry_set_perm" "', argument " "1"" of type '" "struct archive_entry *""'"); } arg1 = (struct archive_entry *)(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + ecode2 = SWIG_AsVal_unsigned_SS_short(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_entry_set_perm" "', argument " "2"" of type '" "mode_t""'"); } @@ -5438,11 +5554,12 @@ SWIGINTERN PyObject *_wrap_archive_errno(PyObject *SWIGUNUSEDPARM(self), PyObjec struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:archive_errno",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_errno" "', argument " "1"" of type '" "struct archive *""'"); } @@ -5460,11 +5577,12 @@ SWIGINTERN PyObject *_wrap_archive_error_string(PyObject *SWIGUNUSEDPARM(self), struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; char *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)"O:archive_error_string",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_error_string" "', argument " "1"" of type '" "struct archive *""'"); } @@ -5485,17 +5603,16 @@ SWIGINTERN PyObject *_wrap_archive_read_data_into_str(PyObject *SWIGUNUSEDPARM(s int res1 = 0 ; int val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; PyObject *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_read_data_into_str",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_read_data_into_str", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_data_into_str" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_read_data_into_str" "', argument " "2"" of type '" "int""'"); } @@ -5514,17 +5631,16 @@ SWIGINTERN PyObject *_wrap_archive_write_data_from_str(PyObject *SWIGUNUSEDPARM( PyObject *arg2 = (PyObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; PyObject *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OO:archive_write_data_from_str",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "archive_write_data_from_str", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_data_from_str" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - arg2 = obj1; + arg2 = swig_obj[1]; result = (PyObject *)archive_write_data_from_str(arg1,arg2); resultobj = result; return resultobj; @@ -5534,93 +5650,106 @@ fail: static PyMethodDef SwigMethods[] = { - { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, - { (char *)"archive_read_new", _wrap_archive_read_new, METH_VARARGS, NULL}, - { (char *)"archive_read_free", _wrap_archive_read_free, METH_VARARGS, NULL}, - { (char *)"archive_read_open_filename", _wrap_archive_read_open_filename, METH_VARARGS, NULL}, - { (char *)"archive_read_open_memory", _wrap_archive_read_open_memory, METH_VARARGS, NULL}, - { (char *)"archive_read_open_memory2", _wrap_archive_read_open_memory2, METH_VARARGS, NULL}, - { (char *)"archive_read_open_fd", _wrap_archive_read_open_fd, METH_VARARGS, NULL}, - { (char *)"archive_read_close", _wrap_archive_read_close, METH_VARARGS, NULL}, - { (char *)"archive_format", _wrap_archive_format, METH_VARARGS, NULL}, - { (char *)"archive_read_next_header2", _wrap_archive_read_next_header2, METH_VARARGS, NULL}, - { (char *)"archive_entry_stat", _wrap_archive_entry_stat, METH_VARARGS, NULL}, - { (char *)"archive_read_header_position", _wrap_archive_read_header_position, METH_VARARGS, NULL}, - { (char *)"archive_read_data_skip", _wrap_archive_read_data_skip, METH_VARARGS, NULL}, - { (char *)"archive_read_data_into_fd", _wrap_archive_read_data_into_fd, METH_VARARGS, NULL}, - { (char *)"archive_read_support_filter_all", _wrap_archive_read_support_filter_all, METH_VARARGS, NULL}, - { (char *)"archive_read_support_filter_bzip2", _wrap_archive_read_support_filter_bzip2, METH_VARARGS, NULL}, - { (char *)"archive_read_support_filter_compress", _wrap_archive_read_support_filter_compress, METH_VARARGS, NULL}, - { (char *)"archive_read_support_filter_gzip", _wrap_archive_read_support_filter_gzip, METH_VARARGS, NULL}, - { (char *)"archive_read_support_filter_lzip", _wrap_archive_read_support_filter_lzip, METH_VARARGS, NULL}, - { (char *)"archive_read_support_filter_lzma", _wrap_archive_read_support_filter_lzma, METH_VARARGS, NULL}, - { (char *)"archive_read_support_filter_none", _wrap_archive_read_support_filter_none, METH_VARARGS, NULL}, - { (char *)"archive_read_support_filter_rpm", _wrap_archive_read_support_filter_rpm, METH_VARARGS, NULL}, - { (char *)"archive_read_support_filter_uu", _wrap_archive_read_support_filter_uu, METH_VARARGS, NULL}, - { (char *)"archive_read_support_filter_xz", _wrap_archive_read_support_filter_xz, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_all", _wrap_archive_read_support_format_all, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_7zip", _wrap_archive_read_support_format_7zip, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_ar", _wrap_archive_read_support_format_ar, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_cab", _wrap_archive_read_support_format_cab, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_cpio", _wrap_archive_read_support_format_cpio, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_empty", _wrap_archive_read_support_format_empty, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_gnutar", _wrap_archive_read_support_format_gnutar, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_iso9660", _wrap_archive_read_support_format_iso9660, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_lha", _wrap_archive_read_support_format_lha, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_rar", _wrap_archive_read_support_format_rar, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_raw", _wrap_archive_read_support_format_raw, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_tar", _wrap_archive_read_support_format_tar, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_xar", _wrap_archive_read_support_format_xar, METH_VARARGS, NULL}, - { (char *)"archive_read_support_format_zip", _wrap_archive_read_support_format_zip, METH_VARARGS, NULL}, - { (char *)"archive_write_new", _wrap_archive_write_new, METH_VARARGS, NULL}, - { (char *)"archive_write_free", _wrap_archive_write_free, METH_VARARGS, NULL}, - { (char *)"archive_write_open", _wrap_archive_write_open, METH_VARARGS, NULL}, - { (char *)"archive_write_open_fd", _wrap_archive_write_open_fd, METH_VARARGS, NULL}, - { (char *)"archive_write_open_filename", _wrap_archive_write_open_filename, METH_VARARGS, NULL}, - { (char *)"archive_write_open_filename_w", _wrap_archive_write_open_filename_w, METH_VARARGS, NULL}, - { (char *)"archive_write_open_memory", _wrap_archive_write_open_memory, METH_VARARGS, NULL}, - { (char *)"archive_write_close", _wrap_archive_write_close, METH_VARARGS, NULL}, - { (char *)"archive_write_header", _wrap_archive_write_header, METH_VARARGS, NULL}, - { (char *)"archive_write_finish_entry", _wrap_archive_write_finish_entry, METH_VARARGS, NULL}, - { (char *)"archive_write_add_filter_bzip2", _wrap_archive_write_add_filter_bzip2, METH_VARARGS, NULL}, - { (char *)"archive_write_add_filter_compress", _wrap_archive_write_add_filter_compress, METH_VARARGS, NULL}, - { (char *)"archive_write_add_filter_gzip", _wrap_archive_write_add_filter_gzip, METH_VARARGS, NULL}, - { (char *)"archive_write_add_filter_lzip", _wrap_archive_write_add_filter_lzip, METH_VARARGS, NULL}, - { (char *)"archive_write_add_filter_lzma", _wrap_archive_write_add_filter_lzma, METH_VARARGS, NULL}, - { (char *)"archive_write_add_filter_none", _wrap_archive_write_add_filter_none, METH_VARARGS, NULL}, - { (char *)"archive_write_add_filter_xz", _wrap_archive_write_add_filter_xz, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format", _wrap_archive_write_set_format, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_by_name", _wrap_archive_write_set_format_by_name, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_ar_bsd", _wrap_archive_write_set_format_ar_bsd, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_ar_svr4", _wrap_archive_write_set_format_ar_svr4, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_cpio", _wrap_archive_write_set_format_cpio, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_cpio_newc", _wrap_archive_write_set_format_cpio_newc, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_gnutar", _wrap_archive_write_set_format_gnutar, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_iso9660", _wrap_archive_write_set_format_iso9660, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_pax", _wrap_archive_write_set_format_pax, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_pax_restricted", _wrap_archive_write_set_format_pax_restricted, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_shar", _wrap_archive_write_set_format_shar, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_shar_dump", _wrap_archive_write_set_format_shar_dump, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_ustar", _wrap_archive_write_set_format_ustar, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_xar", _wrap_archive_write_set_format_xar, METH_VARARGS, NULL}, - { (char *)"archive_write_set_format_zip", _wrap_archive_write_set_format_zip, METH_VARARGS, NULL}, - { (char *)"archive_entry_new", _wrap_archive_entry_new, METH_VARARGS, NULL}, - { (char *)"archive_entry_free", _wrap_archive_entry_free, METH_VARARGS, NULL}, - { (char *)"archive_entry_pathname", _wrap_archive_entry_pathname, METH_VARARGS, NULL}, - { (char *)"archive_entry_pathname_w", _wrap_archive_entry_pathname_w, METH_VARARGS, NULL}, - { (char *)"archive_entry_size", _wrap_archive_entry_size, METH_VARARGS, NULL}, - { (char *)"archive_entry_mtime", _wrap_archive_entry_mtime, METH_VARARGS, NULL}, - { (char *)"archive_entry_filetype", _wrap_archive_entry_filetype, METH_VARARGS, NULL}, - { (char *)"archive_entry_perm", _wrap_archive_entry_perm, METH_VARARGS, NULL}, - { (char *)"archive_entry_set_pathname", _wrap_archive_entry_set_pathname, METH_VARARGS, NULL}, - { (char *)"archive_entry_set_size", _wrap_archive_entry_set_size, METH_VARARGS, NULL}, - { (char *)"archive_entry_set_mtime", _wrap_archive_entry_set_mtime, METH_VARARGS, NULL}, - { (char *)"archive_entry_set_filetype", _wrap_archive_entry_set_filetype, METH_VARARGS, NULL}, - { (char *)"archive_entry_set_perm", _wrap_archive_entry_set_perm, METH_VARARGS, NULL}, - { (char *)"archive_errno", _wrap_archive_errno, METH_VARARGS, NULL}, - { (char *)"archive_error_string", _wrap_archive_error_string, METH_VARARGS, NULL}, - { (char *)"archive_read_data_into_str", _wrap_archive_read_data_into_str, METH_VARARGS, NULL}, - { (char *)"archive_write_data_from_str", _wrap_archive_write_data_from_str, METH_VARARGS, NULL}, + { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL}, + { "archive_read_new", _wrap_archive_read_new, METH_NOARGS, NULL}, + { "archive_read_free", _wrap_archive_read_free, METH_O, NULL}, + { "archive_read_open_filename", _wrap_archive_read_open_filename, METH_VARARGS, NULL}, + { "archive_read_open_memory", _wrap_archive_read_open_memory, METH_VARARGS, NULL}, + { "archive_read_open_memory2", _wrap_archive_read_open_memory2, METH_VARARGS, NULL}, + { "archive_read_open_fd", _wrap_archive_read_open_fd, METH_VARARGS, NULL}, + { "archive_read_close", _wrap_archive_read_close, METH_O, NULL}, + { "archive_format", _wrap_archive_format, METH_O, NULL}, + { "archive_read_next_header2", _wrap_archive_read_next_header2, METH_VARARGS, NULL}, + { "archive_entry_stat", _wrap_archive_entry_stat, METH_O, NULL}, + { "archive_read_header_position", _wrap_archive_read_header_position, METH_O, NULL}, + { "archive_read_data_skip", _wrap_archive_read_data_skip, METH_O, NULL}, + { "archive_read_data_into_fd", _wrap_archive_read_data_into_fd, METH_VARARGS, NULL}, + { "archive_read_support_filter_all", _wrap_archive_read_support_filter_all, METH_O, NULL}, + { "archive_read_support_filter_bzip2", _wrap_archive_read_support_filter_bzip2, METH_O, NULL}, + { "archive_read_support_filter_compress", _wrap_archive_read_support_filter_compress, METH_O, NULL}, + { "archive_read_support_filter_gzip", _wrap_archive_read_support_filter_gzip, METH_O, NULL}, + { "archive_read_support_filter_lzip", _wrap_archive_read_support_filter_lzip, METH_O, NULL}, + { "archive_read_support_filter_lzma", _wrap_archive_read_support_filter_lzma, METH_O, NULL}, + { "archive_read_support_filter_none", _wrap_archive_read_support_filter_none, METH_O, NULL}, + { "archive_read_support_filter_rpm", _wrap_archive_read_support_filter_rpm, METH_O, NULL}, + { "archive_read_support_filter_uu", _wrap_archive_read_support_filter_uu, METH_O, NULL}, + { "archive_read_support_filter_xz", _wrap_archive_read_support_filter_xz, METH_O, NULL}, + { "archive_read_support_format_all", _wrap_archive_read_support_format_all, METH_O, NULL}, + { "archive_read_support_format_7zip", _wrap_archive_read_support_format_7zip, METH_O, NULL}, + { "archive_read_support_format_ar", _wrap_archive_read_support_format_ar, METH_O, NULL}, + { "archive_read_support_format_cab", _wrap_archive_read_support_format_cab, METH_O, NULL}, + { "archive_read_support_format_cpio", _wrap_archive_read_support_format_cpio, METH_O, NULL}, + { "archive_read_support_format_empty", _wrap_archive_read_support_format_empty, METH_O, NULL}, + { "archive_read_support_format_gnutar", _wrap_archive_read_support_format_gnutar, METH_O, NULL}, + { "archive_read_support_format_iso9660", _wrap_archive_read_support_format_iso9660, METH_O, NULL}, + { "archive_read_support_format_lha", _wrap_archive_read_support_format_lha, METH_O, NULL}, + { "archive_read_support_format_rar", _wrap_archive_read_support_format_rar, METH_O, NULL}, + { "archive_read_support_format_raw", _wrap_archive_read_support_format_raw, METH_O, NULL}, + { "archive_read_support_format_tar", _wrap_archive_read_support_format_tar, METH_O, NULL}, + { "archive_read_support_format_xar", _wrap_archive_read_support_format_xar, METH_O, NULL}, + { "archive_read_support_format_zip", _wrap_archive_read_support_format_zip, METH_O, NULL}, + { "archive_write_new", _wrap_archive_write_new, METH_NOARGS, NULL}, + { "archive_write_free", _wrap_archive_write_free, METH_O, NULL}, + { "archive_write_open", _wrap_archive_write_open, METH_VARARGS, NULL}, + { "archive_write_open_fd", _wrap_archive_write_open_fd, METH_VARARGS, NULL}, + { "archive_write_open_filename", _wrap_archive_write_open_filename, METH_VARARGS, NULL}, + { "archive_write_open_filename_w", _wrap_archive_write_open_filename_w, METH_VARARGS, NULL}, + { "archive_write_open_memory", _wrap_archive_write_open_memory, METH_VARARGS, NULL}, + { "archive_write_close", _wrap_archive_write_close, METH_O, NULL}, + { "archive_write_header", _wrap_archive_write_header, METH_VARARGS, NULL}, + { "archive_write_finish_entry", _wrap_archive_write_finish_entry, METH_O, NULL}, + { "archive_write_add_filter_bzip2", _wrap_archive_write_add_filter_bzip2, METH_O, NULL}, + { "archive_write_add_filter_compress", _wrap_archive_write_add_filter_compress, METH_O, NULL}, + { "archive_write_add_filter_gzip", _wrap_archive_write_add_filter_gzip, METH_O, NULL}, + { "archive_write_add_filter_lzip", _wrap_archive_write_add_filter_lzip, METH_O, NULL}, + { "archive_write_add_filter_lzma", _wrap_archive_write_add_filter_lzma, METH_O, NULL}, + { "archive_write_add_filter_none", _wrap_archive_write_add_filter_none, METH_O, NULL}, + { "archive_write_add_filter_xz", _wrap_archive_write_add_filter_xz, METH_O, NULL}, + { "archive_write_set_format", _wrap_archive_write_set_format, METH_VARARGS, NULL}, + { "archive_write_set_format_by_name", _wrap_archive_write_set_format_by_name, METH_VARARGS, NULL}, + { "archive_write_set_format_ar_bsd", _wrap_archive_write_set_format_ar_bsd, METH_O, NULL}, + { "archive_write_set_format_ar_svr4", _wrap_archive_write_set_format_ar_svr4, METH_O, NULL}, + { "archive_write_set_format_cpio", _wrap_archive_write_set_format_cpio, METH_O, NULL}, + { "archive_write_set_format_cpio_newc", _wrap_archive_write_set_format_cpio_newc, METH_O, NULL}, + { "archive_write_set_format_gnutar", _wrap_archive_write_set_format_gnutar, METH_O, NULL}, + { "archive_write_set_format_iso9660", _wrap_archive_write_set_format_iso9660, METH_O, NULL}, + { "archive_write_set_format_pax", _wrap_archive_write_set_format_pax, METH_O, NULL}, + { "archive_write_set_format_pax_restricted", _wrap_archive_write_set_format_pax_restricted, METH_O, NULL}, + { "archive_write_set_format_shar", _wrap_archive_write_set_format_shar, METH_O, NULL}, + { "archive_write_set_format_shar_dump", _wrap_archive_write_set_format_shar_dump, METH_O, NULL}, + { "archive_write_set_format_ustar", _wrap_archive_write_set_format_ustar, METH_O, NULL}, + { "archive_write_set_format_xar", _wrap_archive_write_set_format_xar, METH_O, NULL}, + { "archive_write_set_format_zip", _wrap_archive_write_set_format_zip, METH_O, NULL}, + { "archive_entry_new", _wrap_archive_entry_new, METH_NOARGS, NULL}, + { "archive_entry_free", _wrap_archive_entry_free, METH_O, NULL}, + { "archive_entry_pathname", _wrap_archive_entry_pathname, METH_O, NULL}, + { "archive_entry_pathname_w", _wrap_archive_entry_pathname_w, METH_O, NULL}, + { "archive_entry_size", _wrap_archive_entry_size, METH_O, NULL}, + { "archive_entry_mtime", _wrap_archive_entry_mtime, METH_O, NULL}, + { "archive_entry_filetype", _wrap_archive_entry_filetype, METH_O, NULL}, + { "archive_entry_perm", _wrap_archive_entry_perm, METH_O, NULL}, + { "archive_entry_symlink", _wrap_archive_entry_symlink, METH_O, NULL}, + { "archive_entry_set_link", _wrap_archive_entry_set_link, METH_VARARGS, NULL}, + { "archive_entry_symlink_w", _wrap_archive_entry_symlink_w, METH_O, NULL}, + { "archive_read_disk_set_symlink_logical", _wrap_archive_read_disk_set_symlink_logical, METH_O, NULL}, + { "archive_read_disk_set_symlink_physical", _wrap_archive_read_disk_set_symlink_physical, METH_O, NULL}, + { "archive_read_disk_set_symlink_hybrid", _wrap_archive_read_disk_set_symlink_hybrid, METH_O, NULL}, + { "archive_entry_set_symlink", _wrap_archive_entry_set_symlink, METH_VARARGS, NULL}, + { "archive_entry_copy_symlink", _wrap_archive_entry_copy_symlink, METH_VARARGS, NULL}, + { "archive_entry_copy_symlink_w", _wrap_archive_entry_copy_symlink_w, METH_VARARGS, NULL}, + { "archive_entry_set_pathname", _wrap_archive_entry_set_pathname, METH_VARARGS, NULL}, + { "archive_entry_set_size", _wrap_archive_entry_set_size, METH_VARARGS, NULL}, + { "archive_entry_set_mtime", _wrap_archive_entry_set_mtime, METH_VARARGS, NULL}, + { "archive_entry_set_filetype", _wrap_archive_entry_set_filetype, METH_VARARGS, NULL}, + { "archive_entry_set_perm", _wrap_archive_entry_set_perm, METH_VARARGS, NULL}, + { "archive_errno", _wrap_archive_errno, METH_O, NULL}, + { "archive_error_string", _wrap_archive_error_string, METH_O, NULL}, + { "archive_read_data_into_str", _wrap_archive_read_data_into_str, METH_VARARGS, NULL}, + { "archive_write_data_from_str", _wrap_archive_write_data_from_str, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + +static PyMethodDef SwigMethods_proxydocs[] = { { NULL, NULL, 0, NULL } }; @@ -5694,18 +5823,18 @@ static swig_const_info swig_const_table[] = { #endif /* ----------------------------------------------------------------------------- * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * - * The generated swig_type_info structures are assigned staticly to an initial + * The generated swig_type_info structures are assigned statically to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the @@ -5715,17 +5844,17 @@ static swig_const_info swig_const_table[] = { * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it + * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * - * First off, we lookup the cast->type name to see if it is already loaded. + * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the + * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that @@ -5749,9 +5878,7 @@ SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; - int found, init; - - clientdata = clientdata; + int init; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { @@ -5770,27 +5897,23 @@ SWIG_InitializeModule(void *clientdata) { /* This is the first module loaded for this interpreter */ /* so set the swig module into the interpreter */ SWIG_SetModule(clientdata, &swig_module); - module_head = &swig_module; } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - found=0; iter=module_head; do { if (iter==&swig_module) { - found=1; - break; + /* Our module is already in the list, so there's nothing more to do. */ + return; } iter=iter->next; } while (iter!= module_head); - /* if the is found in the list, then all is done and we may leave */ - if (found) return; - /* otherwise we must add out module into the list */ + /* otherwise we must add our module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; } - /* When multiple interpeters are used, a module could have already been initialized in + /* When multiple interpreters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ @@ -5798,7 +5921,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -5806,7 +5929,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -5881,7 +6004,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; @@ -6003,17 +6126,6 @@ extern "C" { return str; } - SWIGINTERN int - swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { - char *tmp; - PyObject *str = swig_varlink_str(v); - fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(str); - return 0; - } - SWIGINTERN void swig_varlink_dealloc(swig_varlinkobject *v) { swig_globalvar *var = v->vars; @@ -6037,7 +6149,7 @@ extern "C" { var = var->next; } if (res == NULL && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } @@ -6054,7 +6166,7 @@ extern "C" { var = var->next; } if (res == 1 && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } @@ -6066,18 +6178,17 @@ extern "C" { static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { - /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"swigvarlink", /* tp_name */ + "swigvarlink", /* tp_name */ sizeof(swig_varlinkobject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) swig_varlink_dealloc, /* tp_dealloc */ - (printfunc) swig_varlink_print, /* tp_print */ + 0, /* tp_print */ (getattrfunc) swig_varlink_getattr, /* tp_getattr */ (setattrfunc) swig_varlink_setattr, /* tp_setattr */ 0, /* tp_compare */ @@ -6097,27 +6208,30 @@ extern "C" { 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ #endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ #endif }; varlink_type = tmp; type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - varlink_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&varlink_type) < 0) return NULL; -#endif } return &varlink_type; } @@ -6133,14 +6247,14 @@ extern "C" { } SWIGINTERN void - SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v = (swig_varlinkobject *) p; swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); if (gv) { size_t size = strlen(name)+1; gv->name = (char *)malloc(size); if (gv->name) { - strncpy(gv->name,name,size); + memcpy(gv->name, name, size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; @@ -6151,9 +6265,11 @@ extern "C" { SWIGINTERN PyObject * SWIG_globals(void) { - static PyObject *_SWIG_globals = 0; - if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); - return _SWIG_globals; + static PyObject *globals = 0; + if (!globals) { + globals = SWIG_newvarlink(); + } + return globals; } /* ----------------------------------------------------------------------------- @@ -6196,7 +6312,9 @@ extern "C" { size_t i; for (i = 0; methods[i].ml_name; ++i) { const char *c = methods[i].ml_doc; - if (c && (c = strstr(c, "swig_ptr: "))) { + if (!c) continue; + c = strstr(c, "swig_ptr: "); + if (c) { int j; swig_const_info *ci = 0; const char *name = c + 10; @@ -6217,9 +6335,9 @@ extern "C" { char *ndoc = (char*)malloc(ldoc + lptr + 10); if (ndoc) { char *buff = ndoc; - strncpy(buff, methods[i].ml_doc, ldoc); + memcpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; - strncpy(buff, "swig_ptr: ", 10); + memcpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; @@ -6230,6 +6348,64 @@ extern "C" { } } + /* ----------------------------------------------------------------------------- + * Method creation and docstring support functions + * ----------------------------------------------------------------------------- */ + + /* ----------------------------------------------------------------------------- + * Function to find the method definition with the correct docstring for the + * proxy module as opposed to the low-level API + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) { + /* Find the function in the modified method table */ + size_t offset = 0; + int found = 0; + while (SwigMethods_proxydocs[offset].ml_meth != NULL) { + if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) { + found = 1; + break; + } + offset++; + } + /* Use the copy with the modified docstring if available */ + return found ? &SwigMethods_proxydocs[offset] : NULL; + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } +#if PY_VERSION_HEX >= 0x03000000 + return PyInstanceMethod_New(func); +#else + return PyMethod_New(func, NULL, NULL); +#endif + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyStaticMethod_New() + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } + return PyStaticMethod_New(func); + } + #ifdef __cplusplus } #endif @@ -6249,20 +6425,12 @@ PyObject* void #endif SWIG_init(void) { - PyObject *m, *d, *md; + PyObject *m, *d, *md, *globals; + #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { -# if PY_VERSION_HEX >= 0x03020000 PyModuleDef_HEAD_INIT, -# else - { - PyObject_HEAD_INIT(NULL) - NULL, /* m_init */ - 0, /* m_index */ - NULL, /* m_copy */ - }, -# endif - (char *) SWIG_name, + SWIG_name, NULL, -1, SwigMethods, @@ -6281,23 +6449,24 @@ SWIG_init(void) { (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL }; static SwigPyGetSet thisown_getset_closure = { - (PyCFunction) SwigPyObject_own, - (PyCFunction) SwigPyObject_own + SwigPyObject_own, + SwigPyObject_own }; static PyGetSetDef thisown_getset_def = { (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure }; - PyObject *metatype_args; PyTypeObject *builtin_pytype; int builtin_base_count; swig_type_info *builtin_basetype; PyObject *tuple; PyGetSetDescrObject *static_getset; PyTypeObject *metatype; + PyTypeObject *swigpyobject; SwigPyClientData *cd; PyObject *public_interface, *public_symbol; PyObject *this_descr; PyObject *thisown_descr; + PyObject *self = 0; int i; (void)builtin_pytype; @@ -6305,15 +6474,21 @@ SWIG_init(void) { (void)builtin_basetype; (void)tuple; (void)static_getset; + (void)self; - /* metatype is used to implement static member variables. */ - metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); - assert(metatype_args); - metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL); + /* Metaclass is used to implement static member variables */ + metatype = SwigPyObjectType(); assert(metatype); - Py_DECREF(metatype_args); - metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro; - assert(PyType_Ready(metatype) >= 0); +#endif + + (void)globals; + + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ + SWIG_This(); + SWIG_Python_TypeCache(); + SwigPyPacked_type(); +#ifndef SWIGPYTHON_BUILTIN + SwigPyObject_type(); #endif /* Fix SwigMethods to carry the callback ptrs when needed */ @@ -6322,20 +6497,24 @@ SWIG_init(void) { #if PY_VERSION_HEX >= 0x03000000 m = PyModule_Create(&SWIG_module); #else - m = Py_InitModule((char *) SWIG_name, SwigMethods); + m = Py_InitModule(SWIG_name, SwigMethods); #endif + md = d = PyModule_GetDict(m); + (void)md; SWIG_InitializeModule(0); #ifdef SWIGPYTHON_BUILTIN + swigpyobject = SwigPyObject_TypeOnce(); + SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); assert(SwigPyObject_stype); cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; if (!cd) { SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; - SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce(); - } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) { + SwigPyObject_clientdata.pytype = swigpyobject; + } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); # if PY_VERSION_HEX >= 0x03000000 return NULL; From 08704fd4ebf44324836958225e515b5609396d89 Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 11:53:59 -0500 Subject: [PATCH 04/91] wip --- libarchive/__init__.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 985bac4..30b31cf 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -29,6 +29,8 @@ import sys import time import warnings +from ctypes import cdll, c_char_p + from libarchive import _libarchive from io import StringIO @@ -295,7 +297,7 @@ class EntryWriteStream(object): class Entry(object): '''An entry within an archive. Represents the header data and it's location within the archive.''' - def __init__(self, pathname=None, size=None, mtime=None, mode=None, hpos=None, encoding=ENCODING): + def __init__(self, pathname=None, size=None, mtime=None, mode=None, hpos=None, encoding=ENCODING, symlink=None): self.pathname = pathname self.size = size self.mtime = mtime @@ -303,6 +305,11 @@ class Entry(object): self.hpos = hpos self.encoding = encoding + if self.issym(): + self.symlink = symlink + else: + self.symlink = None + @property def header_position(self): return self.hpos @@ -328,6 +335,14 @@ class Entry(object): mode=mode, hpos=archive.header_position, ) + + symLinkPath = "" + + if entry.issym(): + libarchive.archive_entry_copy_symlink(e, symLinkPath) + + print(symLinkPath) + finally: _libarchive.archive_entry_free(e) return entry From 22d911afef4d68534c65875fad6bf4bf47e55446 Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 12:33:02 -0500 Subject: [PATCH 05/91] symlink api --- libarchive/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 30b31cf..8fbc000 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -339,7 +339,7 @@ class Entry(object): symLinkPath = "" if entry.issym(): - libarchive.archive_entry_copy_symlink(e, symLinkPath) + symLinkPath = _libarchive.archive_entry_symlink(e) print(symLinkPath) From e3ccbaaee243896dfb2bd4dd48cf1100a0b6d8c6 Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 13:20:40 -0500 Subject: [PATCH 06/91] update version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1dff175..972d50a 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ except ImportError: name = 'python-libarchive' -version = '4.0.1' +version = '4.2.0' release = '1' versrel = version + '-' + release readme = 'README.rst' From 4729258a402aabda6f1a7b43c674c0b016b9ecab Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 13:35:53 -0500 Subject: [PATCH 07/91] Change default python version to the version I'm using --- libarchive/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarchive/Makefile b/libarchive/Makefile index 7e9b6bb..5d7b8e6 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -2,7 +2,7 @@ CFLAGS = -g INCLUDE = -I/usr/include -I. LIBS = -larchive -PYVER ?= 2.7 +PYVER ?= 3.10 all: __libarchive.so From a5f43e4a5810eb9a940d5827b191c5e93ff5e47d Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 13:36:30 -0500 Subject: [PATCH 08/91] Attempt to fix API for 3.10 compatibility --- libarchive/_libarchive_wrap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index bd56746..4701b3e 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -760,7 +760,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #define PyString_Size(str) PyBytes_Size(str) #define PyString_InternFromString(key) PyUnicode_InternFromString(key) #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE -#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) +#define PyString_AS_STRING(x) PyUnicode_AsUTF8(x) #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) #endif @@ -3199,7 +3199,7 @@ PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } - if (len != archive_read_data(archive, PyString_AS_STRING(str), len)) { + if (len != archive_read_data(archive, (void*)PyString_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); return NULL; } @@ -3208,7 +3208,7 @@ PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *archive_write_data_from_str(struct archive *archive, PyObject *str) { int len = PyString_Size(str); - if (!archive_write_data(archive, PyString_AS_STRING(str), len)) { + if (!archive_write_data(archive, (const void *)PyString_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not write requested data."); return NULL; } From 08db5d3f6ebf1e9812e7f113cd45afba049526b6 Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 17:56:04 -0500 Subject: [PATCH 09/91] fixes --- libarchive/__init__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 8fbc000..91dd011 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -305,10 +305,10 @@ class Entry(object): self.hpos = hpos self.encoding = encoding - if self.issym(): + if self.issym() and symlink: self.symlink = symlink - else: - self.symlink = None + #else: + # self.symlink = None @property def header_position(self): @@ -340,8 +340,8 @@ class Entry(object): if entry.issym(): symLinkPath = _libarchive.archive_entry_symlink(e) - - print(symLinkPath) + entry.symlink = symLinkPath + print(symLinkPath) finally: _libarchive.archive_entry_free(e) @@ -385,6 +385,10 @@ class Entry(object): _libarchive.archive_entry_set_perm(e, stat.S_IMODE(self.mode)) _libarchive.archive_entry_set_size(e, self.size) _libarchive.archive_entry_set_mtime(e, self.mtime, 0) + + if e.issym(): + libarchive.archive_entry_set_symlink(e, self.symlink) + call_and_check(_libarchive.archive_write_header, archive._a, archive._a, e) #self.hpos = archive.header_position finally: From f35ce39dfef38d4a2cca5115ad7c3ead1f1d00de Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 18:01:28 -0500 Subject: [PATCH 10/91] stuff --- libarchive/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 91dd011..2f43a3e 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -336,9 +336,8 @@ class Entry(object): hpos=archive.header_position, ) - symLinkPath = "" - if entry.issym(): + print("issym") symLinkPath = _libarchive.archive_entry_symlink(e) entry.symlink = symLinkPath print(symLinkPath) From 8aded1ab98c437eeb9f8228e921cabe98e60f878 Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 18:30:31 -0500 Subject: [PATCH 11/91] work --- libarchive/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 2f43a3e..4be68a1 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -370,6 +370,10 @@ class Entry(object): entry.size = getattr(f, 'size', 0) entry.mtime = getattr(f, 'mtime', time.time()) entry.mode = stat.S_IFREG + + if stat.S_ISLNK(entry.mode): + print("yo") + return entry def to_archive(self, archive): @@ -385,8 +389,8 @@ class Entry(object): _libarchive.archive_entry_set_size(e, self.size) _libarchive.archive_entry_set_mtime(e, self.mtime, 0) - if e.issym(): - libarchive.archive_entry_set_symlink(e, self.symlink) + if stat.S_ISLNK(self.mode): + _libarchive.archive_entry_set_symlink(e, self.symlink) call_and_check(_libarchive.archive_write_header, archive._a, archive._a, e) #self.hpos = archive.header_position From f78b6717acaa7f8d898e1fd624a601a5306eb2d0 Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 18:49:07 -0500 Subject: [PATCH 12/91] stuff --- libarchive/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 4be68a1..a6053f5 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -297,7 +297,9 @@ class EntryWriteStream(object): class Entry(object): '''An entry within an archive. Represents the header data and it's location within the archive.''' - def __init__(self, pathname=None, size=None, mtime=None, mode=None, hpos=None, encoding=ENCODING, symlink=None): + def __init__(self, pathname=None, size=None, mtime=None, mode=None, hpos=None, encoding=ENCODING): + + #, symlink=None self.pathname = pathname self.size = size self.mtime = mtime @@ -305,8 +307,10 @@ class Entry(object): self.hpos = hpos self.encoding = encoding - if self.issym() and symlink: - self.symlink = symlink + self.symlink = "" + + #if self.issym() and symlink: + # self.symlink = symlink #else: # self.symlink = None @@ -393,6 +397,8 @@ class Entry(object): _libarchive.archive_entry_set_symlink(e, self.symlink) call_and_check(_libarchive.archive_write_header, archive._a, archive._a, e) + + #todo #self.hpos = archive.header_position finally: _libarchive.archive_entry_free(e) From 32a2fa4fb7c15cf5044481ba3e6cf52ed05aa16d Mon Sep 17 00:00:00 2001 From: Richard Young Date: Wed, 17 Nov 2021 10:15:53 -0500 Subject: [PATCH 13/91] switched to python 3.9 --- libarchive/Makefile | 7 ++++--- libarchive/__init__.py | 5 +++-- libarchive/_libarchive.i | 4 ++-- libarchive/_libarchive_wrap.c | 10 +++++----- tests.py | 3 ++- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libarchive/Makefile b/libarchive/Makefile index 5d7b8e6..ad967ee 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -1,13 +1,14 @@ -CFLAGS = -g +CFLAGS = -g INCLUDE = -I/usr/include -I. LIBS = -larchive -PYVER ?= 3.10 +PYVER ?= 3.9 all: __libarchive.so _libarchive_wrap.c: _libarchive.i - swig -python -shadow _libarchive.i + #swig -python -c++ -Wall -shadow _libarchive.i + swig -python -Wall -shadow _libarchive.i _libarchive_wrap.o: _libarchive_wrap.c ${CC} -c ${CFLAGS} -fPIC ${INCLUDE} $$(python${PYVER}-config --cflags) _libarchive_wrap.c diff --git a/libarchive/__init__.py b/libarchive/__init__.py index a6053f5..f387896 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -29,12 +29,13 @@ import sys import time import warnings -from ctypes import cdll, c_char_p +#from ctypes import cdll, c_char_p from libarchive import _libarchive from io import StringIO -PY3 = sys.version_info[0] == 3 +#PY3 = sys.version_info[0] == 3 +PY3 = True # Suggested block size for libarchive. Libarchive may adjust it. BLOCK_SIZE = 10240 diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index 5c2645c..ccf48f2 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -318,8 +318,8 @@ extern const char *archive_error_string(struct archive *); /* CONSTANTS */ -#define ARCHIVE_VERSION_NUMBER 3000001 -#define ARCHIVE_VERSION_STRING "libarchive 3.0.1b" +#define ARCHIVE_VERSION_NUMBER 3005003 +#define ARCHIVE_VERSION_STRING "libarchive 3.5.2" #define ARCHIVE_EOF 1 /* Found end of archive. */ #define ARCHIVE_OK 0 /* Operation was successful. */ #define ARCHIVE_RETRY (-10) /* Retry might succeed. */ diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index 4701b3e..def83ec 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -760,7 +760,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #define PyString_Size(str) PyBytes_Size(str) #define PyString_InternFromString(key) PyUnicode_InternFromString(key) #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE -#define PyString_AS_STRING(x) PyUnicode_AsUTF8(x) +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) #endif @@ -3199,7 +3199,7 @@ PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } - if (len != archive_read_data(archive, (void*)PyString_AS_STRING(str), len)) { + if (len != archive_read_data(archive, PyString_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); return NULL; } @@ -3208,7 +3208,7 @@ PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *archive_write_data_from_str(struct archive *archive, PyObject *str) { int len = PyString_Size(str); - if (!archive_write_data(archive, (const void *)PyString_AS_STRING(str), len)) { + if (!archive_write_data(archive, PyString_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not write requested data."); return NULL; } @@ -6545,8 +6545,8 @@ SWIG_init(void) { SWIG_InstallConstants(d,swig_const_table); - SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_NUMBER",SWIG_From_int((int)(3000001))); - SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_STRING",SWIG_FromCharPtr("libarchive 3.0.1b")); + SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_NUMBER",SWIG_From_int((int)(3005003))); + SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_STRING",SWIG_FromCharPtr("libarchive 3.5.2")); SWIG_Python_SetConstant(d, "ARCHIVE_EOF",SWIG_From_int((int)(1))); SWIG_Python_SetConstant(d, "ARCHIVE_OK",SWIG_From_int((int)(0))); SWIG_Python_SetConstant(d, "ARCHIVE_RETRY",SWIG_From_int((int)((-10)))); diff --git a/tests.py b/tests.py index fcba1d7..baec6dc 100644 --- a/tests.py +++ b/tests.py @@ -33,7 +33,8 @@ import io from libarchive import Archive, is_archive_name, is_archive from libarchive.zip import is_zipfile, ZipFile, ZipEntry -PY3 = sys.version_info[0] == 3 +#PY3 = sys.version_info[0] == 3 +PY3 = True TMPDIR = tempfile.mkdtemp(suffix='.python-libarchive') ZIPFILE = 'test.zip' From 9bb3133f6e0e10a6b66adb6cc3e93e937e162ff6 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 18 Jul 2022 11:42:01 +0200 Subject: [PATCH 14/91] Add password support for read access --- libarchive/Makefile | 11 +- libarchive/__init__.py | 4 + libarchive/_libarchive.i | 122 +++- libarchive/_libarchive.py | 99 ++- libarchive/_libarchive_wrap.c | 1195 ++++++++++++++++++++++++++++++--- 5 files changed, 1307 insertions(+), 124 deletions(-) diff --git a/libarchive/Makefile b/libarchive/Makefile index ad967ee..1ee2982 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -2,19 +2,22 @@ CFLAGS = -g INCLUDE = -I/usr/include -I. LIBS = -larchive +DEFINES = -DPyUnicode_AS_STRING=PyUnicode_AS_DATA PYVER ?= 3.9 all: __libarchive.so -_libarchive_wrap.c: _libarchive.i +_libarchive_wrap.cxx: _libarchive.i #swig -python -c++ -Wall -shadow _libarchive.i - swig -python -Wall -shadow _libarchive.i + swig -python -Wall -shadow _libarchive.i _libarchive_wrap.o: _libarchive_wrap.c - ${CC} -c ${CFLAGS} -fPIC ${INCLUDE} $$(python${PYVER}-config --cflags) _libarchive_wrap.c + echo ${CC} -c ${CFLAGS} -fPIC $$(python${PYVER}-config --cflags) _libarchive_wrap.c + ${CC} -c ${CFLAGS} -fPIC $$(python${PYVER}-config --cflags) ${DEFINES} _libarchive_wrap.c +# ${CXX} -c ${CFLAGS} -fPIC $$(python${PYVER}-config --cflags) -DPyUnicode_AS_STRING=PyUnicode_AS_DATA _libarchive_wrap.cxx __libarchive.so: _libarchive_wrap.o ${CC} _libarchive_wrap.o -shared $$(python${PYVER}-config --ldflags) -o __libarchive.so ${LIBS} clean: - rm -f *.o *.so *.pyc + rm -f *.o *.so *.pyc \ No newline at end of file diff --git a/libarchive/__init__.py b/libarchive/__init__.py index f387896..c4861f1 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -623,6 +623,10 @@ class Archive(object): s.write(entry.pathname) s.flush() + def add_passphrase(self, password): + '''Adds a password to the archive.''' + _libarchive.archive_read_add_passphrase(self._a, password) + class SeekableArchive(Archive): '''A class that provides random-access to archive entries. It does this by using one diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index ccf48f2..6b0bc27 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -153,8 +153,8 @@ extern int archive_read_free(struct archive *); extern int archive_read_open_filename(struct archive *, const char *_filename, size_t _block_size); extern int archive_read_open_memory(struct archive *, - void * buff, size_t size); -extern int archive_read_open_memory2(struct archive *a, void *buff, + const void * buff, size_t size); +extern int archive_read_open_memory2(struct archive *a, void const *buff, size_t size, size_t read_size); extern int archive_read_open_fd(struct archive *, int _fd, size_t _block_size); @@ -169,39 +169,107 @@ extern int archive_read_next_header2(struct archive *, extern const struct stat *archive_entry_stat(struct archive_entry *); extern __LA_INT64_T archive_read_header_position(struct archive *); +/* + * Set read options. + */ +/* Apply option to the format only. */ +extern int archive_read_set_format_option(struct archive *_a, + const char *m, const char *o, + const char *v); +/* Apply option to the filter only. */ +extern int archive_read_set_filter_option(struct archive *_a, + const char *m, const char *o, + const char *v); +/* Apply option to both the format and the filter. */ +extern int archive_read_set_option(struct archive *_a, + const char *m, const char *o, + const char *v); +/* Apply option string to both the format and the filter. */ +extern int archive_read_set_options(struct archive *_a, + const char *opts); + +/* + * Add a decryption passphrase. + */ +extern int archive_read_add_passphrase(struct archive *, const char *); /* data */ extern int archive_read_data_skip(struct archive *); extern int archive_read_data_into_fd(struct archive *, int fd); -/* FILTERS */ +#if ARCHIVE_VERSION_NUMBER < 4000000 +extern int archive_read_support_compression_all(struct archive *); +extern int archive_read_support_compression_bzip2(struct archive *); +extern int archive_read_support_compression_compress(struct archive *); +extern int archive_read_support_compression_gzip(struct archive *); +extern int archive_read_support_compression_lzip(struct archive *); +extern int archive_read_support_compression_lzma(struct archive *); +extern int archive_read_support_compression_none(struct archive *); +extern int archive_read_support_compression_program(struct archive *, const char *command); +extern int archive_read_support_compression_program_signature + (struct archive *, const char *, + const void * /* match */, size_t); + +extern int archive_read_support_compression_rpm(struct archive *); +extern int archive_read_support_compression_uu(struct archive *); +extern int archive_read_support_compression_xz(struct archive *); +#endif + extern int archive_read_support_filter_all(struct archive *); extern int archive_read_support_filter_bzip2(struct archive *); extern int archive_read_support_filter_compress(struct archive *); extern int archive_read_support_filter_gzip(struct archive *); +extern int archive_read_support_filter_grzip(struct archive *); +extern int archive_read_support_filter_lrzip(struct archive *); +extern int archive_read_support_filter_lz4(struct archive *); extern int archive_read_support_filter_lzip(struct archive *); extern int archive_read_support_filter_lzma(struct archive *); +extern int archive_read_support_filter_lzop(struct archive *); extern int archive_read_support_filter_none(struct archive *); +extern int archive_read_support_filter_program(struct archive *, + const char *command); +extern int archive_read_support_filter_program_signature + (struct archive *, const char * /* cmd */, + const void * /* match */, size_t); extern int archive_read_support_filter_rpm(struct archive *); extern int archive_read_support_filter_uu(struct archive *); extern int archive_read_support_filter_xz(struct archive *); -/* FORMATS */ -extern int archive_read_support_format_all(struct archive *); extern int archive_read_support_format_7zip(struct archive *); +extern int archive_read_support_format_all(struct archive *); extern int archive_read_support_format_ar(struct archive *); +extern int archive_read_support_format_by_code(struct archive *, int); extern int archive_read_support_format_cab(struct archive *); extern int archive_read_support_format_cpio(struct archive *); extern int archive_read_support_format_empty(struct archive *); extern int archive_read_support_format_gnutar(struct archive *); extern int archive_read_support_format_iso9660(struct archive *); extern int archive_read_support_format_lha(struct archive *); -/*extern int archive_read_support_format_mtree(struct archive *);*/ +/* extern int archive_read_support_format_mtree(struct archive *); */ extern int archive_read_support_format_rar(struct archive *); extern int archive_read_support_format_raw(struct archive *); extern int archive_read_support_format_tar(struct archive *); +extern int archive_read_support_format_warc(struct archive *); extern int archive_read_support_format_xar(struct archive *); +/* archive_read_support_format_zip() enables both streamable and seekable + * zip readers. */ extern int archive_read_support_format_zip(struct archive *); -/*extern int archive_read_support_format_by_code(struct archive *, int);*/ +/* Reads Zip archives as stream from beginning to end. Doesn't + * correctly handle SFX ZIP files or ZIP archives that have been modified + * in-place. */ +extern int archive_read_support_format_zip_streamable(struct archive *); +/* Reads starting from central directory; requires seekable input. */ +extern int archive_read_support_format_zip_seekable(struct archive *); + +/* Functions to manually set the format and filters to be used. This is + * useful to bypass the bidding process when the format and filters to use + * is known in advance. + */ +extern int archive_read_set_format(struct archive *, int); +extern int archive_read_append_filter(struct archive *, int); +extern int archive_read_append_filter_program(struct archive *, + const char *); +extern int archive_read_append_filter_program_signature + (struct archive *, const char *, const void * /* match */, size_t); /* ARCHIVE WRITING */ extern struct archive *archive_write_new(void); @@ -282,8 +350,8 @@ extern void archive_entry_set_link(struct archive_entry *, const char *); //extern int archive_entry_symlink_type(struct archive_entry *); extern const wchar_t *archive_entry_symlink_w(struct archive_entry *); -//__LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *); -//__LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *); +//extern void archive_entry_copy_link(struct archive_entry *, const char *); +//extern void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *); /* The names for symlink modes here correspond to an old BSD * command-line argument convention: -L, -P, -H */ @@ -318,8 +386,8 @@ extern const char *archive_error_string(struct archive *); /* CONSTANTS */ -#define ARCHIVE_VERSION_NUMBER 3005003 -#define ARCHIVE_VERSION_STRING "libarchive 3.5.2" +#define ARCHIVE_VERSION_NUMBER 3002002 +#define ARCHIVE_VERSION_STRING "libarchive 3.2.2" #define ARCHIVE_EOF 1 /* Found end of archive. */ #define ARCHIVE_OK 0 /* Operation was successful. */ #define ARCHIVE_RETRY (-10) /* Retry might succeed. */ @@ -337,6 +405,10 @@ extern const char *archive_error_string(struct archive *); #define ARCHIVE_FILTER_UU 7 #define ARCHIVE_FILTER_RPM 8 #define ARCHIVE_FILTER_LZIP 9 +#define ARCHIVE_FILTER_LRZIP 10 +#define ARCHIVE_FILTER_LZOP 11 +#define ARCHIVE_FILTER_GRZIP 12 +#define ARCHIVE_FILTER_LZ4 13 #define ARCHIVE_FORMAT_BASE_MASK 0xff0000 #define ARCHIVE_FORMAT_CPIO 0x10000 @@ -368,21 +440,49 @@ extern const char *archive_error_string(struct archive *); #define ARCHIVE_FORMAT_CAB 0xC0000 #define ARCHIVE_FORMAT_RAR 0xD0000 #define ARCHIVE_FORMAT_7ZIP 0xE0000 +#define ARCHIVE_FORMAT_WARC 0xF0000 +/* Default: Do not try to set owner/group. */ #define ARCHIVE_EXTRACT_OWNER (0x0001) +/* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */ #define ARCHIVE_EXTRACT_PERM (0x0002) +/* Default: Do not restore mtime/atime. */ #define ARCHIVE_EXTRACT_TIME (0x0004) +/* Default: Replace existing files. */ #define ARCHIVE_EXTRACT_NO_OVERWRITE (0x0008) +/* Default: Try create first, unlink only if create fails with EEXIST. */ #define ARCHIVE_EXTRACT_UNLINK (0x0010) +/* Default: Do not restore ACLs. */ #define ARCHIVE_EXTRACT_ACL (0x0020) +/* Default: Do not restore fflags. */ #define ARCHIVE_EXTRACT_FFLAGS (0x0040) +/* Default: Do not restore xattrs. */ #define ARCHIVE_EXTRACT_XATTR (0x0080) +/* Default: Do not try to guard against extracts redirected by symlinks. */ +/* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */ #define ARCHIVE_EXTRACT_SECURE_SYMLINKS (0x0100) +/* Default: Do not reject entries with '..' as path elements. */ #define ARCHIVE_EXTRACT_SECURE_NODOTDOT (0x0200) +/* Default: Create parent directories as needed. */ #define ARCHIVE_EXTRACT_NO_AUTODIR (0x0400) +/* Default: Overwrite files, even if one on disk is newer. */ #define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (0x0800) +/* Detect blocks of 0 and write holes instead. */ #define ARCHIVE_EXTRACT_SPARSE (0x1000) +/* Default: Do not restore Mac extended metadata. */ +/* This has no effect except on Mac OS. */ #define ARCHIVE_EXTRACT_MAC_METADATA (0x2000) +/* Default: Use HFS+ compression if it was compressed. */ +/* This has no effect except on Mac OS v10.6 or later. */ +#define ARCHIVE_EXTRACT_NO_HFS_COMPRESSION (0x4000) +/* Default: Do not use HFS+ compression if it was not compressed. */ +/* This has no effect except on Mac OS v10.6 or later. */ +#define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000) +/* Default: Do not reject entries with absolute paths */ +#define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000) +/* Default: Do not clear no-change flags when unlinking object */ +#define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS (0x20000) + %inline %{ PyObject *archive_read_data_into_str(struct archive *archive, int len) { diff --git a/libarchive/_libarchive.py b/libarchive/_libarchive.py index bff869a..36aadd7 100644 --- a/libarchive/_libarchive.py +++ b/libarchive/_libarchive.py @@ -95,12 +95,63 @@ def archive_entry_stat(arg1): def archive_read_header_position(arg1): return __libarchive.archive_read_header_position(arg1) +def archive_read_set_format_option(_a, m, o, v): + return __libarchive.archive_read_set_format_option(_a, m, o, v) + +def archive_read_set_filter_option(_a, m, o, v): + return __libarchive.archive_read_set_filter_option(_a, m, o, v) + +def archive_read_set_option(_a, m, o, v): + return __libarchive.archive_read_set_option(_a, m, o, v) + +def archive_read_set_options(_a, opts): + return __libarchive.archive_read_set_options(_a, opts) + +def archive_read_add_passphrase(arg1, arg2): + return __libarchive.archive_read_add_passphrase(arg1, arg2) + def archive_read_data_skip(arg1): return __libarchive.archive_read_data_skip(arg1) def archive_read_data_into_fd(arg1, fd): return __libarchive.archive_read_data_into_fd(arg1, fd) +def archive_read_support_compression_all(arg1): + return __libarchive.archive_read_support_compression_all(arg1) + +def archive_read_support_compression_bzip2(arg1): + return __libarchive.archive_read_support_compression_bzip2(arg1) + +def archive_read_support_compression_compress(arg1): + return __libarchive.archive_read_support_compression_compress(arg1) + +def archive_read_support_compression_gzip(arg1): + return __libarchive.archive_read_support_compression_gzip(arg1) + +def archive_read_support_compression_lzip(arg1): + return __libarchive.archive_read_support_compression_lzip(arg1) + +def archive_read_support_compression_lzma(arg1): + return __libarchive.archive_read_support_compression_lzma(arg1) + +def archive_read_support_compression_none(arg1): + return __libarchive.archive_read_support_compression_none(arg1) + +def archive_read_support_compression_program(arg1, command): + return __libarchive.archive_read_support_compression_program(arg1, command) + +def archive_read_support_compression_program_signature(arg1, arg2, arg3, arg4): + return __libarchive.archive_read_support_compression_program_signature(arg1, arg2, arg3, arg4) + +def archive_read_support_compression_rpm(arg1): + return __libarchive.archive_read_support_compression_rpm(arg1) + +def archive_read_support_compression_uu(arg1): + return __libarchive.archive_read_support_compression_uu(arg1) + +def archive_read_support_compression_xz(arg1): + return __libarchive.archive_read_support_compression_xz(arg1) + def archive_read_support_filter_all(arg1): return __libarchive.archive_read_support_filter_all(arg1) @@ -113,15 +164,33 @@ def archive_read_support_filter_compress(arg1): def archive_read_support_filter_gzip(arg1): return __libarchive.archive_read_support_filter_gzip(arg1) +def archive_read_support_filter_grzip(arg1): + return __libarchive.archive_read_support_filter_grzip(arg1) + +def archive_read_support_filter_lrzip(arg1): + return __libarchive.archive_read_support_filter_lrzip(arg1) + +def archive_read_support_filter_lz4(arg1): + return __libarchive.archive_read_support_filter_lz4(arg1) + def archive_read_support_filter_lzip(arg1): return __libarchive.archive_read_support_filter_lzip(arg1) def archive_read_support_filter_lzma(arg1): return __libarchive.archive_read_support_filter_lzma(arg1) +def archive_read_support_filter_lzop(arg1): + return __libarchive.archive_read_support_filter_lzop(arg1) + def archive_read_support_filter_none(arg1): return __libarchive.archive_read_support_filter_none(arg1) +def archive_read_support_filter_program(arg1, command): + return __libarchive.archive_read_support_filter_program(arg1, command) + +def archive_read_support_filter_program_signature(arg1, arg2, arg3, arg4): + return __libarchive.archive_read_support_filter_program_signature(arg1, arg2, arg3, arg4) + def archive_read_support_filter_rpm(arg1): return __libarchive.archive_read_support_filter_rpm(arg1) @@ -131,15 +200,18 @@ def archive_read_support_filter_uu(arg1): def archive_read_support_filter_xz(arg1): return __libarchive.archive_read_support_filter_xz(arg1) -def archive_read_support_format_all(arg1): - return __libarchive.archive_read_support_format_all(arg1) - def archive_read_support_format_7zip(arg1): return __libarchive.archive_read_support_format_7zip(arg1) +def archive_read_support_format_all(arg1): + return __libarchive.archive_read_support_format_all(arg1) + def archive_read_support_format_ar(arg1): return __libarchive.archive_read_support_format_ar(arg1) +def archive_read_support_format_by_code(arg1, arg2): + return __libarchive.archive_read_support_format_by_code(arg1, arg2) + def archive_read_support_format_cab(arg1): return __libarchive.archive_read_support_format_cab(arg1) @@ -167,12 +239,33 @@ def archive_read_support_format_raw(arg1): def archive_read_support_format_tar(arg1): return __libarchive.archive_read_support_format_tar(arg1) +def archive_read_support_format_warc(arg1): + return __libarchive.archive_read_support_format_warc(arg1) + def archive_read_support_format_xar(arg1): return __libarchive.archive_read_support_format_xar(arg1) def archive_read_support_format_zip(arg1): return __libarchive.archive_read_support_format_zip(arg1) +def archive_read_support_format_zip_streamable(arg1): + return __libarchive.archive_read_support_format_zip_streamable(arg1) + +def archive_read_support_format_zip_seekable(arg1): + return __libarchive.archive_read_support_format_zip_seekable(arg1) + +def archive_read_set_format(arg1, arg2): + return __libarchive.archive_read_set_format(arg1, arg2) + +def archive_read_append_filter(arg1, arg2): + return __libarchive.archive_read_append_filter(arg1, arg2) + +def archive_read_append_filter_program(arg1, arg2): + return __libarchive.archive_read_append_filter_program(arg1, arg2) + +def archive_read_append_filter_program_signature(arg1, arg2, arg3, arg4): + return __libarchive.archive_read_append_filter_program_signature(arg1, arg2, arg3, arg4) + def archive_write_new(): return __libarchive.archive_write_new() diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index def83ec..aa9555a 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -3316,14 +3316,14 @@ SWIGINTERN PyObject *_wrap_archive_read_open_memory(PyObject *SWIGUNUSEDPARM(sel arg1 = (struct archive *)(argp1); res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_open_memory" "', argument " "2"" of type '" "void *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_open_memory" "', argument " "2"" of type '" "void const *""'"); } ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "archive_read_open_memory" "', argument " "3"" of type '" "size_t""'"); } arg3 = (size_t)(val3); - result = (int)archive_read_open_memory(arg1,arg2,arg3); + result = (int)archive_read_open_memory(arg1,(void const *)arg2,arg3); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3355,7 +3355,7 @@ SWIGINTERN PyObject *_wrap_archive_read_open_memory2(PyObject *SWIGUNUSEDPARM(se arg1 = (struct archive *)(argp1); res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_open_memory2" "', argument " "2"" of type '" "void *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_open_memory2" "', argument " "2"" of type '" "void const *""'"); } ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { @@ -3367,7 +3367,7 @@ SWIGINTERN PyObject *_wrap_archive_read_open_memory2(PyObject *SWIGUNUSEDPARM(se SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "archive_read_open_memory2" "', argument " "4"" of type '" "size_t""'"); } arg4 = (size_t)(val4); - result = (int)archive_read_open_memory2(arg1,arg2,arg3,arg4); + result = (int)archive_read_open_memory2(arg1,(void const *)arg2,arg3,arg4); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3537,60 +3537,934 @@ fail: } +SWIGINTERN PyObject *_wrap_archive_read_set_format_option(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_read_set_format_option", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_set_format_option" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_set_format_option" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_read_set_format_option" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "archive_read_set_format_option" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = (char *)(buf4); + result = (int)archive_read_set_format_option(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_set_filter_option(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_read_set_filter_option", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_set_filter_option" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_set_filter_option" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_read_set_filter_option" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "archive_read_set_filter_option" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = (char *)(buf4); + result = (int)archive_read_set_filter_option(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_set_option(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_read_set_option", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_set_option" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_set_option" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_read_set_option" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "archive_read_set_option" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = (char *)(buf4); + result = (int)archive_read_set_option(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_set_options(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_read_set_options", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_set_options" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_set_options" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)archive_read_set_options(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_add_passphrase(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_read_add_passphrase", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_add_passphrase" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_add_passphrase" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)archive_read_add_passphrase(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + SWIGINTERN PyObject *_wrap_archive_read_data_skip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_data_skip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_data_skip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_data_into_fd(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_read_data_into_fd", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_data_into_fd" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_read_data_into_fd" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)archive_read_data_into_fd(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_all" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_compression_all(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_bzip2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_bzip2" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_compression_bzip2(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_compress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_compress" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_compression_compress(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_gzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_gzip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_compression_gzip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_lzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_lzip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_compression_lzip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_lzma(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_lzma" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_compression_lzma(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_none(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_none" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_compression_none(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_program(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_read_support_compression_program", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_program" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_support_compression_program" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)archive_read_support_compression_program(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_program_signature(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + void *arg3 = (void *) 0 ; + size_t arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + size_t val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_read_support_compression_program_signature", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_program_signature" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_support_compression_program_signature" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_read_support_compression_program_signature" "', argument " "3"" of type '" "void const *""'"); + } + ecode4 = SWIG_AsVal_size_t(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "archive_read_support_compression_program_signature" "', argument " "4"" of type '" "size_t""'"); + } + arg4 = (size_t)(val4); + result = (int)archive_read_support_compression_program_signature(arg1,(char const *)arg2,(void const *)arg3,arg4); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_rpm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_rpm" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_compression_rpm(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_uu(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_uu" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_compression_uu(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_compression_xz(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_compression_xz" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_compression_xz(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_all" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_all(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_bzip2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_bzip2" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_bzip2(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_compress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_compress" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_compress(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_gzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_gzip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_gzip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_grzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_grzip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_grzip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_lrzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_lrzip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_lrzip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_lz4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_lz4" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_lz4(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_lzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_lzip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_lzip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_lzma(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_lzma" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_lzma(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_lzop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_lzop" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_lzop(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_none(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_none" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_read_support_filter_none(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_support_filter_program(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!args) SWIG_fail; - swig_obj[0] = args; + if (!SWIG_Python_UnpackTuple(args, "archive_read_support_filter_program", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_data_skip" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_program" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_data_skip(arg1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_support_filter_program" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)archive_read_support_filter_program(arg1,(char const *)arg2); resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return NULL; } -SWIGINTERN PyObject *_wrap_archive_read_data_into_fd(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_filter_program_signature(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; - int arg2 ; + char *arg2 = (char *) 0 ; + void *arg3 = (void *) 0 ; + size_t arg4 ; void *argp1 = 0 ; int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + size_t val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; int result; - if (!SWIG_Python_UnpackTuple(args, "archive_read_data_into_fd", 2, 2, swig_obj)) SWIG_fail; + if (!SWIG_Python_UnpackTuple(args, "archive_read_support_filter_program_signature", 4, 4, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_data_into_fd" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_program_signature" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_read_data_into_fd" "', argument " "2"" of type '" "int""'"); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_support_filter_program_signature" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_read_support_filter_program_signature" "', argument " "3"" of type '" "void const *""'"); + } + ecode4 = SWIG_AsVal_size_t(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "archive_read_support_filter_program_signature" "', argument " "4"" of type '" "size_t""'"); } - arg2 = (int)(val2); - result = (int)archive_read_data_into_fd(arg1,arg2); + arg4 = (size_t)(val4); + result = (int)archive_read_support_filter_program_signature(arg1,(char const *)arg2,(void const *)arg3,arg4); resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return NULL; } -SWIGINTERN PyObject *_wrap_archive_read_support_filter_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_filter_rpm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3602,10 +4476,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_all(PyObject *SWIGUNUSEDP swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_all" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_rpm" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_filter_all(arg1); + result = (int)archive_read_support_filter_rpm(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3613,7 +4487,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_filter_bzip2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_filter_uu(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3625,10 +4499,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_bzip2(PyObject *SWIGUNUSE swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_bzip2" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_uu" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_filter_bzip2(arg1); + result = (int)archive_read_support_filter_uu(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3636,7 +4510,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_filter_compress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_filter_xz(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3648,10 +4522,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_compress(PyObject *SWIGUN swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_compress" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_xz" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_filter_compress(arg1); + result = (int)archive_read_support_filter_xz(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3659,7 +4533,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_filter_gzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_7zip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3671,10 +4545,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_gzip(PyObject *SWIGUNUSED swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_gzip" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_7zip" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_filter_gzip(arg1); + result = (int)archive_read_support_format_7zip(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3682,7 +4556,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_filter_lzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3694,10 +4568,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_lzip(PyObject *SWIGUNUSED swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_lzip" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_all" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_filter_lzip(arg1); + result = (int)archive_read_support_format_all(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3705,7 +4579,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_filter_lzma(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_ar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3717,10 +4591,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_lzma(PyObject *SWIGUNUSED swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_lzma" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_ar" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_filter_lzma(arg1); + result = (int)archive_read_support_format_ar(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3728,22 +4602,29 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_filter_none(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_by_code(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; + int arg2 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!args) SWIG_fail; - swig_obj[0] = args; + if (!SWIG_Python_UnpackTuple(args, "archive_read_support_format_by_code", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_none" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_by_code" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_filter_none(arg1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_read_support_format_by_code" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)archive_read_support_format_by_code(arg1,arg2); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3751,7 +4632,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_filter_rpm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_cab(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3763,10 +4644,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_rpm(PyObject *SWIGUNUSEDP swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_rpm" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_cab" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_filter_rpm(arg1); + result = (int)archive_read_support_format_cab(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3774,7 +4655,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_filter_uu(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_cpio(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3786,10 +4667,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_uu(PyObject *SWIGUNUSEDPA swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_uu" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_cpio" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_filter_uu(arg1); + result = (int)archive_read_support_format_cpio(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3797,7 +4678,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_filter_xz(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3809,10 +4690,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_filter_xz(PyObject *SWIGUNUSEDPA swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_filter_xz" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_empty" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_filter_xz(arg1); + result = (int)archive_read_support_format_empty(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3820,7 +4701,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_gnutar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3832,10 +4713,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_all(PyObject *SWIGUNUSEDP swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_all" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_gnutar" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_all(arg1); + result = (int)archive_read_support_format_gnutar(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3843,7 +4724,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_7zip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_iso9660(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3855,10 +4736,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_7zip(PyObject *SWIGUNUSED swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_7zip" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_iso9660" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_7zip(arg1); + result = (int)archive_read_support_format_iso9660(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3866,7 +4747,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_ar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_lha(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3878,10 +4759,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_ar(PyObject *SWIGUNUSEDPA swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_ar" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_lha" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_ar(arg1); + result = (int)archive_read_support_format_lha(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3889,7 +4770,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_cab(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_rar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3901,10 +4782,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_cab(PyObject *SWIGUNUSEDP swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_cab" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_rar" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_cab(arg1); + result = (int)archive_read_support_format_rar(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3912,7 +4793,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_cpio(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3924,10 +4805,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_cpio(PyObject *SWIGUNUSED swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_cpio" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_raw" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_cpio(arg1); + result = (int)archive_read_support_format_raw(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3935,7 +4816,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_tar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3947,10 +4828,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_empty(PyObject *SWIGUNUSE swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_empty" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_tar" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_empty(arg1); + result = (int)archive_read_support_format_tar(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3958,7 +4839,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_gnutar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_warc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3970,10 +4851,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_gnutar(PyObject *SWIGUNUS swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_gnutar" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_warc" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_gnutar(arg1); + result = (int)archive_read_support_format_warc(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3981,7 +4862,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_iso9660(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_xar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -3993,10 +4874,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_iso9660(PyObject *SWIGUNU swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_iso9660" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_xar" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_iso9660(arg1); + result = (int)archive_read_support_format_xar(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -4004,7 +4885,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_lha(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_zip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -4016,10 +4897,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_lha(PyObject *SWIGUNUSEDP swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_lha" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_zip" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_lha(arg1); + result = (int)archive_read_support_format_zip(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -4027,7 +4908,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_rar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_zip_streamable(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -4039,10 +4920,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_rar(PyObject *SWIGUNUSEDP swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_rar" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_zip_streamable" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_rar(arg1); + result = (int)archive_read_support_format_zip_streamable(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -4050,7 +4931,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_support_format_zip_seekable(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -4062,10 +4943,10 @@ SWIGINTERN PyObject *_wrap_archive_read_support_format_raw(PyObject *SWIGUNUSEDP swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_raw" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_zip_seekable" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_raw(arg1); + result = (int)archive_read_support_format_zip_seekable(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -4073,22 +4954,29 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_tar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_set_format(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; + int arg2 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!args) SWIG_fail; - swig_obj[0] = args; + if (!SWIG_Python_UnpackTuple(args, "archive_read_set_format", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_tar" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_set_format" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_tar(arg1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_read_set_format" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)archive_read_set_format(arg1,arg2); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -4096,22 +4984,29 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_xar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_append_filter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; + int arg2 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!args) SWIG_fail; - swig_obj[0] = args; + if (!SWIG_Python_UnpackTuple(args, "archive_read_append_filter", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_xar" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_append_filter" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_xar(arg1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_read_append_filter" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)archive_read_append_filter(arg1,arg2); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -4119,25 +5014,82 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_read_support_format_zip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_read_append_filter_program(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!args) SWIG_fail; - swig_obj[0] = args; + if (!SWIG_Python_UnpackTuple(args, "archive_read_append_filter_program", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_support_format_zip" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_append_filter_program" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_read_support_format_zip(arg1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_append_filter_program" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)archive_read_append_filter_program(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_read_append_filter_program_signature(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + void *arg3 = (void *) 0 ; + size_t arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + size_t val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_read_append_filter_program_signature", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_read_append_filter_program_signature" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_read_append_filter_program_signature" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_read_append_filter_program_signature" "', argument " "3"" of type '" "void const *""'"); + } + ecode4 = SWIG_AsVal_size_t(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "archive_read_append_filter_program_signature" "', argument " "4"" of type '" "size_t""'"); + } + arg4 = (size_t)(val4); + result = (int)archive_read_append_filter_program_signature(arg1,(char const *)arg2,(void const *)arg3,arg4); resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return NULL; } @@ -5662,21 +6614,45 @@ static PyMethodDef SwigMethods[] = { { "archive_read_next_header2", _wrap_archive_read_next_header2, METH_VARARGS, NULL}, { "archive_entry_stat", _wrap_archive_entry_stat, METH_O, NULL}, { "archive_read_header_position", _wrap_archive_read_header_position, METH_O, NULL}, + { "archive_read_set_format_option", _wrap_archive_read_set_format_option, METH_VARARGS, NULL}, + { "archive_read_set_filter_option", _wrap_archive_read_set_filter_option, METH_VARARGS, NULL}, + { "archive_read_set_option", _wrap_archive_read_set_option, METH_VARARGS, NULL}, + { "archive_read_set_options", _wrap_archive_read_set_options, METH_VARARGS, NULL}, + { "archive_read_add_passphrase", _wrap_archive_read_add_passphrase, METH_VARARGS, NULL}, { "archive_read_data_skip", _wrap_archive_read_data_skip, METH_O, NULL}, { "archive_read_data_into_fd", _wrap_archive_read_data_into_fd, METH_VARARGS, NULL}, + { "archive_read_support_compression_all", _wrap_archive_read_support_compression_all, METH_O, NULL}, + { "archive_read_support_compression_bzip2", _wrap_archive_read_support_compression_bzip2, METH_O, NULL}, + { "archive_read_support_compression_compress", _wrap_archive_read_support_compression_compress, METH_O, NULL}, + { "archive_read_support_compression_gzip", _wrap_archive_read_support_compression_gzip, METH_O, NULL}, + { "archive_read_support_compression_lzip", _wrap_archive_read_support_compression_lzip, METH_O, NULL}, + { "archive_read_support_compression_lzma", _wrap_archive_read_support_compression_lzma, METH_O, NULL}, + { "archive_read_support_compression_none", _wrap_archive_read_support_compression_none, METH_O, NULL}, + { "archive_read_support_compression_program", _wrap_archive_read_support_compression_program, METH_VARARGS, NULL}, + { "archive_read_support_compression_program_signature", _wrap_archive_read_support_compression_program_signature, METH_VARARGS, NULL}, + { "archive_read_support_compression_rpm", _wrap_archive_read_support_compression_rpm, METH_O, NULL}, + { "archive_read_support_compression_uu", _wrap_archive_read_support_compression_uu, METH_O, NULL}, + { "archive_read_support_compression_xz", _wrap_archive_read_support_compression_xz, METH_O, NULL}, { "archive_read_support_filter_all", _wrap_archive_read_support_filter_all, METH_O, NULL}, { "archive_read_support_filter_bzip2", _wrap_archive_read_support_filter_bzip2, METH_O, NULL}, { "archive_read_support_filter_compress", _wrap_archive_read_support_filter_compress, METH_O, NULL}, { "archive_read_support_filter_gzip", _wrap_archive_read_support_filter_gzip, METH_O, NULL}, + { "archive_read_support_filter_grzip", _wrap_archive_read_support_filter_grzip, METH_O, NULL}, + { "archive_read_support_filter_lrzip", _wrap_archive_read_support_filter_lrzip, METH_O, NULL}, + { "archive_read_support_filter_lz4", _wrap_archive_read_support_filter_lz4, METH_O, NULL}, { "archive_read_support_filter_lzip", _wrap_archive_read_support_filter_lzip, METH_O, NULL}, { "archive_read_support_filter_lzma", _wrap_archive_read_support_filter_lzma, METH_O, NULL}, + { "archive_read_support_filter_lzop", _wrap_archive_read_support_filter_lzop, METH_O, NULL}, { "archive_read_support_filter_none", _wrap_archive_read_support_filter_none, METH_O, NULL}, + { "archive_read_support_filter_program", _wrap_archive_read_support_filter_program, METH_VARARGS, NULL}, + { "archive_read_support_filter_program_signature", _wrap_archive_read_support_filter_program_signature, METH_VARARGS, NULL}, { "archive_read_support_filter_rpm", _wrap_archive_read_support_filter_rpm, METH_O, NULL}, { "archive_read_support_filter_uu", _wrap_archive_read_support_filter_uu, METH_O, NULL}, { "archive_read_support_filter_xz", _wrap_archive_read_support_filter_xz, METH_O, NULL}, - { "archive_read_support_format_all", _wrap_archive_read_support_format_all, METH_O, NULL}, { "archive_read_support_format_7zip", _wrap_archive_read_support_format_7zip, METH_O, NULL}, + { "archive_read_support_format_all", _wrap_archive_read_support_format_all, METH_O, NULL}, { "archive_read_support_format_ar", _wrap_archive_read_support_format_ar, METH_O, NULL}, + { "archive_read_support_format_by_code", _wrap_archive_read_support_format_by_code, METH_VARARGS, NULL}, { "archive_read_support_format_cab", _wrap_archive_read_support_format_cab, METH_O, NULL}, { "archive_read_support_format_cpio", _wrap_archive_read_support_format_cpio, METH_O, NULL}, { "archive_read_support_format_empty", _wrap_archive_read_support_format_empty, METH_O, NULL}, @@ -5686,8 +6662,15 @@ static PyMethodDef SwigMethods[] = { { "archive_read_support_format_rar", _wrap_archive_read_support_format_rar, METH_O, NULL}, { "archive_read_support_format_raw", _wrap_archive_read_support_format_raw, METH_O, NULL}, { "archive_read_support_format_tar", _wrap_archive_read_support_format_tar, METH_O, NULL}, + { "archive_read_support_format_warc", _wrap_archive_read_support_format_warc, METH_O, NULL}, { "archive_read_support_format_xar", _wrap_archive_read_support_format_xar, METH_O, NULL}, { "archive_read_support_format_zip", _wrap_archive_read_support_format_zip, METH_O, NULL}, + { "archive_read_support_format_zip_streamable", _wrap_archive_read_support_format_zip_streamable, METH_O, NULL}, + { "archive_read_support_format_zip_seekable", _wrap_archive_read_support_format_zip_seekable, METH_O, NULL}, + { "archive_read_set_format", _wrap_archive_read_set_format, METH_VARARGS, NULL}, + { "archive_read_append_filter", _wrap_archive_read_append_filter, METH_VARARGS, NULL}, + { "archive_read_append_filter_program", _wrap_archive_read_append_filter_program, METH_VARARGS, NULL}, + { "archive_read_append_filter_program_signature", _wrap_archive_read_append_filter_program_signature, METH_VARARGS, NULL}, { "archive_write_new", _wrap_archive_write_new, METH_NOARGS, NULL}, { "archive_write_free", _wrap_archive_write_free, METH_O, NULL}, { "archive_write_open", _wrap_archive_write_open, METH_VARARGS, NULL}, From 731e119197092dafb1436f5863d0fadf57d8b845 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 18 Jul 2022 11:59:04 +0200 Subject: [PATCH 15/91] upgrade archive write support --- libarchive/_libarchive.i | 40 +- libarchive/_libarchive.py | 81 ++++ libarchive/_libarchive_wrap.c | 793 +++++++++++++++++++++++++++++++++- 3 files changed, 895 insertions(+), 19 deletions(-) diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index 6b0bc27..56d29fa 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -293,42 +293,78 @@ extern int archive_write_close(struct archive *); extern int archive_write_header(struct archive *, struct archive_entry *); +extern int archive_write_set_format_option(struct archive *_a, + const char *m, const char *o, + const char *v); +/* Apply option to the filter only. */ +extern int archive_write_set_filter_option(struct archive *_a, + const char *m, const char *o, + const char *v); +/* Apply option to both the format and the filter. */ +extern int archive_write_set_option(struct archive *_a, + const char *m, const char *o, + const char *v); +/* Apply option string to both the format and the filter. */ +extern int archive_write_set_options(struct archive *_a, + const char *opts); + +/* password */ +extern int archive_write_set_passphrase(struct archive *_a, const char *p); /* data */ /* commit */ extern int archive_write_finish_entry(struct archive *); /* FILTERS */ +extern int archive_write_add_filter(struct archive *, int filter_code); +extern int archive_write_add_filter_by_name(struct archive *, + const char *name); +extern int archive_write_add_filter_b64encode(struct archive *); extern int archive_write_add_filter_bzip2(struct archive *); extern int archive_write_add_filter_compress(struct archive *); +extern int archive_write_add_filter_grzip(struct archive *); extern int archive_write_add_filter_gzip(struct archive *); +extern int archive_write_add_filter_lrzip(struct archive *); +extern int archive_write_add_filter_lz4(struct archive *); extern int archive_write_add_filter_lzip(struct archive *); extern int archive_write_add_filter_lzma(struct archive *); +extern int archive_write_add_filter_lzop(struct archive *); extern int archive_write_add_filter_none(struct archive *); +extern int archive_write_add_filter_program(struct archive *, + const char *cmd); +extern int archive_write_add_filter_uuencode(struct archive *); extern int archive_write_add_filter_xz(struct archive *); -/* FORMATS */ /* A convenience function to set the format based on the code or name. */ extern int archive_write_set_format(struct archive *, int format_code); extern int archive_write_set_format_by_name(struct archive *, const char *name); /* To minimize link pollution, use one or more of the following. */ +extern int archive_write_set_format_7zip(struct archive *); extern int archive_write_set_format_ar_bsd(struct archive *); extern int archive_write_set_format_ar_svr4(struct archive *); extern int archive_write_set_format_cpio(struct archive *); extern int archive_write_set_format_cpio_newc(struct archive *); extern int archive_write_set_format_gnutar(struct archive *); extern int archive_write_set_format_iso9660(struct archive *); -/*extern int archive_write_set_format_mtree(struct archive *);*/ +extern int archive_write_set_format_mtree(struct archive *); +extern int archive_write_set_format_mtree_classic(struct archive *); /* TODO: int archive_write_set_format_old_tar(struct archive *); */ extern int archive_write_set_format_pax(struct archive *); extern int archive_write_set_format_pax_restricted(struct archive *); +extern int archive_write_set_format_raw(struct archive *); extern int archive_write_set_format_shar(struct archive *); extern int archive_write_set_format_shar_dump(struct archive *); extern int archive_write_set_format_ustar(struct archive *); +extern int archive_write_set_format_v7tar(struct archive *); +extern int archive_write_set_format_warc(struct archive *); extern int archive_write_set_format_xar(struct archive *); extern int archive_write_set_format_zip(struct archive *); +extern int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename); +extern int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext); +extern int archive_write_zip_set_compression_deflate(struct archive *); +extern int archive_write_zip_set_compression_store(struct archive *); /* ARCHIVE ENTRY */ extern struct archive_entry *archive_entry_new(void); diff --git a/libarchive/_libarchive.py b/libarchive/_libarchive.py index 36aadd7..9ddcf02 100644 --- a/libarchive/_libarchive.py +++ b/libarchive/_libarchive.py @@ -293,27 +293,69 @@ def archive_write_close(arg1): def archive_write_header(arg1, arg2): return __libarchive.archive_write_header(arg1, arg2) +def archive_write_set_format_option(_a, m, o, v): + return __libarchive.archive_write_set_format_option(_a, m, o, v) + +def archive_write_set_filter_option(_a, m, o, v): + return __libarchive.archive_write_set_filter_option(_a, m, o, v) + +def archive_write_set_option(_a, m, o, v): + return __libarchive.archive_write_set_option(_a, m, o, v) + +def archive_write_set_options(_a, opts): + return __libarchive.archive_write_set_options(_a, opts) + +def archive_write_set_passphrase(_a, p): + return __libarchive.archive_write_set_passphrase(_a, p) + def archive_write_finish_entry(arg1): return __libarchive.archive_write_finish_entry(arg1) +def archive_write_add_filter(arg1, filter_code): + return __libarchive.archive_write_add_filter(arg1, filter_code) + +def archive_write_add_filter_by_name(arg1, name): + return __libarchive.archive_write_add_filter_by_name(arg1, name) + +def archive_write_add_filter_b64encode(arg1): + return __libarchive.archive_write_add_filter_b64encode(arg1) + def archive_write_add_filter_bzip2(arg1): return __libarchive.archive_write_add_filter_bzip2(arg1) def archive_write_add_filter_compress(arg1): return __libarchive.archive_write_add_filter_compress(arg1) +def archive_write_add_filter_grzip(arg1): + return __libarchive.archive_write_add_filter_grzip(arg1) + def archive_write_add_filter_gzip(arg1): return __libarchive.archive_write_add_filter_gzip(arg1) +def archive_write_add_filter_lrzip(arg1): + return __libarchive.archive_write_add_filter_lrzip(arg1) + +def archive_write_add_filter_lz4(arg1): + return __libarchive.archive_write_add_filter_lz4(arg1) + def archive_write_add_filter_lzip(arg1): return __libarchive.archive_write_add_filter_lzip(arg1) def archive_write_add_filter_lzma(arg1): return __libarchive.archive_write_add_filter_lzma(arg1) +def archive_write_add_filter_lzop(arg1): + return __libarchive.archive_write_add_filter_lzop(arg1) + def archive_write_add_filter_none(arg1): return __libarchive.archive_write_add_filter_none(arg1) +def archive_write_add_filter_program(arg1, cmd): + return __libarchive.archive_write_add_filter_program(arg1, cmd) + +def archive_write_add_filter_uuencode(arg1): + return __libarchive.archive_write_add_filter_uuencode(arg1) + def archive_write_add_filter_xz(arg1): return __libarchive.archive_write_add_filter_xz(arg1) @@ -323,6 +365,9 @@ def archive_write_set_format(arg1, format_code): def archive_write_set_format_by_name(arg1, name): return __libarchive.archive_write_set_format_by_name(arg1, name) +def archive_write_set_format_7zip(arg1): + return __libarchive.archive_write_set_format_7zip(arg1) + def archive_write_set_format_ar_bsd(arg1): return __libarchive.archive_write_set_format_ar_bsd(arg1) @@ -341,12 +386,21 @@ def archive_write_set_format_gnutar(arg1): def archive_write_set_format_iso9660(arg1): return __libarchive.archive_write_set_format_iso9660(arg1) +def archive_write_set_format_mtree(arg1): + return __libarchive.archive_write_set_format_mtree(arg1) + +def archive_write_set_format_mtree_classic(arg1): + return __libarchive.archive_write_set_format_mtree_classic(arg1) + def archive_write_set_format_pax(arg1): return __libarchive.archive_write_set_format_pax(arg1) def archive_write_set_format_pax_restricted(arg1): return __libarchive.archive_write_set_format_pax_restricted(arg1) +def archive_write_set_format_raw(arg1): + return __libarchive.archive_write_set_format_raw(arg1) + def archive_write_set_format_shar(arg1): return __libarchive.archive_write_set_format_shar(arg1) @@ -356,12 +410,30 @@ def archive_write_set_format_shar_dump(arg1): def archive_write_set_format_ustar(arg1): return __libarchive.archive_write_set_format_ustar(arg1) +def archive_write_set_format_v7tar(arg1): + return __libarchive.archive_write_set_format_v7tar(arg1) + +def archive_write_set_format_warc(arg1): + return __libarchive.archive_write_set_format_warc(arg1) + def archive_write_set_format_xar(arg1): return __libarchive.archive_write_set_format_xar(arg1) def archive_write_set_format_zip(arg1): return __libarchive.archive_write_set_format_zip(arg1) +def archive_write_set_format_filter_by_ext(a, filename): + return __libarchive.archive_write_set_format_filter_by_ext(a, filename) + +def archive_write_set_format_filter_by_ext_def(a, filename, def_ext): + return __libarchive.archive_write_set_format_filter_by_ext_def(a, filename, def_ext) + +def archive_write_zip_set_compression_deflate(arg1): + return __libarchive.archive_write_zip_set_compression_deflate(arg1) + +def archive_write_zip_set_compression_store(arg1): + return __libarchive.archive_write_zip_set_compression_store(arg1) + def archive_entry_new(): return __libarchive.archive_entry_new() @@ -451,6 +523,10 @@ ARCHIVE_FILTER_XZ = __libarchive.ARCHIVE_FILTER_XZ ARCHIVE_FILTER_UU = __libarchive.ARCHIVE_FILTER_UU ARCHIVE_FILTER_RPM = __libarchive.ARCHIVE_FILTER_RPM ARCHIVE_FILTER_LZIP = __libarchive.ARCHIVE_FILTER_LZIP +ARCHIVE_FILTER_LRZIP = __libarchive.ARCHIVE_FILTER_LRZIP +ARCHIVE_FILTER_LZOP = __libarchive.ARCHIVE_FILTER_LZOP +ARCHIVE_FILTER_GRZIP = __libarchive.ARCHIVE_FILTER_GRZIP +ARCHIVE_FILTER_LZ4 = __libarchive.ARCHIVE_FILTER_LZ4 ARCHIVE_FORMAT_BASE_MASK = __libarchive.ARCHIVE_FORMAT_BASE_MASK ARCHIVE_FORMAT_CPIO = __libarchive.ARCHIVE_FORMAT_CPIO ARCHIVE_FORMAT_CPIO_POSIX = __libarchive.ARCHIVE_FORMAT_CPIO_POSIX @@ -481,6 +557,7 @@ ARCHIVE_FORMAT_LHA = __libarchive.ARCHIVE_FORMAT_LHA ARCHIVE_FORMAT_CAB = __libarchive.ARCHIVE_FORMAT_CAB ARCHIVE_FORMAT_RAR = __libarchive.ARCHIVE_FORMAT_RAR ARCHIVE_FORMAT_7ZIP = __libarchive.ARCHIVE_FORMAT_7ZIP +ARCHIVE_FORMAT_WARC = __libarchive.ARCHIVE_FORMAT_WARC ARCHIVE_EXTRACT_OWNER = __libarchive.ARCHIVE_EXTRACT_OWNER ARCHIVE_EXTRACT_PERM = __libarchive.ARCHIVE_EXTRACT_PERM ARCHIVE_EXTRACT_TIME = __libarchive.ARCHIVE_EXTRACT_TIME @@ -495,6 +572,10 @@ ARCHIVE_EXTRACT_NO_AUTODIR = __libarchive.ARCHIVE_EXTRACT_NO_AUTODIR ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER = __libarchive.ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER ARCHIVE_EXTRACT_SPARSE = __libarchive.ARCHIVE_EXTRACT_SPARSE ARCHIVE_EXTRACT_MAC_METADATA = __libarchive.ARCHIVE_EXTRACT_MAC_METADATA +ARCHIVE_EXTRACT_NO_HFS_COMPRESSION = __libarchive.ARCHIVE_EXTRACT_NO_HFS_COMPRESSION +ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED = __libarchive.ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED +ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS = __libarchive.ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS +ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS = __libarchive.ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS def archive_read_data_into_str(archive, len): return __libarchive.archive_read_data_into_str(archive, len) diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index aa9555a..315ecd2 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -5372,6 +5372,237 @@ fail: } +SWIGINTERN PyObject *_wrap_archive_write_set_format_option(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_write_set_format_option", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_option" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_set_format_option" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_write_set_format_option" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "archive_write_set_format_option" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = (char *)(buf4); + result = (int)archive_write_set_format_option(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_set_filter_option(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_write_set_filter_option", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_filter_option" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_set_filter_option" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_write_set_filter_option" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "archive_write_set_filter_option" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = (char *)(buf4); + result = (int)archive_write_set_filter_option(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_set_option(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_write_set_option", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_option" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_set_option" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_write_set_option" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "archive_write_set_option" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = (char *)(buf4); + result = (int)archive_write_set_option(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_set_options(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_write_set_options", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_options" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_set_options" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)archive_write_set_options(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_set_passphrase(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_write_set_passphrase", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_passphrase" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_set_passphrase" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)archive_write_set_passphrase(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + SWIGINTERN PyObject *_wrap_archive_write_finish_entry(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; @@ -5395,6 +5626,92 @@ fail: } +SWIGINTERN PyObject *_wrap_archive_write_add_filter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_write_add_filter", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "archive_write_add_filter" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)archive_write_add_filter(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_add_filter_by_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_write_add_filter_by_name", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_by_name" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_add_filter_by_name" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)archive_write_add_filter_by_name(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_add_filter_b64encode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_b64encode" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_add_filter_b64encode(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_archive_write_add_filter_bzip2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; @@ -5441,7 +5758,145 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_write_add_filter_gzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_write_add_filter_grzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_grzip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_add_filter_grzip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_add_filter_gzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_gzip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_add_filter_gzip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_add_filter_lrzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_lrzip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_add_filter_lrzip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_add_filter_lz4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_lz4" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_add_filter_lz4(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_add_filter_lzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_lzip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_add_filter_lzip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_add_filter_lzma(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_lzma" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_add_filter_lzma(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_add_filter_lzop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -5453,10 +5908,10 @@ SWIGINTERN PyObject *_wrap_archive_write_add_filter_gzip(PyObject *SWIGUNUSEDPAR swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_gzip" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_lzop" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_write_add_filter_gzip(arg1); + result = (int)archive_write_add_filter_lzop(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -5464,7 +5919,7 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_write_add_filter_lzip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_write_add_filter_none(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -5476,10 +5931,10 @@ SWIGINTERN PyObject *_wrap_archive_write_add_filter_lzip(PyObject *SWIGUNUSEDPAR swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_lzip" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_none" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_write_add_filter_lzip(arg1); + result = (int)archive_write_add_filter_none(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -5487,30 +5942,40 @@ fail: } -SWIGINTERN PyObject *_wrap_archive_write_add_filter_lzma(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_write_add_filter_program(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject *swig_obj[1] ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!args) SWIG_fail; - swig_obj[0] = args; + if (!SWIG_Python_UnpackTuple(args, "archive_write_add_filter_program", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_lzma" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_program" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_write_add_filter_lzma(arg1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_add_filter_program" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)archive_write_add_filter_program(arg1,(char const *)arg2); resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return NULL; } -SWIGINTERN PyObject *_wrap_archive_write_add_filter_none(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_archive_write_add_filter_uuencode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; void *argp1 = 0 ; @@ -5522,10 +5987,10 @@ SWIGINTERN PyObject *_wrap_archive_write_add_filter_none(PyObject *SWIGUNUSEDPAR swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_none" "', argument " "1"" of type '" "struct archive *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_add_filter_uuencode" "', argument " "1"" of type '" "struct archive *""'"); } arg1 = (struct archive *)(argp1); - result = (int)archive_write_add_filter_none(arg1); + result = (int)archive_write_add_filter_uuencode(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -5619,6 +6084,29 @@ fail: } +SWIGINTERN PyObject *_wrap_archive_write_set_format_7zip(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_7zip" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_set_format_7zip(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_archive_write_set_format_ar_bsd(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; @@ -5757,6 +6245,52 @@ fail: } +SWIGINTERN PyObject *_wrap_archive_write_set_format_mtree(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_mtree" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_set_format_mtree(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_set_format_mtree_classic(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_mtree_classic" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_set_format_mtree_classic(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_archive_write_set_format_pax(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; @@ -5803,6 +6337,29 @@ fail: } +SWIGINTERN PyObject *_wrap_archive_write_set_format_raw(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_raw" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_set_format_raw(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_archive_write_set_format_shar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; @@ -5872,6 +6429,52 @@ fail: } +SWIGINTERN PyObject *_wrap_archive_write_set_format_v7tar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_v7tar" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_set_format_v7tar(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_set_format_warc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_warc" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_set_format_warc(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_archive_write_set_format_xar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; @@ -5918,6 +6521,129 @@ fail: } +SWIGINTERN PyObject *_wrap_archive_write_set_format_filter_by_ext(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_write_set_format_filter_by_ext", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_filter_by_ext" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_set_format_filter_by_ext" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)archive_write_set_format_filter_by_ext(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_set_format_filter_by_ext_def(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_write_set_format_filter_by_ext_def", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_set_format_filter_by_ext_def" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "archive_write_set_format_filter_by_ext_def" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "archive_write_set_format_filter_by_ext_def" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + result = (int)archive_write_set_format_filter_by_ext_def(arg1,(char const *)arg2,(char const *)arg3); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_zip_set_compression_deflate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_zip_set_compression_deflate" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_zip_set_compression_deflate(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_write_zip_set_compression_store(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct archive *arg1 = (struct archive *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_archive, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "archive_write_zip_set_compression_store" "', argument " "1"" of type '" "struct archive *""'"); + } + arg1 = (struct archive *)(argp1); + result = (int)archive_write_zip_set_compression_store(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_archive_entry_new(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive_entry *result = 0 ; @@ -6680,29 +7406,53 @@ static PyMethodDef SwigMethods[] = { { "archive_write_open_memory", _wrap_archive_write_open_memory, METH_VARARGS, NULL}, { "archive_write_close", _wrap_archive_write_close, METH_O, NULL}, { "archive_write_header", _wrap_archive_write_header, METH_VARARGS, NULL}, + { "archive_write_set_format_option", _wrap_archive_write_set_format_option, METH_VARARGS, NULL}, + { "archive_write_set_filter_option", _wrap_archive_write_set_filter_option, METH_VARARGS, NULL}, + { "archive_write_set_option", _wrap_archive_write_set_option, METH_VARARGS, NULL}, + { "archive_write_set_options", _wrap_archive_write_set_options, METH_VARARGS, NULL}, + { "archive_write_set_passphrase", _wrap_archive_write_set_passphrase, METH_VARARGS, NULL}, { "archive_write_finish_entry", _wrap_archive_write_finish_entry, METH_O, NULL}, + { "archive_write_add_filter", _wrap_archive_write_add_filter, METH_VARARGS, NULL}, + { "archive_write_add_filter_by_name", _wrap_archive_write_add_filter_by_name, METH_VARARGS, NULL}, + { "archive_write_add_filter_b64encode", _wrap_archive_write_add_filter_b64encode, METH_O, NULL}, { "archive_write_add_filter_bzip2", _wrap_archive_write_add_filter_bzip2, METH_O, NULL}, { "archive_write_add_filter_compress", _wrap_archive_write_add_filter_compress, METH_O, NULL}, + { "archive_write_add_filter_grzip", _wrap_archive_write_add_filter_grzip, METH_O, NULL}, { "archive_write_add_filter_gzip", _wrap_archive_write_add_filter_gzip, METH_O, NULL}, + { "archive_write_add_filter_lrzip", _wrap_archive_write_add_filter_lrzip, METH_O, NULL}, + { "archive_write_add_filter_lz4", _wrap_archive_write_add_filter_lz4, METH_O, NULL}, { "archive_write_add_filter_lzip", _wrap_archive_write_add_filter_lzip, METH_O, NULL}, { "archive_write_add_filter_lzma", _wrap_archive_write_add_filter_lzma, METH_O, NULL}, + { "archive_write_add_filter_lzop", _wrap_archive_write_add_filter_lzop, METH_O, NULL}, { "archive_write_add_filter_none", _wrap_archive_write_add_filter_none, METH_O, NULL}, + { "archive_write_add_filter_program", _wrap_archive_write_add_filter_program, METH_VARARGS, NULL}, + { "archive_write_add_filter_uuencode", _wrap_archive_write_add_filter_uuencode, METH_O, NULL}, { "archive_write_add_filter_xz", _wrap_archive_write_add_filter_xz, METH_O, NULL}, { "archive_write_set_format", _wrap_archive_write_set_format, METH_VARARGS, NULL}, { "archive_write_set_format_by_name", _wrap_archive_write_set_format_by_name, METH_VARARGS, NULL}, + { "archive_write_set_format_7zip", _wrap_archive_write_set_format_7zip, METH_O, NULL}, { "archive_write_set_format_ar_bsd", _wrap_archive_write_set_format_ar_bsd, METH_O, NULL}, { "archive_write_set_format_ar_svr4", _wrap_archive_write_set_format_ar_svr4, METH_O, NULL}, { "archive_write_set_format_cpio", _wrap_archive_write_set_format_cpio, METH_O, NULL}, { "archive_write_set_format_cpio_newc", _wrap_archive_write_set_format_cpio_newc, METH_O, NULL}, { "archive_write_set_format_gnutar", _wrap_archive_write_set_format_gnutar, METH_O, NULL}, { "archive_write_set_format_iso9660", _wrap_archive_write_set_format_iso9660, METH_O, NULL}, + { "archive_write_set_format_mtree", _wrap_archive_write_set_format_mtree, METH_O, NULL}, + { "archive_write_set_format_mtree_classic", _wrap_archive_write_set_format_mtree_classic, METH_O, NULL}, { "archive_write_set_format_pax", _wrap_archive_write_set_format_pax, METH_O, NULL}, { "archive_write_set_format_pax_restricted", _wrap_archive_write_set_format_pax_restricted, METH_O, NULL}, + { "archive_write_set_format_raw", _wrap_archive_write_set_format_raw, METH_O, NULL}, { "archive_write_set_format_shar", _wrap_archive_write_set_format_shar, METH_O, NULL}, { "archive_write_set_format_shar_dump", _wrap_archive_write_set_format_shar_dump, METH_O, NULL}, { "archive_write_set_format_ustar", _wrap_archive_write_set_format_ustar, METH_O, NULL}, + { "archive_write_set_format_v7tar", _wrap_archive_write_set_format_v7tar, METH_O, NULL}, + { "archive_write_set_format_warc", _wrap_archive_write_set_format_warc, METH_O, NULL}, { "archive_write_set_format_xar", _wrap_archive_write_set_format_xar, METH_O, NULL}, { "archive_write_set_format_zip", _wrap_archive_write_set_format_zip, METH_O, NULL}, + { "archive_write_set_format_filter_by_ext", _wrap_archive_write_set_format_filter_by_ext, METH_VARARGS, NULL}, + { "archive_write_set_format_filter_by_ext_def", _wrap_archive_write_set_format_filter_by_ext_def, METH_VARARGS, NULL}, + { "archive_write_zip_set_compression_deflate", _wrap_archive_write_zip_set_compression_deflate, METH_O, NULL}, + { "archive_write_zip_set_compression_store", _wrap_archive_write_zip_set_compression_store, METH_O, NULL}, { "archive_entry_new", _wrap_archive_entry_new, METH_NOARGS, NULL}, { "archive_entry_free", _wrap_archive_entry_free, METH_O, NULL}, { "archive_entry_pathname", _wrap_archive_entry_pathname, METH_O, NULL}, @@ -7528,8 +8278,8 @@ SWIG_init(void) { SWIG_InstallConstants(d,swig_const_table); - SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_NUMBER",SWIG_From_int((int)(3005003))); - SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_STRING",SWIG_FromCharPtr("libarchive 3.5.2")); + SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_NUMBER",SWIG_From_int((int)(3002002))); + SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_STRING",SWIG_FromCharPtr("libarchive 3.2.2")); SWIG_Python_SetConstant(d, "ARCHIVE_EOF",SWIG_From_int((int)(1))); SWIG_Python_SetConstant(d, "ARCHIVE_OK",SWIG_From_int((int)(0))); SWIG_Python_SetConstant(d, "ARCHIVE_RETRY",SWIG_From_int((int)((-10)))); @@ -7546,6 +8296,10 @@ SWIG_init(void) { SWIG_Python_SetConstant(d, "ARCHIVE_FILTER_UU",SWIG_From_int((int)(7))); SWIG_Python_SetConstant(d, "ARCHIVE_FILTER_RPM",SWIG_From_int((int)(8))); SWIG_Python_SetConstant(d, "ARCHIVE_FILTER_LZIP",SWIG_From_int((int)(9))); + SWIG_Python_SetConstant(d, "ARCHIVE_FILTER_LRZIP",SWIG_From_int((int)(10))); + SWIG_Python_SetConstant(d, "ARCHIVE_FILTER_LZOP",SWIG_From_int((int)(11))); + SWIG_Python_SetConstant(d, "ARCHIVE_FILTER_GRZIP",SWIG_From_int((int)(12))); + SWIG_Python_SetConstant(d, "ARCHIVE_FILTER_LZ4",SWIG_From_int((int)(13))); SWIG_Python_SetConstant(d, "ARCHIVE_FORMAT_BASE_MASK",SWIG_From_int((int)(0xff0000))); SWIG_Python_SetConstant(d, "ARCHIVE_FORMAT_CPIO",SWIG_From_int((int)(0x10000))); SWIG_Python_SetConstant(d, "ARCHIVE_FORMAT_CPIO_POSIX",SWIG_From_int((int)((0x10000|1)))); @@ -7576,6 +8330,7 @@ SWIG_init(void) { SWIG_Python_SetConstant(d, "ARCHIVE_FORMAT_CAB",SWIG_From_int((int)(0xC0000))); SWIG_Python_SetConstant(d, "ARCHIVE_FORMAT_RAR",SWIG_From_int((int)(0xD0000))); SWIG_Python_SetConstant(d, "ARCHIVE_FORMAT_7ZIP",SWIG_From_int((int)(0xE0000))); + SWIG_Python_SetConstant(d, "ARCHIVE_FORMAT_WARC",SWIG_From_int((int)(0xF0000))); SWIG_Python_SetConstant(d, "ARCHIVE_EXTRACT_OWNER",SWIG_From_int((int)((0x0001)))); SWIG_Python_SetConstant(d, "ARCHIVE_EXTRACT_PERM",SWIG_From_int((int)((0x0002)))); SWIG_Python_SetConstant(d, "ARCHIVE_EXTRACT_TIME",SWIG_From_int((int)((0x0004)))); @@ -7590,6 +8345,10 @@ SWIG_init(void) { SWIG_Python_SetConstant(d, "ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER",SWIG_From_int((int)((0x0800)))); SWIG_Python_SetConstant(d, "ARCHIVE_EXTRACT_SPARSE",SWIG_From_int((int)((0x1000)))); SWIG_Python_SetConstant(d, "ARCHIVE_EXTRACT_MAC_METADATA",SWIG_From_int((int)((0x2000)))); + SWIG_Python_SetConstant(d, "ARCHIVE_EXTRACT_NO_HFS_COMPRESSION",SWIG_From_int((int)((0x4000)))); + SWIG_Python_SetConstant(d, "ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED",SWIG_From_int((int)((0x8000)))); + SWIG_Python_SetConstant(d, "ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS",SWIG_From_int((int)((0x10000)))); + SWIG_Python_SetConstant(d, "ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS",SWIG_From_int((int)((0x20000)))); #if PY_VERSION_HEX >= 0x03000000 return m; #else From b95ad6fd0593ad213f13458d4d7694ac53addd42 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 18 Jul 2022 12:14:34 +0200 Subject: [PATCH 16/91] Fixes for wraper rule --- libarchive/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarchive/Makefile b/libarchive/Makefile index 1ee2982..b7e1fb2 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -7,7 +7,7 @@ PYVER ?= 3.9 all: __libarchive.so -_libarchive_wrap.cxx: _libarchive.i +_libarchive_wrap.c: _libarchive.i #swig -python -c++ -Wall -shadow _libarchive.i swig -python -Wall -shadow _libarchive.i From 0c5afe44e7292559058a5f6eb2c76d274f3cd64e Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 18 Jul 2022 19:08:31 +0200 Subject: [PATCH 17/91] Fixes to handle password protected archives --- libarchive/__init__.py | 14 ++++++++++++-- libarchive/_libarchive.i | 5 +++-- libarchive/_libarchive_wrap.c | 5 +++-- libarchive/zip.py | 19 ++++++++++--------- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index c4861f1..9df1921 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -426,11 +426,13 @@ class Entry(object): class Archive(object): '''A low-level archive reader which provides forward-only iteration. Consider this a light-weight pythonic libarchive wrapper.''' - def __init__(self, f, mode='r', format=None, filter=None, entry_class=Entry, encoding=ENCODING, blocksize=BLOCK_SIZE): + def __init__(self, f, mode='r', format=None, filter=None, entry_class=Entry, + encoding=ENCODING, blocksize=BLOCK_SIZE, password=None): assert mode in ('r', 'w', 'wb', 'a'), 'Mode should be "r", "w", "wb", or "a".' self._stream = None self.encoding = encoding self.blocksize = blocksize + self.password = password if isinstance(f, str): self.filename = f f = open(f, mode) @@ -499,8 +501,12 @@ class Archive(object): self.format_func(self._a) self.filter_func(self._a) if self.mode == 'r': + if self.password: + self.add_passphrase(self.password) call_and_check(_libarchive.archive_read_open_fd, self._a, self._a, self.f.fileno(), self.blocksize) else: + if self.password: + self.set_passphrase(self.password) call_and_check(_libarchive.archive_write_open_fd, self._a, self._a, self.f.fileno()) def denit(self): @@ -562,7 +568,7 @@ class Archive(object): '''Write current archive entry contents to file. f can be a file-like object or a path.''' if isinstance(f, str): - basedir = os.path.basename(f) + basedir = os.path.dirname(f) if not os.path.exists(basedir): os.makedirs(basedir) f = open(f, 'w') @@ -626,6 +632,10 @@ class Archive(object): def add_passphrase(self, password): '''Adds a password to the archive.''' _libarchive.archive_read_add_passphrase(self._a, password) + + def set_passphrase(self, password): + '''Sets a password for the archive.''' + _libarchive.archive_write_set_passphrase(self._a, password) class SeekableArchive(Archive): diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index 56d29fa..6a09bd2 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -535,8 +535,9 @@ PyObject *archive_read_data_into_str(struct archive *archive, int len) { } PyObject *archive_write_data_from_str(struct archive *archive, PyObject *str) { - int len = PyString_Size(str); - if (!archive_write_data(archive, PyString_AS_STRING(str), len)) { + Py_ssize_t len = PyBytes_Size(str); + + if (!archive_write_data(archive, PyBytes_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not write requested data."); return NULL; } diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index 315ecd2..1adbd15 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -3207,8 +3207,9 @@ PyObject *archive_read_data_into_str(struct archive *archive, int len) { } PyObject *archive_write_data_from_str(struct archive *archive, PyObject *str) { - int len = PyString_Size(str); - if (!archive_write_data(archive, PyString_AS_STRING(str), len)) { + Py_ssize_t len = PyBytes_Size(str); + + if (!archive_write_data(archive, PyBytes_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not write requested data."); return NULL; } diff --git a/libarchive/zip.py b/libarchive/zip.py index 053d712..2995aea 100644 --- a/libarchive/zip.py +++ b/libarchive/zip.py @@ -62,8 +62,8 @@ class ZipEntry(Entry): class ZipFile(SeekableArchive): - def __init__(self, f, mode='r', compression=ZIP_DEFLATED, allowZip64=False): - super(ZipFile, self).__init__(f, mode=mode, format='zip', entry_class=ZipEntry, encoding='CP437') + def __init__(self, f, mode='r', compression=ZIP_DEFLATED, allowZip64=False, password=None): + super(ZipFile, self).__init__(f, mode=mode, format='zip', entry_class=ZipEntry, encoding='CP437', password=password) if mode == 'w' and compression == ZIP_STORED: # Disable compression for writing. _libarchive.archive_write_set_format_option(self.archive._a, "zip", "compression", "store") @@ -72,38 +72,39 @@ class ZipFile(SeekableArchive): getinfo = SeekableArchive.getentry def namelist(self): - return list(self.iterpaths) + return list(self.iterpaths()) def infolist(self): return list(self) def open(self, name, mode, pwd=None): - if pwd: - raise NotImplemented('Encryption not supported.') if mode == 'r': + if pwd: + self.add_passphrase(pwd) return self.readstream(name) else: return self.writestream(name) def extract(self, name, path=None, pwd=None): if pwd: - raise NotImplemented('Encryption not supported.') + self.add_passphrase(pwd) if not path: path = os.getcwd() return self.readpath(name, os.path.join(path, name)) def extractall(self, path, names=None, pwd=None): if pwd: - raise NotImplemented('Encryption not supported.') + self.add_passphrase(pwd) if not names: names = self.namelist() if names: + print(f"Extracting {names} files.") for name in names: self.extract(name, path) def read(self, name, pwd=None): if pwd: - raise NotImplemented('Encryption not supported.') + self.add_passphrase(pwd) return self.read(name) def writestr(self, member, data, compress_type=None): @@ -112,7 +113,7 @@ class ZipFile(SeekableArchive): return self.write(member, data) def setpassword(self, pwd): - raise NotImplemented('Encryption not supported.') + return self.set_passphrase(pwd) def testzip(self): raise NotImplemented() From e66c2a24f3b3b0c3d8c77579c82c4769bee3f4a9 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 18 Jul 2022 19:12:37 +0200 Subject: [PATCH 18/91] Add SONAME to .so file --- libarchive/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarchive/Makefile b/libarchive/Makefile index b7e1fb2..2e33780 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -17,7 +17,7 @@ _libarchive_wrap.o: _libarchive_wrap.c # ${CXX} -c ${CFLAGS} -fPIC $$(python${PYVER}-config --cflags) -DPyUnicode_AS_STRING=PyUnicode_AS_DATA _libarchive_wrap.cxx __libarchive.so: _libarchive_wrap.o - ${CC} _libarchive_wrap.o -shared $$(python${PYVER}-config --ldflags) -o __libarchive.so ${LIBS} + ${CC} _libarchive_wrap.o -shared $$(python${PYVER}-config --ldflags) -Wl,-soname=__libarchive.so -o __libarchive.so ${LIBS} clean: rm -f *.o *.so *.pyc \ No newline at end of file From 35a412ac1f69830c989ef3ef683359cb449fb68d Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 18 Jul 2022 19:27:58 +0200 Subject: [PATCH 19/91] Fix SWIG helper functions --- libarchive/Makefile | 2 +- libarchive/_libarchive.i | 3 ++- libarchive/_libarchive_wrap.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libarchive/Makefile b/libarchive/Makefile index 2e33780..f3945f3 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -2,7 +2,7 @@ CFLAGS = -g INCLUDE = -I/usr/include -I. LIBS = -larchive -DEFINES = -DPyUnicode_AS_STRING=PyUnicode_AS_DATA +#DEFINES = -DPyUnicode_AS_STRING=PyUnicode_AS_DATA PYVER ?= 3.9 all: __libarchive.so diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index 6a09bd2..88a2228 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -521,13 +521,14 @@ extern const char *archive_error_string(struct archive *); %inline %{ + PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *str = NULL; if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } - if (len != archive_read_data(archive, PyString_AS_STRING(str), len)) { + if (len != archive_read_data(archive, PyUnicode_AS_DATA(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); return NULL; } diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index 1adbd15..61d339f 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -3193,13 +3193,14 @@ SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) } + PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *str = NULL; if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } - if (len != archive_read_data(archive, PyString_AS_STRING(str), len)) { + if (len != archive_read_data(archive, PyUnicode_AS_DATA(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); return NULL; } From 84f25fe04f4be7b94f0f5b33125c563606b1d608 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 18 Jul 2022 19:28:37 +0200 Subject: [PATCH 20/91] Fix tests --- tests.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests.py b/tests.py index baec6dc..8bc5894 100644 --- a/tests.py +++ b/tests.py @@ -176,6 +176,13 @@ class TestZipWrite(unittest.TestCase): z.writepath(f) z.close() + def test_writepath_with_password(self): + z = ZipFile(self.f, 'w', password='test') + for fname in FILENAMES: + with open(os.path.join(TMPDIR, fname), 'r') as f: + z.writepath(f) + z.close() + def test_writepath_directory(self): """ Test writing a directory. """ z = ZipFile(self.f, 'w') From fa0e5fe081226776dec85557f5101b4d3c20d738 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 19 Jul 2022 00:15:45 +0200 Subject: [PATCH 21/91] python package rename --- setup.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 972d50a..097d338 100644 --- a/setup.py +++ b/setup.py @@ -34,14 +34,13 @@ except ImportError: from distutils.core import setup, Extension from distutils.command.build_ext import build_ext - -name = 'python-libarchive' -version = '4.2.0' -release = '1' -versrel = version + '-' + release +import libarchive +name = 'python-libarchive-ext' +version = libarchive._libarchive.ARCHIVE_VERSION_STRING.split(' ')[1] +versrel = version readme = 'README.rst' -download_url = "http://" + name + ".googlecode.com/files/" + name + "-" + \ - versrel + ".tar.gz" +repourl = 'https://github.com/Vadiml1024/python-libarchive' +download_url = repourl + '/tarball/extended' long_description = open(readme).read() class build_ext_extra(build_ext, object): @@ -98,9 +97,9 @@ setup(name = name, long_description = long_description, license = 'BSD-style license', platforms = ['any'], - author = 'Ben Timby, Travis Cunningham, Ryan Johnston, SmartFile', - author_email = 'tcunningham@smartfile.com', - url = 'https://github.com/smartfile/python-libarchive', + author = 'Vadim Lebedev, Ben Timby, Travis Cunningham, Ryan Johnston, SmartFile', + author_email = 'vadiml1024@gmail.com', + url = repourl, download_url = download_url, packages = ['libarchive'], classifiers = [ From d6b55c7aafd035fe2542d7303d2a0bcdfa03d6bc Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Wed, 20 Jul 2022 08:49:55 +0200 Subject: [PATCH 22/91] package description fix --- Makefile | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d941090..1784738 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,9 @@ verify: install: python setup.py install +wheel: + pip wheel --wheel-dir dist/ . + publish: python setup.py register python setup.py sdist upload diff --git a/setup.py b/setup.py index 097d338..ebbc561 100644 --- a/setup.py +++ b/setup.py @@ -93,7 +93,7 @@ __libarchive = Extension(name='libarchive.__libarchive', setup(name = name, version = versrel, - description = 'A libarchive wrapper for Python.', + description = 'A libarchive wrapper for Python supporting password protection.', long_description = long_description, license = 'BSD-style license', platforms = ['any'], From 9c0f6391e033a4804cf96bb1a553e718cf2cfd7b Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Thu, 21 Jul 2022 18:05:08 +0200 Subject: [PATCH 23/91] fixes archive_read_data_into_str to return python byte array --- libarchive/_libarchive.i | 4 ++-- libarchive/_libarchive_wrap.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index 88a2228..1dccbc6 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -524,11 +524,11 @@ extern const char *archive_error_string(struct archive *); PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *str = NULL; - if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { + if (!(str = PyBytes_FromStringAndSize(NULL, len))) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } - if (len != archive_read_data(archive, PyUnicode_AS_DATA(str), len)) { + if (len != archive_read_data(archive, PyBytes_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); return NULL; } diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index 61d339f..d13a0e1 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -3196,11 +3196,11 @@ SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *str = NULL; - if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { + if (!(str = PyBytes_FromStringAndSize(NULL, len))) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } - if (len != archive_read_data(archive, PyUnicode_AS_DATA(str), len)) { + if (len != archive_read_data(archive, PyBytes_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); return NULL; } From f38459c730075cbdcd0f5adcdc45c534a9ea15e2 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Thu, 21 Jul 2022 18:30:03 +0200 Subject: [PATCH 24/91] Fix archive element closing --- libarchive/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 9df1921..c546db9 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -544,9 +544,11 @@ class Archive(object): if getattr(self.f, 'closed', False): return # Flush it if not read-only... - if self.f.mode != 'r' and self.f.mode != 'rb': - self.f.flush() - os.fsync(self.f.fileno()) + if hasattr(self.f, "mode") and self.f.mode != 'r' and self.f.mode != 'rb': + if hasattr(self.f, "flush"): + self.f.flush() + if hasattr(self.f, "fileno"): + os.fsync(self.f.fileno()) # and then close it, if we opened it... if getattr(self, '_close', None): self.f.close() From 855dc86d1d70deab86490b6e779b091e252ad2e4 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Fri, 22 Jul 2022 22:50:01 +0200 Subject: [PATCH 25/91] is_archive: Avoid closing a file not opened by is_archive --- libarchive/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index c546db9..ec8c2d8 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -158,8 +158,10 @@ def is_archive(f, formats=(None, ), filters=(None, )): This function will return True if the file can be opened as an archive using the given format(s)/filter(s).''' + need_close : bool = False if isinstance(f, str): f = open(f, 'r') + need_close = True a = _libarchive.archive_read_new() for format in formats: format = get_func(format, FORMATS, 0) @@ -180,7 +182,8 @@ def is_archive(f, formats=(None, ), filters=(None, )): finally: _libarchive.archive_read_close(a) _libarchive.archive_read_free(a) - f.close() + if need_close: + f.close() class EntryReadStream(object): From 546d89852e3b59b61c9dc9faec85f3f542bcbc3c Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Sat, 23 Jul 2022 13:25:14 +0200 Subject: [PATCH 26/91] open archive in binary mode --- libarchive/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index ec8c2d8..ed8010f 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -160,7 +160,7 @@ def is_archive(f, formats=(None, ), filters=(None, )): format(s)/filter(s).''' need_close : bool = False if isinstance(f, str): - f = open(f, 'r') + f = open(f, 'rb') need_close = True a = _libarchive.archive_read_new() for format in formats: From c5e562d4cd557da6f1b3fce7ca4e3ca824cd0e05 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Sat, 23 Jul 2022 14:03:38 +0200 Subject: [PATCH 27/91] Fix exception text --- libarchive/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index ed8010f..4ef2866 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -109,7 +109,7 @@ def call_and_check(func, archive, *args): elif ret == _libarchive.ARCHIVE_EOF: raise EOF() else: - raise Exception('Fatal error executing function, message is: %s.' % get_error(archive)) + raise Exception('Problem executing function, message is: %s.' % get_error(archive)) def get_func(name, items, index): From 72fdfa438bcc09b58c21b6a097442a7a4b103095 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 25 Jul 2022 00:28:18 +0200 Subject: [PATCH 28/91] Adding pyproject.toml --- pyproject.toml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..88a3439 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +# See https://setuptools.readthedocs.io/en/latest/build_meta.html + +[build-system] +# Use setuptools >= 43 because it automatically includes pyproject.toml in source distribution +# Use setuptools >= 46.5 to use attr: package.__version__ +# https://setuptools.readthedocs.io/en/latest/history.html#id284 +requires = ["setuptools", "wheel"] From 794ef1cb179b6e65d27926014c775cbbdf947dce Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 25 Jul 2022 15:27:40 +0200 Subject: [PATCH 29/91] cosmetics --- libarchive/__init__.py | 41 +++++++--- libarchive/_libarchive.py | 167 +++++++++++++++++++++++++++++++++++++- libarchive/tar.py | 35 ++++---- libarchive/zip.py | 8 +- tests.py | 30 +++---- 5 files changed, 229 insertions(+), 52 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 4ef2866..8ad5653 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -29,12 +29,12 @@ import sys import time import warnings -#from ctypes import cdll, c_char_p +# from ctypes import cdll, c_char_p from libarchive import _libarchive from io import StringIO -#PY3 = sys.version_info[0] == 3 +# PY3 = sys.version_info[0] == 3 PY3 = True # Suggested block size for libarchive. Libarchive may adjust it. @@ -91,6 +91,7 @@ FILTER_EXTENSIONS = { class EOF(Exception): '''Raised by ArchiveInfo.from_archive() when unable to read the next archive header.''' + pass @@ -145,7 +146,7 @@ def is_archive_name(filename, formats=None): return format -def is_archive(f, formats=(None, ), filters=(None, )): +def is_archive(f, formats=(None,), filters=(None,)): '''Check to see if the given file is actually an archive. The format parameter can be used to specify which archive format is acceptable. If ommitted, all supported archive formats will be checked. It opens the file using libarchive. If no error is @@ -158,7 +159,7 @@ def is_archive(f, formats=(None, ), filters=(None, )): This function will return True if the file can be opened as an archive using the given format(s)/filter(s).''' - need_close : bool = False + need_close: bool = False if isinstance(f, str): f = open(f, 'rb') need_close = True @@ -188,6 +189,7 @@ def is_archive(f, formats=(None, ), filters=(None, )): class EntryReadStream(object): '''A file-like object for reading an entry from the archive.''' + def __init__(self, archive, size): self.archive = archive self.closed = False @@ -247,6 +249,7 @@ class EntryWriteStream(object): If the size is known ahead of time and provided, then the file contents are not buffered but flushed directly to the archive. If size is omitted, then the file contents are buffered and flushed in the close() method.''' + def __init__(self, archive, pathname, size=None): self.archive = archive self.entry = Entry(pathname=pathname, mtime=time.time(), mode=stat.S_IFREG) @@ -301,9 +304,10 @@ class EntryWriteStream(object): class Entry(object): '''An entry within an archive. Represents the header data and it's location within the archive.''' + def __init__(self, pathname=None, size=None, mtime=None, mode=None, hpos=None, encoding=ENCODING): - #, symlink=None + # , symlink=None self.pathname = pathname self.size = size self.mtime = mtime @@ -313,9 +317,9 @@ class Entry(object): self.symlink = "" - #if self.issym() and symlink: + # if self.issym() and symlink: # self.symlink = symlink - #else: + # else: # self.symlink = None @property @@ -402,8 +406,8 @@ class Entry(object): call_and_check(_libarchive.archive_write_header, archive._a, archive._a, e) - #todo - #self.hpos = archive.header_position + # todo + # self.hpos = archive.header_position finally: _libarchive.archive_entry_free(e) @@ -429,8 +433,18 @@ class Entry(object): class Archive(object): '''A low-level archive reader which provides forward-only iteration. Consider this a light-weight pythonic libarchive wrapper.''' - def __init__(self, f, mode='r', format=None, filter=None, entry_class=Entry, - encoding=ENCODING, blocksize=BLOCK_SIZE, password=None): + + def __init__( + self, + f, + mode='r', + format=None, + filter=None, + entry_class=Entry, + encoding=ENCODING, + blocksize=BLOCK_SIZE, + password=None, + ): assert mode in ('r', 'w', 'wb', 'a'), 'Mode should be "r", "w", "wb", or "a".' self._stream = None self.encoding = encoding @@ -550,7 +564,7 @@ class Archive(object): if hasattr(self.f, "mode") and self.f.mode != 'r' and self.f.mode != 'rb': if hasattr(self.f, "flush"): self.f.flush() - if hasattr(self.f, "fileno"): + if hasattr(self.f, "fileno"): os.fsync(self.f.fileno()) # and then close it, if we opened it... if getattr(self, '_close', None): @@ -637,7 +651,7 @@ class Archive(object): def add_passphrase(self, password): '''Adds a password to the archive.''' _libarchive.archive_read_add_passphrase(self._a, password) - + def set_passphrase(self, password): '''Sets a password for the archive.''' _libarchive.archive_write_set_passphrase(self._a, password) @@ -649,6 +663,7 @@ class SeekableArchive(Archive): occur when reading archive entries in the order in which they appear in the archive. Reading out of order will cause the archive to be closed and opened each time a reverse seek is needed.''' + def __init__(self, f, **kwargs): self._stream = None # Convert file to open file. We need this to reopen the archive. diff --git a/libarchive/_libarchive.py b/libarchive/_libarchive.py index 9ddcf02..f9fe9dd 100644 --- a/libarchive/_libarchive.py +++ b/libarchive/_libarchive.py @@ -5,6 +5,7 @@ # the SWIG interface file instead. from sys import version_info as _swig_python_version_info + if _swig_python_version_info < (2, 7, 0): raise RuntimeError("Python 2.7 or later required") @@ -19,12 +20,17 @@ try: except ImportError: import __builtin__ + def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except __builtin__.Exception: strthis = "" - return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + return "<%s.%s; %s >" % ( + self.__class__.__module__, + self.__class__.__name__, + strthis, + ) def _swig_setattr_nondynamic_instance_variable(set): @@ -37,6 +43,7 @@ def _swig_setattr_nondynamic_instance_variable(set): set(self, name, value) else: raise AttributeError("You cannot add instance attributes to %s" % self) + return set_instance_attr @@ -46,465 +53,617 @@ def _swig_setattr_nondynamic_class_variable(set): set(cls, name, value) else: raise AttributeError("You cannot add class attributes to %s" % cls) + return set_class_attr def _swig_add_metaclass(metaclass): """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" + def wrapper(cls): return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) + return wrapper class _SwigNonDynamicMeta(type): """Meta class to enforce nondynamic attributes (no new attributes) for a class""" - __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) + __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) def archive_read_new(): return __libarchive.archive_read_new() + def archive_read_free(arg1): return __libarchive.archive_read_free(arg1) + def archive_read_open_filename(arg1, _filename, _block_size): return __libarchive.archive_read_open_filename(arg1, _filename, _block_size) + def archive_read_open_memory(arg1, buff, size): return __libarchive.archive_read_open_memory(arg1, buff, size) + def archive_read_open_memory2(a, buff, size, read_size): return __libarchive.archive_read_open_memory2(a, buff, size, read_size) + def archive_read_open_fd(arg1, _fd, _block_size): return __libarchive.archive_read_open_fd(arg1, _fd, _block_size) + def archive_read_close(arg1): return __libarchive.archive_read_close(arg1) + def archive_format(arg1): return __libarchive.archive_format(arg1) + def archive_read_next_header2(arg1, arg2): return __libarchive.archive_read_next_header2(arg1, arg2) + def archive_entry_stat(arg1): return __libarchive.archive_entry_stat(arg1) + def archive_read_header_position(arg1): return __libarchive.archive_read_header_position(arg1) + def archive_read_set_format_option(_a, m, o, v): return __libarchive.archive_read_set_format_option(_a, m, o, v) + def archive_read_set_filter_option(_a, m, o, v): return __libarchive.archive_read_set_filter_option(_a, m, o, v) + def archive_read_set_option(_a, m, o, v): return __libarchive.archive_read_set_option(_a, m, o, v) + def archive_read_set_options(_a, opts): return __libarchive.archive_read_set_options(_a, opts) + def archive_read_add_passphrase(arg1, arg2): return __libarchive.archive_read_add_passphrase(arg1, arg2) + def archive_read_data_skip(arg1): return __libarchive.archive_read_data_skip(arg1) + def archive_read_data_into_fd(arg1, fd): return __libarchive.archive_read_data_into_fd(arg1, fd) + def archive_read_support_compression_all(arg1): return __libarchive.archive_read_support_compression_all(arg1) + def archive_read_support_compression_bzip2(arg1): return __libarchive.archive_read_support_compression_bzip2(arg1) + def archive_read_support_compression_compress(arg1): return __libarchive.archive_read_support_compression_compress(arg1) + def archive_read_support_compression_gzip(arg1): return __libarchive.archive_read_support_compression_gzip(arg1) + def archive_read_support_compression_lzip(arg1): return __libarchive.archive_read_support_compression_lzip(arg1) + def archive_read_support_compression_lzma(arg1): return __libarchive.archive_read_support_compression_lzma(arg1) + def archive_read_support_compression_none(arg1): return __libarchive.archive_read_support_compression_none(arg1) + def archive_read_support_compression_program(arg1, command): return __libarchive.archive_read_support_compression_program(arg1, command) + def archive_read_support_compression_program_signature(arg1, arg2, arg3, arg4): return __libarchive.archive_read_support_compression_program_signature(arg1, arg2, arg3, arg4) + def archive_read_support_compression_rpm(arg1): return __libarchive.archive_read_support_compression_rpm(arg1) + def archive_read_support_compression_uu(arg1): return __libarchive.archive_read_support_compression_uu(arg1) + def archive_read_support_compression_xz(arg1): return __libarchive.archive_read_support_compression_xz(arg1) + def archive_read_support_filter_all(arg1): return __libarchive.archive_read_support_filter_all(arg1) + def archive_read_support_filter_bzip2(arg1): return __libarchive.archive_read_support_filter_bzip2(arg1) + def archive_read_support_filter_compress(arg1): return __libarchive.archive_read_support_filter_compress(arg1) + def archive_read_support_filter_gzip(arg1): return __libarchive.archive_read_support_filter_gzip(arg1) + def archive_read_support_filter_grzip(arg1): return __libarchive.archive_read_support_filter_grzip(arg1) + def archive_read_support_filter_lrzip(arg1): return __libarchive.archive_read_support_filter_lrzip(arg1) + def archive_read_support_filter_lz4(arg1): return __libarchive.archive_read_support_filter_lz4(arg1) + def archive_read_support_filter_lzip(arg1): return __libarchive.archive_read_support_filter_lzip(arg1) + def archive_read_support_filter_lzma(arg1): return __libarchive.archive_read_support_filter_lzma(arg1) + def archive_read_support_filter_lzop(arg1): return __libarchive.archive_read_support_filter_lzop(arg1) + def archive_read_support_filter_none(arg1): return __libarchive.archive_read_support_filter_none(arg1) + def archive_read_support_filter_program(arg1, command): return __libarchive.archive_read_support_filter_program(arg1, command) + def archive_read_support_filter_program_signature(arg1, arg2, arg3, arg4): return __libarchive.archive_read_support_filter_program_signature(arg1, arg2, arg3, arg4) + def archive_read_support_filter_rpm(arg1): return __libarchive.archive_read_support_filter_rpm(arg1) + def archive_read_support_filter_uu(arg1): return __libarchive.archive_read_support_filter_uu(arg1) + def archive_read_support_filter_xz(arg1): return __libarchive.archive_read_support_filter_xz(arg1) + def archive_read_support_format_7zip(arg1): return __libarchive.archive_read_support_format_7zip(arg1) + def archive_read_support_format_all(arg1): return __libarchive.archive_read_support_format_all(arg1) + def archive_read_support_format_ar(arg1): return __libarchive.archive_read_support_format_ar(arg1) + def archive_read_support_format_by_code(arg1, arg2): return __libarchive.archive_read_support_format_by_code(arg1, arg2) + def archive_read_support_format_cab(arg1): return __libarchive.archive_read_support_format_cab(arg1) + def archive_read_support_format_cpio(arg1): return __libarchive.archive_read_support_format_cpio(arg1) + def archive_read_support_format_empty(arg1): return __libarchive.archive_read_support_format_empty(arg1) + def archive_read_support_format_gnutar(arg1): return __libarchive.archive_read_support_format_gnutar(arg1) + def archive_read_support_format_iso9660(arg1): return __libarchive.archive_read_support_format_iso9660(arg1) + def archive_read_support_format_lha(arg1): return __libarchive.archive_read_support_format_lha(arg1) + def archive_read_support_format_rar(arg1): return __libarchive.archive_read_support_format_rar(arg1) + def archive_read_support_format_raw(arg1): return __libarchive.archive_read_support_format_raw(arg1) + def archive_read_support_format_tar(arg1): return __libarchive.archive_read_support_format_tar(arg1) + def archive_read_support_format_warc(arg1): return __libarchive.archive_read_support_format_warc(arg1) + def archive_read_support_format_xar(arg1): return __libarchive.archive_read_support_format_xar(arg1) + def archive_read_support_format_zip(arg1): return __libarchive.archive_read_support_format_zip(arg1) + def archive_read_support_format_zip_streamable(arg1): return __libarchive.archive_read_support_format_zip_streamable(arg1) + def archive_read_support_format_zip_seekable(arg1): return __libarchive.archive_read_support_format_zip_seekable(arg1) + def archive_read_set_format(arg1, arg2): return __libarchive.archive_read_set_format(arg1, arg2) + def archive_read_append_filter(arg1, arg2): return __libarchive.archive_read_append_filter(arg1, arg2) + def archive_read_append_filter_program(arg1, arg2): return __libarchive.archive_read_append_filter_program(arg1, arg2) + def archive_read_append_filter_program_signature(arg1, arg2, arg3, arg4): return __libarchive.archive_read_append_filter_program_signature(arg1, arg2, arg3, arg4) + def archive_write_new(): return __libarchive.archive_write_new() + def archive_write_free(arg1): return __libarchive.archive_write_free(arg1) + def archive_write_open(arg1, arg2, arg3, arg4, arg5): return __libarchive.archive_write_open(arg1, arg2, arg3, arg4, arg5) + def archive_write_open_fd(arg1, _fd): return __libarchive.archive_write_open_fd(arg1, _fd) + def archive_write_open_filename(arg1, _file): return __libarchive.archive_write_open_filename(arg1, _file) + def archive_write_open_filename_w(arg1, _file): return __libarchive.archive_write_open_filename_w(arg1, _file) + def archive_write_open_memory(arg1, _buffer, _buffSize, _used): return __libarchive.archive_write_open_memory(arg1, _buffer, _buffSize, _used) + def archive_write_close(arg1): return __libarchive.archive_write_close(arg1) + def archive_write_header(arg1, arg2): return __libarchive.archive_write_header(arg1, arg2) + def archive_write_set_format_option(_a, m, o, v): return __libarchive.archive_write_set_format_option(_a, m, o, v) + def archive_write_set_filter_option(_a, m, o, v): return __libarchive.archive_write_set_filter_option(_a, m, o, v) + def archive_write_set_option(_a, m, o, v): return __libarchive.archive_write_set_option(_a, m, o, v) + def archive_write_set_options(_a, opts): return __libarchive.archive_write_set_options(_a, opts) + def archive_write_set_passphrase(_a, p): return __libarchive.archive_write_set_passphrase(_a, p) + def archive_write_finish_entry(arg1): return __libarchive.archive_write_finish_entry(arg1) + def archive_write_add_filter(arg1, filter_code): return __libarchive.archive_write_add_filter(arg1, filter_code) + def archive_write_add_filter_by_name(arg1, name): return __libarchive.archive_write_add_filter_by_name(arg1, name) + def archive_write_add_filter_b64encode(arg1): return __libarchive.archive_write_add_filter_b64encode(arg1) + def archive_write_add_filter_bzip2(arg1): return __libarchive.archive_write_add_filter_bzip2(arg1) + def archive_write_add_filter_compress(arg1): return __libarchive.archive_write_add_filter_compress(arg1) + def archive_write_add_filter_grzip(arg1): return __libarchive.archive_write_add_filter_grzip(arg1) + def archive_write_add_filter_gzip(arg1): return __libarchive.archive_write_add_filter_gzip(arg1) + def archive_write_add_filter_lrzip(arg1): return __libarchive.archive_write_add_filter_lrzip(arg1) + def archive_write_add_filter_lz4(arg1): return __libarchive.archive_write_add_filter_lz4(arg1) + def archive_write_add_filter_lzip(arg1): return __libarchive.archive_write_add_filter_lzip(arg1) + def archive_write_add_filter_lzma(arg1): return __libarchive.archive_write_add_filter_lzma(arg1) + def archive_write_add_filter_lzop(arg1): return __libarchive.archive_write_add_filter_lzop(arg1) + def archive_write_add_filter_none(arg1): return __libarchive.archive_write_add_filter_none(arg1) + def archive_write_add_filter_program(arg1, cmd): return __libarchive.archive_write_add_filter_program(arg1, cmd) + def archive_write_add_filter_uuencode(arg1): return __libarchive.archive_write_add_filter_uuencode(arg1) + def archive_write_add_filter_xz(arg1): return __libarchive.archive_write_add_filter_xz(arg1) + def archive_write_set_format(arg1, format_code): return __libarchive.archive_write_set_format(arg1, format_code) + def archive_write_set_format_by_name(arg1, name): return __libarchive.archive_write_set_format_by_name(arg1, name) + def archive_write_set_format_7zip(arg1): return __libarchive.archive_write_set_format_7zip(arg1) + def archive_write_set_format_ar_bsd(arg1): return __libarchive.archive_write_set_format_ar_bsd(arg1) + def archive_write_set_format_ar_svr4(arg1): return __libarchive.archive_write_set_format_ar_svr4(arg1) + def archive_write_set_format_cpio(arg1): return __libarchive.archive_write_set_format_cpio(arg1) + def archive_write_set_format_cpio_newc(arg1): return __libarchive.archive_write_set_format_cpio_newc(arg1) + def archive_write_set_format_gnutar(arg1): return __libarchive.archive_write_set_format_gnutar(arg1) + def archive_write_set_format_iso9660(arg1): return __libarchive.archive_write_set_format_iso9660(arg1) + def archive_write_set_format_mtree(arg1): return __libarchive.archive_write_set_format_mtree(arg1) + def archive_write_set_format_mtree_classic(arg1): return __libarchive.archive_write_set_format_mtree_classic(arg1) + def archive_write_set_format_pax(arg1): return __libarchive.archive_write_set_format_pax(arg1) + def archive_write_set_format_pax_restricted(arg1): return __libarchive.archive_write_set_format_pax_restricted(arg1) + def archive_write_set_format_raw(arg1): return __libarchive.archive_write_set_format_raw(arg1) + def archive_write_set_format_shar(arg1): return __libarchive.archive_write_set_format_shar(arg1) + def archive_write_set_format_shar_dump(arg1): return __libarchive.archive_write_set_format_shar_dump(arg1) + def archive_write_set_format_ustar(arg1): return __libarchive.archive_write_set_format_ustar(arg1) + def archive_write_set_format_v7tar(arg1): return __libarchive.archive_write_set_format_v7tar(arg1) + def archive_write_set_format_warc(arg1): return __libarchive.archive_write_set_format_warc(arg1) + def archive_write_set_format_xar(arg1): return __libarchive.archive_write_set_format_xar(arg1) + def archive_write_set_format_zip(arg1): return __libarchive.archive_write_set_format_zip(arg1) + def archive_write_set_format_filter_by_ext(a, filename): return __libarchive.archive_write_set_format_filter_by_ext(a, filename) + def archive_write_set_format_filter_by_ext_def(a, filename, def_ext): return __libarchive.archive_write_set_format_filter_by_ext_def(a, filename, def_ext) + def archive_write_zip_set_compression_deflate(arg1): return __libarchive.archive_write_zip_set_compression_deflate(arg1) + def archive_write_zip_set_compression_store(arg1): return __libarchive.archive_write_zip_set_compression_store(arg1) + def archive_entry_new(): return __libarchive.archive_entry_new() + def archive_entry_free(arg1): return __libarchive.archive_entry_free(arg1) + def archive_entry_pathname(arg1): return __libarchive.archive_entry_pathname(arg1) + def archive_entry_pathname_w(arg1): return __libarchive.archive_entry_pathname_w(arg1) + def archive_entry_size(arg1): return __libarchive.archive_entry_size(arg1) + def archive_entry_mtime(arg1): return __libarchive.archive_entry_mtime(arg1) + def archive_entry_filetype(arg1): return __libarchive.archive_entry_filetype(arg1) + def archive_entry_perm(arg1): return __libarchive.archive_entry_perm(arg1) + def archive_entry_symlink(arg1): return __libarchive.archive_entry_symlink(arg1) + def archive_entry_set_link(arg1, arg2): return __libarchive.archive_entry_set_link(arg1, arg2) + def archive_entry_symlink_w(arg1): return __libarchive.archive_entry_symlink_w(arg1) + def archive_read_disk_set_symlink_logical(arg1): return __libarchive.archive_read_disk_set_symlink_logical(arg1) + def archive_read_disk_set_symlink_physical(arg1): return __libarchive.archive_read_disk_set_symlink_physical(arg1) + def archive_read_disk_set_symlink_hybrid(arg1): return __libarchive.archive_read_disk_set_symlink_hybrid(arg1) + def archive_entry_set_symlink(arg1, arg2): return __libarchive.archive_entry_set_symlink(arg1, arg2) + def archive_entry_copy_symlink(arg1, arg2): return __libarchive.archive_entry_copy_symlink(arg1, arg2) + def archive_entry_copy_symlink_w(arg1, arg2): return __libarchive.archive_entry_copy_symlink_w(arg1, arg2) + def archive_entry_set_pathname(arg1, arg2): return __libarchive.archive_entry_set_pathname(arg1, arg2) + def archive_entry_set_size(arg1, arg2): return __libarchive.archive_entry_set_size(arg1, arg2) + def archive_entry_set_mtime(arg1, arg2, arg3): return __libarchive.archive_entry_set_mtime(arg1, arg2, arg3) + def archive_entry_set_filetype(arg1, arg2): return __libarchive.archive_entry_set_filetype(arg1, arg2) + def archive_entry_set_perm(arg1, arg2): return __libarchive.archive_entry_set_perm(arg1, arg2) + def archive_errno(arg1): return __libarchive.archive_errno(arg1) + def archive_error_string(arg1): return __libarchive.archive_error_string(arg1) + + ARCHIVE_VERSION_NUMBER = __libarchive.ARCHIVE_VERSION_NUMBER ARCHIVE_VERSION_STRING = __libarchive.ARCHIVE_VERSION_STRING ARCHIVE_EOF = __libarchive.ARCHIVE_EOF @@ -577,10 +736,10 @@ ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED = __libarchive.ARCHIVE_EXTRACT_HFS_COMPRE ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS = __libarchive.ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS = __libarchive.ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS + def archive_read_data_into_str(archive, len): return __libarchive.archive_read_data_into_str(archive, len) + def archive_write_data_from_str(archive, str): return __libarchive.archive_write_data_from_str(archive, str) - - diff --git a/libarchive/tar.py b/libarchive/tar.py index 773234f..4f1826a 100644 --- a/libarchive/tar.py +++ b/libarchive/tar.py @@ -1,13 +1,12 @@ import os from libarchive import is_archive, Entry, SeekableArchive -from tarfile import DEFAULT_FORMAT, USTAR_FORMAT, GNU_FORMAT, PAX_FORMAT, \ - ENCODING +from tarfile import DEFAULT_FORMAT, USTAR_FORMAT, GNU_FORMAT, PAX_FORMAT, ENCODING from tarfile import REGTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CHRTYPE, BLKTYPE FORMAT_CONVERSION = { - USTAR_FORMAT: 'tar', - GNU_FORMAT: 'gnu', - PAX_FORMAT: 'pax', + USTAR_FORMAT: 'tar', + GNU_FORMAT: 'gnu', + PAX_FORMAT: 'pax', } @@ -36,9 +35,13 @@ class TarInfo(Entry): @property def get_type(self): for attr, type in ( - ('isdir', DIRTYPE), ('isfile', REGTYPE), ('issym', SYMTYPE), - ('isfifo', FIFOTYPE), ('ischr', CHRTYPE), ('isblk', BLKTYPE), - ): + ('isdir', DIRTYPE), + ('isfile', REGTYPE), + ('issym', SYMTYPE), + ('isfifo', FIFOTYPE), + ('ischr', CHRTYPE), + ('isblk', BLKTYPE), + ): if getattr(self, attr)(): return type @@ -52,13 +55,12 @@ class TarInfo(Entry): class TarFile(SeekableArchive): - getmember = SeekableArchive.getentry - list = SeekableArchive.printlist - extract = SeekableArchive.readpath + getmember = SeekableArchive.getentry + list = SeekableArchive.printlist + extract = SeekableArchive.readpath extractfile = SeekableArchive.readstream - def __init__(self, name=None, mode='r', fileobj=None, - format=DEFAULT_FORMAT, tarinfo=TarInfo, encoding=ENCODING): + def __init__(self, name=None, mode='r', fileobj=None, format=DEFAULT_FORMAT, tarinfo=TarInfo, encoding=ENCODING): if name: f = name elif fileobj: @@ -67,8 +69,7 @@ class TarFile(SeekableArchive): format = FORMAT_CONVERSION.get(format) except KeyError: raise Exception('Invalid tar format: %s' % format) - super(TarFile, self).__init__(f, mode=mode, format=format, - entry_class=tarinfo, encoding=encoding) + super(TarFile, self).__init__(f, mode=mode, format=format, entry_class=tarinfo, encoding=encoding) def getmembers(self): return list(self) @@ -78,7 +79,7 @@ class TarFile(SeekableArchive): def __next__(self): raise NotImplementedError - pass # TODO: how to do this? + pass # TODO: how to do this? def extract(self, member, path=None): if path is None: @@ -90,7 +91,7 @@ class TarFile(SeekableArchive): return self.readpath(member, f) def add(self, name, arcname, recursive=True, exclude=None, filter=None): - pass # TODO: implement this. + pass # TODO: implement this. def addfile(self, tarinfo, fileobj): return self.writepath(fileobj, tarinfo) diff --git a/libarchive/zip.py b/libarchive/zip.py index 2995aea..9e5d433 100644 --- a/libarchive/zip.py +++ b/libarchive/zip.py @@ -4,7 +4,7 @@ from zipfile import ZIP_STORED, ZIP_DEFLATED def is_zipfile(filename): - return is_archive(filename, formats=('zip', )) + return is_archive(filename, formats=('zip',)) class ZipEntry(Entry): @@ -63,13 +63,15 @@ class ZipEntry(Entry): class ZipFile(SeekableArchive): def __init__(self, f, mode='r', compression=ZIP_DEFLATED, allowZip64=False, password=None): - super(ZipFile, self).__init__(f, mode=mode, format='zip', entry_class=ZipEntry, encoding='CP437', password=password) + super(ZipFile, self).__init__( + f, mode=mode, format='zip', entry_class=ZipEntry, encoding='CP437', password=password + ) if mode == 'w' and compression == ZIP_STORED: # Disable compression for writing. _libarchive.archive_write_set_format_option(self.archive._a, "zip", "compression", "store") self.compression = compression - getinfo = SeekableArchive.getentry + getinfo = SeekableArchive.getentry def namelist(self): return list(self.iterpaths()) diff --git a/tests.py b/tests.py index 8bc5894..bf6cb61 100644 --- a/tests.py +++ b/tests.py @@ -33,7 +33,7 @@ import io from libarchive import Archive, is_archive_name, is_archive from libarchive.zip import is_zipfile, ZipFile, ZipEntry -#PY3 = sys.version_info[0] == 3 +# PY3 = sys.version_info[0] == 3 PY3 = True TMPDIR = tempfile.mkdtemp(suffix='.python-libarchive') @@ -81,8 +81,8 @@ class TestIsArchiveZip(unittest.TestCase): def test_zip(self): self.assertEqual(is_archive(ZIPPATH), True) - self.assertEqual(is_archive(ZIPPATH, formats=('zip', )), True) - self.assertEqual(is_archive(ZIPPATH, formats=('tar', )), False) + self.assertEqual(is_archive(ZIPPATH, formats=('zip',)), True) + self.assertEqual(is_archive(ZIPPATH, formats=('tar',)), False) class TestIsArchiveTar(unittest.TestCase): @@ -112,7 +112,7 @@ class TestZipRead(unittest.TestCase): self.assertEqual(count, len(FILENAMES), 'Did not enumerate correct number of items in archive.') def test_deferred_close_by_archive(self): - """ Test archive deferred close without a stream. """ + """Test archive deferred close without a stream.""" z = ZipFile(self.f, 'r') self.assertIsNotNone(z._a) self.assertIsNone(z._stream) @@ -120,7 +120,7 @@ class TestZipRead(unittest.TestCase): self.assertIsNone(z._a) def test_deferred_close_by_stream(self): - """ Ensure archive closes self if stream is closed first. """ + """Ensure archive closes self if stream is closed first.""" z = ZipFile(self.f, 'r') stream = z.readstream(FILENAMES[0]) stream.close() @@ -132,8 +132,8 @@ class TestZipRead(unittest.TestCase): self.assertTrue(stream.closed) def test_close_stream_first(self): - """ Ensure that archive stays open after being closed if a stream is - open. Further, ensure closing the stream closes the archive. """ + """Ensure that archive stays open after being closed if a stream is + open. Further, ensure closing the stream closes the archive.""" z = ZipFile(self.f, 'r') stream = z.readstream(FILENAMES[0]) z.close() @@ -154,8 +154,8 @@ class TestZipRead(unittest.TestCase): names.append(e.filename) self.assertEqual(names, FILENAMES, 'File names differ in archive.') - #~ def test_non_ascii(self): - #~ pass + # ~ def test_non_ascii(self): + # ~ pass def test_extract_str(self): pass @@ -184,7 +184,7 @@ class TestZipWrite(unittest.TestCase): z.close() def test_writepath_directory(self): - """ Test writing a directory. """ + """Test writing a directory.""" z = ZipFile(self.f, 'w') z.writepath(None, pathname='/testdir', folder=True) z.writepath(None, pathname='/testdir/testinside', folder=True) @@ -238,7 +238,7 @@ class TestZipWrite(unittest.TestCase): z.close() def test_deferred_close_by_archive(self): - """ Test archive deferred close without a stream. """ + """Test archive deferred close without a stream.""" z = ZipFile(self.f, 'w') o = z.writestream(FILENAMES[0]) z.close() @@ -259,7 +259,7 @@ class TestHighLevelAPI(unittest.TestCase): make_temp_archive() def _test_listing_content(self, f): - """ Test helper capturing file paths while iterating the archive. """ + """Test helper capturing file paths while iterating the archive.""" found = [] with Archive(f) as a: for entry in a: @@ -268,16 +268,16 @@ class TestHighLevelAPI(unittest.TestCase): self.assertEqual(set(found), set(FILENAMES)) def test_open_by_name(self): - """ Test an archive opened directly by name. """ + """Test an archive opened directly by name.""" self._test_listing_content(ZIPPATH) def test_open_by_named_fobj(self): - """ Test an archive using a file-like object opened by name. """ + """Test an archive using a file-like object opened by name.""" with open(ZIPPATH, 'rb') as f: self._test_listing_content(f) def test_open_by_unnamed_fobj(self): - """ Test an archive using file-like object opened by fileno(). """ + """Test an archive using file-like object opened by fileno().""" with open(ZIPPATH, 'rb') as zf: with io.FileIO(zf.fileno(), mode='r', closefd=False) as f: self._test_listing_content(f) From 81181965e72359ee82fb8d3290b35bf8c655434e Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 25 Jul 2022 15:28:25 +0200 Subject: [PATCH 30/91] retrive version number from SWIG generated .C file --- setup.py | 96 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/setup.py b/setup.py index ebbc561..724479c 100644 --- a/setup.py +++ b/setup.py @@ -34,29 +34,36 @@ except ImportError: from distutils.core import setup, Extension from distutils.command.build_ext import build_ext -import libarchive +import subprocess + +# retreive the version number form SWIG generated file +cmd = [ + 'awk', + '/ARCHIVE_VERSION_NUMBER/ { if (match($0,"[[:digit:]]+")) print substr($0, RSTART,RLENGTH) }', + "libarchive/_libarchive_wrap.c", +] +p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) +vnum = int(p.stdout) + name = 'python-libarchive-ext' -version = libarchive._libarchive.ARCHIVE_VERSION_STRING.split(' ')[1] +version = '{}.{}.{}'.format(vnum // 1000000, (vnum // 1000) % 100, vnum % 100) versrel = version readme = 'README.rst' repourl = 'https://github.com/Vadiml1024/python-libarchive' -download_url = repourl + '/tarball/extended' +repobranch = 'extended' +download_url = repourl + f'/tarball/{repobranch}' long_description = open(readme).read() + class build_ext_extra(build_ext, object): """ Extend build_ext allowing extra_compile_args and extra_link_args to be set on the command-line. """ + user_options = build_ext.user_options - user_options.append( - ('extra-compile-args=', None, - 'Extra arguments passed directly to the compiler') - ) - user_options.append( - ('extra-link-args=', None, - 'Extra arguments passed directly to the linker') - ) + user_options.append(('extra-compile-args=', None, 'Extra arguments passed directly to the compiler')) + user_options.append(('extra-link-args=', None, 'Extra arguments passed directly to the linker')) def initialize_options(self): build_ext.initialize_options(self) @@ -76,43 +83,44 @@ libarchivePrefix = environ.get('LIBARCHIVE_PREFIX') if libarchivePrefix: extra_compile_args = ['-I{0}/include'.format(libarchivePrefix)] extra_link_args = ['-Wl,-rpath={0}/lib'.format(libarchivePrefix)] - environ['LDFLAGS'] = '-L{0}/lib {1}'.format(libarchivePrefix, - environ.get('LDFLAGS', '')) + environ['LDFLAGS'] = '-L{0}/lib {1}'.format(libarchivePrefix, environ.get('LDFLAGS', '')) else: extra_compile_args = [] extra_link_args = ['-l:libarchive.so.13'] -__libarchive = Extension(name='libarchive.__libarchive', - sources=['libarchive/_libarchive_wrap.c'], - libraries=['archive'], - extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args, - include_dirs=['libarchive'], - ) +__libarchive = Extension( + name='libarchive.__libarchive', + sources=['libarchive/_libarchive_wrap.c'], + libraries=['archive'], + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, + include_dirs=['libarchive'], +) -setup(name = name, - version = versrel, - description = 'A libarchive wrapper for Python supporting password protection.', - long_description = long_description, - license = 'BSD-style license', - platforms = ['any'], - author = 'Vadim Lebedev, Ben Timby, Travis Cunningham, Ryan Johnston, SmartFile', - author_email = 'vadiml1024@gmail.com', - url = repourl, - download_url = download_url, - packages = ['libarchive'], - classifiers = [ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: C', - 'Programming Language :: Python', - 'Topic :: System :: Archiving :: Compression', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - cmdclass = { +setup( + name=name, + version=versrel, + description='A libarchive wrapper for Python supporting password protection.', + long_description=long_description, + license='BSD-style license', + platforms=['any'], + author='Vadim Lebedev, Ben Timby, Travis Cunningham, Ryan Johnston, SmartFile', + author_email='vadiml1024@gmail.com', + url=repourl, + download_url=download_url, + packages=['libarchive'], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: C', + 'Programming Language :: Python', + 'Topic :: System :: Archiving :: Compression', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + cmdclass={ 'build_ext': build_ext_extra, - }, - ext_modules = [__libarchive], - ) + }, + ext_modules=[__libarchive], +) From 5453c154c1334084bea1ecabbf9c48a5106411b2 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 13:59:35 +0200 Subject: [PATCH 31/91] Adding githib workflow --- .github/workflows/build-wheels.yaml | 65 +++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/build-wheels.yaml diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml new file mode 100644 index 0000000..9e79cd0 --- /dev/null +++ b/.github/workflows/build-wheels.yaml @@ -0,0 +1,65 @@ +name: build-wheels + +on: + workflow-dispatch: + branches: + - master + - extended + +jobs: + Manylinux-Wheels: + runs-on: ubuntu-latest + container: quay.io/pypa/manylinux2014_x86_64 + steps: + - uses: actions/checkout@v2 + + - name: Print System Information + run: | + echo "uname -a: $( uname -a )" + cat /etc/issue + echo "Shell: $SHELL" + echo "Mount points:"; mount + env + + - name: Chose Python version + run: | + ln -s /opt/python/cp39-cp39/bin/python3 /usr/local/bin/python3 + export PATH="/opt/python/cp39-cp39/bin:$PATH" + + - name: Install dependencies + run: | + yum install -y libxml2-devel libzstd-devl liblz4-devel liblzma-devel libbzip2-devel + yum install -y libacl-devel librichacl-devel openssl-devel + yum install -y librichacl-devel swig strace + + - name: Install python tools + run: | + python3 -m pip instal pytest auditwheel + + + - name: Build libarchive C sources + run: | + git clone git clone https://github.com/libarchive/libarchive.git libarchive-src + cd libarchive-src; git checkout 3-5 + mkdir build; cd build + cmake ../ + make -j$(nproc); make install + cd ../.. + + + - name: Compile pyhton modules + run: | + rm -rf build wheelhouse + touch libarchive/_libarchive.i + make clean + export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH + make install + + + - name: Build wheels + run: | + make wheel + auditwheel repair dist/*.whl + python3 -m pip install --force-reinstall wheelhouse/*,whl + + \ No newline at end of file From 5aa191626e4ae317b48561a3b41d8ee01b90611b Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 14:08:07 +0200 Subject: [PATCH 32/91] Fixes to build instruction --- libarchive/Makefile | 5 +++-- setup.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libarchive/Makefile b/libarchive/Makefile index f3945f3..1999128 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -1,6 +1,6 @@ CFLAGS = -g -INCLUDE = -I/usr/include -I. -LIBS = -larchive +INCLUDE = -I/usr/local/include -I/usr/include -I. +LIBS = -L /usr/local/lib -larchive #DEFINES = -DPyUnicode_AS_STRING=PyUnicode_AS_DATA PYVER ?= 3.9 @@ -17,6 +17,7 @@ _libarchive_wrap.o: _libarchive_wrap.c # ${CXX} -c ${CFLAGS} -fPIC $$(python${PYVER}-config --cflags) -DPyUnicode_AS_STRING=PyUnicode_AS_DATA _libarchive_wrap.cxx __libarchive.so: _libarchive_wrap.o + echo INCLUDE=$INCLUDE LIBS=$LIBS ${CC} _libarchive_wrap.o -shared $$(python${PYVER}-config --ldflags) -Wl,-soname=__libarchive.so -o __libarchive.so ${LIBS} clean: diff --git a/setup.py b/setup.py index 724479c..8703f5f 100644 --- a/setup.py +++ b/setup.py @@ -90,7 +90,7 @@ else: __libarchive = Extension( name='libarchive.__libarchive', - sources=['libarchive/_libarchive_wrap.c'], + sources=['libarchive/_libarchive.i', 'libarchive/_libarchive_wrap.c'], libraries=['archive'], extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, From e58fb753ed9f0a051b478da1a4c3b8d656938e05 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 15:44:48 +0200 Subject: [PATCH 33/91] Build instructions fixes --- .github/workflows/build-wheels.yaml | 6 +++--- setup.py | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 9e79cd0..c2d5d8a 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -51,14 +51,14 @@ jobs: run: | rm -rf build wheelhouse touch libarchive/_libarchive.i - make clean export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH - make install + export LIBARCHIVE_PREFIX=/usr/local + python3 setup.py install - name: Build wheels run: | - make wheel + pip wheel --wheel-dir dist/ . auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*,whl diff --git a/setup.py b/setup.py index 8703f5f..dddc13c 100644 --- a/setup.py +++ b/setup.py @@ -36,13 +36,22 @@ except ImportError: import subprocess + +# Use a provided libarchive else default to hard-coded path. +libarchivePrefix = environ.get('LIBARCHIVE_PREFIX') + +includePath = f"{libarchivePrefix or '/usr'}/include" # retreive the version number form SWIG generated file +print("includePath:", (libarchivePrefix, includePath)) + cmd = [ 'awk', - '/ARCHIVE_VERSION_NUMBER/ { if (match($0,"[[:digit:]]+")) print substr($0, RSTART,RLENGTH) }', - "libarchive/_libarchive_wrap.c", + '/#define.*ARCHIVE_VERSION_NUMBER/ { if (match($0,"[[:digit:]]+")) print substr($0, RSTART,RLENGTH) }', + f"{includePath}/archive.h" ] + p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) +print("awk output:", p.stdout.decode('utf-8')) vnum = int(p.stdout) name = 'python-libarchive-ext' @@ -78,8 +87,6 @@ class build_ext_extra(build_ext, object): super(build_ext_extra, self).build_extension(ext) -# Use a provided libarchive else default to hard-coded path. -libarchivePrefix = environ.get('LIBARCHIVE_PREFIX') if libarchivePrefix: extra_compile_args = ['-I{0}/include'.format(libarchivePrefix)] extra_link_args = ['-Wl,-rpath={0}/lib'.format(libarchivePrefix)] @@ -90,7 +97,7 @@ else: __libarchive = Extension( name='libarchive.__libarchive', - sources=['libarchive/_libarchive.i', 'libarchive/_libarchive_wrap.c'], + sources=['libarchive/_libarchive.i'], libraries=['archive'], extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, From 44d6dd8f3c422e69d7c38b86d936db5deb316a38 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 15:48:46 +0200 Subject: [PATCH 34/91] User correct libarchive branch --- .github/workflows/build-wheels.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index c2d5d8a..474928a 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -7,7 +7,7 @@ on: - extended jobs: - Manylinux-Wheels: + name: manylinux-wheels: runs-on: ubuntu-latest container: quay.io/pypa/manylinux2014_x86_64 steps: @@ -40,7 +40,7 @@ jobs: - name: Build libarchive C sources run: | git clone git clone https://github.com/libarchive/libarchive.git libarchive-src - cd libarchive-src; git checkout 3-5 + cd libarchive-src; git checkout 3.5 mkdir build; cd build cmake ../ make -j$(nproc); make install From 86c77978f1b42179976adbd523410d05860d78f4 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 15:51:25 +0200 Subject: [PATCH 35/91] workflow syntax error fix --- .github/workflows/build-wheels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 474928a..14cab1e 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -7,7 +7,7 @@ on: - extended jobs: - name: manylinux-wheels: + name: manylinux-wheels runs-on: ubuntu-latest container: quay.io/pypa/manylinux2014_x86_64 steps: From 2575c1d578601e7bc0b5b4298cbe896b8cf73312 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 16:09:13 +0200 Subject: [PATCH 36/91] workflow fix --- .github/workflows/build-wheels.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 14cab1e..f2fa300 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -5,8 +5,9 @@ on: branches: - master - extended - + jobs: + my_first_job: name: manylinux-wheels runs-on: ubuntu-latest container: quay.io/pypa/manylinux2014_x86_64 From 2230c1fe033b3afca93264de2e0c4664017558a5 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 16:55:03 +0200 Subject: [PATCH 37/91] workflow syntax fix --- .github/workflows/build-wheels.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index f2fa300..bb6f3fd 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -5,14 +5,14 @@ on: branches: - master - extended - + jobs: - my_first_job: + many_linux_wheels: name: manylinux-wheels runs-on: ubuntu-latest container: quay.io/pypa/manylinux2014_x86_64 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - name: Print System Information run: | From 345f03b4f1b40a34986426a9a11e31bbec8def62 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 17:00:06 +0200 Subject: [PATCH 38/91] Workflow syntax --- .github/workflows/build-wheels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index bb6f3fd..7e9011c 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -1,7 +1,7 @@ name: build-wheels on: - workflow-dispatch: + workflow_dispatch: branches: - master - extended From d4d03683be437d13b064ec2fa62b26f6153aa466 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 17:16:43 +0200 Subject: [PATCH 39/91] fix depended package name --- .github/workflows/build-wheels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 7e9011c..3532b46 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -29,7 +29,7 @@ jobs: - name: Install dependencies run: | - yum install -y libxml2-devel libzstd-devl liblz4-devel liblzma-devel libbzip2-devel + yum install -y libxml2-devel libzstd-devel liblz4-devel liblzma-devel libbzip2-devel yum install -y libacl-devel librichacl-devel openssl-devel yum install -y librichacl-devel swig strace From b986afde10b9468786902ecede9af7cd90920e9c Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 17:26:13 +0200 Subject: [PATCH 40/91] fixed dependencies --- .github/workflows/build-wheels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 3532b46..3df7d21 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -29,7 +29,7 @@ jobs: - name: Install dependencies run: | - yum install -y libxml2-devel libzstd-devel liblz4-devel liblzma-devel libbzip2-devel + yum install -y libxml2-devel libzstd-devel xz-devel libbzip2-devel yum install -y libacl-devel librichacl-devel openssl-devel yum install -y librichacl-devel swig strace From bba64b2e75e9f3767e2b1276f54192dadd30167c Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 17:38:07 +0200 Subject: [PATCH 41/91] more dependencies fixe --- .github/workflows/build-wheels.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 3df7d21..beb63a8 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -29,8 +29,8 @@ jobs: - name: Install dependencies run: | - yum install -y libxml2-devel libzstd-devel xz-devel libbzip2-devel - yum install -y libacl-devel librichacl-devel openssl-devel + yum install -y libxml2-devel libzstd-devel xz-devel bzip2-devel + yum install -y libacl-devel openssl-devel yum install -y librichacl-devel swig strace - name: Install python tools From e3c90a54e8e144038b933c8186b95373412af80a Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 17:44:52 +0200 Subject: [PATCH 42/91] adding epel dependency --- .github/workflows/build-wheels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index beb63a8..f079be3 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -29,7 +29,7 @@ jobs: - name: Install dependencies run: | - yum install -y libxml2-devel libzstd-devel xz-devel bzip2-devel + yum install -y epel-release libxml2-devel libzstd-devel xz-devel bzip2-devel yum install -y libacl-devel openssl-devel yum install -y librichacl-devel swig strace From a0c02a2074c5dd2eb5d3259f6e490f8ac626f06c Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 17:54:15 +0200 Subject: [PATCH 43/91] syntax error --- .github/workflows/build-wheels.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index f079be3..40cff0d 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -35,7 +35,7 @@ jobs: - name: Install python tools run: | - python3 -m pip instal pytest auditwheel + python3 -m pip install pytest auditwheel - name: Build libarchive C sources @@ -59,8 +59,8 @@ jobs: - name: Build wheels run: | - pip wheel --wheel-dir dist/ . + pyhton -m pip wheel --wheel-dir dist/ . auditwheel repair dist/*.whl - python3 -m pip install --force-reinstall wheelhouse/*,whl + python3 -m pip install --force-reinstall wheelhouse/*.whl \ No newline at end of file From 0544fedc2be417fed328160a612a59ec86969b9a Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 18:00:06 +0200 Subject: [PATCH 44/91] use correct git clone command --- .github/workflows/build-wheels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 40cff0d..af6a799 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -40,7 +40,7 @@ jobs: - name: Build libarchive C sources run: | - git clone git clone https://github.com/libarchive/libarchive.git libarchive-src + git clone https://github.com/libarchive/libarchive.git libarchive-src cd libarchive-src; git checkout 3.5 mkdir build; cd build cmake ../ From a982dc427c0641fc4bddcb31c7a54d90f5a9d9c8 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 18:05:10 +0200 Subject: [PATCH 45/91] fix cmake instructions --- .github/workflows/build-wheels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index af6a799..8ddab33 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -42,7 +42,7 @@ jobs: run: | git clone https://github.com/libarchive/libarchive.git libarchive-src cd libarchive-src; git checkout 3.5 - mkdir build; cd build + mkdir build-libarchive; cd build-libarchive cmake ../ make -j$(nproc); make install cd ../.. From 5cebb52994c66aa3c6b545ee685ec4a8b64588b0 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 18:11:33 +0200 Subject: [PATCH 46/91] syntax error --- .github/workflows/build-wheels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 8ddab33..0bdb197 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -59,7 +59,7 @@ jobs: - name: Build wheels run: | - pyhton -m pip wheel --wheel-dir dist/ . + python3 -m pip wheel --wheel-dir dist/ . auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*.whl From 9d78f86a7d3808c17dba8f11c5455542fa551ea2 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 18:27:37 +0200 Subject: [PATCH 47/91] Fix environemnt for wheel building --- .github/workflows/build-wheels.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 0bdb197..1276ad7 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -59,6 +59,8 @@ jobs: - name: Build wheels run: | + export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH + export LIBARCHIVE_PREFIX=/usr/local python3 -m pip wheel --wheel-dir dist/ . auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*.whl From ce813dd2cb27fefb8fb2499f14b0d8fed2bd03d9 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 1 Aug 2022 20:02:22 +0200 Subject: [PATCH 48/91] Implement arifact upload --- .github/workflows/build-wheels.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 1276ad7..71fa680 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -65,4 +65,10 @@ jobs: auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*.whl + - uses: actions/upload-artifact@v3 + with: + name: python_libarchive_ext-3.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + path: ./wheelhouse/python_libarchive_ext-3.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + + \ No newline at end of file From 7fc18dfd79a2216517192b8e2008f88a51a10385 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 11:10:41 +0200 Subject: [PATCH 49/91] Generate a release --- .github/workflows/build-wheels.yaml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 71fa680..a1e4822 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -65,10 +65,35 @@ jobs: auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*.whl + - name: version + run: | + echo "::set-output name=version::$(python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])'')" + id: version + - uses: actions/upload-artifact@v3 with: - name: python_libarchive_ext-3.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - path: ./wheelhouse/python_libarchive_ext-3.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + name: python_libarchive_ext-${{ steps.version.outputs.version }}-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + path: ./wheelhouse/python_libarchive_ext-${{ steps.version.outputs.version }}-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + - name: release + uses: actions/create-release@v1 + id: create_release + with: + draft: false + prerelease: false + release_name: ${{ steps.version.outputs.version }} + tag_name: ${{ github.ref }} + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: upload artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./wheelhouse/python_libarchive_ext-${{ steps.version.outputs.version }}-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + asset_name: python_libarchive_ext-${{ steps.version.outputs.version }}-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + asset_content_type: application/zip \ No newline at end of file From d7107fd1b1b4acfc4dcf190006bb833e2b02606b Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 11:35:08 +0200 Subject: [PATCH 50/91] Fix version step --- .github/workflows/build-wheels.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index a1e4822..fe726b0 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -20,6 +20,7 @@ jobs: cat /etc/issue echo "Shell: $SHELL" echo "Mount points:"; mount + echo "nproc: $( nproc )" env - name: Chose Python version @@ -67,7 +68,7 @@ jobs: - name: version run: | - echo "::set-output name=version::$(python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])'')" + echo "::set-output name=version::$(python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])')" id: version - uses: actions/upload-artifact@v3 From c987fc4d094754ebae10d994b8cf46fdee8fad24 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 11:57:33 +0200 Subject: [PATCH 51/91] Fix version step --- .github/workflows/build-wheels.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index fe726b0..ab081f2 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -68,6 +68,8 @@ jobs: - name: version run: | + export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH + export LIBARCHIVE_PREFIX=/usr/local echo "::set-output name=version::$(python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])')" id: version From bbb73ab76cbef7e242e474dce0edc6f84871cef3 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 13:18:07 +0200 Subject: [PATCH 52/91] Adding mini test step --- .github/workflows/build-wheels.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index ab081f2..2fe6bf8 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -66,11 +66,17 @@ jobs: auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*.whl + - name Minit test + run: | + strace -e open,openat python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])' \ + | tee strace.out + - name: version run: | export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH export LIBARCHIVE_PREFIX=/usr/local - echo "::set-output name=version::$(python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])')" + + echo "::set-output name=version::$(cd /; python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])')" id: version - uses: actions/upload-artifact@v3 From a18fbc1e3a54fee0a19ca11332151731cd11fc05 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 13:18:50 +0200 Subject: [PATCH 53/91] syntax error fix --- .github/workflows/build-wheels.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 2fe6bf8..f9015ba 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -66,9 +66,9 @@ jobs: auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*.whl - - name Minit test - run: | - strace -e open,openat python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])' \ + - name: Minit test + run: | + strace -e open,openat python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])' \ | tee strace.out - name: version From 13180b370bec9e1b0f541a39b6e7de23b0dc7bab Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 13:29:59 +0200 Subject: [PATCH 54/91] Run minitest from /tmp --- .github/workflows/build-wheels.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index f9015ba..0ae1d0f 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -66,8 +66,9 @@ jobs: auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*.whl - - name: Minit test + - name: Mini test run: | + cd /tmp strace -e open,openat python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])' \ | tee strace.out From 42a487e7814ae2a7ab753b85e034c8039503311f Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 14:18:38 +0200 Subject: [PATCH 55/91] Debugging workflow --- .github/workflows/build-wheels.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 0ae1d0f..305070d 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -12,6 +12,11 @@ jobs: runs-on: ubuntu-latest container: quay.io/pypa/manylinux2014_x86_64 steps: + - name: Status + run: | + git status + ls -lR + - uses: actions/checkout@v2 - name: Print System Information @@ -69,8 +74,9 @@ jobs: - name: Mini test run: | cd /tmp - strace -e open,openat python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])' \ + python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])' \ | tee strace.out + - name: version run: | From e11c498291aad351652984cc7ebbccb3182f3217 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 14:33:58 +0200 Subject: [PATCH 56/91] Fixes for version number verification --- .github/workflows/build-wheels.yaml | 11 ++++------- libarchive/__init__.py | 4 ++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 305070d..5e0c756 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -12,11 +12,6 @@ jobs: runs-on: ubuntu-latest container: quay.io/pypa/manylinux2014_x86_64 steps: - - name: Status - run: | - git status - ls -lR - - uses: actions/checkout@v2 - name: Print System Information @@ -74,9 +69,11 @@ jobs: - name: Mini test run: | cd /tmp - python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])' \ + python3 -c 'import libarchive; print(libarchive.version())' \ | tee strace.out - + find / -name 'libarchive*.so' | xargs ls -l + find / -name 'libarchive*.so' | xargs strings | grep 'libarchive' + - name: version run: | diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 8ad5653..7af2342 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -94,6 +94,10 @@ class EOF(Exception): pass +def version(): + '''Returns the version of the libarchive library.''' + return _libarchive.ARCHIVE_VERSION_STRING.split()[1] + def get_error(archive): '''Retrieves the last error description for the given archive instance.''' From e2a0d6e33604b6743b63bd8b79258a2869523575 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 17:20:40 +0200 Subject: [PATCH 57/91] Compile flag fixes --- libarchive/archive.h | 459 +++++++++++++++++++++++++++++-------- libarchive/archive_entry.h | 186 +++++++++++---- setup.py | 2 +- 3 files changed, 508 insertions(+), 139 deletions(-) diff --git a/libarchive/archive.h b/libarchive/archive.h index d5316ca..d5d6f93 100644 --- a/libarchive/archive.h +++ b/libarchive/archive.h @@ -28,9 +28,20 @@ #ifndef ARCHIVE_H_INCLUDED #define ARCHIVE_H_INCLUDED +/* + * The version number is expressed as a single integer that makes it + * easy to compare versions at build time: for version a.b.c, the + * version number is printf("%d%03d%03d",a,b,c). For example, if you + * know your application requires version 2.12.108 or later, you can + * assert that ARCHIVE_VERSION_NUMBER >= 2012108. + */ +/* Note: Compiler will complain if this does not match archive_entry.h! */ +#define ARCHIVE_VERSION_NUMBER 3005003 + #include #include /* for wchar_t */ #include /* For FILE * */ +#include /* For time_t */ /* * Note: archive.h is for use outside of libarchive; the configuration @@ -41,29 +52,53 @@ */ #if defined(__BORLANDC__) && __BORLANDC__ >= 0x560 # include -#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) +#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__) && !defined(__CLANG_INTTYPES_H) # include #endif -/* Get appropriate definitions of standard POSIX-style types. */ -/* These should match the types used in 'struct stat' */ -#if defined(_WIN32) && !defined(__CYGWIN__) -# define __LA_INT64_T __int64 -# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_) -# define __LA_SSIZE_T ssize_t -# elif defined(_WIN64) -# define __LA_SSIZE_T __int64 -# else -# define __LA_SSIZE_T long +/* Get appropriate definitions of 64-bit integer */ +#if !defined(__LA_INT64_T_DEFINED) +/* Older code relied on the __LA_INT64_T macro; after 4.0 we'll switch to the typedef exclusively. */ +# if ARCHIVE_VERSION_NUMBER < 4000000 +#define __LA_INT64_T la_int64_t # endif -#else +#define __LA_INT64_T_DEFINED +# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) +typedef __int64 la_int64_t; +# else # include /* ssize_t */ -# if defined(_SCO_DS) -# define __LA_INT64_T long long +# if defined(_SCO_DS) || defined(__osf__) +typedef long long la_int64_t; +# else +typedef int64_t la_int64_t; +# endif +# endif +#endif + +/* The la_ssize_t should match the type used in 'struct stat' */ +#if !defined(__LA_SSIZE_T_DEFINED) +/* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */ +# if ARCHIVE_VERSION_NUMBER < 4000000 +#define __LA_SSIZE_T la_ssize_t +# endif +#define __LA_SSIZE_T_DEFINED +# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) +# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_) +typedef ssize_t la_ssize_t; +# elif defined(_WIN64) +typedef __int64 la_ssize_t; +# else +typedef long la_ssize_t; +# endif # else -# define __LA_INT64_T int64_t +# include /* ssize_t */ +typedef ssize_t la_ssize_t; # endif -# define __LA_SSIZE_T ssize_t +#endif + +/* Large file support for Android */ +#ifdef __ANDROID__ +#include "android_lf.h" #endif /* @@ -97,6 +132,12 @@ #define __LA_PRINTF(fmtarg, firstvararg) /* nothing */ #endif +#if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1 +# define __LA_DEPRECATED __attribute__((deprecated)) +#else +# define __LA_DEPRECATED +#endif + #ifdef __cplusplus extern "C" { #endif @@ -109,24 +150,35 @@ extern "C" { * header and library are very different, you should expect some * strangeness. Don't do that. */ - -/* - * The version number is expressed as a single integer that makes it - * easy to compare versions at build time: for version a.b.c, the - * version number is printf("%d%03d%03d",a,b,c). For example, if you - * know your application requires version 2.12.108 or later, you can - * assert that ARCHIVE_VERSION_NUMBER >= 2012108. - */ -/* Note: Compiler will complain if this does not match archive_entry.h! */ -#define ARCHIVE_VERSION_NUMBER 3000004 __LA_DECL int archive_version_number(void); /* * Textual name/version of the library, useful for version displays. */ -#define ARCHIVE_VERSION_STRING "libarchive 3.0.4" +#define ARCHIVE_VERSION_ONLY_STRING "3.5.3" +#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING __LA_DECL const char * archive_version_string(void); +/* + * Detailed textual name/version of the library and its dependencies. + * This has the form: + * "libarchive x.y.z zlib/a.b.c liblzma/d.e.f ... etc ..." + * the list of libraries described here will vary depending on how + * libarchive was compiled. + */ +__LA_DECL const char * archive_version_details(void); + +/* + * Returns NULL if libarchive was compiled without the associated library. + * Otherwise, returns the version number that libarchive was compiled + * against. + */ +__LA_DECL const char * archive_zlib_version(void); +__LA_DECL const char * archive_liblzma_version(void); +__LA_DECL const char * archive_bzlib_version(void); +__LA_DECL const char * archive_liblz4_version(void); +__LA_DECL const char * archive_libzstd_version(void); + /* Declare our basic types. */ struct archive; struct archive_entry; @@ -167,7 +219,7 @@ struct archive_entry; */ /* Returns pointer and size of next block of data from archive. */ -typedef __LA_SSIZE_T archive_read_callback(struct archive *, +typedef la_ssize_t archive_read_callback(struct archive *, void *_client_data, const void **_buffer); /* Skips at most request bytes from archive and returns the skipped amount. @@ -175,18 +227,18 @@ typedef __LA_SSIZE_T archive_read_callback(struct archive *, * If you do skip fewer bytes than requested, libarchive will invoke your * read callback and discard data as necessary to make up the full skip. */ -typedef __LA_INT64_T archive_skip_callback(struct archive *, - void *_client_data, __LA_INT64_T request); +typedef la_int64_t archive_skip_callback(struct archive *, + void *_client_data, la_int64_t request); /* Seeks to specified location in the file and returns the position. * Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h. * Return ARCHIVE_FATAL if the seek fails for any reason. */ -typedef __LA_INT64_T archive_seek_callback(struct archive *, - void *_client_data, __LA_INT64_T offset, int whence); +typedef la_int64_t archive_seek_callback(struct archive *, + void *_client_data, la_int64_t offset, int whence); /* Returns size actually written, zero on EOF, -1 on error. */ -typedef __LA_SSIZE_T archive_write_callback(struct archive *, +typedef la_ssize_t archive_write_callback(struct archive *, void *_client_data, const void *_buffer, size_t _length); @@ -194,6 +246,22 @@ typedef int archive_open_callback(struct archive *, void *_client_data); typedef int archive_close_callback(struct archive *, void *_client_data); +typedef int archive_free_callback(struct archive *, void *_client_data); + +/* Switches from one client data object to the next/prev client data object. + * This is useful for reading from different data blocks such as a set of files + * that make up one large file. + */ +typedef int archive_switch_callback(struct archive *, void *_client_data1, + void *_client_data2); + +/* + * Returns a passphrase used for encryption or decryption, NULL on nothing + * to do and give it up. + */ +typedef const char *archive_passphrase_callback(struct archive *, + void *_client_data); + /* * Codes to identify various stream filters. */ @@ -207,6 +275,11 @@ typedef int archive_close_callback(struct archive *, void *_client_data); #define ARCHIVE_FILTER_UU 7 #define ARCHIVE_FILTER_RPM 8 #define ARCHIVE_FILTER_LZIP 9 +#define ARCHIVE_FILTER_LRZIP 10 +#define ARCHIVE_FILTER_LZOP 11 +#define ARCHIVE_FILTER_GRZIP 12 +#define ARCHIVE_FILTER_LZ4 13 +#define ARCHIVE_FILTER_ZSTD 14 #if ARCHIVE_VERSION_NUMBER < 4000000 #define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE @@ -219,6 +292,7 @@ typedef int archive_close_callback(struct archive *, void *_client_data); #define ARCHIVE_COMPRESSION_UU ARCHIVE_FILTER_UU #define ARCHIVE_COMPRESSION_RPM ARCHIVE_FILTER_RPM #define ARCHIVE_COMPRESSION_LZIP ARCHIVE_FILTER_LZIP +#define ARCHIVE_COMPRESSION_LRZIP ARCHIVE_FILTER_LRZIP #endif /* @@ -245,6 +319,7 @@ typedef int archive_close_callback(struct archive *, void *_client_data); #define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4) #define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5) #define ARCHIVE_FORMAT_CPIO_AFIO_LARGE (ARCHIVE_FORMAT_CPIO | 6) +#define ARCHIVE_FORMAT_CPIO_PWB (ARCHIVE_FORMAT_CPIO | 7) #define ARCHIVE_FORMAT_SHAR 0x20000 #define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1) #define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2) @@ -267,6 +342,32 @@ typedef int archive_close_callback(struct archive *, void *_client_data); #define ARCHIVE_FORMAT_CAB 0xC0000 #define ARCHIVE_FORMAT_RAR 0xD0000 #define ARCHIVE_FORMAT_7ZIP 0xE0000 +#define ARCHIVE_FORMAT_WARC 0xF0000 +#define ARCHIVE_FORMAT_RAR_V5 0x100000 + +/* + * Codes returned by archive_read_format_capabilities(). + * + * This list can be extended with values between 0 and 0xffff. + * The original purpose of this list was to let different archive + * format readers expose their general capabilities in terms of + * encryption. + */ +#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */ +#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */ +#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */ + +/* + * Codes returned by archive_read_has_encrypted_entries(). + * + * In case the archive does not support encryption detection at all + * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader + * for some other reason (e.g. not enough bytes read) cannot say if + * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW + * is returned. + */ +#define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2 +#define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1 /*- * Basic outline for reading an archive: @@ -278,7 +379,7 @@ typedef int archive_close_callback(struct archive *, void *_client_data); * 4) Repeatedly call archive_read_next_header to get information about * successive archive entries. Call archive_read_data to extract * data for entries of interest. - * 5) Call archive_read_finish to end processing. + * 5) Call archive_read_free to end processing. */ __LA_DECL struct archive *archive_read_new(void); @@ -291,40 +392,55 @@ __LA_DECL struct archive *archive_read_new(void); */ #if ARCHIVE_VERSION_NUMBER < 4000000 -__LA_DECL int archive_read_support_compression_all(struct archive *); -__LA_DECL int archive_read_support_compression_bzip2(struct archive *); -__LA_DECL int archive_read_support_compression_compress(struct archive *); -__LA_DECL int archive_read_support_compression_gzip(struct archive *); -__LA_DECL int archive_read_support_compression_lzip(struct archive *); -__LA_DECL int archive_read_support_compression_lzma(struct archive *); -__LA_DECL int archive_read_support_compression_none(struct archive *); +__LA_DECL int archive_read_support_compression_all(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_read_support_compression_bzip2(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_read_support_compression_compress(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_read_support_compression_gzip(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_read_support_compression_lzip(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_read_support_compression_lzma(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_read_support_compression_none(struct archive *) + __LA_DEPRECATED; __LA_DECL int archive_read_support_compression_program(struct archive *, - const char *command); + const char *command) __LA_DEPRECATED; __LA_DECL int archive_read_support_compression_program_signature (struct archive *, const char *, - const void * /* match */, size_t); - -__LA_DECL int archive_read_support_compression_rpm(struct archive *); -__LA_DECL int archive_read_support_compression_uu(struct archive *); -__LA_DECL int archive_read_support_compression_xz(struct archive *); + const void * /* match */, size_t) __LA_DEPRECATED; + +__LA_DECL int archive_read_support_compression_rpm(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_read_support_compression_uu(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_read_support_compression_xz(struct archive *) + __LA_DEPRECATED; #endif __LA_DECL int archive_read_support_filter_all(struct archive *); +__LA_DECL int archive_read_support_filter_by_code(struct archive *, int); __LA_DECL int archive_read_support_filter_bzip2(struct archive *); __LA_DECL int archive_read_support_filter_compress(struct archive *); __LA_DECL int archive_read_support_filter_gzip(struct archive *); +__LA_DECL int archive_read_support_filter_grzip(struct archive *); +__LA_DECL int archive_read_support_filter_lrzip(struct archive *); +__LA_DECL int archive_read_support_filter_lz4(struct archive *); __LA_DECL int archive_read_support_filter_lzip(struct archive *); __LA_DECL int archive_read_support_filter_lzma(struct archive *); +__LA_DECL int archive_read_support_filter_lzop(struct archive *); __LA_DECL int archive_read_support_filter_none(struct archive *); __LA_DECL int archive_read_support_filter_program(struct archive *, const char *command); __LA_DECL int archive_read_support_filter_program_signature - (struct archive *, const char *, + (struct archive *, const char * /* cmd */, const void * /* match */, size_t); - __LA_DECL int archive_read_support_filter_rpm(struct archive *); __LA_DECL int archive_read_support_filter_uu(struct archive *); __LA_DECL int archive_read_support_filter_xz(struct archive *); +__LA_DECL int archive_read_support_filter_zstd(struct archive *); __LA_DECL int archive_read_support_format_7zip(struct archive *); __LA_DECL int archive_read_support_format_all(struct archive *); @@ -338,10 +454,31 @@ __LA_DECL int archive_read_support_format_iso9660(struct archive *); __LA_DECL int archive_read_support_format_lha(struct archive *); __LA_DECL int archive_read_support_format_mtree(struct archive *); __LA_DECL int archive_read_support_format_rar(struct archive *); +__LA_DECL int archive_read_support_format_rar5(struct archive *); __LA_DECL int archive_read_support_format_raw(struct archive *); __LA_DECL int archive_read_support_format_tar(struct archive *); +__LA_DECL int archive_read_support_format_warc(struct archive *); __LA_DECL int archive_read_support_format_xar(struct archive *); +/* archive_read_support_format_zip() enables both streamable and seekable + * zip readers. */ __LA_DECL int archive_read_support_format_zip(struct archive *); +/* Reads Zip archives as stream from beginning to end. Doesn't + * correctly handle SFX ZIP files or ZIP archives that have been modified + * in-place. */ +__LA_DECL int archive_read_support_format_zip_streamable(struct archive *); +/* Reads starting from central directory; requires seekable input. */ +__LA_DECL int archive_read_support_format_zip_seekable(struct archive *); + +/* Functions to manually set the format and filters to be used. This is + * useful to bypass the bidding process when the format and filters to use + * is known in advance. + */ +__LA_DECL int archive_read_set_format(struct archive *, int); +__LA_DECL int archive_read_append_filter(struct archive *, int); +__LA_DECL int archive_read_append_filter_program(struct archive *, + const char *); +__LA_DECL int archive_read_append_filter_program_signature + (struct archive *, const char *, const void * /* match */, size_t); /* Set various callbacks. */ __LA_DECL int archive_read_set_open_callback(struct archive *, @@ -354,8 +491,23 @@ __LA_DECL int archive_read_set_skip_callback(struct archive *, archive_skip_callback *); __LA_DECL int archive_read_set_close_callback(struct archive *, archive_close_callback *); -/* The callback data is provided to all of the callbacks above. */ +/* Callback used to switch between one data object to the next */ +__LA_DECL int archive_read_set_switch_callback(struct archive *, + archive_switch_callback *); + +/* This sets the first data object. */ __LA_DECL int archive_read_set_callback_data(struct archive *, void *); +/* This sets data object at specified index */ +__LA_DECL int archive_read_set_callback_data2(struct archive *, void *, + unsigned int); +/* This adds a data object at the specified index. */ +__LA_DECL int archive_read_add_callback_data(struct archive *, void *, + unsigned int); +/* This appends a data object to the end of list */ +__LA_DECL int archive_read_append_callback_data(struct archive *, void *); +/* This prepends a data object to the beginning of list */ +__LA_DECL int archive_read_prepend_callback_data(struct archive *, void *); + /* Opening freezes the callbacks. */ __LA_DECL int archive_read_open1(struct archive *); @@ -375,16 +527,20 @@ __LA_DECL int archive_read_open2(struct archive *, void *_client_data, /* Use this if you know the filename. Note: NULL indicates stdin. */ __LA_DECL int archive_read_open_filename(struct archive *, const char *_filename, size_t _block_size); +/* Use this for reading multivolume files by filenames. + * NOTE: Must be NULL terminated. Sorting is NOT done. */ +__LA_DECL int archive_read_open_filenames(struct archive *, + const char **_filenames, size_t _block_size); __LA_DECL int archive_read_open_filename_w(struct archive *, const wchar_t *_filename, size_t _block_size); /* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */ __LA_DECL int archive_read_open_file(struct archive *, - const char *_filename, size_t _block_size); + const char *_filename, size_t _block_size) __LA_DEPRECATED; /* Read an archive that's stored in memory. */ __LA_DECL int archive_read_open_memory(struct archive *, - void * buff, size_t size); + const void * buff, size_t size); /* A more involved version that is only used for internal testing. */ -__LA_DECL int archive_read_open_memory2(struct archive *a, void *buff, +__LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff, size_t size, size_t read_size); /* Read an archive that's already open, using the file descriptor. */ __LA_DECL int archive_read_open_fd(struct archive *, int _fd, @@ -405,12 +561,41 @@ __LA_DECL int archive_read_next_header2(struct archive *, * Retrieve the byte offset in UNCOMPRESSED data where last-read * header started. */ -__LA_DECL __LA_INT64_T archive_read_header_position(struct archive *); +__LA_DECL la_int64_t archive_read_header_position(struct archive *); + +/* + * Returns 1 if the archive contains at least one encrypted entry. + * If the archive format not support encryption at all + * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. + * If for any other reason (e.g. not enough data read so far) + * we cannot say whether there are encrypted entries, then + * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned. + * In general, this function will return values below zero when the + * reader is uncertain or totally incapable of encryption support. + * When this function returns 0 you can be sure that the reader + * supports encryption detection but no encrypted entries have + * been found yet. + * + * NOTE: If the metadata/header of an archive is also encrypted, you + * cannot rely on the number of encrypted entries. That is why this + * function does not return the number of encrypted entries but# + * just shows that there are some. + */ +__LA_DECL int archive_read_has_encrypted_entries(struct archive *); + +/* + * Returns a bitmask of capabilities that are supported by the archive format reader. + * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned. + */ +__LA_DECL int archive_read_format_capabilities(struct archive *); /* Read data from the body of an entry. Similar to read(2). */ -__LA_DECL __LA_SSIZE_T archive_read_data(struct archive *, +__LA_DECL la_ssize_t archive_read_data(struct archive *, void *, size_t); +/* Seek within the body of an entry. Similar to lseek(2). */ +__LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int); + /* * A zero-copy version of archive_read_data that also exposes the file offset * of each returned block. Note that the client has no way to specify @@ -418,7 +603,7 @@ __LA_DECL __LA_SSIZE_T archive_read_data(struct archive *, * be strictly increasing and that returned blocks will not overlap. */ __LA_DECL int archive_read_data_block(struct archive *a, - const void **buff, size_t *size, __LA_INT64_T *offset); + const void **buff, size_t *size, la_int64_t *offset); /*- * Some convenience functions that are built on archive_read_data: @@ -448,6 +633,14 @@ __LA_DECL int archive_read_set_option(struct archive *_a, __LA_DECL int archive_read_set_options(struct archive *_a, const char *opts); +/* + * Add a decryption passphrase. + */ +__LA_DECL int archive_read_add_passphrase(struct archive *, const char *); +__LA_DECL int archive_read_set_passphrase_callback(struct archive *, + void *client_data, archive_passphrase_callback *); + + /*- * Convenience function to recreate the current entry (whose header * has just been read) on disk. @@ -494,6 +687,18 @@ __LA_DECL int archive_read_set_options(struct archive *_a, /* Default: Do not restore Mac extended metadata. */ /* This has no effect except on Mac OS. */ #define ARCHIVE_EXTRACT_MAC_METADATA (0x2000) +/* Default: Use HFS+ compression if it was compressed. */ +/* This has no effect except on Mac OS v10.6 or later. */ +#define ARCHIVE_EXTRACT_NO_HFS_COMPRESSION (0x4000) +/* Default: Do not use HFS+ compression if it was not compressed. */ +/* This has no effect except on Mac OS v10.6 or later. */ +#define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000) +/* Default: Do not reject entries with absolute paths */ +#define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000) +/* Default: Do not clear no-change flags when unlinking object */ +#define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS (0x20000) +/* Default: Do not extract atomically (using rename) */ +#define ARCHIVE_EXTRACT_SAFE_WRITES (0x40000) __LA_DECL int archive_read_extract(struct archive *, struct archive_entry *, int flags); @@ -505,7 +710,7 @@ __LA_DECL void archive_read_extract_set_progress_callback(struct archive *, /* Record the dev/ino of a file that will not be written. This is * generally set to the dev/ino of the archive being read. */ __LA_DECL void archive_read_extract_set_skip_file(struct archive *, - __LA_INT64_T, __LA_INT64_T); + la_int64_t, la_int64_t); /* Close the file and release most resources. */ __LA_DECL int archive_read_close(struct archive *); @@ -514,7 +719,7 @@ __LA_DECL int archive_read_close(struct archive *); __LA_DECL int archive_read_free(struct archive *); #if ARCHIVE_VERSION_NUMBER < 4000000 /* Synonym for archive_read_free() for backwards compatibility. */ -__LA_DECL int archive_read_finish(struct archive *); +__LA_DECL int archive_read_finish(struct archive *) __LA_DEPRECATED; #endif /*- @@ -544,31 +749,47 @@ __LA_DECL int archive_write_get_bytes_in_last_block(struct archive *); /* The dev/ino of a file that won't be archived. This is used * to avoid recursively adding an archive to itself. */ __LA_DECL int archive_write_set_skip_file(struct archive *, - __LA_INT64_T, __LA_INT64_T); + la_int64_t, la_int64_t); #if ARCHIVE_VERSION_NUMBER < 4000000 -__LA_DECL int archive_write_set_compression_bzip2(struct archive *); -__LA_DECL int archive_write_set_compression_compress(struct archive *); -__LA_DECL int archive_write_set_compression_gzip(struct archive *); -__LA_DECL int archive_write_set_compression_lzip(struct archive *); -__LA_DECL int archive_write_set_compression_lzma(struct archive *); -__LA_DECL int archive_write_set_compression_none(struct archive *); +__LA_DECL int archive_write_set_compression_bzip2(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_write_set_compression_compress(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_write_set_compression_gzip(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_write_set_compression_lzip(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_write_set_compression_lzma(struct archive *) + __LA_DEPRECATED; +__LA_DECL int archive_write_set_compression_none(struct archive *) + __LA_DEPRECATED; __LA_DECL int archive_write_set_compression_program(struct archive *, - const char *cmd); -__LA_DECL int archive_write_set_compression_xz(struct archive *); + const char *cmd) __LA_DEPRECATED; +__LA_DECL int archive_write_set_compression_xz(struct archive *) + __LA_DEPRECATED; #endif /* A convenience function to set the filter based on the code. */ __LA_DECL int archive_write_add_filter(struct archive *, int filter_code); +__LA_DECL int archive_write_add_filter_by_name(struct archive *, + const char *name); +__LA_DECL int archive_write_add_filter_b64encode(struct archive *); __LA_DECL int archive_write_add_filter_bzip2(struct archive *); __LA_DECL int archive_write_add_filter_compress(struct archive *); +__LA_DECL int archive_write_add_filter_grzip(struct archive *); __LA_DECL int archive_write_add_filter_gzip(struct archive *); +__LA_DECL int archive_write_add_filter_lrzip(struct archive *); +__LA_DECL int archive_write_add_filter_lz4(struct archive *); __LA_DECL int archive_write_add_filter_lzip(struct archive *); __LA_DECL int archive_write_add_filter_lzma(struct archive *); +__LA_DECL int archive_write_add_filter_lzop(struct archive *); __LA_DECL int archive_write_add_filter_none(struct archive *); __LA_DECL int archive_write_add_filter_program(struct archive *, const char *cmd); +__LA_DECL int archive_write_add_filter_uuencode(struct archive *); __LA_DECL int archive_write_add_filter_xz(struct archive *); +__LA_DECL int archive_write_add_filter_zstd(struct archive *); /* A convenience function to set the format based on the code or name. */ @@ -580,27 +801,43 @@ __LA_DECL int archive_write_set_format_7zip(struct archive *); __LA_DECL int archive_write_set_format_ar_bsd(struct archive *); __LA_DECL int archive_write_set_format_ar_svr4(struct archive *); __LA_DECL int archive_write_set_format_cpio(struct archive *); +__LA_DECL int archive_write_set_format_cpio_bin(struct archive *); __LA_DECL int archive_write_set_format_cpio_newc(struct archive *); +__LA_DECL int archive_write_set_format_cpio_odc(struct archive *); +__LA_DECL int archive_write_set_format_cpio_pwb(struct archive *); __LA_DECL int archive_write_set_format_gnutar(struct archive *); __LA_DECL int archive_write_set_format_iso9660(struct archive *); __LA_DECL int archive_write_set_format_mtree(struct archive *); +__LA_DECL int archive_write_set_format_mtree_classic(struct archive *); /* TODO: int archive_write_set_format_old_tar(struct archive *); */ __LA_DECL int archive_write_set_format_pax(struct archive *); __LA_DECL int archive_write_set_format_pax_restricted(struct archive *); +__LA_DECL int archive_write_set_format_raw(struct archive *); __LA_DECL int archive_write_set_format_shar(struct archive *); __LA_DECL int archive_write_set_format_shar_dump(struct archive *); __LA_DECL int archive_write_set_format_ustar(struct archive *); +__LA_DECL int archive_write_set_format_v7tar(struct archive *); +__LA_DECL int archive_write_set_format_warc(struct archive *); __LA_DECL int archive_write_set_format_xar(struct archive *); __LA_DECL int archive_write_set_format_zip(struct archive *); +__LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename); +__LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext); +__LA_DECL int archive_write_zip_set_compression_deflate(struct archive *); +__LA_DECL int archive_write_zip_set_compression_store(struct archive *); +/* Deprecated; use archive_write_open2 instead */ __LA_DECL int archive_write_open(struct archive *, void *, archive_open_callback *, archive_write_callback *, archive_close_callback *); +__LA_DECL int archive_write_open2(struct archive *, void *, + archive_open_callback *, archive_write_callback *, + archive_close_callback *, archive_free_callback *); __LA_DECL int archive_write_open_fd(struct archive *, int _fd); __LA_DECL int archive_write_open_filename(struct archive *, const char *_file); __LA_DECL int archive_write_open_filename_w(struct archive *, const wchar_t *_file); /* A deprecated synonym for archive_write_open_filename() */ -__LA_DECL int archive_write_open_file(struct archive *, const char *_file); +__LA_DECL int archive_write_open_file(struct archive *, const char *_file) + __LA_DEPRECATED; __LA_DECL int archive_write_open_FILE(struct archive *, FILE *); /* _buffSize is the size of the buffer, _used refers to a variable that * will be updated after each write into the buffer. */ @@ -613,21 +850,25 @@ __LA_DECL int archive_write_open_memory(struct archive *, */ __LA_DECL int archive_write_header(struct archive *, struct archive_entry *); -__LA_DECL __LA_SSIZE_T archive_write_data(struct archive *, +__LA_DECL la_ssize_t archive_write_data(struct archive *, const void *, size_t); /* This interface is currently only available for archive_write_disk handles. */ -__LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *, - const void *, size_t, __LA_INT64_T); +__LA_DECL la_ssize_t archive_write_data_block(struct archive *, + const void *, size_t, la_int64_t); __LA_DECL int archive_write_finish_entry(struct archive *); __LA_DECL int archive_write_close(struct archive *); +/* Marks the archive as FATAL so that a subsequent free() operation + * won't try to close() cleanly. Provides a fast abort capability + * when the client discovers that things have gone wrong. */ +__LA_DECL int archive_write_fail(struct archive *); /* This can fail if the archive wasn't already closed, in which case * archive_write_free() will implicitly call archive_write_close(). */ __LA_DECL int archive_write_free(struct archive *); #if ARCHIVE_VERSION_NUMBER < 4000000 /* Synonym for archive_write_free() for backwards compatibility. */ -__LA_DECL int archive_write_finish(struct archive *); +__LA_DECL int archive_write_finish(struct archive *) __LA_DEPRECATED; #endif /* @@ -649,6 +890,13 @@ __LA_DECL int archive_write_set_option(struct archive *_a, __LA_DECL int archive_write_set_options(struct archive *_a, const char *opts); +/* + * Set a encryption passphrase. + */ +__LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p); +__LA_DECL int archive_write_set_passphrase_callback(struct archive *, + void *client_data, archive_passphrase_callback *); + /*- * ARCHIVE_WRITE_DISK API * @@ -668,7 +916,7 @@ __LA_DECL int archive_write_set_options(struct archive *_a, __LA_DECL struct archive *archive_write_disk_new(void); /* This file will not be overwritten. */ __LA_DECL int archive_write_disk_set_skip_file(struct archive *, - __LA_INT64_T, __LA_INT64_T); + la_int64_t, la_int64_t); /* Set flags to control how the next item gets created. * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */ __LA_DECL int archive_write_disk_set_options(struct archive *, @@ -698,14 +946,14 @@ __LA_DECL int archive_write_disk_set_standard_lookup(struct archive *); */ __LA_DECL int archive_write_disk_set_group_lookup(struct archive *, void * /* private_data */, - __LA_INT64_T (*)(void *, const char *, __LA_INT64_T), + la_int64_t (*)(void *, const char *, la_int64_t), void (* /* cleanup */)(void *)); __LA_DECL int archive_write_disk_set_user_lookup(struct archive *, void * /* private_data */, - __LA_INT64_T (*)(void *, const char *, __LA_INT64_T), + la_int64_t (*)(void *, const char *, la_int64_t), void (* /* cleanup */)(void *)); -__LA_DECL __LA_INT64_T archive_write_disk_gid(struct archive *, const char *, __LA_INT64_T); -__LA_DECL __LA_INT64_T archive_write_disk_uid(struct archive *, const char *, __LA_INT64_T); +__LA_DECL la_int64_t archive_write_disk_gid(struct archive *, const char *, la_int64_t); +__LA_DECL la_int64_t archive_write_disk_uid(struct archive *, const char *, la_int64_t); /* * ARCHIVE_READ_DISK API @@ -726,19 +974,19 @@ __LA_DECL int archive_read_disk_entry_from_file(struct archive *, struct archive_entry *, int /* fd */, const struct stat *); /* Look up gname for gid or uname for uid. */ /* Default implementations are very, very stupid. */ -__LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_INT64_T); -__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_INT64_T); +__LA_DECL const char *archive_read_disk_gname(struct archive *, la_int64_t); +__LA_DECL const char *archive_read_disk_uname(struct archive *, la_int64_t); /* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the * results for performance. */ __LA_DECL int archive_read_disk_set_standard_lookup(struct archive *); /* You can install your own lookups if you like. */ __LA_DECL int archive_read_disk_set_gname_lookup(struct archive *, void * /* private_data */, - const char *(* /* lookup_fn */)(void *, __LA_INT64_T), + const char *(* /* lookup_fn */)(void *, la_int64_t), void (* /* cleanup_fn */)(void *)); __LA_DECL int archive_read_disk_set_uname_lookup(struct archive *, void * /* private_data */, - const char *(* /* lookup_fn */)(void *, __LA_INT64_T), + const char *(* /* lookup_fn */)(void *, la_int64_t), void (* /* cleanup_fn */)(void *)); /* Start traversal. */ __LA_DECL int archive_read_disk_open(struct archive *, const char *); @@ -755,12 +1003,12 @@ __LA_DECL int archive_read_disk_can_descend(struct archive *); __LA_DECL int archive_read_disk_current_filesystem(struct archive *); __LA_DECL int archive_read_disk_current_filesystem_is_synthetic(struct archive *); __LA_DECL int archive_read_disk_current_filesystem_is_remote(struct archive *); -/* Request that the access time of the entry visited by travesal be restored. */ +/* Request that the access time of the entry visited by traversal be restored. */ __LA_DECL int archive_read_disk_set_atime_restored(struct archive *); /* * Set behavior. The "flags" argument selects optional behavior. */ -/* Request that the access time of the entry visited by travesal be restored. +/* Request that the access time of the entry visited by traversal be restored. * This is the same as archive_read_disk_set_atime_restored. */ #define ARCHIVE_READDISK_RESTORE_ATIME (0x0001) /* Default: Do not skip an entry which has nodump flags. */ @@ -768,8 +1016,14 @@ __LA_DECL int archive_read_disk_set_atime_restored(struct archive *); /* Default: Skip a mac resource fork file whose prefix is "._" because of * using copyfile. */ #define ARCHIVE_READDISK_MAC_COPYFILE (0x0004) -/* Default: Do not traverse mount points. */ +/* Default: Traverse mount points. */ #define ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS (0x0008) +/* Default: Xattrs are read from disk. */ +#define ARCHIVE_READDISK_NO_XATTR (0x0010) +/* Default: ACLs are read from disk. */ +#define ARCHIVE_READDISK_NO_ACL (0x0020) +/* Default: File flags are read from disk. */ +#define ARCHIVE_READDISK_NO_FFLAGS (0x0040) __LA_DECL int archive_read_disk_set_behavior(struct archive *, int flags); @@ -788,6 +1042,10 @@ __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *, int (*_metadata_filter_func)(struct archive *, void *, struct archive_entry *), void *_client_data); +/* Simplified cleanup interface; + * This calls archive_read_free() or archive_write_free() as needed. */ +__LA_DECL int archive_free(struct archive *); + /* * Accessor functions to read/set various information in * the struct archive object: @@ -798,7 +1056,7 @@ __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *, * last filter, which is always the pseudo-filter that wraps the * client callbacks. */ __LA_DECL int archive_filter_count(struct archive *); -__LA_DECL __LA_INT64_T archive_filter_bytes(struct archive *, int); +__LA_DECL la_int64_t archive_filter_bytes(struct archive *, int); __LA_DECL int archive_filter_code(struct archive *, int); __LA_DECL const char * archive_filter_name(struct archive *, int); @@ -806,13 +1064,17 @@ __LA_DECL const char * archive_filter_name(struct archive *, int); /* These don't properly handle multiple filters, so are deprecated and * will eventually be removed. */ /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */ -__LA_DECL __LA_INT64_T archive_position_compressed(struct archive *); +__LA_DECL la_int64_t archive_position_compressed(struct archive *) + __LA_DEPRECATED; /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */ -__LA_DECL __LA_INT64_T archive_position_uncompressed(struct archive *); +__LA_DECL la_int64_t archive_position_uncompressed(struct archive *) + __LA_DEPRECATED; /* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */ -__LA_DECL const char *archive_compression_name(struct archive *); +__LA_DECL const char *archive_compression_name(struct archive *) + __LA_DEPRECATED; /* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */ -__LA_DECL int archive_compression(struct archive *); +__LA_DECL int archive_compression(struct archive *) + __LA_DEPRECATED; #endif __LA_DECL int archive_errno(struct archive *); @@ -846,6 +1108,8 @@ __LA_DECL int archive_match_excluded(struct archive *, */ __LA_DECL int archive_match_path_excluded(struct archive *, struct archive_entry *); +/* Control recursive inclusion of directory content when directory is included. Default on. */ +__LA_DECL int archive_match_set_inclusion_recursion(struct archive *, int); /* Add exclusion pathname pattern. */ __LA_DECL int archive_match_exclude_pattern(struct archive *, const char *); __LA_DECL int archive_match_exclude_pattern_w(struct archive *, @@ -885,7 +1149,7 @@ __LA_DECL int archive_match_time_excluded(struct archive *, /* * Flags to tell a matching type of time stamps. These are used for - * following functinos. + * following functions. */ /* Time flag: mtime to be tested. */ #define ARCHIVE_MATCH_MTIME (0x0100) @@ -905,7 +1169,7 @@ __LA_DECL int archive_match_include_date(struct archive *, int _flag, const char *_datestr); __LA_DECL int archive_match_include_date_w(struct archive *, int _flag, const wchar_t *_datestr); -/* Set inclusion time by a particluar file. */ +/* Set inclusion time by a particular file. */ __LA_DECL int archive_match_include_file_time(struct archive *, int _flag, const char *_pathname); __LA_DECL int archive_match_include_file_time_w(struct archive *, @@ -921,8 +1185,8 @@ __LA_DECL int archive_match_exclude_entry(struct archive *, __LA_DECL int archive_match_owner_excluded(struct archive *, struct archive_entry *); /* Add inclusion uid, gid, uname and gname. */ -__LA_DECL int archive_match_include_uid(struct archive *, __LA_INT64_T); -__LA_DECL int archive_match_include_gid(struct archive *, __LA_INT64_T); +__LA_DECL int archive_match_include_uid(struct archive *, la_int64_t); +__LA_DECL int archive_match_include_gid(struct archive *, la_int64_t); __LA_DECL int archive_match_include_uname(struct archive *, const char *); __LA_DECL int archive_match_include_uname_w(struct archive *, const wchar_t *); @@ -930,6 +1194,10 @@ __LA_DECL int archive_match_include_gname(struct archive *, const char *); __LA_DECL int archive_match_include_gname_w(struct archive *, const wchar_t *); +/* Utility functions */ +/* Convenience function to sort a NULL terminated list of strings */ +__LA_DECL int archive_utility_string_sort(char **); + #ifdef __cplusplus } #endif @@ -937,9 +1205,4 @@ __LA_DECL int archive_match_include_gname_w(struct archive *, /* These are meaningless outside of this header. */ #undef __LA_DECL -/* These need to remain defined because they're used in the - * callback type definitions. XXX Fix this. This is ugly. XXX */ -/* #undef __LA_INT64_T */ -/* #undef __LA_SSIZE_T */ - #endif /* !ARCHIVE_H_INCLUDED */ diff --git a/libarchive/archive_entry.h b/libarchive/archive_entry.h index 5fd7cab..4cb7db3 100644 --- a/libarchive/archive_entry.h +++ b/libarchive/archive_entry.h @@ -1,5 +1,6 @@ /*- * Copyright (c) 2003-2008 Tim Kientzle + * Copyright (c) 2016 Martin Matuska * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +30,7 @@ #define ARCHIVE_ENTRY_H_INCLUDED /* Note: Compiler will complain if this does not match archive.h! */ -#define ARCHIVE_VERSION_NUMBER 3000004 +#define ARCHIVE_VERSION_NUMBER 3005003 /* * Note: archive_entry.h is for use outside of libarchive; the @@ -41,6 +42,7 @@ #include #include /* for wchar_t */ +#include #include #if defined(_WIN32) && !defined(__CYGWIN__) @@ -48,14 +50,41 @@ #endif /* Get a suitable 64-bit integer type. */ -#if defined(_WIN32) && !defined(__CYGWIN__) -# define __LA_INT64_T __int64 -#else +#if !defined(__LA_INT64_T_DEFINED) +# if ARCHIVE_VERSION_NUMBER < 4000000 +#define __LA_INT64_T la_int64_t +# endif +#define __LA_INT64_T_DEFINED +# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) +typedef __int64 la_int64_t; +# else #include -# if defined(_SCO_DS) -# define __LA_INT64_T long long +# if defined(_SCO_DS) || defined(__osf__) +typedef long long la_int64_t; +# else +typedef int64_t la_int64_t; +# endif +# endif +#endif + +/* The la_ssize_t should match the type used in 'struct stat' */ +#if !defined(__LA_SSIZE_T_DEFINED) +/* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */ +# if ARCHIVE_VERSION_NUMBER < 4000000 +#define __LA_SSIZE_T la_ssize_t +# endif +#define __LA_SSIZE_T_DEFINED +# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) +# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_) +typedef ssize_t la_ssize_t; +# elif defined(_WIN64) +typedef __int64 la_ssize_t; +# else +typedef long la_ssize_t; +# endif # else -# define __LA_INT64_T int64_t +# include /* ssize_t */ +typedef ssize_t la_ssize_t; # endif #endif @@ -63,12 +92,17 @@ #if ARCHIVE_VERSION_NUMBER >= 3999000 /* Switch to plain 'int' for libarchive 4.0. It's less broken than 'mode_t' */ # define __LA_MODE_T int -#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) +#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__) # define __LA_MODE_T unsigned short #else # define __LA_MODE_T mode_t #endif +/* Large file support for Android */ +#ifdef __ANDROID__ +#include "android_lf.h" +#endif + /* * On Windows, define LIBARCHIVE_STATIC if you're building or using a * .lib. The default here assumes you're building a DLL. Only @@ -93,6 +127,12 @@ # define __LA_DECL #endif +#if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1 +# define __LA_DEPRECATED __attribute__((deprecated)) +#else +# define __LA_DEPRECATED +#endif + #ifdef __cplusplus extern "C" { #endif @@ -150,6 +190,13 @@ struct archive_entry; #define AE_IFDIR ((__LA_MODE_T)0040000) #define AE_IFIFO ((__LA_MODE_T)0010000) +/* + * Symlink types + */ +#define AE_SYMLINK_TYPE_UNDEFINED 0 +#define AE_SYMLINK_TYPE_FILE 1 +#define AE_SYMLINK_TYPE_DIRECTORY 2 + /* * Basic object manipulation */ @@ -206,13 +253,15 @@ __LA_DECL void archive_entry_fflags(struct archive_entry *, unsigned long * /* set */, unsigned long * /* clear */); __LA_DECL const char *archive_entry_fflags_text(struct archive_entry *); -__LA_DECL __LA_INT64_T archive_entry_gid(struct archive_entry *); +__LA_DECL la_int64_t archive_entry_gid(struct archive_entry *); __LA_DECL const char *archive_entry_gname(struct archive_entry *); +__LA_DECL const char *archive_entry_gname_utf8(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_gname_w(struct archive_entry *); __LA_DECL const char *archive_entry_hardlink(struct archive_entry *); +__LA_DECL const char *archive_entry_hardlink_utf8(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *); -__LA_DECL __LA_INT64_T archive_entry_ino(struct archive_entry *); -__LA_DECL __LA_INT64_T archive_entry_ino64(struct archive_entry *); +__LA_DECL la_int64_t archive_entry_ino(struct archive_entry *); +__LA_DECL la_int64_t archive_entry_ino64(struct archive_entry *); __LA_DECL int archive_entry_ino_is_set(struct archive_entry *); __LA_DECL __LA_MODE_T archive_entry_mode(struct archive_entry *); __LA_DECL time_t archive_entry_mtime(struct archive_entry *); @@ -220,6 +269,7 @@ __LA_DECL long archive_entry_mtime_nsec(struct archive_entry *); __LA_DECL int archive_entry_mtime_is_set(struct archive_entry *); __LA_DECL unsigned int archive_entry_nlink(struct archive_entry *); __LA_DECL const char *archive_entry_pathname(struct archive_entry *); +__LA_DECL const char *archive_entry_pathname_utf8(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *); __LA_DECL __LA_MODE_T archive_entry_perm(struct archive_entry *); __LA_DECL dev_t archive_entry_rdev(struct archive_entry *); @@ -227,14 +277,20 @@ __LA_DECL dev_t archive_entry_rdevmajor(struct archive_entry *); __LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *); __LA_DECL const char *archive_entry_sourcepath(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_sourcepath_w(struct archive_entry *); -__LA_DECL __LA_INT64_T archive_entry_size(struct archive_entry *); +__LA_DECL la_int64_t archive_entry_size(struct archive_entry *); __LA_DECL int archive_entry_size_is_set(struct archive_entry *); __LA_DECL const char *archive_entry_strmode(struct archive_entry *); __LA_DECL const char *archive_entry_symlink(struct archive_entry *); +__LA_DECL const char *archive_entry_symlink_utf8(struct archive_entry *); +__LA_DECL int archive_entry_symlink_type(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *); -__LA_DECL __LA_INT64_T archive_entry_uid(struct archive_entry *); +__LA_DECL la_int64_t archive_entry_uid(struct archive_entry *); __LA_DECL const char *archive_entry_uname(struct archive_entry *); +__LA_DECL const char *archive_entry_uname_utf8(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *); +__LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *); +__LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *); +__LA_DECL int archive_entry_is_encrypted(struct archive_entry *); /* * Set fields in an archive_entry. @@ -266,18 +322,21 @@ __LA_DECL const char *archive_entry_copy_fflags_text(struct archive_entry *, const char *); __LA_DECL const wchar_t *archive_entry_copy_fflags_text_w(struct archive_entry *, const wchar_t *); -__LA_DECL void archive_entry_set_gid(struct archive_entry *, __LA_INT64_T); +__LA_DECL void archive_entry_set_gid(struct archive_entry *, la_int64_t); __LA_DECL void archive_entry_set_gname(struct archive_entry *, const char *); +__LA_DECL void archive_entry_set_gname_utf8(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_gname(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_gname_w(struct archive_entry *, const wchar_t *); __LA_DECL int archive_entry_update_gname_utf8(struct archive_entry *, const char *); __LA_DECL void archive_entry_set_hardlink(struct archive_entry *, const char *); +__LA_DECL void archive_entry_set_hardlink_utf8(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_hardlink(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_hardlink_w(struct archive_entry *, const wchar_t *); __LA_DECL int archive_entry_update_hardlink_utf8(struct archive_entry *, const char *); -__LA_DECL void archive_entry_set_ino(struct archive_entry *, __LA_INT64_T); -__LA_DECL void archive_entry_set_ino64(struct archive_entry *, __LA_INT64_T); +__LA_DECL void archive_entry_set_ino(struct archive_entry *, la_int64_t); +__LA_DECL void archive_entry_set_ino64(struct archive_entry *, la_int64_t); __LA_DECL void archive_entry_set_link(struct archive_entry *, const char *); +__LA_DECL void archive_entry_set_link_utf8(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *); __LA_DECL int archive_entry_update_link_utf8(struct archive_entry *, const char *); @@ -286,6 +345,7 @@ __LA_DECL void archive_entry_set_mtime(struct archive_entry *, time_t, long); __LA_DECL void archive_entry_unset_mtime(struct archive_entry *); __LA_DECL void archive_entry_set_nlink(struct archive_entry *, unsigned int); __LA_DECL void archive_entry_set_pathname(struct archive_entry *, const char *); +__LA_DECL void archive_entry_set_pathname_utf8(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_pathname(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_pathname_w(struct archive_entry *, const wchar_t *); __LA_DECL int archive_entry_update_pathname_utf8(struct archive_entry *, const char *); @@ -293,19 +353,24 @@ __LA_DECL void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T); __LA_DECL void archive_entry_set_rdev(struct archive_entry *, dev_t); __LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t); __LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t); -__LA_DECL void archive_entry_set_size(struct archive_entry *, __LA_INT64_T); +__LA_DECL void archive_entry_set_size(struct archive_entry *, la_int64_t); __LA_DECL void archive_entry_unset_size(struct archive_entry *); __LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_sourcepath_w(struct archive_entry *, const wchar_t *); __LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *); +__LA_DECL void archive_entry_set_symlink_type(struct archive_entry *, int); +__LA_DECL void archive_entry_set_symlink_utf8(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_symlink(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *); __LA_DECL int archive_entry_update_symlink_utf8(struct archive_entry *, const char *); -__LA_DECL void archive_entry_set_uid(struct archive_entry *, __LA_INT64_T); +__LA_DECL void archive_entry_set_uid(struct archive_entry *, la_int64_t); __LA_DECL void archive_entry_set_uname(struct archive_entry *, const char *); +__LA_DECL void archive_entry_set_uname_utf8(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *); __LA_DECL int archive_entry_update_uname_utf8(struct archive_entry *, const char *); +__LA_DECL void archive_entry_set_is_data_encrypted(struct archive_entry *, char is_encrypted); +__LA_DECL void archive_entry_set_is_metadata_encrypted(struct archive_entry *, char is_encrypted); /* * Routines to bulk copy fields to/from a platform-native "struct * stat." Libarchive used to just store a struct stat inside of each @@ -331,6 +396,19 @@ __LA_DECL void archive_entry_copy_stat(struct archive_entry *, const struct stat __LA_DECL const void * archive_entry_mac_metadata(struct archive_entry *, size_t *); __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const void *, size_t); +/* + * Digest routine. This is used to query the raw hex digest for the + * given entry. The type of digest is provided as an argument. + */ +#define ARCHIVE_ENTRY_DIGEST_MD5 0x00000001 +#define ARCHIVE_ENTRY_DIGEST_RMD160 0x00000002 +#define ARCHIVE_ENTRY_DIGEST_SHA1 0x00000003 +#define ARCHIVE_ENTRY_DIGEST_SHA256 0x00000004 +#define ARCHIVE_ENTRY_DIGEST_SHA384 0x00000005 +#define ARCHIVE_ENTRY_DIGEST_SHA512 0x00000006 + +__LA_DECL const unsigned char * archive_entry_digest(struct archive_entry *, int /* type */); + /* * ACL routines. This used to simply store and return text-format ACL * strings, but that proved insufficient for a number of reasons: @@ -393,6 +471,7 @@ __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const voi /* * Inheritance values (NFS4 ACLs only); included in permset. */ +#define ARCHIVE_ENTRY_ACL_ENTRY_INHERITED 0x01000000 #define ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT 0x02000000 #define ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT 0x04000000 #define ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT 0x08000000 @@ -406,15 +485,16 @@ __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const voi | ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT \ | ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY \ | ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS \ - | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS) + | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS \ + | ARCHIVE_ENTRY_ACL_ENTRY_INHERITED) /* We need to be able to specify combinations of these. */ -#define ARCHIVE_ENTRY_ACL_TYPE_ACCESS 256 /* POSIX.1e only */ -#define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT 512 /* POSIX.1e only */ -#define ARCHIVE_ENTRY_ACL_TYPE_ALLOW 1024 /* NFS4 only */ -#define ARCHIVE_ENTRY_ACL_TYPE_DENY 2048 /* NFS4 only */ -#define ARCHIVE_ENTRY_ACL_TYPE_AUDIT 4096 /* NFS4 only */ -#define ARCHIVE_ENTRY_ACL_TYPE_ALARM 8192 /* NFS4 only */ +#define ARCHIVE_ENTRY_ACL_TYPE_ACCESS 0x00000100 /* POSIX.1e only */ +#define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT 0x00000200 /* POSIX.1e only */ +#define ARCHIVE_ENTRY_ACL_TYPE_ALLOW 0x00000400 /* NFS4 only */ +#define ARCHIVE_ENTRY_ACL_TYPE_DENY 0x00000800 /* NFS4 only */ +#define ARCHIVE_ENTRY_ACL_TYPE_AUDIT 0x00001000 /* NFS4 only */ +#define ARCHIVE_ENTRY_ACL_TYPE_ALARM 0x00002000 /* NFS4 only */ #define ARCHIVE_ENTRY_ACL_TYPE_POSIX1E (ARCHIVE_ENTRY_ACL_TYPE_ACCESS \ | ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) #define ARCHIVE_ENTRY_ACL_TYPE_NFS4 (ARCHIVE_ENTRY_ACL_TYPE_ALLOW \ @@ -457,29 +537,56 @@ __LA_DECL int archive_entry_acl_reset(struct archive_entry *, int /* want_type __LA_DECL int archive_entry_acl_next(struct archive_entry *, int /* want_type */, int * /* type */, int * /* permset */, int * /* tag */, int * /* qual */, const char ** /* name */); -__LA_DECL int archive_entry_acl_next_w(struct archive_entry *, int /* want_type */, - int * /* type */, int * /* permset */, int * /* tag */, - int * /* qual */, const wchar_t ** /* name */); /* * Construct a text-format ACL. The flags argument is a bitmask that * can include any of the following: * + * Flags only for archive entries with POSIX.1e ACL: * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - Include POSIX.1e "access" entries. * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - Include POSIX.1e "default" entries. - * ARCHIVE_ENTRY_ACL_TYPE_NFS4 - Include NFS4 entries. - * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in - * each ACL entry. ('star' introduced this for POSIX.1e, this flag - * also applies to NFS4.) * ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT - Include "default:" before each - * default ACL entry, as used in old Solaris ACLs. + * default ACL entry. + * ARCHIVE_ENTRY_ACL_STYLE_SOLARIS - Output only one colon after "other" and + * "mask" entries. + * + * Flags only for archive entries with NFSv4 ACL: + * ARCHIVE_ENTRY_ACL_STYLE_COMPACT - Do not output the minus character for + * unset permissions and flags in NFSv4 ACL permission and flag fields + * + * Flags for for archive entries with POSIX.1e ACL or NFSv4 ACL: + * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in + * each ACL entry. + * ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA - Separate entries with comma + * instead of newline. */ -#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024 -#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048 +#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 0x00000001 +#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 0x00000002 +#define ARCHIVE_ENTRY_ACL_STYLE_SOLARIS 0x00000004 +#define ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA 0x00000008 +#define ARCHIVE_ENTRY_ACL_STYLE_COMPACT 0x00000010 + +__LA_DECL wchar_t *archive_entry_acl_to_text_w(struct archive_entry *, + la_ssize_t * /* len */, int /* flags */); +__LA_DECL char *archive_entry_acl_to_text(struct archive_entry *, + la_ssize_t * /* len */, int /* flags */); +__LA_DECL int archive_entry_acl_from_text_w(struct archive_entry *, + const wchar_t * /* wtext */, int /* type */); +__LA_DECL int archive_entry_acl_from_text(struct archive_entry *, + const char * /* text */, int /* type */); + +/* Deprecated constants */ +#define OLD_ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024 +#define OLD_ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048 + +/* Deprecated functions */ __LA_DECL const wchar_t *archive_entry_acl_text_w(struct archive_entry *, - int /* flags */); + int /* flags */) __LA_DEPRECATED; __LA_DECL const char *archive_entry_acl_text(struct archive_entry *, - int /* flags */); + int /* flags */) __LA_DEPRECATED; + +/* Return bitmask of ACL types in an archive entry */ +__LA_DECL int archive_entry_acl_types(struct archive_entry *); /* Return a count of entries matching 'want_type' */ __LA_DECL int archive_entry_acl_count(struct archive_entry *, int /* want_type */); @@ -514,7 +621,7 @@ __LA_DECL int archive_entry_xattr_next(struct archive_entry *, __LA_DECL void archive_entry_sparse_clear(struct archive_entry *); __LA_DECL void archive_entry_sparse_add_entry(struct archive_entry *, - __LA_INT64_T /* offset */, __LA_INT64_T /* length */); + la_int64_t /* offset */, la_int64_t /* length */); /* * To retrieve the xattr list, first "reset", then repeatedly ask for the @@ -524,7 +631,7 @@ __LA_DECL void archive_entry_sparse_add_entry(struct archive_entry *, __LA_DECL int archive_entry_sparse_count(struct archive_entry *); __LA_DECL int archive_entry_sparse_reset(struct archive_entry *); __LA_DECL int archive_entry_sparse_next(struct archive_entry *, - __LA_INT64_T * /* offset */, __LA_INT64_T * /* length */); + la_int64_t * /* offset */, la_int64_t * /* length */); /* * Utility to match up hardlinks. @@ -604,7 +711,6 @@ __LA_DECL void archive_entry_linkify(struct archive_entry_linkresolver *, struct archive_entry **, struct archive_entry **); __LA_DECL struct archive_entry *archive_entry_partial_links( struct archive_entry_linkresolver *res, unsigned int *links); - #ifdef __cplusplus } #endif diff --git a/setup.py b/setup.py index dddc13c..02646dd 100644 --- a/setup.py +++ b/setup.py @@ -93,7 +93,7 @@ if libarchivePrefix: environ['LDFLAGS'] = '-L{0}/lib {1}'.format(libarchivePrefix, environ.get('LDFLAGS', '')) else: extra_compile_args = [] - extra_link_args = ['-l:libarchive.so.13'] + extra_link_args = ['-l:libarchive.so.18'] __libarchive = Extension( name='libarchive.__libarchive', From 5f94da7c4d39cd5b82c748323ead4058d72bfe88 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 17:59:35 +0200 Subject: [PATCH 58/91] Fix version function --- libarchive/__init__.py | 4 +- libarchive/_libarchive.i | 5 +- libarchive/_libarchive.py | 171 ++-------------------------------- libarchive/_libarchive_wrap.c | 30 +++++- 4 files changed, 41 insertions(+), 169 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 7af2342..7763ac7 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -96,8 +96,8 @@ class EOF(Exception): def version(): '''Returns the version of the libarchive library.''' - return _libarchive.ARCHIVE_VERSION_STRING.split()[1] - + return _libarchive.archive_version_string().split()[1] + def get_error(archive): '''Retrieves the last error description for the given archive instance.''' diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index 1dccbc6..7a9d90f 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -420,10 +420,11 @@ extern void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T); extern int archive_errno(struct archive *); extern const char *archive_error_string(struct archive *); +extern int archive_version_number(void); +extern const char *archive_version_string(void); /* CONSTANTS */ -#define ARCHIVE_VERSION_NUMBER 3002002 -#define ARCHIVE_VERSION_STRING "libarchive 3.2.2" + #define ARCHIVE_EOF 1 /* Found end of archive. */ #define ARCHIVE_OK 0 /* Operation was successful. */ #define ARCHIVE_RETRY (-10) /* Retry might succeed. */ diff --git a/libarchive/_libarchive.py b/libarchive/_libarchive.py index f9fe9dd..dbb0ddc 100644 --- a/libarchive/_libarchive.py +++ b/libarchive/_libarchive.py @@ -5,7 +5,6 @@ # the SWIG interface file instead. from sys import version_info as _swig_python_version_info - if _swig_python_version_info < (2, 7, 0): raise RuntimeError("Python 2.7 or later required") @@ -20,17 +19,12 @@ try: except ImportError: import __builtin__ - def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except __builtin__.Exception: strthis = "" - return "<%s.%s; %s >" % ( - self.__class__.__module__, - self.__class__.__name__, - strthis, - ) + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) def _swig_setattr_nondynamic_instance_variable(set): @@ -43,7 +37,6 @@ def _swig_setattr_nondynamic_instance_variable(set): set(self, name, value) else: raise AttributeError("You cannot add instance attributes to %s" % self) - return set_instance_attr @@ -53,619 +46,471 @@ def _swig_setattr_nondynamic_class_variable(set): set(cls, name, value) else: raise AttributeError("You cannot add class attributes to %s" % cls) - return set_class_attr def _swig_add_metaclass(metaclass): """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" - def wrapper(cls): return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) - return wrapper class _SwigNonDynamicMeta(type): """Meta class to enforce nondynamic attributes (no new attributes) for a class""" - __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) + def archive_read_new(): return __libarchive.archive_read_new() - def archive_read_free(arg1): return __libarchive.archive_read_free(arg1) - def archive_read_open_filename(arg1, _filename, _block_size): return __libarchive.archive_read_open_filename(arg1, _filename, _block_size) - def archive_read_open_memory(arg1, buff, size): return __libarchive.archive_read_open_memory(arg1, buff, size) - def archive_read_open_memory2(a, buff, size, read_size): return __libarchive.archive_read_open_memory2(a, buff, size, read_size) - def archive_read_open_fd(arg1, _fd, _block_size): return __libarchive.archive_read_open_fd(arg1, _fd, _block_size) - def archive_read_close(arg1): return __libarchive.archive_read_close(arg1) - def archive_format(arg1): return __libarchive.archive_format(arg1) - def archive_read_next_header2(arg1, arg2): return __libarchive.archive_read_next_header2(arg1, arg2) - def archive_entry_stat(arg1): return __libarchive.archive_entry_stat(arg1) - def archive_read_header_position(arg1): return __libarchive.archive_read_header_position(arg1) - def archive_read_set_format_option(_a, m, o, v): return __libarchive.archive_read_set_format_option(_a, m, o, v) - def archive_read_set_filter_option(_a, m, o, v): return __libarchive.archive_read_set_filter_option(_a, m, o, v) - def archive_read_set_option(_a, m, o, v): return __libarchive.archive_read_set_option(_a, m, o, v) - def archive_read_set_options(_a, opts): return __libarchive.archive_read_set_options(_a, opts) - def archive_read_add_passphrase(arg1, arg2): return __libarchive.archive_read_add_passphrase(arg1, arg2) - def archive_read_data_skip(arg1): return __libarchive.archive_read_data_skip(arg1) - def archive_read_data_into_fd(arg1, fd): return __libarchive.archive_read_data_into_fd(arg1, fd) - def archive_read_support_compression_all(arg1): return __libarchive.archive_read_support_compression_all(arg1) - def archive_read_support_compression_bzip2(arg1): return __libarchive.archive_read_support_compression_bzip2(arg1) - def archive_read_support_compression_compress(arg1): return __libarchive.archive_read_support_compression_compress(arg1) - def archive_read_support_compression_gzip(arg1): return __libarchive.archive_read_support_compression_gzip(arg1) - def archive_read_support_compression_lzip(arg1): return __libarchive.archive_read_support_compression_lzip(arg1) - def archive_read_support_compression_lzma(arg1): return __libarchive.archive_read_support_compression_lzma(arg1) - def archive_read_support_compression_none(arg1): return __libarchive.archive_read_support_compression_none(arg1) - def archive_read_support_compression_program(arg1, command): return __libarchive.archive_read_support_compression_program(arg1, command) - def archive_read_support_compression_program_signature(arg1, arg2, arg3, arg4): return __libarchive.archive_read_support_compression_program_signature(arg1, arg2, arg3, arg4) - def archive_read_support_compression_rpm(arg1): return __libarchive.archive_read_support_compression_rpm(arg1) - def archive_read_support_compression_uu(arg1): return __libarchive.archive_read_support_compression_uu(arg1) - def archive_read_support_compression_xz(arg1): return __libarchive.archive_read_support_compression_xz(arg1) - def archive_read_support_filter_all(arg1): return __libarchive.archive_read_support_filter_all(arg1) - def archive_read_support_filter_bzip2(arg1): return __libarchive.archive_read_support_filter_bzip2(arg1) - def archive_read_support_filter_compress(arg1): return __libarchive.archive_read_support_filter_compress(arg1) - def archive_read_support_filter_gzip(arg1): return __libarchive.archive_read_support_filter_gzip(arg1) - def archive_read_support_filter_grzip(arg1): return __libarchive.archive_read_support_filter_grzip(arg1) - def archive_read_support_filter_lrzip(arg1): return __libarchive.archive_read_support_filter_lrzip(arg1) - def archive_read_support_filter_lz4(arg1): return __libarchive.archive_read_support_filter_lz4(arg1) - def archive_read_support_filter_lzip(arg1): return __libarchive.archive_read_support_filter_lzip(arg1) - def archive_read_support_filter_lzma(arg1): return __libarchive.archive_read_support_filter_lzma(arg1) - def archive_read_support_filter_lzop(arg1): return __libarchive.archive_read_support_filter_lzop(arg1) - def archive_read_support_filter_none(arg1): return __libarchive.archive_read_support_filter_none(arg1) - def archive_read_support_filter_program(arg1, command): return __libarchive.archive_read_support_filter_program(arg1, command) - def archive_read_support_filter_program_signature(arg1, arg2, arg3, arg4): return __libarchive.archive_read_support_filter_program_signature(arg1, arg2, arg3, arg4) - def archive_read_support_filter_rpm(arg1): return __libarchive.archive_read_support_filter_rpm(arg1) - def archive_read_support_filter_uu(arg1): return __libarchive.archive_read_support_filter_uu(arg1) - def archive_read_support_filter_xz(arg1): return __libarchive.archive_read_support_filter_xz(arg1) - def archive_read_support_format_7zip(arg1): return __libarchive.archive_read_support_format_7zip(arg1) - def archive_read_support_format_all(arg1): return __libarchive.archive_read_support_format_all(arg1) - def archive_read_support_format_ar(arg1): return __libarchive.archive_read_support_format_ar(arg1) - def archive_read_support_format_by_code(arg1, arg2): return __libarchive.archive_read_support_format_by_code(arg1, arg2) - def archive_read_support_format_cab(arg1): return __libarchive.archive_read_support_format_cab(arg1) - def archive_read_support_format_cpio(arg1): return __libarchive.archive_read_support_format_cpio(arg1) - def archive_read_support_format_empty(arg1): return __libarchive.archive_read_support_format_empty(arg1) - def archive_read_support_format_gnutar(arg1): return __libarchive.archive_read_support_format_gnutar(arg1) - def archive_read_support_format_iso9660(arg1): return __libarchive.archive_read_support_format_iso9660(arg1) - def archive_read_support_format_lha(arg1): return __libarchive.archive_read_support_format_lha(arg1) - def archive_read_support_format_rar(arg1): return __libarchive.archive_read_support_format_rar(arg1) - def archive_read_support_format_raw(arg1): return __libarchive.archive_read_support_format_raw(arg1) - def archive_read_support_format_tar(arg1): return __libarchive.archive_read_support_format_tar(arg1) - def archive_read_support_format_warc(arg1): return __libarchive.archive_read_support_format_warc(arg1) - def archive_read_support_format_xar(arg1): return __libarchive.archive_read_support_format_xar(arg1) - def archive_read_support_format_zip(arg1): return __libarchive.archive_read_support_format_zip(arg1) - def archive_read_support_format_zip_streamable(arg1): return __libarchive.archive_read_support_format_zip_streamable(arg1) - def archive_read_support_format_zip_seekable(arg1): return __libarchive.archive_read_support_format_zip_seekable(arg1) - def archive_read_set_format(arg1, arg2): return __libarchive.archive_read_set_format(arg1, arg2) - def archive_read_append_filter(arg1, arg2): return __libarchive.archive_read_append_filter(arg1, arg2) - def archive_read_append_filter_program(arg1, arg2): return __libarchive.archive_read_append_filter_program(arg1, arg2) - def archive_read_append_filter_program_signature(arg1, arg2, arg3, arg4): return __libarchive.archive_read_append_filter_program_signature(arg1, arg2, arg3, arg4) - def archive_write_new(): return __libarchive.archive_write_new() - def archive_write_free(arg1): return __libarchive.archive_write_free(arg1) - def archive_write_open(arg1, arg2, arg3, arg4, arg5): return __libarchive.archive_write_open(arg1, arg2, arg3, arg4, arg5) - def archive_write_open_fd(arg1, _fd): return __libarchive.archive_write_open_fd(arg1, _fd) - def archive_write_open_filename(arg1, _file): return __libarchive.archive_write_open_filename(arg1, _file) - def archive_write_open_filename_w(arg1, _file): return __libarchive.archive_write_open_filename_w(arg1, _file) - def archive_write_open_memory(arg1, _buffer, _buffSize, _used): return __libarchive.archive_write_open_memory(arg1, _buffer, _buffSize, _used) - def archive_write_close(arg1): return __libarchive.archive_write_close(arg1) - def archive_write_header(arg1, arg2): return __libarchive.archive_write_header(arg1, arg2) - def archive_write_set_format_option(_a, m, o, v): return __libarchive.archive_write_set_format_option(_a, m, o, v) - def archive_write_set_filter_option(_a, m, o, v): return __libarchive.archive_write_set_filter_option(_a, m, o, v) - def archive_write_set_option(_a, m, o, v): return __libarchive.archive_write_set_option(_a, m, o, v) - def archive_write_set_options(_a, opts): return __libarchive.archive_write_set_options(_a, opts) - def archive_write_set_passphrase(_a, p): return __libarchive.archive_write_set_passphrase(_a, p) - def archive_write_finish_entry(arg1): return __libarchive.archive_write_finish_entry(arg1) - def archive_write_add_filter(arg1, filter_code): return __libarchive.archive_write_add_filter(arg1, filter_code) - def archive_write_add_filter_by_name(arg1, name): return __libarchive.archive_write_add_filter_by_name(arg1, name) - def archive_write_add_filter_b64encode(arg1): return __libarchive.archive_write_add_filter_b64encode(arg1) - def archive_write_add_filter_bzip2(arg1): return __libarchive.archive_write_add_filter_bzip2(arg1) - def archive_write_add_filter_compress(arg1): return __libarchive.archive_write_add_filter_compress(arg1) - def archive_write_add_filter_grzip(arg1): return __libarchive.archive_write_add_filter_grzip(arg1) - def archive_write_add_filter_gzip(arg1): return __libarchive.archive_write_add_filter_gzip(arg1) - def archive_write_add_filter_lrzip(arg1): return __libarchive.archive_write_add_filter_lrzip(arg1) - def archive_write_add_filter_lz4(arg1): return __libarchive.archive_write_add_filter_lz4(arg1) - def archive_write_add_filter_lzip(arg1): return __libarchive.archive_write_add_filter_lzip(arg1) - def archive_write_add_filter_lzma(arg1): return __libarchive.archive_write_add_filter_lzma(arg1) - def archive_write_add_filter_lzop(arg1): return __libarchive.archive_write_add_filter_lzop(arg1) - def archive_write_add_filter_none(arg1): return __libarchive.archive_write_add_filter_none(arg1) - def archive_write_add_filter_program(arg1, cmd): return __libarchive.archive_write_add_filter_program(arg1, cmd) - def archive_write_add_filter_uuencode(arg1): return __libarchive.archive_write_add_filter_uuencode(arg1) - def archive_write_add_filter_xz(arg1): return __libarchive.archive_write_add_filter_xz(arg1) - def archive_write_set_format(arg1, format_code): return __libarchive.archive_write_set_format(arg1, format_code) - def archive_write_set_format_by_name(arg1, name): return __libarchive.archive_write_set_format_by_name(arg1, name) - def archive_write_set_format_7zip(arg1): return __libarchive.archive_write_set_format_7zip(arg1) - def archive_write_set_format_ar_bsd(arg1): return __libarchive.archive_write_set_format_ar_bsd(arg1) - def archive_write_set_format_ar_svr4(arg1): return __libarchive.archive_write_set_format_ar_svr4(arg1) - def archive_write_set_format_cpio(arg1): return __libarchive.archive_write_set_format_cpio(arg1) - def archive_write_set_format_cpio_newc(arg1): return __libarchive.archive_write_set_format_cpio_newc(arg1) - def archive_write_set_format_gnutar(arg1): return __libarchive.archive_write_set_format_gnutar(arg1) - def archive_write_set_format_iso9660(arg1): return __libarchive.archive_write_set_format_iso9660(arg1) - def archive_write_set_format_mtree(arg1): return __libarchive.archive_write_set_format_mtree(arg1) - def archive_write_set_format_mtree_classic(arg1): return __libarchive.archive_write_set_format_mtree_classic(arg1) - def archive_write_set_format_pax(arg1): return __libarchive.archive_write_set_format_pax(arg1) - def archive_write_set_format_pax_restricted(arg1): return __libarchive.archive_write_set_format_pax_restricted(arg1) - def archive_write_set_format_raw(arg1): return __libarchive.archive_write_set_format_raw(arg1) - def archive_write_set_format_shar(arg1): return __libarchive.archive_write_set_format_shar(arg1) - def archive_write_set_format_shar_dump(arg1): return __libarchive.archive_write_set_format_shar_dump(arg1) - def archive_write_set_format_ustar(arg1): return __libarchive.archive_write_set_format_ustar(arg1) - def archive_write_set_format_v7tar(arg1): return __libarchive.archive_write_set_format_v7tar(arg1) - def archive_write_set_format_warc(arg1): return __libarchive.archive_write_set_format_warc(arg1) - def archive_write_set_format_xar(arg1): return __libarchive.archive_write_set_format_xar(arg1) - def archive_write_set_format_zip(arg1): return __libarchive.archive_write_set_format_zip(arg1) - def archive_write_set_format_filter_by_ext(a, filename): return __libarchive.archive_write_set_format_filter_by_ext(a, filename) - def archive_write_set_format_filter_by_ext_def(a, filename, def_ext): return __libarchive.archive_write_set_format_filter_by_ext_def(a, filename, def_ext) - def archive_write_zip_set_compression_deflate(arg1): return __libarchive.archive_write_zip_set_compression_deflate(arg1) - def archive_write_zip_set_compression_store(arg1): return __libarchive.archive_write_zip_set_compression_store(arg1) - def archive_entry_new(): return __libarchive.archive_entry_new() - def archive_entry_free(arg1): return __libarchive.archive_entry_free(arg1) - def archive_entry_pathname(arg1): return __libarchive.archive_entry_pathname(arg1) - def archive_entry_pathname_w(arg1): return __libarchive.archive_entry_pathname_w(arg1) - def archive_entry_size(arg1): return __libarchive.archive_entry_size(arg1) - def archive_entry_mtime(arg1): return __libarchive.archive_entry_mtime(arg1) - def archive_entry_filetype(arg1): return __libarchive.archive_entry_filetype(arg1) - def archive_entry_perm(arg1): return __libarchive.archive_entry_perm(arg1) - def archive_entry_symlink(arg1): return __libarchive.archive_entry_symlink(arg1) - def archive_entry_set_link(arg1, arg2): return __libarchive.archive_entry_set_link(arg1, arg2) - def archive_entry_symlink_w(arg1): return __libarchive.archive_entry_symlink_w(arg1) - def archive_read_disk_set_symlink_logical(arg1): return __libarchive.archive_read_disk_set_symlink_logical(arg1) - def archive_read_disk_set_symlink_physical(arg1): return __libarchive.archive_read_disk_set_symlink_physical(arg1) - def archive_read_disk_set_symlink_hybrid(arg1): return __libarchive.archive_read_disk_set_symlink_hybrid(arg1) - def archive_entry_set_symlink(arg1, arg2): return __libarchive.archive_entry_set_symlink(arg1, arg2) - def archive_entry_copy_symlink(arg1, arg2): return __libarchive.archive_entry_copy_symlink(arg1, arg2) - def archive_entry_copy_symlink_w(arg1, arg2): return __libarchive.archive_entry_copy_symlink_w(arg1, arg2) - def archive_entry_set_pathname(arg1, arg2): return __libarchive.archive_entry_set_pathname(arg1, arg2) - def archive_entry_set_size(arg1, arg2): return __libarchive.archive_entry_set_size(arg1, arg2) - def archive_entry_set_mtime(arg1, arg2, arg3): return __libarchive.archive_entry_set_mtime(arg1, arg2, arg3) - def archive_entry_set_filetype(arg1, arg2): return __libarchive.archive_entry_set_filetype(arg1, arg2) - def archive_entry_set_perm(arg1, arg2): return __libarchive.archive_entry_set_perm(arg1, arg2) - def archive_errno(arg1): return __libarchive.archive_errno(arg1) - def archive_error_string(arg1): return __libarchive.archive_error_string(arg1) +def archive_version_number(): + return __libarchive.archive_version_number() -ARCHIVE_VERSION_NUMBER = __libarchive.ARCHIVE_VERSION_NUMBER -ARCHIVE_VERSION_STRING = __libarchive.ARCHIVE_VERSION_STRING +def archive_version_string(): + return __libarchive.archive_version_string() ARCHIVE_EOF = __libarchive.ARCHIVE_EOF ARCHIVE_OK = __libarchive.ARCHIVE_OK ARCHIVE_RETRY = __libarchive.ARCHIVE_RETRY @@ -736,10 +581,10 @@ ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED = __libarchive.ARCHIVE_EXTRACT_HFS_COMPRE ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS = __libarchive.ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS = __libarchive.ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS - def archive_read_data_into_str(archive, len): return __libarchive.archive_read_data_into_str(archive, len) - def archive_write_data_from_str(archive, str): return __libarchive.archive_write_data_from_str(archive, str) + + diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index d13a0e1..bcc604f 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -7275,6 +7275,32 @@ fail: } +SWIGINTERN PyObject *_wrap_archive_version_number(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!SWIG_Python_UnpackTuple(args, "archive_version_number", 0, 0, 0)) SWIG_fail; + result = (int)archive_version_number(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_archive_version_string(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "archive_version_string", 0, 0, 0)) SWIG_fail; + result = (char *)archive_version_string(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_archive_read_data_into_str(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct archive *arg1 = (struct archive *) 0 ; @@ -7479,6 +7505,8 @@ static PyMethodDef SwigMethods[] = { { "archive_entry_set_perm", _wrap_archive_entry_set_perm, METH_VARARGS, NULL}, { "archive_errno", _wrap_archive_errno, METH_O, NULL}, { "archive_error_string", _wrap_archive_error_string, METH_O, NULL}, + { "archive_version_number", _wrap_archive_version_number, METH_NOARGS, NULL}, + { "archive_version_string", _wrap_archive_version_string, METH_NOARGS, NULL}, { "archive_read_data_into_str", _wrap_archive_read_data_into_str, METH_VARARGS, NULL}, { "archive_write_data_from_str", _wrap_archive_write_data_from_str, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } @@ -8280,8 +8308,6 @@ SWIG_init(void) { SWIG_InstallConstants(d,swig_const_table); - SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_NUMBER",SWIG_From_int((int)(3002002))); - SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_STRING",SWIG_FromCharPtr("libarchive 3.2.2")); SWIG_Python_SetConstant(d, "ARCHIVE_EOF",SWIG_From_int((int)(1))); SWIG_Python_SetConstant(d, "ARCHIVE_OK",SWIG_From_int((int)(0))); SWIG_Python_SetConstant(d, "ARCHIVE_RETRY",SWIG_From_int((int)((-10)))); From 33bbd694ff83315db8795406f85138ca20d8b0a4 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 18:06:50 +0200 Subject: [PATCH 59/91] Remove mini test step --- .github/workflows/build-wheels.yaml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 5e0c756..21a6831 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -66,21 +66,11 @@ jobs: auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*.whl - - name: Mini test - run: | - cd /tmp - python3 -c 'import libarchive; print(libarchive.version())' \ - | tee strace.out - find / -name 'libarchive*.so' | xargs ls -l - find / -name 'libarchive*.so' | xargs strings | grep 'libarchive' - - - name: version run: | export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH export LIBARCHIVE_PREFIX=/usr/local - - echo "::set-output name=version::$(cd /; python3 -c 'import libarchive; print(libarchive._libarchive.ARCHIVE_VERSION_STRING.split()[1])')" + echo "::set-output name=version::$(cd /tmp; python3 -c 'import libarchive; print(libarchive.version()')" id: version - uses: actions/upload-artifact@v3 From 4faf9b4ad5f9969233fa9690424930e28efa079a Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 18:13:29 +0200 Subject: [PATCH 60/91] syntax error --- .github/workflows/build-wheels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 21a6831..e743f7b 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -70,7 +70,7 @@ jobs: run: | export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH export LIBARCHIVE_PREFIX=/usr/local - echo "::set-output name=version::$(cd /tmp; python3 -c 'import libarchive; print(libarchive.version()')" + echo "::set-output name=version::$(cd /tmp; python3 -c 'import libarchive; print(libarchive.version())')" id: version - uses: actions/upload-artifact@v3 From e607d7b08ead3531b733d3ce18f38f7bbda556e8 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 2 Aug 2022 19:10:25 +0200 Subject: [PATCH 61/91] Fix release production --- .github/workflows/build-wheels.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index e743f7b..9334d95 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -85,8 +85,8 @@ jobs: with: draft: false prerelease: false - release_name: ${{ steps.version.outputs.version }} - tag_name: ${{ github.ref }} + release_name: Release ${{ steps.version.outputs.version }} + tag_name: V${{ steps.version.outputs.version }} env: GITHUB_TOKEN: ${{ github.token }} From 1598bc823e36a611eeb913707d22b7ef774db97d Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Wed, 3 Aug 2022 14:22:21 +0200 Subject: [PATCH 62/91] Add missing dependecies --- .github/workflows/build-wheels.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 9334d95..1005821 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | yum install -y epel-release libxml2-devel libzstd-devel xz-devel bzip2-devel - yum install -y libacl-devel openssl-devel + yum install -y libacl-devel lz4-devel e2fsprogs-devel libb2-devel lzo-devel openssl-devel yum install -y librichacl-devel swig strace - name: Install python tools @@ -86,7 +86,7 @@ jobs: draft: false prerelease: false release_name: Release ${{ steps.version.outputs.version }} - tag_name: V${{ steps.version.outputs.version }} + tag_name: V${{ steps.version.outputs.version }}-p1 env: GITHUB_TOKEN: ${{ github.token }} From 104b2c2ccad03207991ff9ca0a5bbac8997bc150 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Wed, 3 Aug 2022 17:23:09 +0200 Subject: [PATCH 63/91] Optimize workflow --- .github/workflows/build-wheels.yaml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 1005821..b26ab36 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -53,23 +53,19 @@ jobs: run: | rm -rf build wheelhouse touch libarchive/_libarchive.i - export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH - export LIBARCHIVE_PREFIX=/usr/local + echo LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH >>$GITHUB_ENV + echo LIBARCHIVE_PREFIX=/usr/local >>$GITHUB_ENV python3 setup.py install - name: Build wheels run: | - export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH - export LIBARCHIVE_PREFIX=/usr/local python3 -m pip wheel --wheel-dir dist/ . auditwheel repair dist/*.whl python3 -m pip install --force-reinstall wheelhouse/*.whl - name: version run: | - export LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH - export LIBARCHIVE_PREFIX=/usr/local echo "::set-output name=version::$(cd /tmp; python3 -c 'import libarchive; print(libarchive.version())')" id: version @@ -86,7 +82,7 @@ jobs: draft: false prerelease: false release_name: Release ${{ steps.version.outputs.version }} - tag_name: V${{ steps.version.outputs.version }}-p1 + tag_name: V${{ steps.version.outputs.version }}-${{ github.ref_name }}-${{ github.run_number }} env: GITHUB_TOKEN: ${{ github.token }} From 8194803759ddb9ab4d1d8f58ddd5ac86b53160a0 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Wed, 3 Aug 2022 17:31:15 +0200 Subject: [PATCH 64/91] Fix python copmile step --- .github/workflows/build-wheels.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index b26ab36..1b2e80c 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -49,12 +49,15 @@ jobs: cd ../.. - - name: Compile pyhton modules + - name: Prepare build environment run: | rm -rf build wheelhouse touch libarchive/_libarchive.i echo LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH >>$GITHUB_ENV echo LIBARCHIVE_PREFIX=/usr/local >>$GITHUB_ENV + + - name: Compile pyhton modules + run: | python3 setup.py install From c865efb5f0ee231da91c543b52e822cad2715d4c Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Fri, 5 Aug 2022 15:19:14 +0200 Subject: [PATCH 65/91] Siwtch to libachive v3.6.1 --- .github/workflows/build-wheels.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 9334d95..1fea5e2 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -6,6 +6,9 @@ on: - master - extended +env: + libarchive_tag: v3.6.1 + jobs: many_linux_wheels: name: manylinux-wheels @@ -42,7 +45,7 @@ jobs: - name: Build libarchive C sources run: | git clone https://github.com/libarchive/libarchive.git libarchive-src - cd libarchive-src; git checkout 3.5 + cd libarchive-src; git checkout {{ env.libarchive_tag }} mkdir build-libarchive; cd build-libarchive cmake ../ make -j$(nproc); make install From cc26e02ecf3f394d52774e2ae50787af0c27b29c Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Fri, 5 Aug 2022 15:32:10 +0200 Subject: [PATCH 66/91] Syntax error --- .github/workflows/build-wheels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml index 52703d2..ad0a5c6 100644 --- a/.github/workflows/build-wheels.yaml +++ b/.github/workflows/build-wheels.yaml @@ -45,7 +45,7 @@ jobs: - name: Build libarchive C sources run: | git clone https://github.com/libarchive/libarchive.git libarchive-src - cd libarchive-src; git checkout {{ env.libarchive_tag }} + cd libarchive-src; git checkout ${{ env.libarchive_tag }} mkdir build-libarchive; cd build-libarchive cmake ../ make -j$(nproc); make install From 88051247e9822af1f275e0682926dff4223d7d27 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Fri, 5 Aug 2022 16:31:30 +0200 Subject: [PATCH 67/91] remove printing if symlink data --- libarchive/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 7763ac7..dd52ac2 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -353,10 +353,8 @@ class Entry(object): ) if entry.issym(): - print("issym") symLinkPath = _libarchive.archive_entry_symlink(e) entry.symlink = symLinkPath - print(symLinkPath) finally: _libarchive.archive_entry_free(e) From 5307ed6b877c7a1c2bf7415edd576115811b5da0 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 8 Aug 2022 19:35:21 +0200 Subject: [PATCH 68/91] Fix for Python2 compatibility --- libarchive/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index dd52ac2..0efde21 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -163,7 +163,7 @@ def is_archive(f, formats=(None,), filters=(None,)): This function will return True if the file can be opened as an archive using the given format(s)/filter(s).''' - need_close: bool = False + need_close = False if isinstance(f, str): f = open(f, 'rb') need_close = True From f334049b58c9ac06d7d8ee3d416b637eb6609e23 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 8 Aug 2022 19:39:58 +0200 Subject: [PATCH 69/91] More Fixes for Python2 compatiblity --- libarchive/zip.py | 1 - 1 file changed, 1 deletion(-) diff --git a/libarchive/zip.py b/libarchive/zip.py index 9e5d433..62fe4c1 100644 --- a/libarchive/zip.py +++ b/libarchive/zip.py @@ -100,7 +100,6 @@ class ZipFile(SeekableArchive): if not names: names = self.namelist() if names: - print(f"Extracting {names} files.") for name in names: self.extract(name, path) From 2f7a7d674fe0a2cfa92da8ca00037032b4c7b61b Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 8 Aug 2022 20:03:44 +0200 Subject: [PATCH 70/91] More Python 2 compatibility fixes --- libarchive/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 0efde21..038fe81 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -285,7 +285,10 @@ class EntryWriteStream(object): if self.closed: raise Exception('Cannot write to closed stream.') if self.buffer: - self.buffer.write(data) + if PY3: + self.buffer.write(data) + else: + self.buffer.write(data.encode('utf-8')) else: _libarchive.archive_write_data_from_str(self.archive._a, data.encode('utf-8')) self.bytes += len(data) From 70a29e44c986c2e1d74c6275c2cc4abdff0e6988 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 8 Aug 2022 20:08:57 +0200 Subject: [PATCH 71/91] Fix python version check --- libarchive/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 038fe81..4580b52 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -34,8 +34,7 @@ import warnings from libarchive import _libarchive from io import StringIO -# PY3 = sys.version_info[0] == 3 -PY3 = True +PY3 = sys.version_info[0] >= 3 # Suggested block size for libarchive. Libarchive may adjust it. BLOCK_SIZE = 10240 From c94a053099031dd98f0447d5435335e30f1f0926 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 8 Aug 2022 20:23:13 +0200 Subject: [PATCH 72/91] Unicode - related fixes --- libarchive/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 4580b52..5823835 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -287,9 +287,9 @@ class EntryWriteStream(object): if PY3: self.buffer.write(data) else: - self.buffer.write(data.encode('utf-8')) + self.buffer.write(unicode(data, ENCODING)) else: - _libarchive.archive_write_data_from_str(self.archive._a, data.encode('utf-8')) + _libarchive.archive_write_data_from_str(self.archive._a, data.encode(ENCODING)) self.bytes += len(data) def close(self): @@ -298,7 +298,7 @@ class EntryWriteStream(object): if self.buffer: self.entry.size = self.buffer.tell() self.entry.to_archive(self.archive) - _libarchive.archive_write_data_from_str(self.archive._a, self.buffer.getvalue().encode('utf-8')) + _libarchive.archive_write_data_from_str(self.archive._a, self.buffer.getvalue().encode(ENCODING)) _libarchive.archive_write_finish_entry(self.archive._a) # Call archive.close() with _defer True to let it know we have been @@ -615,7 +615,7 @@ class Archive(object): if isinstance(data, bytes): result = _libarchive.archive_write_data_from_str(self._a, data) else: - result = _libarchive.archive_write_data_from_str(self._a, data.encode('utf8')) + result = _libarchive.archive_write_data_from_str(self._a, data.encode(self.encoding)) else: result = _libarchive.archive_write_data_from_str(self._a, data) _libarchive.archive_write_finish_entry(self._a) From 4cf8f946b405628c18d2d89798e28790db109cdd Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 14:47:49 +0200 Subject: [PATCH 73/91] Cosmetics --- libarchive/Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libarchive/Makefile b/libarchive/Makefile index 1999128..863f30d 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -1,4 +1,4 @@ -CFLAGS = -g +CFLAGS = -g INCLUDE = -I/usr/local/include -I/usr/include -I. LIBS = -L /usr/local/lib -larchive @@ -8,16 +8,12 @@ PYVER ?= 3.9 all: __libarchive.so _libarchive_wrap.c: _libarchive.i - #swig -python -c++ -Wall -shadow _libarchive.i swig -python -Wall -shadow _libarchive.i _libarchive_wrap.o: _libarchive_wrap.c - echo ${CC} -c ${CFLAGS} -fPIC $$(python${PYVER}-config --cflags) _libarchive_wrap.c ${CC} -c ${CFLAGS} -fPIC $$(python${PYVER}-config --cflags) ${DEFINES} _libarchive_wrap.c -# ${CXX} -c ${CFLAGS} -fPIC $$(python${PYVER}-config --cflags) -DPyUnicode_AS_STRING=PyUnicode_AS_DATA _libarchive_wrap.cxx __libarchive.so: _libarchive_wrap.o - echo INCLUDE=$INCLUDE LIBS=$LIBS ${CC} _libarchive_wrap.o -shared $$(python${PYVER}-config --ldflags) -Wl,-soname=__libarchive.so -o __libarchive.so ${LIBS} clean: From e9c1df8f77f4a81f0a2c7752119ae34f4017d384 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 15:08:41 +0200 Subject: [PATCH 74/91] Cleanup unused code --- libarchive/__init__.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 5823835..79f520a 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -28,9 +28,6 @@ import stat import sys import time import warnings - -# from ctypes import cdll, c_char_p - from libarchive import _libarchive from io import StringIO @@ -323,11 +320,6 @@ class Entry(object): self.symlink = "" - # if self.issym() and symlink: - # self.symlink = symlink - # else: - # self.symlink = None - @property def header_position(self): return self.hpos @@ -387,9 +379,7 @@ class Entry(object): entry.mtime = getattr(f, 'mtime', time.time()) entry.mode = stat.S_IFREG - if stat.S_ISLNK(entry.mode): - print("yo") - + return entry def to_archive(self, archive): @@ -410,8 +400,6 @@ class Entry(object): call_and_check(_libarchive.archive_write_header, archive._a, archive._a, e) - # todo - # self.hpos = archive.header_position finally: _libarchive.archive_entry_free(e) From 1f55eb40759b0766206c5e0e763d48acd5df850a Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 15:55:47 +0200 Subject: [PATCH 75/91] Fixes to setup script to merge with parent --- setup.py | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/setup.py b/setup.py index 02646dd..c234791 100644 --- a/setup.py +++ b/setup.py @@ -34,33 +34,27 @@ except ImportError: from distutils.core import setup, Extension from distutils.command.build_ext import build_ext -import subprocess # Use a provided libarchive else default to hard-coded path. libarchivePrefix = environ.get('LIBARCHIVE_PREFIX') -includePath = f"{libarchivePrefix or '/usr'}/include" -# retreive the version number form SWIG generated file -print("includePath:", (libarchivePrefix, includePath)) +if libarchivePrefix: + includePath = libarchivePrefix + '/include' +else: + includePath = '/usr/local/include' + -cmd = [ - 'awk', - '/#define.*ARCHIVE_VERSION_NUMBER/ { if (match($0,"[[:digit:]]+")) print substr($0, RSTART,RLENGTH) }', - f"{includePath}/archive.h" -] -p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) -print("awk output:", p.stdout.decode('utf-8')) -vnum = int(p.stdout) -name = 'python-libarchive-ext' -version = '{}.{}.{}'.format(vnum // 1000000, (vnum // 1000) % 100, vnum % 100) -versrel = version +name = 'python-libarchive' +version = '4.0.1' +release = '2' +versrel = version + '-' + release readme = 'README.rst' -repourl = 'https://github.com/Vadiml1024/python-libarchive' -repobranch = 'extended' -download_url = repourl + f'/tarball/{repobranch}' +download_url = "http://" + name + ".googlecode.com/files/" + name + "-" + \ + versrel + ".tar.gz" +repourl = 'https://github.com/smartfile/python-libarchive' long_description = open(readme).read() @@ -101,7 +95,7 @@ __libarchive = Extension( libraries=['archive'], extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, - include_dirs=['libarchive'], + include_dirs=[includePath, 'libarchive'], ) From 825687dfe903c6fc737d1868e43a7b9dc39a52ab Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 16:05:34 +0200 Subject: [PATCH 76/91] Fixest for merging with parent --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 1784738..f3b25d0 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,6 @@ verify: install: python setup.py install -wheel: - pip wheel --wheel-dir dist/ . publish: python setup.py register From f18e798fa0a9954d30c55ab075622fa6c2085910 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 21:03:28 +0200 Subject: [PATCH 77/91] Fix to test for password protection --- .github/workflows/build-wheels.yaml | 104 ---------------------------- libarchive/zip.py | 2 +- tests.py | 19 +++++ 3 files changed, 20 insertions(+), 105 deletions(-) delete mode 100644 .github/workflows/build-wheels.yaml diff --git a/.github/workflows/build-wheels.yaml b/.github/workflows/build-wheels.yaml deleted file mode 100644 index ad0a5c6..0000000 --- a/.github/workflows/build-wheels.yaml +++ /dev/null @@ -1,104 +0,0 @@ -name: build-wheels - -on: - workflow_dispatch: - branches: - - master - - extended - -env: - libarchive_tag: v3.6.1 - -jobs: - many_linux_wheels: - name: manylinux-wheels - runs-on: ubuntu-latest - container: quay.io/pypa/manylinux2014_x86_64 - steps: - - uses: actions/checkout@v2 - - - name: Print System Information - run: | - echo "uname -a: $( uname -a )" - cat /etc/issue - echo "Shell: $SHELL" - echo "Mount points:"; mount - echo "nproc: $( nproc )" - env - - - name: Chose Python version - run: | - ln -s /opt/python/cp39-cp39/bin/python3 /usr/local/bin/python3 - export PATH="/opt/python/cp39-cp39/bin:$PATH" - - - name: Install dependencies - run: | - yum install -y epel-release libxml2-devel libzstd-devel xz-devel bzip2-devel - yum install -y libacl-devel lz4-devel e2fsprogs-devel libb2-devel lzo-devel openssl-devel - yum install -y librichacl-devel swig strace - - - name: Install python tools - run: | - python3 -m pip install pytest auditwheel - - - - name: Build libarchive C sources - run: | - git clone https://github.com/libarchive/libarchive.git libarchive-src - cd libarchive-src; git checkout ${{ env.libarchive_tag }} - mkdir build-libarchive; cd build-libarchive - cmake ../ - make -j$(nproc); make install - cd ../.. - - - - name: Prepare build environment - run: | - rm -rf build wheelhouse - touch libarchive/_libarchive.i - echo LD_LIBRARY_PATH=/usr/local/lib64/:/usr/local/lib:$LD_LIBRARY_PATH >>$GITHUB_ENV - echo LIBARCHIVE_PREFIX=/usr/local >>$GITHUB_ENV - - - name: Compile pyhton modules - run: | - python3 setup.py install - - - - name: Build wheels - run: | - python3 -m pip wheel --wheel-dir dist/ . - auditwheel repair dist/*.whl - python3 -m pip install --force-reinstall wheelhouse/*.whl - - - name: version - run: | - echo "::set-output name=version::$(cd /tmp; python3 -c 'import libarchive; print(libarchive.version())')" - id: version - - - uses: actions/upload-artifact@v3 - with: - name: python_libarchive_ext-${{ steps.version.outputs.version }}-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - path: ./wheelhouse/python_libarchive_ext-${{ steps.version.outputs.version }}-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - - - - name: release - uses: actions/create-release@v1 - id: create_release - with: - draft: false - prerelease: false - release_name: Release ${{ steps.version.outputs.version }} - tag_name: V${{ steps.version.outputs.version }}-${{ github.ref_name }}-${{ github.run_number }} - env: - GITHUB_TOKEN: ${{ github.token }} - - - name: upload artifact - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./wheelhouse/python_libarchive_ext-${{ steps.version.outputs.version }}-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - asset_name: python_libarchive_ext-${{ steps.version.outputs.version }}-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - asset_content_type: application/zip - \ No newline at end of file diff --git a/libarchive/zip.py b/libarchive/zip.py index 62fe4c1..be65386 100644 --- a/libarchive/zip.py +++ b/libarchive/zip.py @@ -106,7 +106,7 @@ class ZipFile(SeekableArchive): def read(self, name, pwd=None): if pwd: self.add_passphrase(pwd) - return self.read(name) + return super(ZipFile, self).read(name) def writestr(self, member, data, compress_type=None): if compress_type != self.compression: diff --git a/tests.py b/tests.py index bf6cb61..bc3fdc4 100644 --- a/tests.py +++ b/tests.py @@ -182,6 +182,25 @@ class TestZipWrite(unittest.TestCase): with open(os.path.join(TMPDIR, fname), 'r') as f: z.writepath(f) z.close() + self.f.close() + + + nz = ZipFile(ZIPPATH, 'r', password='test') + for fname in FILENAMES: + ffname = os.path.join(TMPDIR, fname) + with open(ffname, 'r') as f: + self.assertEqual(f.read(), nz.read(ffname)) + + nz.close() + + nz = ZipFile(ZIPPATH, 'r') + with self.assertRaises(Exception) as ctx: + ffname = os.path.join(TMPDIR, FILENAMES[0]) + with open(ffname, 'r') as f: + self.assertEqual(f.read(), nz.read(ffname)) + nz.close() + + def test_writepath_directory(self): """Test writing a directory.""" From b565ace61a1a23e36cdc59a4d3a901a27b1f0a5f Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 22:35:29 +0200 Subject: [PATCH 78/91] Implemnet correct password protection test --- tests.py | 60 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/tests.py b/tests.py index bc3fdc4..f984bc7 100644 --- a/tests.py +++ b/tests.py @@ -176,31 +176,6 @@ class TestZipWrite(unittest.TestCase): z.writepath(f) z.close() - def test_writepath_with_password(self): - z = ZipFile(self.f, 'w', password='test') - for fname in FILENAMES: - with open(os.path.join(TMPDIR, fname), 'r') as f: - z.writepath(f) - z.close() - self.f.close() - - - nz = ZipFile(ZIPPATH, 'r', password='test') - for fname in FILENAMES: - ffname = os.path.join(TMPDIR, fname) - with open(ffname, 'r') as f: - self.assertEqual(f.read(), nz.read(ffname)) - - nz.close() - - nz = ZipFile(ZIPPATH, 'r') - with self.assertRaises(Exception) as ctx: - ffname = os.path.join(TMPDIR, FILENAMES[0]) - with open(ffname, 'r') as f: - self.assertEqual(f.read(), nz.read(ffname)) - nz.close() - - def test_writepath_directory(self): """Test writing a directory.""" @@ -273,6 +248,41 @@ class TestZipWrite(unittest.TestCase): z.close() +import base64 + +ZIP_CONTENT='UEsDBAoACQAAAKubCVVjZ7b1FQAAAAkAAAAIABwAdGVzdC50eHRVVAkAA5K18mKStfJid' + \ + 'XgLAAEEAAAAAAQAAAAA5ryoP1rrRK5apjO41YMAPjpkWdU3UEsHCGNntvUVAAAACQAAAF' + \ + 'BLAQIeAwoACQAAAKubCVVjZ7b1FQAAAAkAAAAIABgAAAAAAAEAAACkgQAAAAB0ZXN0LnR' + \ + '4dFVUBQADkrXyYnV4CwABBAAAAAAEAAAAAFBLBQYAAAAAAQABAE4AAABnAAAAAAA=' + +ITEM_CONTENT='test.txt\n' +ITEM_NAME='test.txt' + + +class TestPasswordProtection(unittest.TestCase): + def setUp(self): + with open(ZIPPATH, mode='w') as f: + f.write(base64.b64decode(ZIP_CONTENT)) + + def tearDown(self): + os.remove(ZIPPATH) + + def test_read_with_password(self): + z = ZipFile(ZIPPATH, 'r', password='pwd') + self.assertEqual(z.read(ITEM_NAME), ITEM_CONTENT) + z.close() + + def test_read_without_password(self): + z = ZipFile(ZIPPATH, 'r') + self.assertRaises(RuntimeError, z.read, ITEM_NAME) + z.close() + + def test_read_with_wrong_password(self): + z = ZipFile(ZIPPATH, 'r', password='wrong') + self.assertRaises(RuntimeError, z.read, ITEM_NAME) + z.close() + + class TestHighLevelAPI(unittest.TestCase): def setUp(self): make_temp_archive() From 8d96aa686aa906ebff645956a87f338b1f0c7712 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 22:38:05 +0200 Subject: [PATCH 79/91] Remove pyproject.toml --- pyproject.toml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 88a3439..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,7 +0,0 @@ -# See https://setuptools.readthedocs.io/en/latest/build_meta.html - -[build-system] -# Use setuptools >= 43 because it automatically includes pyproject.toml in source distribution -# Use setuptools >= 46.5 to use attr: package.__version__ -# https://setuptools.readthedocs.io/en/latest/history.html#id284 -requires = ["setuptools", "wheel"] From 9a3680ded74ab86e3c27fe37396d1e0fdfbe3b24 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 22:54:47 +0200 Subject: [PATCH 80/91] Fix tests to wokr in python2 and Python3 environments --- tests.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests.py b/tests.py index f984bc7..8dbb753 100644 --- a/tests.py +++ b/tests.py @@ -33,8 +33,7 @@ import io from libarchive import Archive, is_archive_name, is_archive from libarchive.zip import is_zipfile, ZipFile, ZipEntry -# PY3 = sys.version_info[0] == 3 -PY3 = True +PY3 = sys.version_info[0] == 3 TMPDIR = tempfile.mkdtemp(suffix='.python-libarchive') ZIPFILE = 'test.zip' @@ -250,6 +249,15 @@ class TestZipWrite(unittest.TestCase): import base64 +# ZIP_CONTENT is base64 encoded password protected zip file with password: 'pwd' and following contents: +# unzip -l /tmp/zzz.zip +#Archive: /tmp/zzz.zip +# Length Date Time Name +#--------- ---------- ----- ---- +# 9 08-09-2022 19:29 test.txt +#--------- ------- +# 9 1 file + ZIP_CONTENT='UEsDBAoACQAAAKubCVVjZ7b1FQAAAAkAAAAIABwAdGVzdC50eHRVVAkAA5K18mKStfJid' + \ 'XgLAAEEAAAAAAQAAAAA5ryoP1rrRK5apjO41YMAPjpkWdU3UEsHCGNntvUVAAAACQAAAF' + \ 'BLAQIeAwoACQAAAKubCVVjZ7b1FQAAAAkAAAAIABgAAAAAAAEAAACkgQAAAAB0ZXN0LnR' + \ @@ -262,7 +270,11 @@ ITEM_NAME='test.txt' class TestPasswordProtection(unittest.TestCase): def setUp(self): with open(ZIPPATH, mode='w') as f: - f.write(base64.b64decode(ZIP_CONTENT)) + if PY3: + f.write(base64.b64decode(ZIP_CONTENT).decode('utf-8')) + else: + f.write(base64.b64decode(ZIP_CONTENT)) + def tearDown(self): os.remove(ZIPPATH) From 0b924d905048be8d047fe90deafedc0153f19ee0 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 23:06:58 +0200 Subject: [PATCH 81/91] Fix writing unicod data in python2 --- libarchive/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 79f520a..b95890f 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -283,7 +283,7 @@ class EntryWriteStream(object): if self.buffer: if PY3: self.buffer.write(data) - else: + elif isinstance(data, str): self.buffer.write(unicode(data, ENCODING)) else: _libarchive.archive_write_data_from_str(self.archive._a, data.encode(ENCODING)) From 0566cec2adef4476c17330341e82b8a8c79d5638 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 23:17:54 +0200 Subject: [PATCH 82/91] Fixes for python3 --- tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.py b/tests.py index 8dbb753..5abcba5 100644 --- a/tests.py +++ b/tests.py @@ -271,7 +271,7 @@ class TestPasswordProtection(unittest.TestCase): def setUp(self): with open(ZIPPATH, mode='w') as f: if PY3: - f.write(base64.b64decode(ZIP_CONTENT).decode('utf-8')) + f.write(base64.b64decode(ZIP_CONTENT).decode('latin1')) else: f.write(base64.b64decode(ZIP_CONTENT)) From be4531ffbc35123e31f84b8c70e1a53e4a7577c1 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Tue, 9 Aug 2022 23:26:54 +0200 Subject: [PATCH 83/91] More python3 fixes --- tests.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests.py b/tests.py index 5abcba5..5135362 100644 --- a/tests.py +++ b/tests.py @@ -269,10 +269,11 @@ ITEM_NAME='test.txt' class TestPasswordProtection(unittest.TestCase): def setUp(self): - with open(ZIPPATH, mode='w') as f: - if PY3: - f.write(base64.b64decode(ZIP_CONTENT).decode('latin1')) - else: + if PY3: + with open(ZIPPATH, mode='wb') as f: + f.write(base64.b64decode(ZIP_CONTENT)) + else: + with open(ZIPPATH, mode='w') as f: f.write(base64.b64decode(ZIP_CONTENT)) From aa419e61d9ebd8b535ea5b74c62eb92ffd63c6d9 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Wed, 10 Aug 2022 00:50:43 +0200 Subject: [PATCH 84/91] String and unicode handling fixes --- libarchive/__init__.py | 5 +---- libarchive/_libarchive_wrap.c | 25 ++++++++++++++++++++++++- tests.py | 5 ++++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index b95890f..df8c115 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -281,10 +281,7 @@ class EntryWriteStream(object): if self.closed: raise Exception('Cannot write to closed stream.') if self.buffer: - if PY3: - self.buffer.write(data) - elif isinstance(data, str): - self.buffer.write(unicode(data, ENCODING)) + self.buffer.write(data) else: _libarchive.archive_write_data_from_str(self.archive._a, data.encode(ENCODING)) self.bytes += len(data) diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index bcc604f..44a3147 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -3193,7 +3193,7 @@ SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) } - +#if 1 PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *str = NULL; if (!(str = PyBytes_FromStringAndSize(NULL, len))) { @@ -3216,6 +3216,29 @@ PyObject *archive_write_data_from_str(struct archive *archive, PyObject *str) { } return PyInt_FromLong(len); } +#else +PyObject *archive_read_data_into_str(struct archive *archive, int len) { + PyObject *str = NULL; + if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { + PyErr_SetString(PyExc_MemoryError, "could not allocate string."); + return NULL; + } + if (len != archive_read_data(archive, PyString_AS_STRING(str), len)) { + PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); + return NULL; + } + return str; +} + +PyObject *archive_write_data_from_str(struct archive *archive, PyObject *str) { + int len = PyString_Size(str); + if (!archive_write_data(archive, PyString_AS_STRING(str), len)) { + PyErr_SetString(PyExc_RuntimeError, "could not write requested data."); + return NULL; + } + return PyInt_FromLong(len); +} +#endif #ifdef __cplusplus extern "C" { diff --git a/tests.py b/tests.py index 5135362..6c6ad7c 100644 --- a/tests.py +++ b/tests.py @@ -282,7 +282,10 @@ class TestPasswordProtection(unittest.TestCase): def test_read_with_password(self): z = ZipFile(ZIPPATH, 'r', password='pwd') - self.assertEqual(z.read(ITEM_NAME), ITEM_CONTENT) + if PY3: + self.assertEqual(z.read(ITEM_NAME), bytes(ITEM_CONTENT, 'utf-8')) + else: + self.assertEqual(z.read(ITEM_NAME), ITEM_CONTENT) z.close() def test_read_without_password(self): From 0f1190d007638b3d8fa0af515f78675b68ffba09 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Thu, 11 Aug 2022 00:35:33 +0200 Subject: [PATCH 85/91] Fix password protected ZIP creation and reading --- libarchive/__init__.py | 305 +++++++++++++++++++++++++---------------- libarchive/zip.py | 60 ++++++-- 2 files changed, 235 insertions(+), 130 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index df8c115..829b36d 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -36,81 +36,116 @@ PY3 = sys.version_info[0] >= 3 # Suggested block size for libarchive. Libarchive may adjust it. BLOCK_SIZE = 10240 -MTIME_FORMAT = '' +MTIME_FORMAT = "" # Default encoding scheme. -ENCODING = 'utf-8' +ENCODING = "utf-8" # Functions to initialize read/write for various libarchive supported formats and filters. FORMATS = { None: (_libarchive.archive_read_support_format_all, None), - 'tar': (_libarchive.archive_read_support_format_tar, _libarchive.archive_write_set_format_ustar), - 'pax': (_libarchive.archive_read_support_format_tar, _libarchive.archive_write_set_format_pax), - 'gnu': (_libarchive.archive_read_support_format_gnutar, _libarchive.archive_write_set_format_gnutar), - 'zip': (_libarchive.archive_read_support_format_zip, _libarchive.archive_write_set_format_zip), - 'rar': (_libarchive.archive_read_support_format_rar, None), - '7zip': (_libarchive.archive_read_support_format_7zip, None), - 'ar': (_libarchive.archive_read_support_format_ar, None), - 'cab': (_libarchive.archive_read_support_format_cab, None), - 'cpio': (_libarchive.archive_read_support_format_cpio, _libarchive.archive_write_set_format_cpio_newc), - 'iso': (_libarchive.archive_read_support_format_iso9660, _libarchive.archive_write_set_format_iso9660), - 'lha': (_libarchive.archive_read_support_format_lha, None), - 'xar': (_libarchive.archive_read_support_format_xar, _libarchive.archive_write_set_format_xar), + "tar": ( + _libarchive.archive_read_support_format_tar, + _libarchive.archive_write_set_format_ustar, + ), + "pax": ( + _libarchive.archive_read_support_format_tar, + _libarchive.archive_write_set_format_pax, + ), + "gnu": ( + _libarchive.archive_read_support_format_gnutar, + _libarchive.archive_write_set_format_gnutar, + ), + "zip": ( + _libarchive.archive_read_support_format_zip, + _libarchive.archive_write_set_format_zip, + ), + "rar": (_libarchive.archive_read_support_format_rar, None), + "7zip": (_libarchive.archive_read_support_format_7zip, None), + "ar": (_libarchive.archive_read_support_format_ar, None), + "cab": (_libarchive.archive_read_support_format_cab, None), + "cpio": ( + _libarchive.archive_read_support_format_cpio, + _libarchive.archive_write_set_format_cpio_newc, + ), + "iso": ( + _libarchive.archive_read_support_format_iso9660, + _libarchive.archive_write_set_format_iso9660, + ), + "lha": (_libarchive.archive_read_support_format_lha, None), + "xar": ( + _libarchive.archive_read_support_format_xar, + _libarchive.archive_write_set_format_xar, + ), } FILTERS = { - None: (_libarchive.archive_read_support_filter_all, _libarchive.archive_write_add_filter_none), - 'gz': (_libarchive.archive_read_support_filter_gzip, _libarchive.archive_write_add_filter_gzip), - 'bz2': (_libarchive.archive_read_support_filter_bzip2, _libarchive.archive_write_add_filter_bzip2), + None: ( + _libarchive.archive_read_support_filter_all, + _libarchive.archive_write_add_filter_none, + ), + "gz": ( + _libarchive.archive_read_support_filter_gzip, + _libarchive.archive_write_add_filter_gzip, + ), + "bz2": ( + _libarchive.archive_read_support_filter_bzip2, + _libarchive.archive_write_add_filter_bzip2, + ), } # Map file extensions to formats and filters. To support quick detection. FORMAT_EXTENSIONS = { - '.tar': 'tar', - '.zip': 'zip', - '.rar': 'rar', - '.7z': '7zip', - '.ar': 'ar', - '.cab': 'cab', - '.rpm': 'cpio', - '.cpio': 'cpio', - '.iso': 'iso', - '.lha': 'lha', - '.xar': 'xar', + ".tar": "tar", + ".zip": "zip", + ".rar": "rar", + ".7z": "7zip", + ".ar": "ar", + ".cab": "cab", + ".rpm": "cpio", + ".cpio": "cpio", + ".iso": "iso", + ".lha": "lha", + ".xar": "xar", } FILTER_EXTENSIONS = { - '.gz': 'gz', - '.bz2': 'bz2', + ".gz": "gz", + ".bz2": "bz2", } class EOF(Exception): - '''Raised by ArchiveInfo.from_archive() when unable to read the next - archive header.''' + """Raised by ArchiveInfo.from_archive() when unable to read the next + archive header.""" pass + def version(): - '''Returns the version of the libarchive library.''' + """Returns the version of the libarchive library.""" return _libarchive.archive_version_string().split()[1] def get_error(archive): - '''Retrieves the last error description for the given archive instance.''' + """Retrieves the last error description for the given archive instance.""" return _libarchive.archive_error_string(archive) def call_and_check(func, archive, *args): - '''Executes a libarchive function and raises an exception when appropriate.''' + """Executes a libarchive function and raises an exception when appropriate.""" ret = func(*args) if ret == _libarchive.ARCHIVE_OK: return elif ret == _libarchive.ARCHIVE_WARN: - warnings.warn('Warning executing function: %s.' % get_error(archive), RuntimeWarning) + warnings.warn( + "Warning executing function: %s." % get_error(archive), RuntimeWarning + ) elif ret == _libarchive.ARCHIVE_EOF: raise EOF() else: - raise Exception('Problem executing function, message is: %s.' % get_error(archive)) + raise Exception( + "Problem executing function, message is: %s." % get_error(archive) + ) def get_func(name, items, index): @@ -122,7 +157,7 @@ def get_func(name, items, index): def guess_format(filename): if isinstance(filename, int): - filename = ext = '' + filename = ext = "" else: filename, ext = os.path.splitext(filename) filter = FILTER_EXTENSIONS.get(ext) @@ -133,12 +168,12 @@ def guess_format(filename): def is_archive_name(filename, formats=None): - '''Quick check to see if the given file has an extension indiciating that it is + """Quick check to see if the given file has an extension indiciating that it is an archive. The format parameter can be used to limit what archive format is acceptable. If omitted, all supported archive formats will be checked. This function will return the name of the most likely archive format, None if the file is - unlikely to be an archive.''' + unlikely to be an archive.""" if formats is None: formats = list(FORMAT_EXTENSIONS.values()) format, filter = guess_format(filename) @@ -147,7 +182,7 @@ def is_archive_name(filename, formats=None): def is_archive(f, formats=(None,), filters=(None,)): - '''Check to see if the given file is actually an archive. The format parameter + """Check to see if the given file is actually an archive. The format parameter can be used to specify which archive format is acceptable. If ommitted, all supported archive formats will be checked. It opens the file using libarchive. If no error is received, the file was successfully detected by the libarchive bidding process. @@ -158,10 +193,10 @@ def is_archive(f, formats=(None,), filters=(None,)): this function. This function will return True if the file can be opened as an archive using the given - format(s)/filter(s).''' + format(s)/filter(s).""" need_close = False if isinstance(f, str): - f = open(f, 'rb') + f = open(f, "rb") need_close = True a = _libarchive.archive_read_new() for format in formats: @@ -176,7 +211,9 @@ def is_archive(f, formats=(None,), filters=(None,)): filter(a) try: try: - call_and_check(_libarchive.archive_read_open_fd, a, a, f.fileno(), BLOCK_SIZE) + call_and_check( + _libarchive.archive_read_open_fd, a, a, f.fileno(), BLOCK_SIZE + ) return True except: return False @@ -188,7 +225,7 @@ def is_archive(f, formats=(None,), filters=(None,)): class EntryReadStream(object): - '''A file-like object for reading an entry from the archive.''' + """A file-like object for reading an entry from the archive.""" def __init__(self, archive, size): self.archive = archive @@ -244,11 +281,11 @@ class EntryReadStream(object): class EntryWriteStream(object): - '''A file-like object for writing an entry to an archive. + """A file-like object for writing an entry to an archive. If the size is known ahead of time and provided, then the file contents are not buffered but flushed directly to the archive. If size is omitted, - then the file contents are buffered and flushed in the close() method.''' + then the file contents are buffered and flushed in the close() method.""" def __init__(self, archive, pathname, size=None): self.archive = archive @@ -279,11 +316,13 @@ class EntryWriteStream(object): def write(self, data): if self.closed: - raise Exception('Cannot write to closed stream.') + raise Exception("Cannot write to closed stream.") if self.buffer: self.buffer.write(data) else: - _libarchive.archive_write_data_from_str(self.archive._a, data.encode(ENCODING)) + _libarchive.archive_write_data_from_str( + self.archive._a, data.encode(ENCODING) + ) self.bytes += len(data) def close(self): @@ -292,7 +331,9 @@ class EntryWriteStream(object): if self.buffer: self.entry.size = self.buffer.tell() self.entry.to_archive(self.archive) - _libarchive.archive_write_data_from_str(self.archive._a, self.buffer.getvalue().encode(ENCODING)) + _libarchive.archive_write_data_from_str( + self.archive._a, self.buffer.getvalue().encode(ENCODING) + ) _libarchive.archive_write_finish_entry(self.archive._a) # Call archive.close() with _defer True to let it know we have been @@ -303,9 +344,17 @@ class EntryWriteStream(object): class Entry(object): - '''An entry within an archive. Represents the header data and it's location within the archive.''' + """An entry within an archive. Represents the header data and it's location within the archive.""" - def __init__(self, pathname=None, size=None, mtime=None, mode=None, hpos=None, encoding=ENCODING): + def __init__( + self, + pathname=None, + size=None, + mtime=None, + mode=None, + hpos=None, + encoding=ENCODING, + ): # , symlink=None self.pathname = pathname @@ -323,10 +372,12 @@ class Entry(object): @classmethod def from_archive(cls, archive, encoding=ENCODING): - '''Instantiates an Entry class and sets all the properties from an archive header.''' + """Instantiates an Entry class and sets all the properties from an archive header.""" e = _libarchive.archive_entry_new() try: - call_and_check(_libarchive.archive_read_next_header2, archive._a, archive._a, e) + call_and_check( + _libarchive.archive_read_next_header2, archive._a, archive._a, e + ) mode = _libarchive.archive_entry_filetype(e) mode |= _libarchive.archive_entry_perm(e) @@ -353,8 +404,8 @@ class Entry(object): @classmethod def from_file(cls, f, entry=None, encoding=ENCODING): - '''Instantiates an Entry class and sets all the properties from a file on the file system. - f can be a file-like object or a path.''' + """Instantiates an Entry class and sets all the properties from a file on the file system. + f can be a file-like object or a path.""" if entry is None: entry = cls(encoding=encoding) if entry.pathname is None: @@ -364,29 +415,30 @@ class Entry(object): entry.size = st.st_size entry.mtime = st.st_mtime entry.mode = st.st_mode - elif hasattr(f, 'fileno'): + elif hasattr(f, "fileno"): st = os.fstat(f.fileno()) - entry.pathname = getattr(f, 'name', None) + entry.pathname = getattr(f, "name", None) entry.size = st.st_size entry.mtime = st.st_mtime entry.mode = st.st_mode else: - entry.pathname = getattr(f, 'pathname', None) - entry.size = getattr(f, 'size', 0) - entry.mtime = getattr(f, 'mtime', time.time()) + entry.pathname = getattr(f, "pathname", None) + entry.size = getattr(f, "size", 0) + entry.mtime = getattr(f, "mtime", time.time()) entry.mode = stat.S_IFREG - return entry def to_archive(self, archive): - '''Creates an archive header and writes it to the given archive.''' + """Creates an archive header and writes it to the given archive.""" e = _libarchive.archive_entry_new() try: if PY3: _libarchive.archive_entry_set_pathname(e, self.pathname) else: - _libarchive.archive_entry_set_pathname(e, self.pathname.encode(self.encoding)) + _libarchive.archive_entry_set_pathname( + e, self.pathname.encode(self.encoding) + ) _libarchive.archive_entry_set_filetype(e, stat.S_IFMT(self.mode)) _libarchive.archive_entry_set_perm(e, stat.S_IMODE(self.mode)) _libarchive.archive_entry_set_size(e, self.size) @@ -420,13 +472,13 @@ class Entry(object): class Archive(object): - '''A low-level archive reader which provides forward-only iteration. Consider - this a light-weight pythonic libarchive wrapper.''' + """A low-level archive reader which provides forward-only iteration. Consider + this a light-weight pythonic libarchive wrapper.""" def __init__( self, f, - mode='r', + mode="r", format=None, filter=None, entry_class=Entry, @@ -434,7 +486,7 @@ class Archive(object): blocksize=BLOCK_SIZE, password=None, ): - assert mode in ('r', 'w', 'wb', 'a'), 'Mode should be "r", "w", "wb", or "a".' + assert mode in ("r", "w", "wb", "a"), 'Mode should be "r", "w", "wb", or "a".' self._stream = None self.encoding = encoding self.blocksize = blocksize @@ -444,12 +496,12 @@ class Archive(object): f = open(f, mode) # Only close it if we opened it... self._defer_close = True - elif hasattr(f, 'fileno'): - self.filename = getattr(f, 'name', None) + elif hasattr(f, "fileno"): + self.filename = getattr(f, "name", None) # Leave the fd alone, caller should manage it... self._defer_close = False else: - raise Exception('Provided file is not path or open file.') + raise Exception("Provided file is not path or open file.") self.f = f self.mode = mode # Guess the format/filter from file name (if not provided) @@ -463,23 +515,23 @@ class Archive(object): # The class to use for entries. self.entry_class = entry_class # Select filter/format functions. - if self.mode == 'r': + if self.mode == "r": self.format_func = get_func(self.format, FORMATS, 0) if self.format_func is None: - raise Exception('Unsupported format %s' % format) + raise Exception("Unsupported format %s" % format) self.filter_func = get_func(self.filter, FILTERS, 0) if self.filter_func is None: - raise Exception('Unsupported filter %s' % filter) + raise Exception("Unsupported filter %s" % filter) else: # TODO: how to support appending? if self.format is None: - raise Exception('You must specify a format for writing.') + raise Exception("You must specify a format for writing.") self.format_func = get_func(self.format, FORMATS, 1) if self.format_func is None: - raise Exception('Unsupported format %s' % format) + raise Exception("Unsupported format %s" % format) self.filter_func = get_func(self.filter, FILTERS, 1) if self.filter_func is None: - raise Exception('Unsupported filter %s' % filter) + raise Exception("Unsupported filter %s" % filter) # Open the archive, apply filter/format functions. self.init() @@ -499,31 +551,47 @@ class Archive(object): def __del__(self): self.close() + def set_initial_options(self): + pass + def init(self): - if self.mode == 'r': + if self.mode == "r": self._a = _libarchive.archive_read_new() else: self._a = _libarchive.archive_write_new() self.format_func(self._a) self.filter_func(self._a) - if self.mode == 'r': + self.set_initial_options() + if self.mode == "r": if self.password: - self.add_passphrase(self.password) - call_and_check(_libarchive.archive_read_open_fd, self._a, self._a, self.f.fileno(), self.blocksize) + if isinstance(self.password, list): + for pwd in self.password: + self.add_passphrase(pwd) + else: + self.add_passphrase(self.password) + call_and_check( + _libarchive.archive_read_open_fd, + self._a, + self._a, + self.f.fileno(), + self.blocksize, + ) else: if self.password: self.set_passphrase(self.password) - call_and_check(_libarchive.archive_write_open_fd, self._a, self._a, self.f.fileno()) + call_and_check( + _libarchive.archive_write_open_fd, self._a, self._a, self.f.fileno() + ) def denit(self): - '''Closes and deallocates the archive reader/writer.''' - if getattr(self, '_a', None) is None: + """Closes and deallocates the archive reader/writer.""" + if getattr(self, "_a", None) is None: return try: - if self.mode == 'r': + if self.mode == "r": _libarchive.archive_read_close(self._a) _libarchive.archive_read_free(self._a) - elif self.mode == 'w': + elif self.mode == "w": _libarchive.archive_write_close(self._a) _libarchive.archive_write_free(self._a) finally: @@ -545,23 +613,23 @@ class Archive(object): return self.denit() # If there is a file attached... - if hasattr(self, 'f'): + if hasattr(self, "f"): # Make sure it is not already closed... - if getattr(self.f, 'closed', False): + if getattr(self.f, "closed", False): return # Flush it if not read-only... - if hasattr(self.f, "mode") and self.f.mode != 'r' and self.f.mode != 'rb': + if hasattr(self.f, "mode") and self.f.mode != "r" and self.f.mode != "rb": if hasattr(self.f, "flush"): self.f.flush() if hasattr(self.f, "fileno"): os.fsync(self.f.fileno()) # and then close it, if we opened it... - if getattr(self, '_close', None): + if getattr(self, "_close", None): self.f.close() @property def header_position(self): - '''The position within the file.''' + """The position within the file.""" return _libarchive.archive_read_header_position(self._a) def iterpaths(self): @@ -569,30 +637,33 @@ class Archive(object): yield entry.pathname def read(self, size): - '''Read current archive entry contents into string.''' + """Read current archive entry contents into string.""" return _libarchive.archive_read_data_into_str(self._a, size) def readpath(self, f): - '''Write current archive entry contents to file. f can be a file-like object or - a path.''' + """Write current archive entry contents to file. f can be a file-like object or + a path.""" if isinstance(f, str): basedir = os.path.dirname(f) if not os.path.exists(basedir): os.makedirs(basedir) - f = open(f, 'w') + f = open(f, "w") return _libarchive.archive_read_data_into_fd(self._a, f.fileno()) def readstream(self, size): - '''Returns a file-like object for reading current archive entry contents.''' + """Returns a file-like object for reading current archive entry contents.""" self._stream = EntryReadStream(self, size) return self._stream def write(self, member, data=None): - '''Writes a string buffer to the archive as the given entry.''' + """Writes a string buffer to the archive as the given entry.""" if isinstance(member, str): member = self.entry_class(pathname=member, encoding=self.encoding) + member.mode = stat.S_IFREG + member.mtime = time.time() if data: member.size = len(data) + member.to_archive(self) if data: @@ -600,63 +671,65 @@ class Archive(object): if isinstance(data, bytes): result = _libarchive.archive_write_data_from_str(self._a, data) else: - result = _libarchive.archive_write_data_from_str(self._a, data.encode(self.encoding)) + result = _libarchive.archive_write_data_from_str( + self._a, data.encode(self.encoding) + ) else: result = _libarchive.archive_write_data_from_str(self._a, data) _libarchive.archive_write_finish_entry(self._a) def writepath(self, f, pathname=None, folder=False): - '''Writes a file to the archive. f can be a file-like object or a path. Uses - write() to do the actual writing.''' + """Writes a file to the archive. f can be a file-like object or a path. Uses + write() to do the actual writing.""" member = self.entry_class.from_file(f, encoding=self.encoding) if isinstance(f, str): if os.path.isfile(f): - f = open(f, 'r') + f = open(f, "r") if pathname: member.pathname = pathname if folder and not member.isdir(): member.mode = stat.S_IFDIR - if hasattr(f, 'read'): + if hasattr(f, "read"): # TODO: optimize this to write directly from f to archive. self.write(member, data=f.read()) else: self.write(member) def writestream(self, pathname, size=None): - '''Returns a file-like object for writing a new entry.''' + """Returns a file-like object for writing a new entry.""" self._stream = EntryWriteStream(self, pathname, size) return self._stream def printlist(self, s=sys.stdout): for entry in self: s.write(entry.size) - s.write('\t') + s.write("\t") s.write(entry.mtime.strftime(MTIME_FORMAT)) - s.write('\t') + s.write("\t") s.write(entry.pathname) s.flush() def add_passphrase(self, password): - '''Adds a password to the archive.''' + """Adds a password to the archive.""" _libarchive.archive_read_add_passphrase(self._a, password) def set_passphrase(self, password): - '''Sets a password for the archive.''' + """Sets a password for the archive.""" _libarchive.archive_write_set_passphrase(self._a, password) class SeekableArchive(Archive): - '''A class that provides random-access to archive entries. It does this by using one + """A class that provides random-access to archive entries. It does this by using one or many Archive instances to seek to the correct location. The best performance will occur when reading archive entries in the order in which they appear in the archive. Reading out of order will cause the archive to be closed and opened each time a - reverse seek is needed.''' + reverse seek is needed.""" def __init__(self, f, **kwargs): self._stream = None # Convert file to open file. We need this to reopen the archive. - mode = kwargs.setdefault('mode', 'r') + mode = kwargs.setdefault("mode", "r") if isinstance(f, str): f = open(f, mode) super(SeekableArchive, self).__init__(f, **kwargs) @@ -675,21 +748,21 @@ class SeekableArchive(Archive): self.eof = True def reopen(self): - '''Seeks the underlying fd to 0 position, then opens the archive. If the archive - is already open, this will effectively re-open it (rewind to the beginning).''' + """Seeks the underlying fd to 0 position, then opens the archive. If the archive + is already open, this will effectively re-open it (rewind to the beginning).""" self.denit() self.f.seek(0) self.init() def getentry(self, pathname): - '''Take a name or entry object and returns an entry object.''' + """Take a name or entry object and returns an entry object.""" for entry in self: if entry.pathname == pathname: return entry raise KeyError(pathname) def seek(self, entry): - '''Seeks the archive to the requested entry. Will reopen if necessary.''' + """Seeks the archive to the requested entry. Will reopen if necessary.""" move = entry.header_position - self.header_position if move != 0: if move < 0: @@ -701,7 +774,7 @@ class SeekableArchive(Archive): break def read(self, member): - '''Return the requested archive entry contents as a string.''' + """Return the requested archive entry contents as a string.""" entry = self.getentry(member) self.seek(entry) return super(SeekableArchive, self).read(entry.size) @@ -712,7 +785,7 @@ class SeekableArchive(Archive): return super(SeekableArchive, self).readpath(f) def readstream(self, member): - '''Returns a file-like object for reading requested archive entry contents.''' + """Returns a file-like object for reading requested archive entry contents.""" entry = self.getentry(member) self.seek(entry) self._stream = EntryReadStream(self, entry.size) diff --git a/libarchive/zip.py b/libarchive/zip.py index be65386..85cacb1 100644 --- a/libarchive/zip.py +++ b/libarchive/zip.py @@ -1,10 +1,10 @@ import os, time -from libarchive import is_archive, Entry, SeekableArchive +from libarchive import is_archive, Entry, SeekableArchive, _libarchive from zipfile import ZIP_STORED, ZIP_DEFLATED def is_zipfile(filename): - return is_archive(filename, formats=('zip',)) + return is_archive(filename, formats=("zip",)) class ZipEntry(Entry): @@ -23,7 +23,7 @@ class ZipEntry(Entry): return self.size def set_file_size(self, value): - assert isinstance(value, int), 'Please provide size as int or long.' + assert isinstance(value, int), "Please provide size as int or long." self.size = value file_size = property(get_file_size, set_file_size) @@ -32,8 +32,12 @@ class ZipEntry(Entry): return time.localtime(self.mtime)[0:6] def set_date_time(self, value): - assert isinstance(value, tuple), 'mtime should be tuple (year, month, day, hour, minute, second).' - assert len(value) == 6, 'mtime should be tuple (year, month, day, hour, minute, second).' + assert isinstance( + value, tuple + ), "mtime should be tuple (year, month, day, hour, minute, second)." + assert ( + len(value) == 6 + ), "mtime should be tuple (year, month, day, hour, minute, second)." self.mtime = time.mktime(value + (0, 0, 0)) date_time = property(get_date_time, set_date_time) @@ -61,18 +65,46 @@ class ZipEntry(Entry): compress_size = property(_get_missing, _set_missing) +# encryption is one of (traditional = zipcrypt, aes128, aes256) class ZipFile(SeekableArchive): - def __init__(self, f, mode='r', compression=ZIP_DEFLATED, allowZip64=False, password=None): + def __init__( + self, + f, + mode="r", + compression=ZIP_DEFLATED, + allowZip64=False, + password=None, + encryption=None, + ): + + self.encryption = encryption + self.compression = compression + super(ZipFile, self).__init__( - f, mode=mode, format='zip', entry_class=ZipEntry, encoding='CP437', password=password + f, + mode=mode, + format="zip", + entry_class=ZipEntry, + encoding="CP437", + password=password, ) - if mode == 'w' and compression == ZIP_STORED: - # Disable compression for writing. - _libarchive.archive_write_set_format_option(self.archive._a, "zip", "compression", "store") - self.compression = compression getinfo = SeekableArchive.getentry + def set_initial_options(self): + if self.mode == "w" and self.compression == ZIP_STORED: + # Disable compression for writing. + _libarchive.archive_write_set_format_option( + self._a, "zip", "compression", "store" + ) + + if self.mode == "w" and self.password: + if not self.encryption: + self.encryption = "traditional" + _libarchive.archive_write_set_format_option( + self._a, "zip", "encryption", self.encryption + ) + def namelist(self): return list(self.iterpaths()) @@ -80,7 +112,7 @@ class ZipFile(SeekableArchive): return list(self) def open(self, name, mode, pwd=None): - if mode == 'r': + if mode == "r": if pwd: self.add_passphrase(pwd) return self.readstream(name) @@ -109,8 +141,8 @@ class ZipFile(SeekableArchive): return super(ZipFile, self).read(name) def writestr(self, member, data, compress_type=None): - if compress_type != self.compression: - raise Exception('Cannot change compression type for individual entries.') + if compress_type != self.compression and not (compress_type is None): + raise Exception("Cannot change compression type for individual entries.") return self.write(member, data) def setpassword(self, pwd): From 4dafc2696a39b3b892cd4c017326229c587c10ff Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Thu, 11 Aug 2022 00:37:32 +0200 Subject: [PATCH 86/91] Implement testing of password protected zip creation --- tests.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/tests.py b/tests.py index 6c6ad7c..9380e63 100644 --- a/tests.py +++ b/tests.py @@ -266,22 +266,58 @@ ZIP_CONTENT='UEsDBAoACQAAAKubCVVjZ7b1FQAAAAkAAAAIABwAdGVzdC50eHRVVAkAA5K18mKStfJ ITEM_CONTENT='test.txt\n' ITEM_NAME='test.txt' +ZIP1_PWD='pwd' +ZIP2_PWD='12345' +def create_file_from_content(): + if PY3: + with open(ZIPPATH, mode='wb') as f: + f.write(base64.b64decode(ZIP_CONTENT)) + else: + with open(ZIPPATH, mode='w') as f: + f.write(base64.b64decode(ZIP_CONTENT)) -class TestPasswordProtection(unittest.TestCase): + +def create_protected_zip(): + z = ZipFile(ZIPPATH, mode='w', password=ZIP2_PWD) + z.writestr(ITEM_NAME, ITEM_CONTENT) + z.close() + + +class TestProtectedReading(unittest.TestCase): def setUp(self): + create_file_from_content() + + + def tearDown(self): + os.remove(ZIPPATH) + + def test_read_with_password(self): + z = ZipFile(ZIPPATH, 'r', password=ZIP1_PWD) if PY3: - with open(ZIPPATH, mode='wb') as f: - f.write(base64.b64decode(ZIP_CONTENT)) + self.assertEqual(z.read(ITEM_NAME), bytes(ITEM_CONTENT, 'utf-8')) else: - with open(ZIPPATH, mode='w') as f: - f.write(base64.b64decode(ZIP_CONTENT)) + self.assertEqual(z.read(ITEM_NAME), ITEM_CONTENT) + z.close() + + def test_read_without_password(self): + z = ZipFile(ZIPPATH, 'r') + self.assertRaises(RuntimeError, z.read, ITEM_NAME) + z.close() + + def test_read_with_wrong_password(self): + z = ZipFile(ZIPPATH, 'r', password='wrong') + self.assertRaises(RuntimeError, z.read, ITEM_NAME) + z.close() + +class TestProtectedWriting(unittest.TestCase): + def setUp(self): + create_protected_zip() - def tearDown(self): os.remove(ZIPPATH) def test_read_with_password(self): - z = ZipFile(ZIPPATH, 'r', password='pwd') + z = ZipFile(ZIPPATH, 'r', password=ZIP2_PWD) if PY3: self.assertEqual(z.read(ITEM_NAME), bytes(ITEM_CONTENT, 'utf-8')) else: @@ -298,6 +334,15 @@ class TestPasswordProtection(unittest.TestCase): self.assertRaises(RuntimeError, z.read, ITEM_NAME) z.close() + def test_read_with_password_list(self): + z = ZipFile(ZIPPATH, 'r', password=[ZIP1_PWD, ZIP2_PWD]) + if PY3: + self.assertEqual(z.read(ITEM_NAME), bytes(ITEM_CONTENT, 'utf-8')) + else: + self.assertEqual(z.read(ITEM_NAME), ITEM_CONTENT) + z.close() + + class TestHighLevelAPI(unittest.TestCase): def setUp(self): From 4864f77f55249975623009dac499153ade7a31e6 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Thu, 11 Aug 2022 18:01:32 +0200 Subject: [PATCH 87/91] Restore formatting --- libarchive/__init__.py | 305 ++++++++++++++++------------------------- libarchive/zip.py | 60 ++------ 2 files changed, 130 insertions(+), 235 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 829b36d..df8c115 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -36,116 +36,81 @@ PY3 = sys.version_info[0] >= 3 # Suggested block size for libarchive. Libarchive may adjust it. BLOCK_SIZE = 10240 -MTIME_FORMAT = "" +MTIME_FORMAT = '' # Default encoding scheme. -ENCODING = "utf-8" +ENCODING = 'utf-8' # Functions to initialize read/write for various libarchive supported formats and filters. FORMATS = { None: (_libarchive.archive_read_support_format_all, None), - "tar": ( - _libarchive.archive_read_support_format_tar, - _libarchive.archive_write_set_format_ustar, - ), - "pax": ( - _libarchive.archive_read_support_format_tar, - _libarchive.archive_write_set_format_pax, - ), - "gnu": ( - _libarchive.archive_read_support_format_gnutar, - _libarchive.archive_write_set_format_gnutar, - ), - "zip": ( - _libarchive.archive_read_support_format_zip, - _libarchive.archive_write_set_format_zip, - ), - "rar": (_libarchive.archive_read_support_format_rar, None), - "7zip": (_libarchive.archive_read_support_format_7zip, None), - "ar": (_libarchive.archive_read_support_format_ar, None), - "cab": (_libarchive.archive_read_support_format_cab, None), - "cpio": ( - _libarchive.archive_read_support_format_cpio, - _libarchive.archive_write_set_format_cpio_newc, - ), - "iso": ( - _libarchive.archive_read_support_format_iso9660, - _libarchive.archive_write_set_format_iso9660, - ), - "lha": (_libarchive.archive_read_support_format_lha, None), - "xar": ( - _libarchive.archive_read_support_format_xar, - _libarchive.archive_write_set_format_xar, - ), + 'tar': (_libarchive.archive_read_support_format_tar, _libarchive.archive_write_set_format_ustar), + 'pax': (_libarchive.archive_read_support_format_tar, _libarchive.archive_write_set_format_pax), + 'gnu': (_libarchive.archive_read_support_format_gnutar, _libarchive.archive_write_set_format_gnutar), + 'zip': (_libarchive.archive_read_support_format_zip, _libarchive.archive_write_set_format_zip), + 'rar': (_libarchive.archive_read_support_format_rar, None), + '7zip': (_libarchive.archive_read_support_format_7zip, None), + 'ar': (_libarchive.archive_read_support_format_ar, None), + 'cab': (_libarchive.archive_read_support_format_cab, None), + 'cpio': (_libarchive.archive_read_support_format_cpio, _libarchive.archive_write_set_format_cpio_newc), + 'iso': (_libarchive.archive_read_support_format_iso9660, _libarchive.archive_write_set_format_iso9660), + 'lha': (_libarchive.archive_read_support_format_lha, None), + 'xar': (_libarchive.archive_read_support_format_xar, _libarchive.archive_write_set_format_xar), } FILTERS = { - None: ( - _libarchive.archive_read_support_filter_all, - _libarchive.archive_write_add_filter_none, - ), - "gz": ( - _libarchive.archive_read_support_filter_gzip, - _libarchive.archive_write_add_filter_gzip, - ), - "bz2": ( - _libarchive.archive_read_support_filter_bzip2, - _libarchive.archive_write_add_filter_bzip2, - ), + None: (_libarchive.archive_read_support_filter_all, _libarchive.archive_write_add_filter_none), + 'gz': (_libarchive.archive_read_support_filter_gzip, _libarchive.archive_write_add_filter_gzip), + 'bz2': (_libarchive.archive_read_support_filter_bzip2, _libarchive.archive_write_add_filter_bzip2), } # Map file extensions to formats and filters. To support quick detection. FORMAT_EXTENSIONS = { - ".tar": "tar", - ".zip": "zip", - ".rar": "rar", - ".7z": "7zip", - ".ar": "ar", - ".cab": "cab", - ".rpm": "cpio", - ".cpio": "cpio", - ".iso": "iso", - ".lha": "lha", - ".xar": "xar", + '.tar': 'tar', + '.zip': 'zip', + '.rar': 'rar', + '.7z': '7zip', + '.ar': 'ar', + '.cab': 'cab', + '.rpm': 'cpio', + '.cpio': 'cpio', + '.iso': 'iso', + '.lha': 'lha', + '.xar': 'xar', } FILTER_EXTENSIONS = { - ".gz": "gz", - ".bz2": "bz2", + '.gz': 'gz', + '.bz2': 'bz2', } class EOF(Exception): - """Raised by ArchiveInfo.from_archive() when unable to read the next - archive header.""" + '''Raised by ArchiveInfo.from_archive() when unable to read the next + archive header.''' pass - def version(): - """Returns the version of the libarchive library.""" + '''Returns the version of the libarchive library.''' return _libarchive.archive_version_string().split()[1] def get_error(archive): - """Retrieves the last error description for the given archive instance.""" + '''Retrieves the last error description for the given archive instance.''' return _libarchive.archive_error_string(archive) def call_and_check(func, archive, *args): - """Executes a libarchive function and raises an exception when appropriate.""" + '''Executes a libarchive function and raises an exception when appropriate.''' ret = func(*args) if ret == _libarchive.ARCHIVE_OK: return elif ret == _libarchive.ARCHIVE_WARN: - warnings.warn( - "Warning executing function: %s." % get_error(archive), RuntimeWarning - ) + warnings.warn('Warning executing function: %s.' % get_error(archive), RuntimeWarning) elif ret == _libarchive.ARCHIVE_EOF: raise EOF() else: - raise Exception( - "Problem executing function, message is: %s." % get_error(archive) - ) + raise Exception('Problem executing function, message is: %s.' % get_error(archive)) def get_func(name, items, index): @@ -157,7 +122,7 @@ def get_func(name, items, index): def guess_format(filename): if isinstance(filename, int): - filename = ext = "" + filename = ext = '' else: filename, ext = os.path.splitext(filename) filter = FILTER_EXTENSIONS.get(ext) @@ -168,12 +133,12 @@ def guess_format(filename): def is_archive_name(filename, formats=None): - """Quick check to see if the given file has an extension indiciating that it is + '''Quick check to see if the given file has an extension indiciating that it is an archive. The format parameter can be used to limit what archive format is acceptable. If omitted, all supported archive formats will be checked. This function will return the name of the most likely archive format, None if the file is - unlikely to be an archive.""" + unlikely to be an archive.''' if formats is None: formats = list(FORMAT_EXTENSIONS.values()) format, filter = guess_format(filename) @@ -182,7 +147,7 @@ def is_archive_name(filename, formats=None): def is_archive(f, formats=(None,), filters=(None,)): - """Check to see if the given file is actually an archive. The format parameter + '''Check to see if the given file is actually an archive. The format parameter can be used to specify which archive format is acceptable. If ommitted, all supported archive formats will be checked. It opens the file using libarchive. If no error is received, the file was successfully detected by the libarchive bidding process. @@ -193,10 +158,10 @@ def is_archive(f, formats=(None,), filters=(None,)): this function. This function will return True if the file can be opened as an archive using the given - format(s)/filter(s).""" + format(s)/filter(s).''' need_close = False if isinstance(f, str): - f = open(f, "rb") + f = open(f, 'rb') need_close = True a = _libarchive.archive_read_new() for format in formats: @@ -211,9 +176,7 @@ def is_archive(f, formats=(None,), filters=(None,)): filter(a) try: try: - call_and_check( - _libarchive.archive_read_open_fd, a, a, f.fileno(), BLOCK_SIZE - ) + call_and_check(_libarchive.archive_read_open_fd, a, a, f.fileno(), BLOCK_SIZE) return True except: return False @@ -225,7 +188,7 @@ def is_archive(f, formats=(None,), filters=(None,)): class EntryReadStream(object): - """A file-like object for reading an entry from the archive.""" + '''A file-like object for reading an entry from the archive.''' def __init__(self, archive, size): self.archive = archive @@ -281,11 +244,11 @@ class EntryReadStream(object): class EntryWriteStream(object): - """A file-like object for writing an entry to an archive. + '''A file-like object for writing an entry to an archive. If the size is known ahead of time and provided, then the file contents are not buffered but flushed directly to the archive. If size is omitted, - then the file contents are buffered and flushed in the close() method.""" + then the file contents are buffered and flushed in the close() method.''' def __init__(self, archive, pathname, size=None): self.archive = archive @@ -316,13 +279,11 @@ class EntryWriteStream(object): def write(self, data): if self.closed: - raise Exception("Cannot write to closed stream.") + raise Exception('Cannot write to closed stream.') if self.buffer: self.buffer.write(data) else: - _libarchive.archive_write_data_from_str( - self.archive._a, data.encode(ENCODING) - ) + _libarchive.archive_write_data_from_str(self.archive._a, data.encode(ENCODING)) self.bytes += len(data) def close(self): @@ -331,9 +292,7 @@ class EntryWriteStream(object): if self.buffer: self.entry.size = self.buffer.tell() self.entry.to_archive(self.archive) - _libarchive.archive_write_data_from_str( - self.archive._a, self.buffer.getvalue().encode(ENCODING) - ) + _libarchive.archive_write_data_from_str(self.archive._a, self.buffer.getvalue().encode(ENCODING)) _libarchive.archive_write_finish_entry(self.archive._a) # Call archive.close() with _defer True to let it know we have been @@ -344,17 +303,9 @@ class EntryWriteStream(object): class Entry(object): - """An entry within an archive. Represents the header data and it's location within the archive.""" + '''An entry within an archive. Represents the header data and it's location within the archive.''' - def __init__( - self, - pathname=None, - size=None, - mtime=None, - mode=None, - hpos=None, - encoding=ENCODING, - ): + def __init__(self, pathname=None, size=None, mtime=None, mode=None, hpos=None, encoding=ENCODING): # , symlink=None self.pathname = pathname @@ -372,12 +323,10 @@ class Entry(object): @classmethod def from_archive(cls, archive, encoding=ENCODING): - """Instantiates an Entry class and sets all the properties from an archive header.""" + '''Instantiates an Entry class and sets all the properties from an archive header.''' e = _libarchive.archive_entry_new() try: - call_and_check( - _libarchive.archive_read_next_header2, archive._a, archive._a, e - ) + call_and_check(_libarchive.archive_read_next_header2, archive._a, archive._a, e) mode = _libarchive.archive_entry_filetype(e) mode |= _libarchive.archive_entry_perm(e) @@ -404,8 +353,8 @@ class Entry(object): @classmethod def from_file(cls, f, entry=None, encoding=ENCODING): - """Instantiates an Entry class and sets all the properties from a file on the file system. - f can be a file-like object or a path.""" + '''Instantiates an Entry class and sets all the properties from a file on the file system. + f can be a file-like object or a path.''' if entry is None: entry = cls(encoding=encoding) if entry.pathname is None: @@ -415,30 +364,29 @@ class Entry(object): entry.size = st.st_size entry.mtime = st.st_mtime entry.mode = st.st_mode - elif hasattr(f, "fileno"): + elif hasattr(f, 'fileno'): st = os.fstat(f.fileno()) - entry.pathname = getattr(f, "name", None) + entry.pathname = getattr(f, 'name', None) entry.size = st.st_size entry.mtime = st.st_mtime entry.mode = st.st_mode else: - entry.pathname = getattr(f, "pathname", None) - entry.size = getattr(f, "size", 0) - entry.mtime = getattr(f, "mtime", time.time()) + entry.pathname = getattr(f, 'pathname', None) + entry.size = getattr(f, 'size', 0) + entry.mtime = getattr(f, 'mtime', time.time()) entry.mode = stat.S_IFREG + return entry def to_archive(self, archive): - """Creates an archive header and writes it to the given archive.""" + '''Creates an archive header and writes it to the given archive.''' e = _libarchive.archive_entry_new() try: if PY3: _libarchive.archive_entry_set_pathname(e, self.pathname) else: - _libarchive.archive_entry_set_pathname( - e, self.pathname.encode(self.encoding) - ) + _libarchive.archive_entry_set_pathname(e, self.pathname.encode(self.encoding)) _libarchive.archive_entry_set_filetype(e, stat.S_IFMT(self.mode)) _libarchive.archive_entry_set_perm(e, stat.S_IMODE(self.mode)) _libarchive.archive_entry_set_size(e, self.size) @@ -472,13 +420,13 @@ class Entry(object): class Archive(object): - """A low-level archive reader which provides forward-only iteration. Consider - this a light-weight pythonic libarchive wrapper.""" + '''A low-level archive reader which provides forward-only iteration. Consider + this a light-weight pythonic libarchive wrapper.''' def __init__( self, f, - mode="r", + mode='r', format=None, filter=None, entry_class=Entry, @@ -486,7 +434,7 @@ class Archive(object): blocksize=BLOCK_SIZE, password=None, ): - assert mode in ("r", "w", "wb", "a"), 'Mode should be "r", "w", "wb", or "a".' + assert mode in ('r', 'w', 'wb', 'a'), 'Mode should be "r", "w", "wb", or "a".' self._stream = None self.encoding = encoding self.blocksize = blocksize @@ -496,12 +444,12 @@ class Archive(object): f = open(f, mode) # Only close it if we opened it... self._defer_close = True - elif hasattr(f, "fileno"): - self.filename = getattr(f, "name", None) + elif hasattr(f, 'fileno'): + self.filename = getattr(f, 'name', None) # Leave the fd alone, caller should manage it... self._defer_close = False else: - raise Exception("Provided file is not path or open file.") + raise Exception('Provided file is not path or open file.') self.f = f self.mode = mode # Guess the format/filter from file name (if not provided) @@ -515,23 +463,23 @@ class Archive(object): # The class to use for entries. self.entry_class = entry_class # Select filter/format functions. - if self.mode == "r": + if self.mode == 'r': self.format_func = get_func(self.format, FORMATS, 0) if self.format_func is None: - raise Exception("Unsupported format %s" % format) + raise Exception('Unsupported format %s' % format) self.filter_func = get_func(self.filter, FILTERS, 0) if self.filter_func is None: - raise Exception("Unsupported filter %s" % filter) + raise Exception('Unsupported filter %s' % filter) else: # TODO: how to support appending? if self.format is None: - raise Exception("You must specify a format for writing.") + raise Exception('You must specify a format for writing.') self.format_func = get_func(self.format, FORMATS, 1) if self.format_func is None: - raise Exception("Unsupported format %s" % format) + raise Exception('Unsupported format %s' % format) self.filter_func = get_func(self.filter, FILTERS, 1) if self.filter_func is None: - raise Exception("Unsupported filter %s" % filter) + raise Exception('Unsupported filter %s' % filter) # Open the archive, apply filter/format functions. self.init() @@ -551,47 +499,31 @@ class Archive(object): def __del__(self): self.close() - def set_initial_options(self): - pass - def init(self): - if self.mode == "r": + if self.mode == 'r': self._a = _libarchive.archive_read_new() else: self._a = _libarchive.archive_write_new() self.format_func(self._a) self.filter_func(self._a) - self.set_initial_options() - if self.mode == "r": + if self.mode == 'r': if self.password: - if isinstance(self.password, list): - for pwd in self.password: - self.add_passphrase(pwd) - else: - self.add_passphrase(self.password) - call_and_check( - _libarchive.archive_read_open_fd, - self._a, - self._a, - self.f.fileno(), - self.blocksize, - ) + self.add_passphrase(self.password) + call_and_check(_libarchive.archive_read_open_fd, self._a, self._a, self.f.fileno(), self.blocksize) else: if self.password: self.set_passphrase(self.password) - call_and_check( - _libarchive.archive_write_open_fd, self._a, self._a, self.f.fileno() - ) + call_and_check(_libarchive.archive_write_open_fd, self._a, self._a, self.f.fileno()) def denit(self): - """Closes and deallocates the archive reader/writer.""" - if getattr(self, "_a", None) is None: + '''Closes and deallocates the archive reader/writer.''' + if getattr(self, '_a', None) is None: return try: - if self.mode == "r": + if self.mode == 'r': _libarchive.archive_read_close(self._a) _libarchive.archive_read_free(self._a) - elif self.mode == "w": + elif self.mode == 'w': _libarchive.archive_write_close(self._a) _libarchive.archive_write_free(self._a) finally: @@ -613,23 +545,23 @@ class Archive(object): return self.denit() # If there is a file attached... - if hasattr(self, "f"): + if hasattr(self, 'f'): # Make sure it is not already closed... - if getattr(self.f, "closed", False): + if getattr(self.f, 'closed', False): return # Flush it if not read-only... - if hasattr(self.f, "mode") and self.f.mode != "r" and self.f.mode != "rb": + if hasattr(self.f, "mode") and self.f.mode != 'r' and self.f.mode != 'rb': if hasattr(self.f, "flush"): self.f.flush() if hasattr(self.f, "fileno"): os.fsync(self.f.fileno()) # and then close it, if we opened it... - if getattr(self, "_close", None): + if getattr(self, '_close', None): self.f.close() @property def header_position(self): - """The position within the file.""" + '''The position within the file.''' return _libarchive.archive_read_header_position(self._a) def iterpaths(self): @@ -637,33 +569,30 @@ class Archive(object): yield entry.pathname def read(self, size): - """Read current archive entry contents into string.""" + '''Read current archive entry contents into string.''' return _libarchive.archive_read_data_into_str(self._a, size) def readpath(self, f): - """Write current archive entry contents to file. f can be a file-like object or - a path.""" + '''Write current archive entry contents to file. f can be a file-like object or + a path.''' if isinstance(f, str): basedir = os.path.dirname(f) if not os.path.exists(basedir): os.makedirs(basedir) - f = open(f, "w") + f = open(f, 'w') return _libarchive.archive_read_data_into_fd(self._a, f.fileno()) def readstream(self, size): - """Returns a file-like object for reading current archive entry contents.""" + '''Returns a file-like object for reading current archive entry contents.''' self._stream = EntryReadStream(self, size) return self._stream def write(self, member, data=None): - """Writes a string buffer to the archive as the given entry.""" + '''Writes a string buffer to the archive as the given entry.''' if isinstance(member, str): member = self.entry_class(pathname=member, encoding=self.encoding) - member.mode = stat.S_IFREG - member.mtime = time.time() if data: member.size = len(data) - member.to_archive(self) if data: @@ -671,65 +600,63 @@ class Archive(object): if isinstance(data, bytes): result = _libarchive.archive_write_data_from_str(self._a, data) else: - result = _libarchive.archive_write_data_from_str( - self._a, data.encode(self.encoding) - ) + result = _libarchive.archive_write_data_from_str(self._a, data.encode(self.encoding)) else: result = _libarchive.archive_write_data_from_str(self._a, data) _libarchive.archive_write_finish_entry(self._a) def writepath(self, f, pathname=None, folder=False): - """Writes a file to the archive. f can be a file-like object or a path. Uses - write() to do the actual writing.""" + '''Writes a file to the archive. f can be a file-like object or a path. Uses + write() to do the actual writing.''' member = self.entry_class.from_file(f, encoding=self.encoding) if isinstance(f, str): if os.path.isfile(f): - f = open(f, "r") + f = open(f, 'r') if pathname: member.pathname = pathname if folder and not member.isdir(): member.mode = stat.S_IFDIR - if hasattr(f, "read"): + if hasattr(f, 'read'): # TODO: optimize this to write directly from f to archive. self.write(member, data=f.read()) else: self.write(member) def writestream(self, pathname, size=None): - """Returns a file-like object for writing a new entry.""" + '''Returns a file-like object for writing a new entry.''' self._stream = EntryWriteStream(self, pathname, size) return self._stream def printlist(self, s=sys.stdout): for entry in self: s.write(entry.size) - s.write("\t") + s.write('\t') s.write(entry.mtime.strftime(MTIME_FORMAT)) - s.write("\t") + s.write('\t') s.write(entry.pathname) s.flush() def add_passphrase(self, password): - """Adds a password to the archive.""" + '''Adds a password to the archive.''' _libarchive.archive_read_add_passphrase(self._a, password) def set_passphrase(self, password): - """Sets a password for the archive.""" + '''Sets a password for the archive.''' _libarchive.archive_write_set_passphrase(self._a, password) class SeekableArchive(Archive): - """A class that provides random-access to archive entries. It does this by using one + '''A class that provides random-access to archive entries. It does this by using one or many Archive instances to seek to the correct location. The best performance will occur when reading archive entries in the order in which they appear in the archive. Reading out of order will cause the archive to be closed and opened each time a - reverse seek is needed.""" + reverse seek is needed.''' def __init__(self, f, **kwargs): self._stream = None # Convert file to open file. We need this to reopen the archive. - mode = kwargs.setdefault("mode", "r") + mode = kwargs.setdefault('mode', 'r') if isinstance(f, str): f = open(f, mode) super(SeekableArchive, self).__init__(f, **kwargs) @@ -748,21 +675,21 @@ class SeekableArchive(Archive): self.eof = True def reopen(self): - """Seeks the underlying fd to 0 position, then opens the archive. If the archive - is already open, this will effectively re-open it (rewind to the beginning).""" + '''Seeks the underlying fd to 0 position, then opens the archive. If the archive + is already open, this will effectively re-open it (rewind to the beginning).''' self.denit() self.f.seek(0) self.init() def getentry(self, pathname): - """Take a name or entry object and returns an entry object.""" + '''Take a name or entry object and returns an entry object.''' for entry in self: if entry.pathname == pathname: return entry raise KeyError(pathname) def seek(self, entry): - """Seeks the archive to the requested entry. Will reopen if necessary.""" + '''Seeks the archive to the requested entry. Will reopen if necessary.''' move = entry.header_position - self.header_position if move != 0: if move < 0: @@ -774,7 +701,7 @@ class SeekableArchive(Archive): break def read(self, member): - """Return the requested archive entry contents as a string.""" + '''Return the requested archive entry contents as a string.''' entry = self.getentry(member) self.seek(entry) return super(SeekableArchive, self).read(entry.size) @@ -785,7 +712,7 @@ class SeekableArchive(Archive): return super(SeekableArchive, self).readpath(f) def readstream(self, member): - """Returns a file-like object for reading requested archive entry contents.""" + '''Returns a file-like object for reading requested archive entry contents.''' entry = self.getentry(member) self.seek(entry) self._stream = EntryReadStream(self, entry.size) diff --git a/libarchive/zip.py b/libarchive/zip.py index 85cacb1..be65386 100644 --- a/libarchive/zip.py +++ b/libarchive/zip.py @@ -1,10 +1,10 @@ import os, time -from libarchive import is_archive, Entry, SeekableArchive, _libarchive +from libarchive import is_archive, Entry, SeekableArchive from zipfile import ZIP_STORED, ZIP_DEFLATED def is_zipfile(filename): - return is_archive(filename, formats=("zip",)) + return is_archive(filename, formats=('zip',)) class ZipEntry(Entry): @@ -23,7 +23,7 @@ class ZipEntry(Entry): return self.size def set_file_size(self, value): - assert isinstance(value, int), "Please provide size as int or long." + assert isinstance(value, int), 'Please provide size as int or long.' self.size = value file_size = property(get_file_size, set_file_size) @@ -32,12 +32,8 @@ class ZipEntry(Entry): return time.localtime(self.mtime)[0:6] def set_date_time(self, value): - assert isinstance( - value, tuple - ), "mtime should be tuple (year, month, day, hour, minute, second)." - assert ( - len(value) == 6 - ), "mtime should be tuple (year, month, day, hour, minute, second)." + assert isinstance(value, tuple), 'mtime should be tuple (year, month, day, hour, minute, second).' + assert len(value) == 6, 'mtime should be tuple (year, month, day, hour, minute, second).' self.mtime = time.mktime(value + (0, 0, 0)) date_time = property(get_date_time, set_date_time) @@ -65,45 +61,17 @@ class ZipEntry(Entry): compress_size = property(_get_missing, _set_missing) -# encryption is one of (traditional = zipcrypt, aes128, aes256) class ZipFile(SeekableArchive): - def __init__( - self, - f, - mode="r", - compression=ZIP_DEFLATED, - allowZip64=False, - password=None, - encryption=None, - ): - - self.encryption = encryption - self.compression = compression - + def __init__(self, f, mode='r', compression=ZIP_DEFLATED, allowZip64=False, password=None): super(ZipFile, self).__init__( - f, - mode=mode, - format="zip", - entry_class=ZipEntry, - encoding="CP437", - password=password, + f, mode=mode, format='zip', entry_class=ZipEntry, encoding='CP437', password=password ) - - getinfo = SeekableArchive.getentry - - def set_initial_options(self): - if self.mode == "w" and self.compression == ZIP_STORED: + if mode == 'w' and compression == ZIP_STORED: # Disable compression for writing. - _libarchive.archive_write_set_format_option( - self._a, "zip", "compression", "store" - ) + _libarchive.archive_write_set_format_option(self.archive._a, "zip", "compression", "store") + self.compression = compression - if self.mode == "w" and self.password: - if not self.encryption: - self.encryption = "traditional" - _libarchive.archive_write_set_format_option( - self._a, "zip", "encryption", self.encryption - ) + getinfo = SeekableArchive.getentry def namelist(self): return list(self.iterpaths()) @@ -112,7 +80,7 @@ class ZipFile(SeekableArchive): return list(self) def open(self, name, mode, pwd=None): - if mode == "r": + if mode == 'r': if pwd: self.add_passphrase(pwd) return self.readstream(name) @@ -141,8 +109,8 @@ class ZipFile(SeekableArchive): return super(ZipFile, self).read(name) def writestr(self, member, data, compress_type=None): - if compress_type != self.compression and not (compress_type is None): - raise Exception("Cannot change compression type for individual entries.") + if compress_type != self.compression: + raise Exception('Cannot change compression type for individual entries.') return self.write(member, data) def setpassword(self, pwd): From f1a4504aae8f33b7deb660b1d86299101c87614a Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Thu, 11 Aug 2022 18:17:17 +0200 Subject: [PATCH 88/91] Fix creation of password protected ZIP files --- libarchive/__init__.py | 4 ++++ libarchive/zip.py | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index df8c115..2ea051a 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -499,6 +499,9 @@ class Archive(object): def __del__(self): self.close() + def set_initila_options(self): + pass + def init(self): if self.mode == 'r': self._a = _libarchive.archive_read_new() @@ -506,6 +509,7 @@ class Archive(object): self._a = _libarchive.archive_write_new() self.format_func(self._a) self.filter_func(self._a) + self.set_initila_options() if self.mode == 'r': if self.password: self.add_passphrase(self.password) diff --git a/libarchive/zip.py b/libarchive/zip.py index be65386..e19b4f6 100644 --- a/libarchive/zip.py +++ b/libarchive/zip.py @@ -1,5 +1,5 @@ import os, time -from libarchive import is_archive, Entry, SeekableArchive +from libarchive import is_archive, Entry, SeekableArchive, _libarchive from zipfile import ZIP_STORED, ZIP_DEFLATED @@ -60,19 +60,34 @@ class ZipEntry(Entry): CRC = property(_get_missing, _set_missing) compress_size = property(_get_missing, _set_missing) - +# encryption is one of (traditional = zipcrypt, aes128, aes256) class ZipFile(SeekableArchive): - def __init__(self, f, mode='r', compression=ZIP_DEFLATED, allowZip64=False, password=None): + def __init__(self, f, mode='r', compression=ZIP_DEFLATED, allowZip64=False, password=None, + encryption=None): super(ZipFile, self).__init__( f, mode=mode, format='zip', entry_class=ZipEntry, encoding='CP437', password=password ) + self.compression = compression + self.encryption = encryption if mode == 'w' and compression == ZIP_STORED: # Disable compression for writing. _libarchive.archive_write_set_format_option(self.archive._a, "zip", "compression", "store") - self.compression = compression + getinfo = SeekableArchive.getentry + def set_initial_options(self): + if self.mode == 'w' and self.compression == ZIP_STORED: + # Disable compression for writing. + _libarchive.archive_write_set_format_option(self.archive._a, "zip", "compression", "store") + + if self.mode == 'w' and self.password: + if not self.encryption: + self.encryption = "traditional" + _libarchive.archive_write_set_format_option(self._a, "zip", "encryption", self.encryption) + + + def namelist(self): return list(self.iterpaths()) From c5658c78d7a21980c7246ab48eceb592938025d0 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Thu, 11 Aug 2022 18:40:36 +0200 Subject: [PATCH 89/91] Fixes to create password protected ZIP files --- libarchive/__init__.py | 13 +++++++++---- libarchive/zip.py | 11 ++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 2ea051a..9dbb434 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -499,7 +499,7 @@ class Archive(object): def __del__(self): self.close() - def set_initila_options(self): + def set_initial_options(self): pass def init(self): @@ -509,10 +509,14 @@ class Archive(object): self._a = _libarchive.archive_write_new() self.format_func(self._a) self.filter_func(self._a) - self.set_initila_options() + self.set_initial_options() if self.mode == 'r': if self.password: - self.add_passphrase(self.password) + if isinstance(self.password, list): + for pwd in self.password: + self.add_passphrase(pwd) + else: + self.add_passphrase(self.password) call_and_check(_libarchive.archive_read_open_fd, self._a, self._a, self.f.fileno(), self.blocksize) else: if self.password: @@ -594,7 +598,8 @@ class Archive(object): def write(self, member, data=None): '''Writes a string buffer to the archive as the given entry.''' if isinstance(member, str): - member = self.entry_class(pathname=member, encoding=self.encoding) + member = self.entry_class(pathname=member, encoding=self.encoding, + mtime=time.time(), mode=stat.S_IFREG) if data: member.size = len(data) member.to_archive(self) diff --git a/libarchive/zip.py b/libarchive/zip.py index e19b4f6..a200aa7 100644 --- a/libarchive/zip.py +++ b/libarchive/zip.py @@ -64,14 +64,11 @@ class ZipEntry(Entry): class ZipFile(SeekableArchive): def __init__(self, f, mode='r', compression=ZIP_DEFLATED, allowZip64=False, password=None, encryption=None): + self.compression = compression + self.encryption = encryption super(ZipFile, self).__init__( f, mode=mode, format='zip', entry_class=ZipEntry, encoding='CP437', password=password ) - self.compression = compression - self.encryption = encryption - if mode == 'w' and compression == ZIP_STORED: - # Disable compression for writing. - _libarchive.archive_write_set_format_option(self.archive._a, "zip", "compression", "store") getinfo = SeekableArchive.getentry @@ -79,7 +76,7 @@ class ZipFile(SeekableArchive): def set_initial_options(self): if self.mode == 'w' and self.compression == ZIP_STORED: # Disable compression for writing. - _libarchive.archive_write_set_format_option(self.archive._a, "zip", "compression", "store") + _libarchive.archive_write_set_format_option(self._a, "zip", "compression", "store") if self.mode == 'w' and self.password: if not self.encryption: @@ -124,7 +121,7 @@ class ZipFile(SeekableArchive): return super(ZipFile, self).read(name) def writestr(self, member, data, compress_type=None): - if compress_type != self.compression: + if compress_type != self.compression and not (compress_type is None): raise Exception('Cannot change compression type for individual entries.') return self.write(member, data) From 7ae17e9df753af7fae70417a678e5033a7bcb673 Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Fri, 12 Aug 2022 16:45:50 +0200 Subject: [PATCH 90/91] Cleanup --- libarchive/Makefile | 3 +-- libarchive/__init__.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libarchive/Makefile b/libarchive/Makefile index 863f30d..d86fe81 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -2,7 +2,6 @@ CFLAGS = -g INCLUDE = -I/usr/local/include -I/usr/include -I. LIBS = -L /usr/local/lib -larchive -#DEFINES = -DPyUnicode_AS_STRING=PyUnicode_AS_DATA PYVER ?= 3.9 all: __libarchive.so @@ -11,7 +10,7 @@ _libarchive_wrap.c: _libarchive.i swig -python -Wall -shadow _libarchive.i _libarchive_wrap.o: _libarchive_wrap.c - ${CC} -c ${CFLAGS} -fPIC $$(python${PYVER}-config --cflags) ${DEFINES} _libarchive_wrap.c + ${CC} -c ${CFLAGS} -fPIC $$(python${PYVER}-config --cflags) _libarchive_wrap.c __libarchive.so: _libarchive_wrap.o ${CC} _libarchive_wrap.o -shared $$(python${PYVER}-config --ldflags) -Wl,-soname=__libarchive.so -o __libarchive.so ${LIBS} diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 9dbb434..424e7a4 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -307,7 +307,6 @@ class Entry(object): def __init__(self, pathname=None, size=None, mtime=None, mode=None, hpos=None, encoding=ENCODING): - # , symlink=None self.pathname = pathname self.size = size self.mtime = mtime From 9d5895ff211d6247127894a366844559c8d72f5f Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Fri, 12 Aug 2022 16:46:30 +0200 Subject: [PATCH 91/91] Fix release number --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c234791..6bc4c23 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ else: name = 'python-libarchive' version = '4.0.1' -release = '2' +release = '1' versrel = version + '-' + release readme = 'README.rst' download_url = "http://" + name + ".googlecode.com/files/" + name + "-" + \