~ubuntu-branches/ubuntu/quantal/cmake/quantal

« back to all changes in this revision

Viewing changes to Utilities/cmlibarchive/libarchive/archive.h

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-04-30 12:14:32 UTC
  • mfrom: (3.1.30 sid)
  • Revision ID: package-import@ubuntu.com-20120430121432-rqh2fjl3zcblehh5
Tags: 2.8.8-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add xfail_compiler_flag.diff: Mark compiler flag tests as expected
    failures.
  - Add ubuntu_qt_import_dir_variable.diff: define QT_IMPORTS_DIR even
    when that dir does not exist.
* Remove increase_ctest_test_timeout.diff, merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*-
2
 
 * Copyright (c) 2003-2007 Tim Kientzle
 
2
 * Copyright (c) 2003-2010 Tim Kientzle
3
3
 * All rights reserved.
4
4
 *
5
5
 * Redistribution and use in source and binary forms, with or without
26
26
 */
27
27
 
28
28
#ifndef ARCHIVE_H_INCLUDED
29
 
#define ARCHIVE_H_INCLUDED
 
29
#define ARCHIVE_H_INCLUDED
 
30
 
 
31
#include <sys/stat.h>
 
32
#include <stddef.h>  /* for wchar_t */
 
33
#include <stdio.h> /* For FILE * */
30
34
 
31
35
/*
32
36
 * Note: archive.h is for use outside of libarchive; the configuration
36
40
 * platform macros.
37
41
 */
38
42
#if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
39
 
# define __LA_STDINT_H <stdint.h>
40
 
#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(__osf__)
41
 
# define __LA_STDINT_H <inttypes.h>
 
43
# include <stdint.h>
 
44
#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__)
 
45
# include <inttypes.h>
42
46
#endif
43
47
 
44
 
#include <sys/stat.h>
45
 
#include <sys/types.h>  /* Linux requires this for off_t */
46
 
#ifdef __LA_STDINT_H
47
 
# include __LA_STDINT_H /* int64_t, etc. */
 
48
/* Borland symbols are case-insensitive.  This workaround only works
 
49
   within CMake because we do not mix compilers.  */
 
50
#if defined(__BORLANDC__)
 
51
# define archive_read_open_FILE archive_read_open_FILE_
 
52
# define archive_write_open_FILE archive_write_open_FILE_
48
53
#endif
49
 
#include <stdio.h> /* For FILE * */
50
54
 
51
55
/* Get appropriate definitions of standard POSIX-style types. */
52
56
/* These should match the types used in 'struct stat' */
53
57
#if defined(_WIN32) && !defined(__CYGWIN__)
54
 
#define __LA_INT64_T    __int64
 
58
# define        __LA_INT64_T    __int64
55
59
# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
56
 
#  define __LA_SSIZE_T ssize_t
 
60
#  define       __LA_SSIZE_T    ssize_t
57
61
# elif defined(_WIN64)
58
 
#  define   __LA_SSIZE_T    __int64
 
62
#  define       __LA_SSIZE_T    __int64
59
63
# else
60
 
#  define   __LA_SSIZE_T    long
 
64
#  define       __LA_SSIZE_T    long
61
65
# endif
62
66
# if defined(__BORLANDC__)
63
 
#  define __LA_UID_T uid_t
64
 
#  define __LA_GID_T gid_t
65
 
# else
66
 
#  define __LA_UID_T short
67
 
#  define __LA_GID_T short
68
 
# endif
69
 
#else
70
 
#include <unistd.h>  /* ssize_t, uid_t, and gid_t */
71
 
#if defined(__osf__)
72
 
#  define __LA_INT64_T    long long
73
 
#else
74
 
#  define __LA_INT64_T    int64_t
75
 
#endif
76
 
#define __LA_SSIZE_T    ssize_t
77
 
#define __LA_UID_T  uid_t
78
 
#define __LA_GID_T  gid_t
 
67
#  define       __LA_UID_T      uid_t
 
68
#  define       __LA_GID_T      gid_t
 
69
# else
 
70
#  define       __LA_UID_T      short
 
71
#  define       __LA_GID_T      short
 
72
# endif
 
73
#else
 
74
# include <unistd.h>  /* ssize_t, uid_t, and gid_t */
 
75
# if defined(_SCO_DS) || defined(__osf__)
 
76
#  define       __LA_INT64_T    long long
 
77
# else
 
78
#  define       __LA_INT64_T    int64_t
 
79
# endif
 
80
# define        __LA_SSIZE_T    ssize_t
 
81
# define        __LA_UID_T      uid_t
 
82
# define        __LA_GID_T      gid_t
79
83
#endif
80
84
 
81
85
/*
86
90
#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
87
91
# ifdef __LIBARCHIVE_BUILD
88
92
#  ifdef __GNUC__
89
 
#   define __LA_DECL    __attribute__((dllexport)) extern
 
93
#   define __LA_DECL    __attribute__((dllexport)) extern
90
94
#  else
91
 
#   define __LA_DECL    __declspec(dllexport)
 
95
#   define __LA_DECL    __declspec(dllexport)
92
96
#  endif
93
97
# else
94
98
#  ifdef __GNUC__
95
 
#   define __LA_DECL    __attribute__((dllimport)) extern
 
99
#   define __LA_DECL
96
100
#  else
97
 
#   define __LA_DECL    __declspec(dllimport)
 
101
#   define __LA_DECL    __declspec(dllimport)
98
102
#  endif
99
103
# endif
100
104
#else
102
106
# define __LA_DECL
103
107
#endif
104
108
 
 
109
#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__MINGW32__)
 
110
#define __LA_PRINTF(fmtarg, firstvararg) \
 
111
        __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
 
112
#else
 
113
#define __LA_PRINTF(fmtarg, firstvararg)        /* nothing */
 
114
#endif
 
115
 
105
116
#ifdef __cplusplus
106
117
extern "C" {
107
118
#endif
120
131
 * easy to compare versions at build time: for version a.b.c, the
121
132
 * version number is printf("%d%03d%03d",a,b,c).  For example, if you
122
133
 * know your application requires version 2.12.108 or later, you can
123
 
 * assert that ARCHIVE_VERSION >= 2012108.
124
 
 *
125
 
 * This single-number format was introduced with libarchive 1.9.0 in
126
 
 * the libarchive 1.x family and libarchive 2.2.4 in the libarchive
127
 
 * 2.x family.  The following may be useful if you really want to do
128
 
 * feature detection for earlier libarchive versions (which defined
129
 
 * ARCHIVE_API_VERSION and ARCHIVE_API_FEATURE instead):
130
 
 *
131
 
 * #ifndef ARCHIVE_VERSION_NUMBER
132
 
 * #define ARCHIVE_VERSION_NUMBER   \
133
 
 *             (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
134
 
 * #endif
 
134
 * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
135
135
 */
136
 
#define ARCHIVE_VERSION_NUMBER 2007900
137
 
__LA_DECL int       archive_version_number(void);
 
136
/* Note: Compiler will complain if this does not match archive_entry.h! */
 
137
#define ARCHIVE_VERSION_NUMBER 3000002
 
138
__LA_DECL int           archive_version_number(void);
138
139
 
139
140
/*
140
141
 * Textual name/version of the library, useful for version displays.
141
142
 */
142
 
#define ARCHIVE_VERSION_STRING "libarchive 2.7.900a"
143
 
__LA_DECL const char *  archive_version_string(void);
144
 
 
145
 
#if ARCHIVE_VERSION_NUMBER < 3000000
146
 
/*
147
 
 * Deprecated; these are older names that will be removed in favor of
148
 
 * the simpler definitions above.
149
 
 */
150
 
#define ARCHIVE_VERSION_STAMP   ARCHIVE_VERSION_NUMBER
151
 
__LA_DECL int       archive_version_stamp(void);
152
 
#define ARCHIVE_LIBRARY_VERSION ARCHIVE_VERSION_STRING
153
 
__LA_DECL const char *  archive_version(void);
154
 
#define ARCHIVE_API_VERSION (ARCHIVE_VERSION_NUMBER / 1000000)
155
 
__LA_DECL int       archive_api_version(void);
156
 
#define ARCHIVE_API_FEATURE ((ARCHIVE_VERSION_NUMBER / 1000) % 1000)
157
 
__LA_DECL int       archive_api_feature(void);
158
 
#endif
159
 
 
160
 
#if ARCHIVE_VERSION_NUMBER < 3000000
161
 
/* This should never have been here in the first place. */
162
 
/* Legacy of old tar assumptions, will be removed in libarchive 3.0. */
163
 
#define ARCHIVE_BYTES_PER_RECORD      512
164
 
#define ARCHIVE_DEFAULT_BYTES_PER_BLOCK 10240
165
 
#endif
 
143
#define ARCHIVE_VERSION_STRING "libarchive 3.0.2"
 
144
__LA_DECL const char *  archive_version_string(void);
166
145
 
167
146
/* Declare our basic types. */
168
147
struct archive;
173
152
 * to retrieve details.  Unless specified otherwise, all functions
174
153
 * that return 'int' use these codes.
175
154
 */
176
 
#define ARCHIVE_EOF   1 /* Found end of archive. */
177
 
#define ARCHIVE_OK    0 /* Operation was successful. */
178
 
#define ARCHIVE_RETRY   (-10)   /* Retry might succeed. */
179
 
#define ARCHIVE_WARN    (-20)   /* Partial success. */
 
155
#define ARCHIVE_EOF       1     /* Found end of archive. */
 
156
#define ARCHIVE_OK        0     /* Operation was successful. */
 
157
#define ARCHIVE_RETRY   (-10)   /* Retry might succeed. */
 
158
#define ARCHIVE_WARN    (-20)   /* Partial success. */
180
159
/* For example, if write_header "fails", then you can't push data. */
181
 
#define ARCHIVE_FAILED  (-25)   /* Current operation cannot complete. */
 
160
#define ARCHIVE_FAILED  (-25)   /* Current operation cannot complete. */
182
161
/* But if write_header is "fatal," then this archive is dead and useless. */
183
 
#define ARCHIVE_FATAL   (-30)   /* No more operations are possible. */
 
162
#define ARCHIVE_FATAL   (-30)   /* No more operations are possible. */
184
163
 
185
164
/*
186
165
 * As far as possible, archive_errno returns standard platform errno codes.
190
169
 * platform-dependent error code.
191
170
 */
192
171
/* Unrecognized or invalid file format. */
193
 
/* #define  ARCHIVE_ERRNO_FILE_FORMAT */
 
172
/* #define      ARCHIVE_ERRNO_FILE_FORMAT */
194
173
/* Illegal usage of the library. */
195
 
/* #define  ARCHIVE_ERRNO_PROGRAMMER_ERROR */
 
174
/* #define      ARCHIVE_ERRNO_PROGRAMMER_ERROR */
196
175
/* Unknown or unclassified error. */
197
 
/* #define  ARCHIVE_ERRNO_MISC */
 
176
/* #define      ARCHIVE_ERRNO_MISC */
198
177
 
199
178
/*
200
179
 * Callbacks are invoked to automatically read/skip/write/open/close the
204
183
 */
205
184
 
206
185
/* Returns pointer and size of next block of data from archive. */
207
 
typedef __LA_SSIZE_T    archive_read_callback(struct archive *,
208
 
                void *_client_data, const void **_buffer);
209
 
 
210
 
/* Skips at most request bytes from archive and returns the skipped amount */
211
 
#if ARCHIVE_VERSION_NUMBER < 2000000
212
 
/* Libarchive 1.0 used ssize_t for the return, which is only 32 bits
213
 
 * on most 32-bit platforms; not large enough. */
214
 
typedef __LA_SSIZE_T    archive_skip_callback(struct archive *,
215
 
                void *_client_data, size_t request);
216
 
#elif ARCHIVE_VERSION_NUMBER < 3000000
217
 
/* Libarchive 2.0 used off_t here, but that is a bad idea on Linux and a
218
 
 * few other platforms where off_t varies with build settings. */
219
 
typedef off_t       archive_skip_callback(struct archive *,
220
 
                void *_client_data, off_t request);
221
 
#else
222
 
/* Libarchive 3.0 uses int64_t here, which is actually guaranteed to be
223
 
 * 64 bits on every platform. */
224
 
typedef __LA_INT64_T    archive_skip_callback(struct archive *,
225
 
                void *_client_data, __LA_INT64_T request);
226
 
#endif
 
186
typedef __LA_SSIZE_T    archive_read_callback(struct archive *,
 
187
                            void *_client_data, const void **_buffer);
 
188
 
 
189
/* Skips at most request bytes from archive and returns the skipped amount.
 
190
 * This may skip fewer bytes than requested; it may even skip zero bytes.
 
191
 * If you do skip fewer bytes than requested, libarchive will invoke your
 
192
 * read callback and discard data as necessary to make up the full skip.
 
193
 */
 
194
typedef __LA_INT64_T    archive_skip_callback(struct archive *,
 
195
                            void *_client_data, __LA_INT64_T request);
 
196
 
 
197
/* Seeks to specified location in the file and returns the position.
 
198
 * Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h.
 
199
 * Return ARCHIVE_FATAL if the seek fails for any reason.
 
200
 */
 
201
typedef __LA_INT64_T    archive_seek_callback(struct archive *,
 
202
    void *_client_data, __LA_INT64_T offset, int whence);
227
203
 
228
204
/* Returns size actually written, zero on EOF, -1 on error. */
229
 
typedef __LA_SSIZE_T    archive_write_callback(struct archive *,
230
 
                void *_client_data,
231
 
                const void *_buffer, size_t _length);
232
 
 
233
 
#if ARCHIVE_VERSION_NUMBER < 3000000
234
 
/* Open callback is actually never needed; remove it in libarchive 3.0. */
235
 
typedef int archive_open_callback(struct archive *, void *_client_data);
 
205
typedef __LA_SSIZE_T    archive_write_callback(struct archive *,
 
206
                            void *_client_data,
 
207
                            const void *_buffer, size_t _length);
 
208
 
 
209
typedef int     archive_open_callback(struct archive *, void *_client_data);
 
210
 
 
211
typedef int     archive_close_callback(struct archive *, void *_client_data);
 
212
 
 
213
/*
 
214
 * Codes to identify various stream filters.
 
215
 */
 
216
#define ARCHIVE_FILTER_NONE     0
 
217
#define ARCHIVE_FILTER_GZIP     1
 
218
#define ARCHIVE_FILTER_BZIP2    2
 
219
#define ARCHIVE_FILTER_COMPRESS 3
 
220
#define ARCHIVE_FILTER_PROGRAM  4
 
221
#define ARCHIVE_FILTER_LZMA     5
 
222
#define ARCHIVE_FILTER_XZ       6
 
223
#define ARCHIVE_FILTER_UU       7
 
224
#define ARCHIVE_FILTER_RPM      8
 
225
#define ARCHIVE_FILTER_LZIP     9
 
226
 
 
227
#if ARCHIVE_VERSION_NUMBER < 4000000
 
228
#define ARCHIVE_COMPRESSION_NONE        ARCHIVE_FILTER_NONE
 
229
#define ARCHIVE_COMPRESSION_GZIP        ARCHIVE_FILTER_GZIP
 
230
#define ARCHIVE_COMPRESSION_BZIP2       ARCHIVE_FILTER_BZIP2
 
231
#define ARCHIVE_COMPRESSION_COMPRESS    ARCHIVE_FILTER_COMPRESS
 
232
#define ARCHIVE_COMPRESSION_PROGRAM     ARCHIVE_FILTER_PROGRAM
 
233
#define ARCHIVE_COMPRESSION_LZMA        ARCHIVE_FILTER_LZMA
 
234
#define ARCHIVE_COMPRESSION_XZ          ARCHIVE_FILTER_XZ
 
235
#define ARCHIVE_COMPRESSION_UU          ARCHIVE_FILTER_UU
 
236
#define ARCHIVE_COMPRESSION_RPM         ARCHIVE_FILTER_RPM
 
237
#define ARCHIVE_COMPRESSION_LZIP        ARCHIVE_FILTER_LZIP
236
238
#endif
237
239
 
238
 
typedef int archive_close_callback(struct archive *, void *_client_data);
239
 
 
240
 
/*
241
 
 * Codes for archive_compression.
242
 
 */
243
 
#define ARCHIVE_COMPRESSION_NONE    0
244
 
#define ARCHIVE_COMPRESSION_GZIP    1
245
 
#define ARCHIVE_COMPRESSION_BZIP2   2
246
 
#define ARCHIVE_COMPRESSION_COMPRESS    3
247
 
#define ARCHIVE_COMPRESSION_PROGRAM 4
248
 
#define ARCHIVE_COMPRESSION_LZMA    5
249
 
#define ARCHIVE_COMPRESSION_XZ      6
250
 
 
251
240
/*
252
241
 * Codes returned by archive_format.
253
242
 *
260
249
 * will change the format code to indicate the extended format that
261
250
 * was used).  In other cases, it's because different tools have
262
251
 * modified the archive and so different parts of the archive
263
 
 * actually have slightly different formts.  (Both tar and cpio store
 
252
 * actually have slightly different formats.  (Both tar and cpio store
264
253
 * format codes in each entry, so it is quite possible for each
265
254
 * entry to be in a different format.)
266
255
 */
267
 
#define ARCHIVE_FORMAT_BASE_MASK        0xff0000
268
 
#define ARCHIVE_FORMAT_CPIO         0x10000
269
 
#define ARCHIVE_FORMAT_CPIO_POSIX       (ARCHIVE_FORMAT_CPIO | 1)
270
 
#define ARCHIVE_FORMAT_CPIO_BIN_LE      (ARCHIVE_FORMAT_CPIO | 2)
271
 
#define ARCHIVE_FORMAT_CPIO_BIN_BE      (ARCHIVE_FORMAT_CPIO | 3)
272
 
#define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC      (ARCHIVE_FORMAT_CPIO | 4)
273
 
#define ARCHIVE_FORMAT_CPIO_SVR4_CRC        (ARCHIVE_FORMAT_CPIO | 5)
274
 
#define ARCHIVE_FORMAT_SHAR         0x20000
275
 
#define ARCHIVE_FORMAT_SHAR_BASE        (ARCHIVE_FORMAT_SHAR | 1)
276
 
#define ARCHIVE_FORMAT_SHAR_DUMP        (ARCHIVE_FORMAT_SHAR | 2)
277
 
#define ARCHIVE_FORMAT_TAR          0x30000
278
 
#define ARCHIVE_FORMAT_TAR_USTAR        (ARCHIVE_FORMAT_TAR | 1)
279
 
#define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE  (ARCHIVE_FORMAT_TAR | 2)
280
 
#define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED   (ARCHIVE_FORMAT_TAR | 3)
281
 
#define ARCHIVE_FORMAT_TAR_GNUTAR       (ARCHIVE_FORMAT_TAR | 4)
282
 
#define ARCHIVE_FORMAT_ISO9660          0x40000
283
 
#define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE    (ARCHIVE_FORMAT_ISO9660 | 1)
284
 
#define ARCHIVE_FORMAT_ZIP          0x50000
285
 
#define ARCHIVE_FORMAT_EMPTY            0x60000
286
 
#define ARCHIVE_FORMAT_AR           0x70000
287
 
#define ARCHIVE_FORMAT_AR_GNU           (ARCHIVE_FORMAT_AR | 1)
288
 
#define ARCHIVE_FORMAT_AR_BSD           (ARCHIVE_FORMAT_AR | 2)
289
 
#define ARCHIVE_FORMAT_MTREE            0x80000
290
 
#define ARCHIVE_FORMAT_RAW          0x90000
 
256
#define ARCHIVE_FORMAT_BASE_MASK                0xff0000
 
257
#define ARCHIVE_FORMAT_CPIO                     0x10000
 
258
#define ARCHIVE_FORMAT_CPIO_POSIX               (ARCHIVE_FORMAT_CPIO | 1)
 
259
#define ARCHIVE_FORMAT_CPIO_BIN_LE              (ARCHIVE_FORMAT_CPIO | 2)
 
260
#define ARCHIVE_FORMAT_CPIO_BIN_BE              (ARCHIVE_FORMAT_CPIO | 3)
 
261
#define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC          (ARCHIVE_FORMAT_CPIO | 4)
 
262
#define ARCHIVE_FORMAT_CPIO_SVR4_CRC            (ARCHIVE_FORMAT_CPIO | 5)
 
263
#define ARCHIVE_FORMAT_CPIO_AFIO_LARGE          (ARCHIVE_FORMAT_CPIO | 6)
 
264
#define ARCHIVE_FORMAT_SHAR                     0x20000
 
265
#define ARCHIVE_FORMAT_SHAR_BASE                (ARCHIVE_FORMAT_SHAR | 1)
 
266
#define ARCHIVE_FORMAT_SHAR_DUMP                (ARCHIVE_FORMAT_SHAR | 2)
 
267
#define ARCHIVE_FORMAT_TAR                      0x30000
 
268
#define ARCHIVE_FORMAT_TAR_USTAR                (ARCHIVE_FORMAT_TAR | 1)
 
269
#define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE      (ARCHIVE_FORMAT_TAR | 2)
 
270
#define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED       (ARCHIVE_FORMAT_TAR | 3)
 
271
#define ARCHIVE_FORMAT_TAR_GNUTAR               (ARCHIVE_FORMAT_TAR | 4)
 
272
#define ARCHIVE_FORMAT_ISO9660                  0x40000
 
273
#define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE        (ARCHIVE_FORMAT_ISO9660 | 1)
 
274
#define ARCHIVE_FORMAT_ZIP                      0x50000
 
275
#define ARCHIVE_FORMAT_EMPTY                    0x60000
 
276
#define ARCHIVE_FORMAT_AR                       0x70000
 
277
#define ARCHIVE_FORMAT_AR_GNU                   (ARCHIVE_FORMAT_AR | 1)
 
278
#define ARCHIVE_FORMAT_AR_BSD                   (ARCHIVE_FORMAT_AR | 2)
 
279
#define ARCHIVE_FORMAT_MTREE                    0x80000
 
280
#define ARCHIVE_FORMAT_RAW                      0x90000
 
281
#define ARCHIVE_FORMAT_XAR                      0xA0000
 
282
#define ARCHIVE_FORMAT_LHA                      0xB0000
 
283
#define ARCHIVE_FORMAT_CAB                      0xC0000
 
284
#define ARCHIVE_FORMAT_RAR                      0xD0000
 
285
#define ARCHIVE_FORMAT_7ZIP                     0xE0000
291
286
 
292
287
/*-
293
288
 * Basic outline for reading an archive:
301
296
 *      data for entries of interest.
302
297
 *   5) Call archive_read_finish to end processing.
303
298
 */
304
 
__LA_DECL struct archive    *archive_read_new(void);
 
299
__LA_DECL struct archive        *archive_read_new(void);
305
300
 
306
301
/*
307
302
 * The archive_read_support_XXX calls enable auto-detect for this
310
305
 * support_compression_bzip2().  The "all" functions provide the
311
306
 * obvious shorthand.
312
307
 */
313
 
__LA_DECL int        archive_read_support_compression_all(struct archive *);
314
 
__LA_DECL int        archive_read_support_compression_bzip2(struct archive *);
315
 
__LA_DECL int        archive_read_support_compression_compress(struct archive *);
316
 
__LA_DECL int        archive_read_support_compression_gzip(struct archive *);
317
 
__LA_DECL int        archive_read_support_compression_lzma(struct archive *);
318
 
__LA_DECL int        archive_read_support_compression_none(struct archive *);
319
 
__LA_DECL int        archive_read_support_compression_program(struct archive *,
320
 
             const char *command);
321
 
__LA_DECL int        archive_read_support_compression_program_signature
322
 
                (struct archive *, const char *,
323
 
                    const void * /* match */, size_t);
324
 
 
325
 
__LA_DECL int        archive_read_support_compression_xz(struct archive *);
326
 
 
327
 
__LA_DECL int        archive_read_support_format_all(struct archive *);
328
 
__LA_DECL int        archive_read_support_format_ar(struct archive *);
329
 
__LA_DECL int        archive_read_support_format_cpio(struct archive *);
330
 
__LA_DECL int        archive_read_support_format_empty(struct archive *);
331
 
__LA_DECL int        archive_read_support_format_gnutar(struct archive *);
332
 
__LA_DECL int        archive_read_support_format_iso9660(struct archive *);
333
 
__LA_DECL int        archive_read_support_format_mtree(struct archive *);
334
 
__LA_DECL int        archive_read_support_format_raw(struct archive *);
335
 
__LA_DECL int        archive_read_support_format_tar(struct archive *);
336
 
__LA_DECL int        archive_read_support_format_zip(struct archive *);
337
 
 
338
 
 
339
 
/* Open the archive using callbacks for archive I/O. */
340
 
__LA_DECL int        archive_read_open(struct archive *, void *_client_data,
341
 
             archive_open_callback *, archive_read_callback *,
342
 
             archive_close_callback *);
343
 
__LA_DECL int        archive_read_open2(struct archive *, void *_client_data,
344
 
             archive_open_callback *, archive_read_callback *,
345
 
             archive_skip_callback *, archive_close_callback *);
 
308
 
 
309
#if ARCHIVE_VERSION_NUMBER < 4000000
 
310
__LA_DECL int archive_read_support_compression_all(struct archive *);
 
311
__LA_DECL int archive_read_support_compression_bzip2(struct archive *);
 
312
__LA_DECL int archive_read_support_compression_compress(struct archive *);
 
313
__LA_DECL int archive_read_support_compression_gzip(struct archive *);
 
314
__LA_DECL int archive_read_support_compression_lzip(struct archive *);
 
315
__LA_DECL int archive_read_support_compression_lzma(struct archive *);
 
316
__LA_DECL int archive_read_support_compression_none(struct archive *);
 
317
__LA_DECL int archive_read_support_compression_program(struct archive *,
 
318
                     const char *command);
 
319
__LA_DECL int archive_read_support_compression_program_signature
 
320
                (struct archive *, const char *,
 
321
                                    const void * /* match */, size_t);
 
322
 
 
323
__LA_DECL int archive_read_support_compression_rpm(struct archive *);
 
324
__LA_DECL int archive_read_support_compression_uu(struct archive *);
 
325
__LA_DECL int archive_read_support_compression_xz(struct archive *);
 
326
#endif
 
327
 
 
328
__LA_DECL int archive_read_support_filter_all(struct archive *);
 
329
__LA_DECL int archive_read_support_filter_bzip2(struct archive *);
 
330
__LA_DECL int archive_read_support_filter_compress(struct archive *);
 
331
__LA_DECL int archive_read_support_filter_gzip(struct archive *);
 
332
__LA_DECL int archive_read_support_filter_lzip(struct archive *);
 
333
__LA_DECL int archive_read_support_filter_lzma(struct archive *);
 
334
__LA_DECL int archive_read_support_filter_none(struct archive *);
 
335
__LA_DECL int archive_read_support_filter_program(struct archive *,
 
336
                     const char *command);
 
337
__LA_DECL int archive_read_support_filter_program_signature
 
338
                (struct archive *, const char *,
 
339
                                    const void * /* match */, size_t);
 
340
 
 
341
__LA_DECL int archive_read_support_filter_rpm(struct archive *);
 
342
__LA_DECL int archive_read_support_filter_uu(struct archive *);
 
343
__LA_DECL int archive_read_support_filter_xz(struct archive *);
 
344
 
 
345
__LA_DECL int archive_read_support_format_7zip(struct archive *);
 
346
__LA_DECL int archive_read_support_format_all(struct archive *);
 
347
__LA_DECL int archive_read_support_format_ar(struct archive *);
 
348
__LA_DECL int archive_read_support_format_by_code(struct archive *, int);
 
349
__LA_DECL int archive_read_support_format_cab(struct archive *);
 
350
__LA_DECL int archive_read_support_format_cpio(struct archive *);
 
351
__LA_DECL int archive_read_support_format_empty(struct archive *);
 
352
__LA_DECL int archive_read_support_format_gnutar(struct archive *);
 
353
__LA_DECL int archive_read_support_format_iso9660(struct archive *);
 
354
__LA_DECL int archive_read_support_format_lha(struct archive *);
 
355
__LA_DECL int archive_read_support_format_mtree(struct archive *);
 
356
__LA_DECL int archive_read_support_format_rar(struct archive *);
 
357
__LA_DECL int archive_read_support_format_raw(struct archive *);
 
358
__LA_DECL int archive_read_support_format_tar(struct archive *);
 
359
__LA_DECL int archive_read_support_format_xar(struct archive *);
 
360
__LA_DECL int archive_read_support_format_zip(struct archive *);
 
361
 
 
362
/* Set various callbacks. */
 
363
__LA_DECL int archive_read_set_open_callback(struct archive *,
 
364
    archive_open_callback *);
 
365
__LA_DECL int archive_read_set_read_callback(struct archive *,
 
366
    archive_read_callback *);
 
367
__LA_DECL int archive_read_set_seek_callback(struct archive *,
 
368
    archive_seek_callback *);
 
369
__LA_DECL int archive_read_set_skip_callback(struct archive *,
 
370
    archive_skip_callback *);
 
371
__LA_DECL int archive_read_set_close_callback(struct archive *,
 
372
    archive_close_callback *);
 
373
/* The callback data is provided to all of the callbacks above. */
 
374
__LA_DECL int archive_read_set_callback_data(struct archive *, void *);
 
375
/* Opening freezes the callbacks. */
 
376
__LA_DECL int archive_read_open1(struct archive *);
 
377
 
 
378
/* Convenience wrappers around the above. */
 
379
__LA_DECL int archive_read_open(struct archive *, void *_client_data,
 
380
                     archive_open_callback *, archive_read_callback *,
 
381
                     archive_close_callback *);
 
382
__LA_DECL int archive_read_open2(struct archive *, void *_client_data,
 
383
                     archive_open_callback *, archive_read_callback *,
 
384
                     archive_skip_callback *, archive_close_callback *);
346
385
 
347
386
/*
348
387
 * A variety of shortcuts that invoke archive_read_open() with
350
389
 * accept a block size handle tape blocking correctly.
351
390
 */
352
391
/* Use this if you know the filename.  Note: NULL indicates stdin. */
353
 
__LA_DECL int        archive_read_open_filename(struct archive *,
354
 
             const char *_filename, size_t _block_size);
 
392
__LA_DECL int archive_read_open_filename(struct archive *,
 
393
                     const char *_filename, size_t _block_size);
 
394
__LA_DECL int archive_read_open_filename_w(struct archive *,
 
395
                     const wchar_t *_filename, size_t _block_size);
355
396
/* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */
356
 
__LA_DECL int        archive_read_open_file(struct archive *,
357
 
             const char *_filename, size_t _block_size);
 
397
__LA_DECL int archive_read_open_file(struct archive *,
 
398
                     const char *_filename, size_t _block_size);
358
399
/* Read an archive that's stored in memory. */
359
 
__LA_DECL int        archive_read_open_memory(struct archive *,
360
 
             void * buff, size_t size);
 
400
__LA_DECL int archive_read_open_memory(struct archive *,
 
401
                     void * buff, size_t size);
361
402
/* A more involved version that is only used for internal testing. */
362
 
__LA_DECL int       archive_read_open_memory2(struct archive *a, void *buff,
363
 
             size_t size, size_t read_size);
 
403
__LA_DECL int archive_read_open_memory2(struct archive *a, void *buff,
 
404
                     size_t size, size_t read_size);
364
405
/* Read an archive that's already open, using the file descriptor. */
365
 
__LA_DECL int        archive_read_open_fd(struct archive *, int _fd,
366
 
             size_t _block_size);
 
406
__LA_DECL int archive_read_open_fd(struct archive *, int _fd,
 
407
                     size_t _block_size);
367
408
/* Read an archive that's already open, using a FILE *. */
368
409
/* Note: DO NOT use this with tape drives. */
369
 
__LA_DECL int        archive_read_open_FILE(struct archive *, FILE *_file);
 
410
__LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);
370
411
 
371
412
/* Parses and returns next entry header. */
372
 
__LA_DECL int        archive_read_next_header(struct archive *,
373
 
             struct archive_entry **);
 
413
__LA_DECL int archive_read_next_header(struct archive *,
 
414
                     struct archive_entry **);
374
415
 
375
416
/* Parses and returns next entry header using the archive_entry passed in */
376
 
__LA_DECL int        archive_read_next_header2(struct archive *,
377
 
             struct archive_entry *);
 
417
__LA_DECL int archive_read_next_header2(struct archive *,
 
418
                     struct archive_entry *);
378
419
 
379
420
/*
380
421
 * Retrieve the byte offset in UNCOMPRESSED data where last-read
381
422
 * header started.
382
423
 */
383
 
__LA_DECL __LA_INT64_T       archive_read_header_position(struct archive *);
 
424
__LA_DECL __LA_INT64_T           archive_read_header_position(struct archive *);
384
425
 
385
426
/* Read data from the body of an entry.  Similar to read(2). */
386
 
__LA_DECL __LA_SSIZE_T       archive_read_data(struct archive *,
387
 
                    void *, size_t);
 
427
__LA_DECL __LA_SSIZE_T           archive_read_data(struct archive *,
 
428
                                    void *, size_t);
388
429
 
389
430
/*
390
431
 * A zero-copy version of archive_read_data that also exposes the file offset
392
433
 * the desired size of the block.  The API does guarantee that offsets will
393
434
 * be strictly increasing and that returned blocks will not overlap.
394
435
 */
395
 
#if ARCHIVE_VERSION_NUMBER < 3000000
396
 
__LA_DECL int        archive_read_data_block(struct archive *a,
397
 
                const void **buff, size_t *size, off_t *offset);
398
 
#else
399
 
__LA_DECL int        archive_read_data_block(struct archive *a,
400
 
                const void **buff, size_t *size,
401
 
                __LA_INT64_T *offset);
402
 
#endif
 
436
__LA_DECL int archive_read_data_block(struct archive *a,
 
437
                    const void **buff, size_t *size, __LA_INT64_T *offset);
403
438
 
404
439
/*-
405
440
 * Some convenience functions that are built on archive_read_data:
407
442
 *  'into_buffer': writes data into memory buffer that you provide
408
443
 *  'into_fd': writes data to specified filedes
409
444
 */
410
 
__LA_DECL int        archive_read_data_skip(struct archive *);
411
 
__LA_DECL int        archive_read_data_into_buffer(struct archive *,
412
 
                void *buffer, __LA_SSIZE_T len);
413
 
__LA_DECL int        archive_read_data_into_fd(struct archive *, int fd);
 
445
__LA_DECL int archive_read_data_skip(struct archive *);
 
446
__LA_DECL int archive_read_data_into_fd(struct archive *, int fd);
414
447
 
415
448
/*
416
449
 * Set read options.
417
450
 */
418
 
/* Apply option string to the format only. */
419
 
__LA_DECL int       archive_read_set_format_options(struct archive *_a,
420
 
                const char *s);
421
 
/* Apply option string to the filter only. */
422
 
__LA_DECL int       archive_read_set_filter_options(struct archive *_a,
423
 
                const char *s);
 
451
/* Apply option to the format only. */
 
452
__LA_DECL int archive_read_set_format_option(struct archive *_a,
 
453
                            const char *m, const char *o,
 
454
                            const char *v);
 
455
/* Apply option to the filter only. */
 
456
__LA_DECL int archive_read_set_filter_option(struct archive *_a,
 
457
                            const char *m, const char *o,
 
458
                            const char *v);
 
459
/* Apply option to both the format and the filter. */
 
460
__LA_DECL int archive_read_set_option(struct archive *_a,
 
461
                            const char *m, const char *o,
 
462
                            const char *v);
424
463
/* Apply option string to both the format and the filter. */
425
 
__LA_DECL int       archive_read_set_options(struct archive *_a,
426
 
                const char *s);
 
464
__LA_DECL int archive_read_set_options(struct archive *_a,
 
465
                            const char *opts);
427
466
 
428
467
/*-
429
468
 * Convenience function to recreate the current entry (whose header
442
481
/* The "flags" argument selects optional behavior, 'OR' the flags you want. */
443
482
 
444
483
/* Default: Do not try to set owner/group. */
445
 
#define ARCHIVE_EXTRACT_OWNER           (0x0001)
 
484
#define ARCHIVE_EXTRACT_OWNER                   (0x0001)
446
485
/* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */
447
 
#define ARCHIVE_EXTRACT_PERM            (0x0002)
 
486
#define ARCHIVE_EXTRACT_PERM                    (0x0002)
448
487
/* Default: Do not restore mtime/atime. */
449
 
#define ARCHIVE_EXTRACT_TIME            (0x0004)
 
488
#define ARCHIVE_EXTRACT_TIME                    (0x0004)
450
489
/* Default: Replace existing files. */
451
 
#define ARCHIVE_EXTRACT_NO_OVERWRITE        (0x0008)
 
490
#define ARCHIVE_EXTRACT_NO_OVERWRITE            (0x0008)
452
491
/* Default: Try create first, unlink only if create fails with EEXIST. */
453
 
#define ARCHIVE_EXTRACT_UNLINK          (0x0010)
 
492
#define ARCHIVE_EXTRACT_UNLINK                  (0x0010)
454
493
/* Default: Do not restore ACLs. */
455
 
#define ARCHIVE_EXTRACT_ACL         (0x0020)
 
494
#define ARCHIVE_EXTRACT_ACL                     (0x0020)
456
495
/* Default: Do not restore fflags. */
457
 
#define ARCHIVE_EXTRACT_FFLAGS          (0x0040)
 
496
#define ARCHIVE_EXTRACT_FFLAGS                  (0x0040)
458
497
/* Default: Do not restore xattrs. */
459
 
#define ARCHIVE_EXTRACT_XATTR           (0x0080)
 
498
#define ARCHIVE_EXTRACT_XATTR                   (0x0080)
460
499
/* Default: Do not try to guard against extracts redirected by symlinks. */
461
500
/* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */
462
 
#define ARCHIVE_EXTRACT_SECURE_SYMLINKS     (0x0100)
 
501
#define ARCHIVE_EXTRACT_SECURE_SYMLINKS         (0x0100)
463
502
/* Default: Do not reject entries with '..' as path elements. */
464
 
#define ARCHIVE_EXTRACT_SECURE_NODOTDOT     (0x0200)
 
503
#define ARCHIVE_EXTRACT_SECURE_NODOTDOT         (0x0200)
465
504
/* Default: Create parent directories as needed. */
466
 
#define ARCHIVE_EXTRACT_NO_AUTODIR      (0x0400)
 
505
#define ARCHIVE_EXTRACT_NO_AUTODIR              (0x0400)
467
506
/* Default: Overwrite files, even if one on disk is newer. */
468
 
#define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER  (0x0800)
 
507
#define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER      (0x0800)
469
508
/* Detect blocks of 0 and write holes instead. */
470
 
#define ARCHIVE_EXTRACT_SPARSE          (0x1000)
 
509
#define ARCHIVE_EXTRACT_SPARSE                  (0x1000)
 
510
/* Default: Do not restore Mac extended metadata. */
 
511
/* This has no effect except on Mac OS. */
 
512
#define ARCHIVE_EXTRACT_MAC_METADATA            (0x2000)
471
513
 
472
 
__LA_DECL int    archive_read_extract(struct archive *, struct archive_entry *,
473
 
             int flags);
474
 
__LA_DECL int    archive_read_extract2(struct archive *, struct archive_entry *,
475
 
             struct archive * /* dest */);
476
 
__LA_DECL void   archive_read_extract_set_progress_callback(struct archive *,
477
 
             void (*_progress_func)(void *), void *_user_data);
 
514
__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
 
515
                     int flags);
 
516
__LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
 
517
                     struct archive * /* dest */);
 
518
__LA_DECL void   archive_read_extract_set_progress_callback(struct archive *,
 
519
                     void (*_progress_func)(void *), void *_user_data);
478
520
 
479
521
/* Record the dev/ino of a file that will not be written.  This is
480
522
 * generally set to the dev/ino of the archive being read. */
481
 
__LA_DECL void      archive_read_extract_set_skip_file(struct archive *,
482
 
             dev_t, ino_t);
 
523
__LA_DECL void          archive_read_extract_set_skip_file(struct archive *,
 
524
                     __LA_INT64_T, __LA_INT64_T);
483
525
 
484
526
/* Close the file and release most resources. */
485
 
__LA_DECL int        archive_read_close(struct archive *);
 
527
__LA_DECL int            archive_read_close(struct archive *);
486
528
/* Release all resources and destroy the object. */
487
 
/* Note that archive_read_finish will call archive_read_close for you. */
488
 
#if ARCHIVE_VERSION_NUMBER < 2000000
489
 
/* Erroneously declared to return void in libarchive 1.x */
490
 
__LA_DECL void       archive_read_finish(struct archive *);
491
 
#else
492
 
__LA_DECL int        archive_read_finish(struct archive *);
 
529
/* Note that archive_read_free will call archive_read_close for you. */
 
530
__LA_DECL int            archive_read_free(struct archive *);
 
531
#if ARCHIVE_VERSION_NUMBER < 4000000
 
532
/* Synonym for archive_read_free() for backwards compatibility. */
 
533
__LA_DECL int            archive_read_finish(struct archive *);
493
534
#endif
494
535
 
495
536
/*-
496
537
 * To create an archive:
497
 
 *   1) Ask archive_write_new for a archive writer object.
 
538
 *   1) Ask archive_write_new for an archive writer object.
498
539
 *   2) Set any global properties.  In particular, you should set
499
540
 *      the compression and format to use.
500
541
 *   3) Call archive_write_open to open the file (most people
505
546
 *      - archive_write_header to write the header
506
547
 *      - archive_write_data to write the entry data
507
548
 *   5) archive_write_close to close the output
508
 
 *   6) archive_write_finish to cleanup the writer and release resources
 
549
 *   6) archive_write_free to cleanup the writer and release resources
509
550
 */
510
 
__LA_DECL struct archive    *archive_write_new(void);
511
 
__LA_DECL int        archive_write_set_bytes_per_block(struct archive *,
512
 
             int bytes_per_block);
513
 
__LA_DECL int        archive_write_get_bytes_per_block(struct archive *);
 
551
__LA_DECL struct archive        *archive_write_new(void);
 
552
__LA_DECL int archive_write_set_bytes_per_block(struct archive *,
 
553
                     int bytes_per_block);
 
554
__LA_DECL int archive_write_get_bytes_per_block(struct archive *);
514
555
/* XXX This is badly misnamed; suggestions appreciated. XXX */
515
 
__LA_DECL int        archive_write_set_bytes_in_last_block(struct archive *,
516
 
             int bytes_in_last_block);
517
 
__LA_DECL int        archive_write_get_bytes_in_last_block(struct archive *);
 
556
__LA_DECL int archive_write_set_bytes_in_last_block(struct archive *,
 
557
                     int bytes_in_last_block);
 
558
__LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);
518
559
 
519
560
/* The dev/ino of a file that won't be archived.  This is used
520
561
 * to avoid recursively adding an archive to itself. */
521
 
__LA_DECL int        archive_write_set_skip_file(struct archive *, dev_t, ino_t);
522
 
 
523
 
__LA_DECL int        archive_write_set_compression_bzip2(struct archive *);
524
 
__LA_DECL int        archive_write_set_compression_compress(struct archive *);
525
 
__LA_DECL int        archive_write_set_compression_gzip(struct archive *);
526
 
__LA_DECL int        archive_write_set_compression_lzma(struct archive *);
527
 
__LA_DECL int        archive_write_set_compression_none(struct archive *);
528
 
__LA_DECL int        archive_write_set_compression_program(struct archive *,
529
 
             const char *cmd);
530
 
__LA_DECL int        archive_write_set_compression_xz(struct archive *);
 
562
__LA_DECL int archive_write_set_skip_file(struct archive *,
 
563
    __LA_INT64_T, __LA_INT64_T);
 
564
 
 
565
#if ARCHIVE_VERSION_NUMBER < 4000000
 
566
__LA_DECL int archive_write_set_compression_bzip2(struct archive *);
 
567
__LA_DECL int archive_write_set_compression_compress(struct archive *);
 
568
__LA_DECL int archive_write_set_compression_gzip(struct archive *);
 
569
__LA_DECL int archive_write_set_compression_lzip(struct archive *);
 
570
__LA_DECL int archive_write_set_compression_lzma(struct archive *);
 
571
__LA_DECL int archive_write_set_compression_none(struct archive *);
 
572
__LA_DECL int archive_write_set_compression_program(struct archive *,
 
573
                     const char *cmd);
 
574
__LA_DECL int archive_write_set_compression_xz(struct archive *);
 
575
#endif
 
576
 
 
577
__LA_DECL int archive_write_add_filter_bzip2(struct archive *);
 
578
__LA_DECL int archive_write_add_filter_compress(struct archive *);
 
579
__LA_DECL int archive_write_add_filter_gzip(struct archive *);
 
580
__LA_DECL int archive_write_add_filter_lzip(struct archive *);
 
581
__LA_DECL int archive_write_add_filter_lzma(struct archive *);
 
582
__LA_DECL int archive_write_add_filter_none(struct archive *);
 
583
__LA_DECL int archive_write_add_filter_program(struct archive *,
 
584
                     const char *cmd);
 
585
__LA_DECL int archive_write_add_filter_xz(struct archive *);
 
586
 
 
587
 
531
588
/* A convenience function to set the format based on the code or name. */
532
 
__LA_DECL int        archive_write_set_format(struct archive *, int format_code);
533
 
__LA_DECL int        archive_write_set_format_by_name(struct archive *,
534
 
             const char *name);
 
589
__LA_DECL int archive_write_set_format(struct archive *, int format_code);
 
590
__LA_DECL int archive_write_set_format_by_name(struct archive *,
 
591
                     const char *name);
535
592
/* To minimize link pollution, use one or more of the following. */
536
 
__LA_DECL int        archive_write_set_format_ar_bsd(struct archive *);
537
 
__LA_DECL int        archive_write_set_format_ar_svr4(struct archive *);
538
 
__LA_DECL int        archive_write_set_format_cpio(struct archive *);
539
 
__LA_DECL int        archive_write_set_format_cpio_newc(struct archive *);
540
 
__LA_DECL int        archive_write_set_format_mtree(struct archive *);
 
593
__LA_DECL int archive_write_set_format_7zip(struct archive *);
 
594
__LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
 
595
__LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
 
596
__LA_DECL int archive_write_set_format_cpio(struct archive *);
 
597
__LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
 
598
__LA_DECL int archive_write_set_format_gnutar(struct archive *);
 
599
__LA_DECL int archive_write_set_format_iso9660(struct archive *);
 
600
__LA_DECL int archive_write_set_format_mtree(struct archive *);
541
601
/* TODO: int archive_write_set_format_old_tar(struct archive *); */
542
 
__LA_DECL int        archive_write_set_format_pax(struct archive *);
543
 
__LA_DECL int        archive_write_set_format_pax_restricted(struct archive *);
544
 
__LA_DECL int        archive_write_set_format_shar(struct archive *);
545
 
__LA_DECL int        archive_write_set_format_shar_dump(struct archive *);
546
 
__LA_DECL int        archive_write_set_format_ustar(struct archive *);
547
 
__LA_DECL int        archive_write_set_format_zip(struct archive *);
548
 
__LA_DECL int        archive_write_open(struct archive *, void *,
549
 
             archive_open_callback *, archive_write_callback *,
550
 
             archive_close_callback *);
551
 
__LA_DECL int        archive_write_open_fd(struct archive *, int _fd);
552
 
__LA_DECL int        archive_write_open_filename(struct archive *, const char *_file);
 
602
__LA_DECL int archive_write_set_format_pax(struct archive *);
 
603
__LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
 
604
__LA_DECL int archive_write_set_format_shar(struct archive *);
 
605
__LA_DECL int archive_write_set_format_shar_dump(struct archive *);
 
606
__LA_DECL int archive_write_set_format_ustar(struct archive *);
 
607
__LA_DECL int archive_write_set_format_xar(struct archive *);
 
608
__LA_DECL int archive_write_set_format_zip(struct archive *);
 
609
__LA_DECL int archive_write_open(struct archive *, void *,
 
610
                     archive_open_callback *, archive_write_callback *,
 
611
                     archive_close_callback *);
 
612
__LA_DECL int archive_write_open_fd(struct archive *, int _fd);
 
613
__LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
 
614
__LA_DECL int archive_write_open_filename_w(struct archive *,
 
615
                     const wchar_t *_file);
553
616
/* A deprecated synonym for archive_write_open_filename() */
554
 
__LA_DECL int        archive_write_open_file(struct archive *, const char *_file);
555
 
__LA_DECL int        archive_write_open_FILE(struct archive *, FILE *);
 
617
__LA_DECL int archive_write_open_file(struct archive *, const char *_file);
 
618
__LA_DECL int archive_write_open_FILE(struct archive *, FILE *);
556
619
/* _buffSize is the size of the buffer, _used refers to a variable that
557
620
 * will be updated after each write into the buffer. */
558
 
__LA_DECL int        archive_write_open_memory(struct archive *,
559
 
            void *_buffer, size_t _buffSize, size_t *_used);
 
621
__LA_DECL int archive_write_open_memory(struct archive *,
 
622
                        void *_buffer, size_t _buffSize, size_t *_used);
560
623
 
561
624
/*
562
625
 * Note that the library will truncate writes beyond the size provided
563
626
 * to archive_write_header or pad if the provided data is short.
564
627
 */
565
 
__LA_DECL int        archive_write_header(struct archive *,
566
 
             struct archive_entry *);
567
 
#if ARCHIVE_VERSION_NUMBER < 2000000
568
 
/* This was erroneously declared to return "int" in libarchive 1.x. */
569
 
__LA_DECL int        archive_write_data(struct archive *,
570
 
                const void *, size_t);
571
 
#else
572
 
/* Libarchive 2.0 and later return ssize_t here. */
573
 
__LA_DECL __LA_SSIZE_T   archive_write_data(struct archive *,
574
 
                const void *, size_t);
575
 
#endif
576
 
 
577
 
#if ARCHIVE_VERSION_NUMBER < 3000000
578
 
/* Libarchive 1.x and 2.x use off_t for the argument, but that's not
579
 
 * stable on Linux. */
580
 
__LA_DECL __LA_SSIZE_T   archive_write_data_block(struct archive *,
581
 
                    const void *, size_t, off_t);
582
 
#else
583
 
/* Libarchive 3.0 uses explicit int64_t to ensure consistent 64-bit support. */
584
 
__LA_DECL __LA_SSIZE_T   archive_write_data_block(struct archive *,
585
 
                    const void *, size_t, __LA_INT64_T);
586
 
#endif
587
 
__LA_DECL int        archive_write_finish_entry(struct archive *);
588
 
__LA_DECL int        archive_write_close(struct archive *);
589
 
#if ARCHIVE_VERSION_NUMBER < 2000000
590
 
/* Return value was incorrect in libarchive 1.x. */
591
 
__LA_DECL void       archive_write_finish(struct archive *);
592
 
#else
593
 
/* Libarchive 2.x and later returns an error if this fails. */
594
 
/* It can fail if the archive wasn't already closed, in which case
595
 
 * archive_write_finish() will implicitly call archive_write_close(). */
596
 
__LA_DECL int        archive_write_finish(struct archive *);
 
628
__LA_DECL int archive_write_header(struct archive *,
 
629
                     struct archive_entry *);
 
630
__LA_DECL __LA_SSIZE_T  archive_write_data(struct archive *,
 
631
                            const void *, size_t);
 
632
 
 
633
/* This interface is currently only available for archive_write_disk handles.  */
 
634
__LA_DECL __LA_SSIZE_T   archive_write_data_block(struct archive *,
 
635
                                    const void *, size_t, __LA_INT64_T);
 
636
 
 
637
__LA_DECL int            archive_write_finish_entry(struct archive *);
 
638
__LA_DECL int            archive_write_close(struct archive *);
 
639
/* This can fail if the archive wasn't already closed, in which case
 
640
 * archive_write_free() will implicitly call archive_write_close(). */
 
641
__LA_DECL int            archive_write_free(struct archive *);
 
642
#if ARCHIVE_VERSION_NUMBER < 4000000
 
643
/* Synonym for archive_write_free() for backwards compatibility. */
 
644
__LA_DECL int            archive_write_finish(struct archive *);
597
645
#endif
598
646
 
599
647
/*
600
648
 * Set write options.
601
649
 */
602
 
/* Apply option string to the format only. */
603
 
__LA_DECL int       archive_write_set_format_options(struct archive *_a,
604
 
                const char *s);
605
 
/* Apply option string to the compressor only. */
606
 
__LA_DECL int       archive_write_set_compressor_options(struct archive *_a,
607
 
                const char *s);
608
 
/* Apply option string to both the format and the compressor. */
609
 
__LA_DECL int       archive_write_set_options(struct archive *_a,
610
 
                const char *s);
611
 
 
 
650
/* Apply option to the format only. */
 
651
__LA_DECL int archive_write_set_format_option(struct archive *_a,
 
652
                            const char *m, const char *o,
 
653
                            const char *v);
 
654
/* Apply option to the filter only. */
 
655
__LA_DECL int archive_write_set_filter_option(struct archive *_a,
 
656
                            const char *m, const char *o,
 
657
                            const char *v);
 
658
/* Apply option to both the format and the filter. */
 
659
__LA_DECL int archive_write_set_option(struct archive *_a,
 
660
                            const char *m, const char *o,
 
661
                            const char *v);
 
662
/* Apply option string to both the format and the filter. */
 
663
__LA_DECL int archive_write_set_options(struct archive *_a,
 
664
                            const char *opts);
612
665
 
613
666
/*-
614
667
 * ARCHIVE_WRITE_DISK API
621
674
 *      - construct an appropriate struct archive_entry structure
622
675
 *      - archive_write_header to create the file/dir/etc on disk
623
676
 *      - archive_write_data to write the entry data
624
 
 *   4) archive_write_finish to cleanup the writer and release resources
 
677
 *   4) archive_write_free to cleanup the writer and release resources
625
678
 *
626
679
 * In particular, you can use this in conjunction with archive_read()
627
680
 * to pull entries out of an archive and create them on disk.
628
681
 */
629
 
__LA_DECL struct archive    *archive_write_disk_new(void);
 
682
__LA_DECL struct archive        *archive_write_disk_new(void);
630
683
/* This file will not be overwritten. */
631
 
__LA_DECL int        archive_write_disk_set_skip_file(struct archive *,
632
 
             dev_t, ino_t);
 
684
__LA_DECL int archive_write_disk_set_skip_file(struct archive *,
 
685
    __LA_INT64_T, __LA_INT64_T);
633
686
/* Set flags to control how the next item gets created.
634
687
 * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
635
 
__LA_DECL int        archive_write_disk_set_options(struct archive *,
636
 
             int flags);
 
688
__LA_DECL int            archive_write_disk_set_options(struct archive *,
 
689
                     int flags);
637
690
/*
638
691
 * The lookup functions are given uname/uid (or gname/gid) pairs and
639
692
 * return a uid (gid) suitable for this system.  These are used for
651
704
 * particular, these match the specifications of POSIX "pax" and old
652
705
 * POSIX "tar".
653
706
 */
654
 
__LA_DECL int    archive_write_disk_set_standard_lookup(struct archive *);
 
707
__LA_DECL int    archive_write_disk_set_standard_lookup(struct archive *);
655
708
/*
656
709
 * If neither the default (naive) nor the standard (big) functions suit
657
710
 * your needs, you can write your own and register them.  Be sure to
658
711
 * include a cleanup function if you have allocated private data.
659
712
 */
660
 
__LA_DECL int    archive_write_disk_set_group_lookup(struct archive *,
661
 
                void * /* private_data */,
662
 
                __LA_GID_T (*)(void *, const char *, __LA_GID_T),
663
 
                void (* /* cleanup */)(void *));
664
 
__LA_DECL int    archive_write_disk_set_user_lookup(struct archive *,
665
 
                void * /* private_data */,
666
 
                __LA_UID_T (*)(void *, const char *, __LA_UID_T),
667
 
                void (* /* cleanup */)(void *));
 
713
__LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
 
714
    void * /* private_data */,
 
715
    __LA_INT64_T (*)(void *, const char *, __LA_INT64_T),
 
716
    void (* /* cleanup */)(void *));
 
717
__LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
 
718
    void * /* private_data */,
 
719
    __LA_INT64_T (*)(void *, const char *, __LA_INT64_T),
 
720
    void (* /* cleanup */)(void *));
 
721
__LA_DECL __LA_INT64_T archive_write_disk_gid(struct archive *, const char *, __LA_INT64_T);
 
722
__LA_DECL __LA_INT64_T archive_write_disk_uid(struct archive *, const char *, __LA_INT64_T);
668
723
 
669
724
/*
670
725
 * ARCHIVE_READ_DISK API
685
740
    struct archive_entry *, int /* fd */, const struct stat *);
686
741
/* Look up gname for gid or uname for uid. */
687
742
/* Default implementations are very, very stupid. */
688
 
__LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_GID_T);
689
 
__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_UID_T);
 
743
__LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_INT64_T);
 
744
__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_INT64_T);
690
745
/* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the
691
746
 * results for performance. */
692
 
__LA_DECL int   archive_read_disk_set_standard_lookup(struct archive *);
 
747
__LA_DECL int   archive_read_disk_set_standard_lookup(struct archive *);
693
748
/* You can install your own lookups if you like. */
694
 
__LA_DECL int   archive_read_disk_set_gname_lookup(struct archive *,
695
 
    void * /* private_data */,
696
 
    const char *(* /* lookup_fn */)(void *, __LA_GID_T),
697
 
    void (* /* cleanup_fn */)(void *));
698
 
__LA_DECL int   archive_read_disk_set_uname_lookup(struct archive *,
699
 
    void * /* private_data */,
700
 
    const char *(* /* lookup_fn */)(void *, __LA_UID_T),
701
 
    void (* /* cleanup_fn */)(void *));
 
749
__LA_DECL int   archive_read_disk_set_gname_lookup(struct archive *,
 
750
    void * /* private_data */,
 
751
    const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
 
752
    void (* /* cleanup_fn */)(void *));
 
753
__LA_DECL int   archive_read_disk_set_uname_lookup(struct archive *,
 
754
    void * /* private_data */,
 
755
    const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
 
756
    void (* /* cleanup_fn */)(void *));
 
757
/* Start traversal. */
 
758
__LA_DECL int   archive_read_disk_open(struct archive *, const char *);
 
759
__LA_DECL int   archive_read_disk_open_w(struct archive *, const wchar_t *);
 
760
/*
 
761
 * Request that current entry be visited.  If you invoke it on every
 
762
 * directory, you'll get a physical traversal.  This is ignored if the
 
763
 * current entry isn't a directory or a link to a directory.  So, if
 
764
 * you invoke this on every returned path, you'll get a full logical
 
765
 * traversal.
 
766
 */
 
767
__LA_DECL int   archive_read_disk_descend(struct archive *);
 
768
__LA_DECL int   archive_read_disk_current_filesystem(struct archive *);
 
769
__LA_DECL int   archive_read_disk_current_filesystem_is_synthetic(struct archive *);
 
770
__LA_DECL int   archive_read_disk_current_filesystem_is_remote(struct archive *);
 
771
/* Request that the access time of the entry visited by travesal be restored. */
 
772
__LA_DECL int  archive_read_disk_set_atime_restored(struct archive *);
702
773
 
703
774
/*
704
775
 * Accessor functions to read/set various information in
705
776
 * the struct archive object:
706
777
 */
707
 
/* Bytes written after compression or read before decompression. */
708
 
__LA_DECL __LA_INT64_T   archive_position_compressed(struct archive *);
709
 
/* Bytes written to compressor or read from decompressor. */
710
 
__LA_DECL __LA_INT64_T   archive_position_uncompressed(struct archive *);
711
 
 
712
 
__LA_DECL const char    *archive_compression_name(struct archive *);
713
 
__LA_DECL int        archive_compression(struct archive *);
714
 
__LA_DECL int        archive_errno(struct archive *);
715
 
__LA_DECL const char    *archive_error_string(struct archive *);
716
 
__LA_DECL const char    *archive_format_name(struct archive *);
717
 
__LA_DECL int        archive_format(struct archive *);
718
 
__LA_DECL void       archive_clear_error(struct archive *);
719
 
__LA_DECL void       archive_set_error(struct archive *, int _err,
720
 
                const char *fmt, ...);
721
 
__LA_DECL void       archive_copy_error(struct archive *dest,
722
 
                struct archive *src);
723
 
__LA_DECL int        archive_file_count(struct archive *);
 
778
 
 
779
/* Number of filters in the current filter pipeline. */
 
780
/* Filter #0 is the one closest to the format, -1 is a synonym for the
 
781
 * last filter, which is always the pseudo-filter that wraps the
 
782
 * client callbacks. */
 
783
__LA_DECL int            archive_filter_count(struct archive *);
 
784
__LA_DECL __LA_INT64_T   archive_filter_bytes(struct archive *, int);
 
785
__LA_DECL int            archive_filter_code(struct archive *, int);
 
786
__LA_DECL const char *   archive_filter_name(struct archive *, int);
 
787
 
 
788
#if ARCHIVE_VERSION_NUMBER < 4000000
 
789
/* These don't properly handle multiple filters, so are deprecated and
 
790
 * will eventually be removed. */
 
791
/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */
 
792
__LA_DECL __LA_INT64_T   archive_position_compressed(struct archive *);
 
793
/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */
 
794
__LA_DECL __LA_INT64_T   archive_position_uncompressed(struct archive *);
 
795
/* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */
 
796
__LA_DECL const char    *archive_compression_name(struct archive *);
 
797
/* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */
 
798
__LA_DECL int            archive_compression(struct archive *);
 
799
#endif
 
800
 
 
801
__LA_DECL int            archive_errno(struct archive *);
 
802
__LA_DECL const char    *archive_error_string(struct archive *);
 
803
__LA_DECL const char    *archive_format_name(struct archive *);
 
804
__LA_DECL int            archive_format(struct archive *);
 
805
__LA_DECL void           archive_clear_error(struct archive *);
 
806
__LA_DECL void           archive_set_error(struct archive *, int _err,
 
807
                            const char *fmt, ...) __LA_PRINTF(3, 4);
 
808
__LA_DECL void           archive_copy_error(struct archive *dest,
 
809
                            struct archive *src);
 
810
__LA_DECL int            archive_file_count(struct archive *);
724
811
 
725
812
#ifdef __cplusplus
726
813
}