1 #ifndef LIBARCHIVE_COMPAT_H
2 #define LIBARCHIVE_COMPAT_H
3 
4 /*
5  * libarchive-compat.h
6  *
7  *  Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <stdint.h>
24 
_alpm_archive_read_free(struct archive * archive)25 static inline int _alpm_archive_read_free(struct archive *archive)
26 {
27 #if ARCHIVE_VERSION_NUMBER >= 3000000
28 	return archive_read_free(archive);
29 #else
30 	return archive_read_finish(archive);
31 #endif
32 }
33 
_alpm_archive_compressed_ftell(struct archive * archive)34 static inline int64_t _alpm_archive_compressed_ftell(struct archive *archive)
35 {
36 #if ARCHIVE_VERSION_NUMBER >= 3000000
37 	return archive_filter_bytes(archive, -1);
38 #else
39 	return archive_position_compressed(archive);
40 #endif
41 }
42 
_alpm_archive_read_open_file(struct archive * archive,const char * filename,size_t block_size)43 static inline int _alpm_archive_read_open_file(struct archive *archive,
44 		const char *filename, size_t block_size)
45 {
46 #if ARCHIVE_VERSION_NUMBER >= 3000000
47 	return archive_read_open_filename(archive, filename, block_size);
48 #else
49 	return archive_read_open_file(archive, filename, block_size);
50 #endif
51 }
52 
_alpm_archive_filter_code(struct archive * archive)53 static inline int _alpm_archive_filter_code(struct archive *archive)
54 {
55 #if ARCHIVE_VERSION_NUMBER >= 3000000
56 	return archive_filter_code(archive, 0);
57 #else
58 	return archive_compression(archive);
59 #endif
60 }
61 
_alpm_archive_read_support_filter_all(struct archive * archive)62 static inline int _alpm_archive_read_support_filter_all(struct archive *archive)
63 {
64 #if ARCHIVE_VERSION_NUMBER >= 3000000
65 	return archive_read_support_filter_all(archive);
66 #else
67 	return archive_read_support_compression_all(archive);
68 #endif
69 }
70 
71 #endif /* LIBARCHIVE_COMPAT_H */
72