Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-20 09:08:46

0001 /*-
0002  * Copyright (c) 2003-2008 Tim Kientzle
0003  * Copyright (c) 2016 Martin Matuska
0004  * All rights reserved.
0005  *
0006  * Redistribution and use in source and binary forms, with or without
0007  * modification, are permitted provided that the following conditions
0008  * are met:
0009  * 1. Redistributions of source code must retain the above copyright
0010  *    notice, this list of conditions and the following disclaimer.
0011  * 2. Redistributions in binary form must reproduce the above copyright
0012  *    notice, this list of conditions and the following disclaimer in the
0013  *    documentation and/or other materials provided with the distribution.
0014  *
0015  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
0016  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0017  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0018  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
0019  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0020  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0021  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0022  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0023  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0024  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0025  */
0026 
0027 #ifndef ARCHIVE_ENTRY_H_INCLUDED
0028 #define ARCHIVE_ENTRY_H_INCLUDED
0029 
0030 /* Note: Compiler will complain if this does not match archive.h! */
0031 #define ARCHIVE_VERSION_NUMBER 3008000
0032 
0033 /*
0034  * Note: archive_entry.h is for use outside of libarchive; the
0035  * configuration headers (config.h, archive_platform.h, etc.) are
0036  * purely internal.  Do NOT use HAVE_XXX configuration macros to
0037  * control the behavior of this header!  If you must conditionalize,
0038  * use predefined compiler and/or platform macros.
0039  */
0040 
0041 #include <sys/types.h>
0042 #include <stddef.h>  /* for wchar_t */
0043 #include <stdint.h>  /* for C99 int64_t, etc. */
0044 #if ARCHIVE_VERSION_NUMBER < 4000000
0045 /* time_t is slated to be removed from public includes in 4.0 */
0046 #include <time.h>
0047 #endif
0048 
0049 #if defined(_WIN32) && !defined(__CYGWIN__)
0050 #include <windows.h>
0051 #endif
0052 
0053 /* Get a suitable 64-bit integer type. */
0054 #if !defined(__LA_INT64_T_DEFINED)
0055 # if ARCHIVE_VERSION_NUMBER < 4000000
0056 #define __LA_INT64_T la_int64_t
0057 # endif
0058 #define __LA_INT64_T_DEFINED
0059 # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
0060 typedef __int64 la_int64_t;
0061 typedef unsigned __int64 la_uint64_t;
0062 # else
0063 #include <unistd.h>
0064 #  if defined(_SCO_DS) || defined(__osf__)
0065 typedef long long la_int64_t;
0066 typedef unsigned long long la_uint64_t;
0067 #  else
0068 typedef int64_t la_int64_t;
0069 typedef uint64_t la_uint64_t;
0070 #  endif
0071 # endif
0072 #endif
0073 
0074 /* The la_ssize_t should match the type used in 'struct stat' */
0075 #if !defined(__LA_SSIZE_T_DEFINED)
0076 /* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */
0077 # if ARCHIVE_VERSION_NUMBER < 4000000
0078 #define __LA_SSIZE_T la_ssize_t
0079 # endif
0080 #define __LA_SSIZE_T_DEFINED
0081 # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
0082 #  if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
0083 typedef ssize_t la_ssize_t;
0084 #  elif defined(_WIN64)
0085 typedef __int64 la_ssize_t;
0086 #  else
0087 typedef long la_ssize_t;
0088 #  endif
0089 # else
0090 # include <unistd.h>  /* ssize_t */
0091 typedef ssize_t la_ssize_t;
0092 # endif
0093 #endif
0094 
0095 /* Get a suitable definition for mode_t */
0096 #if ARCHIVE_VERSION_NUMBER >= 3999000
0097 /* Switch to plain 'int' for libarchive 4.0.  It's less broken than 'mode_t' */
0098 # define    __LA_MODE_T int
0099 #elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
0100 # define    __LA_MODE_T unsigned short
0101 #else
0102 # define    __LA_MODE_T mode_t
0103 #endif
0104 
0105 #if ARCHIVE_VERSION_NUMBER < 4000000
0106 /* Use the platform types for time_t */
0107 #define __LA_TIME_T time_t
0108 #else
0109 /* Use 64-bits integer types for time_t */
0110 #define __LA_TIME_T la_int64_t
0111 #endif
0112 
0113 #if ARCHIVE_VERSION_NUMBER < 4000000
0114 /* Use the platform types for dev_t */
0115 #define __LA_DEV_T dev_t
0116 #else
0117 /* Use 64-bits integer types for dev_t */
0118 #define __LA_DEV_T la_int64_t
0119 #endif
0120 
0121 #if ARCHIVE_VERSION_NUMBER < 4000000
0122 /* Libarchive 3.x used signed int64 for inode numbers */
0123 #define __LA_INO_T la_int64_t
0124 #else
0125 /* Switch to unsigned for libarchive 4.0 */
0126 #define __LA_INO_T la_uint64_t
0127 #endif
0128 
0129 /* Large file support for Android */
0130 #if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)
0131 #include "android_lf.h"
0132 #endif
0133 
0134 /*
0135  * On Windows, define LIBARCHIVE_STATIC if you're building or using a
0136  * .lib.  The default here assumes you're building a DLL.  Only
0137  * libarchive source should ever define __LIBARCHIVE_BUILD.
0138  */
0139 #if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
0140 # ifdef __LIBARCHIVE_BUILD
0141 #  ifdef __GNUC__
0142 #   define __LA_DECL    __attribute__((dllexport)) extern
0143 #  else
0144 #   define __LA_DECL    __declspec(dllexport)
0145 #  endif
0146 # else
0147 #  ifdef __GNUC__
0148 #   define __LA_DECL
0149 #  else
0150 #   define __LA_DECL    __declspec(dllimport)
0151 #  endif
0152 # endif
0153 #elif defined __LIBARCHIVE_ENABLE_VISIBILITY
0154 #  define __LA_DECL __attribute__((visibility("default")))
0155 #else
0156 /* Static libraries on all platforms and shared libraries on non-Windows. */
0157 # define __LA_DECL
0158 #endif
0159 
0160 #if defined(__GNUC__) && (__GNUC__ > 3 || \
0161     (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
0162 # define __LA_DEPRECATED __attribute__((deprecated))
0163 #else
0164 # define __LA_DEPRECATED
0165 #endif
0166 
0167 #ifdef __cplusplus
0168 extern "C" {
0169 #endif
0170 
0171 /*
0172  * Description of an archive entry.
0173  *
0174  * You can think of this as "struct stat" with some text fields added in.
0175  *
0176  * TODO: Add "comment", "charset", and possibly other entries that are
0177  * supported by "pax interchange" format.  However, GNU, ustar, cpio,
0178  * and other variants don't support these features, so they're not an
0179  * excruciatingly high priority right now.
0180  *
0181  * TODO: "pax interchange" format allows essentially arbitrary
0182  * key/value attributes to be attached to any entry.  Supporting
0183  * such extensions may make this library useful for special
0184  * applications (e.g., a package manager could attach special
0185  * package-management attributes to each entry).
0186  */
0187 struct archive;
0188 struct archive_entry;
0189 
0190 /*
0191  * File-type constants.  These are returned from archive_entry_filetype()
0192  * and passed to archive_entry_set_filetype().
0193  *
0194  * These values match S_XXX defines on every platform I've checked,
0195  * including Windows, AIX, Linux, Solaris, and BSD.  They're
0196  * (re)defined here because platforms generally don't define the ones
0197  * they don't support.  For example, Windows doesn't define S_IFLNK or
0198  * S_IFBLK.  Instead of having a mass of conditional logic and system
0199  * checks to define any S_XXX values that aren't supported locally,
0200  * I've just defined a new set of such constants so that
0201  * libarchive-based applications can manipulate and identify archive
0202  * entries properly even if the hosting platform can't store them on
0203  * disk.
0204  *
0205  * These values are also used directly within some portable formats,
0206  * such as cpio.  If you find a platform that varies from these, the
0207  * correct solution is to leave these alone and translate from these
0208  * portable values to platform-native values when entries are read from
0209  * or written to disk.
0210  */
0211 /*
0212  * In libarchive 4.0, we can drop the casts here.
0213  * They're needed to work around Borland C's broken mode_t.
0214  */
0215 #define AE_IFMT     ((__LA_MODE_T)0170000)
0216 #define AE_IFREG    ((__LA_MODE_T)0100000)
0217 #define AE_IFLNK    ((__LA_MODE_T)0120000)
0218 #define AE_IFSOCK   ((__LA_MODE_T)0140000)
0219 #define AE_IFCHR    ((__LA_MODE_T)0020000)
0220 #define AE_IFBLK    ((__LA_MODE_T)0060000)
0221 #define AE_IFDIR    ((__LA_MODE_T)0040000)
0222 #define AE_IFIFO    ((__LA_MODE_T)0010000)
0223 
0224 /*
0225  * Symlink types
0226  */
0227 #define AE_SYMLINK_TYPE_UNDEFINED   0
0228 #define AE_SYMLINK_TYPE_FILE        1
0229 #define AE_SYMLINK_TYPE_DIRECTORY   2
0230 
0231 /*
0232  * Basic object manipulation
0233  */
0234 
0235 __LA_DECL struct archive_entry  *archive_entry_clear(struct archive_entry *);
0236 /* The 'clone' function does a deep copy; all of the strings are copied too. */
0237 __LA_DECL struct archive_entry  *archive_entry_clone(struct archive_entry *);
0238 __LA_DECL void           archive_entry_free(struct archive_entry *);
0239 __LA_DECL struct archive_entry  *archive_entry_new(void);
0240 
0241 /*
0242  * This form of archive_entry_new2() will pull character-set
0243  * conversion information from the specified archive handle.  The
0244  * older archive_entry_new(void) form is equivalent to calling
0245  * archive_entry_new2(NULL) and will result in the use of an internal
0246  * default character-set conversion.
0247  */
0248 __LA_DECL struct archive_entry  *archive_entry_new2(struct archive *);
0249 
0250 /*
0251  * Retrieve fields from an archive_entry.
0252  *
0253  * There are a number of implicit conversions among these fields.  For
0254  * example, if a regular string field is set and you read the _w wide
0255  * character field, the entry will implicitly convert narrow-to-wide
0256  * using the current locale.  Similarly, dev values are automatically
0257  * updated when you write devmajor or devminor and vice versa.
0258  *
0259  * In addition, fields can be "set" or "unset."  Unset string fields
0260  * return NULL, non-string fields have _is_set() functions to test
0261  * whether they've been set.  You can "unset" a string field by
0262  * assigning NULL; non-string fields have _unset() functions to
0263  * unset them.
0264  *
0265  * Note: There is one ambiguity in the above; string fields will
0266  * also return NULL when implicit character set conversions fail.
0267  * This is usually what you want.
0268  */
0269 __LA_DECL __LA_TIME_T    archive_entry_atime(struct archive_entry *);
0270 __LA_DECL long       archive_entry_atime_nsec(struct archive_entry *);
0271 __LA_DECL int        archive_entry_atime_is_set(struct archive_entry *);
0272 __LA_DECL __LA_TIME_T    archive_entry_birthtime(struct archive_entry *);
0273 __LA_DECL long       archive_entry_birthtime_nsec(struct archive_entry *);
0274 __LA_DECL int        archive_entry_birthtime_is_set(struct archive_entry *);
0275 __LA_DECL __LA_TIME_T    archive_entry_ctime(struct archive_entry *);
0276 __LA_DECL long       archive_entry_ctime_nsec(struct archive_entry *);
0277 __LA_DECL int        archive_entry_ctime_is_set(struct archive_entry *);
0278 __LA_DECL __LA_DEV_T         archive_entry_dev(struct archive_entry *);
0279 __LA_DECL int        archive_entry_dev_is_set(struct archive_entry *);
0280 __LA_DECL __LA_DEV_T         archive_entry_devmajor(struct archive_entry *);
0281 __LA_DECL __LA_DEV_T         archive_entry_devminor(struct archive_entry *);
0282 __LA_DECL __LA_MODE_T    archive_entry_filetype(struct archive_entry *);
0283 __LA_DECL int        archive_entry_filetype_is_set(struct archive_entry *);
0284 __LA_DECL void       archive_entry_fflags(struct archive_entry *,
0285                 unsigned long * /* set */,
0286                 unsigned long * /* clear */);
0287 __LA_DECL const char    *archive_entry_fflags_text(struct archive_entry *);
0288 __LA_DECL la_int64_t     archive_entry_gid(struct archive_entry *);
0289 __LA_DECL int        archive_entry_gid_is_set(struct archive_entry *);
0290 __LA_DECL const char    *archive_entry_gname(struct archive_entry *);
0291 __LA_DECL const char    *archive_entry_gname_utf8(struct archive_entry *);
0292 __LA_DECL const wchar_t *archive_entry_gname_w(struct archive_entry *);
0293 __LA_DECL void       archive_entry_set_link_to_hardlink(struct archive_entry *);
0294 __LA_DECL const char    *archive_entry_hardlink(struct archive_entry *);
0295 __LA_DECL const char    *archive_entry_hardlink_utf8(struct archive_entry *);
0296 __LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *);
0297 __LA_DECL int        archive_entry_hardlink_is_set(struct archive_entry *);
0298 __LA_DECL __LA_INO_T     archive_entry_ino(struct archive_entry *);
0299 __LA_DECL __LA_INO_T     archive_entry_ino64(struct archive_entry *);
0300 __LA_DECL int        archive_entry_ino_is_set(struct archive_entry *);
0301 __LA_DECL __LA_MODE_T    archive_entry_mode(struct archive_entry *);
0302 __LA_DECL time_t     archive_entry_mtime(struct archive_entry *);
0303 __LA_DECL long       archive_entry_mtime_nsec(struct archive_entry *);
0304 __LA_DECL int        archive_entry_mtime_is_set(struct archive_entry *);
0305 __LA_DECL unsigned int   archive_entry_nlink(struct archive_entry *);
0306 __LA_DECL const char    *archive_entry_pathname(struct archive_entry *);
0307 __LA_DECL const char    *archive_entry_pathname_utf8(struct archive_entry *);
0308 __LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *);
0309 __LA_DECL __LA_MODE_T    archive_entry_perm(struct archive_entry *);
0310 __LA_DECL int        archive_entry_perm_is_set(struct archive_entry *);
0311 __LA_DECL int        archive_entry_rdev_is_set(struct archive_entry *);
0312 __LA_DECL __LA_DEV_T         archive_entry_rdev(struct archive_entry *);
0313 __LA_DECL __LA_DEV_T         archive_entry_rdevmajor(struct archive_entry *);
0314 __LA_DECL __LA_DEV_T         archive_entry_rdevminor(struct archive_entry *);
0315 __LA_DECL const char    *archive_entry_sourcepath(struct archive_entry *);
0316 __LA_DECL const wchar_t *archive_entry_sourcepath_w(struct archive_entry *);
0317 __LA_DECL la_int64_t     archive_entry_size(struct archive_entry *);
0318 __LA_DECL int        archive_entry_size_is_set(struct archive_entry *);
0319 __LA_DECL const char    *archive_entry_strmode(struct archive_entry *);
0320 __LA_DECL void       archive_entry_set_link_to_symlink(struct archive_entry *);
0321 __LA_DECL const char    *archive_entry_symlink(struct archive_entry *);
0322 __LA_DECL const char    *archive_entry_symlink_utf8(struct archive_entry *);
0323 __LA_DECL int        archive_entry_symlink_type(struct archive_entry *);
0324 __LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *);
0325 __LA_DECL la_int64_t     archive_entry_uid(struct archive_entry *);
0326 __LA_DECL int        archive_entry_uid_is_set(struct archive_entry *);
0327 __LA_DECL const char    *archive_entry_uname(struct archive_entry *);
0328 __LA_DECL const char    *archive_entry_uname_utf8(struct archive_entry *);
0329 __LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *);
0330 __LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *);
0331 __LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *);
0332 __LA_DECL int archive_entry_is_encrypted(struct archive_entry *);
0333 
0334 /*
0335  * Set fields in an archive_entry.
0336  *
0337  * Note: Before libarchive 2.4, there were 'set' and 'copy' versions
0338  * of the string setters.  'copy' copied the actual string, 'set' just
0339  * stored the pointer.  In libarchive 2.4 and later, strings are
0340  * always copied.
0341  */
0342 
0343 __LA_DECL void  archive_entry_set_atime(struct archive_entry *, __LA_TIME_T, long);
0344 __LA_DECL void  archive_entry_unset_atime(struct archive_entry *);
0345 #if defined(_WIN32) && !defined(__CYGWIN__)
0346 __LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, BY_HANDLE_FILE_INFORMATION *);
0347 #endif
0348 __LA_DECL void  archive_entry_set_birthtime(struct archive_entry *, __LA_TIME_T, long);
0349 __LA_DECL void  archive_entry_unset_birthtime(struct archive_entry *);
0350 __LA_DECL void  archive_entry_set_ctime(struct archive_entry *, __LA_TIME_T, long);
0351 __LA_DECL void  archive_entry_unset_ctime(struct archive_entry *);
0352 __LA_DECL void  archive_entry_set_dev(struct archive_entry *, __LA_DEV_T);
0353 __LA_DECL void  archive_entry_set_devmajor(struct archive_entry *, __LA_DEV_T);
0354 __LA_DECL void  archive_entry_set_devminor(struct archive_entry *, __LA_DEV_T);
0355 __LA_DECL void  archive_entry_set_filetype(struct archive_entry *, unsigned int);
0356 __LA_DECL void  archive_entry_set_fflags(struct archive_entry *,
0357         unsigned long /* set */, unsigned long /* clear */);
0358 /* Returns pointer to start of first invalid token, or NULL if none. */
0359 /* Note that all recognized tokens are processed, regardless. */
0360 __LA_DECL const char *archive_entry_copy_fflags_text(struct archive_entry *,
0361         const char *);
0362 __LA_DECL const char *archive_entry_copy_fflags_text_len(struct archive_entry *,
0363         const char *, size_t);
0364 __LA_DECL const wchar_t *archive_entry_copy_fflags_text_w(struct archive_entry *,
0365         const wchar_t *);
0366 __LA_DECL void  archive_entry_set_gid(struct archive_entry *, la_int64_t);
0367 __LA_DECL void  archive_entry_set_gname(struct archive_entry *, const char *);
0368 __LA_DECL void  archive_entry_set_gname_utf8(struct archive_entry *, const char *);
0369 __LA_DECL void  archive_entry_copy_gname(struct archive_entry *, const char *);
0370 __LA_DECL void  archive_entry_copy_gname_w(struct archive_entry *, const wchar_t *);
0371 __LA_DECL int   archive_entry_update_gname_utf8(struct archive_entry *, const char *);
0372 __LA_DECL void  archive_entry_set_hardlink(struct archive_entry *, const char *);
0373 __LA_DECL void  archive_entry_set_hardlink_utf8(struct archive_entry *, const char *);
0374 __LA_DECL void  archive_entry_copy_hardlink(struct archive_entry *, const char *);
0375 __LA_DECL void  archive_entry_copy_hardlink_w(struct archive_entry *, const wchar_t *);
0376 __LA_DECL int   archive_entry_update_hardlink_utf8(struct archive_entry *, const char *);
0377 __LA_DECL void  archive_entry_set_ino(struct archive_entry *, __LA_INO_T);
0378 __LA_DECL void  archive_entry_set_ino64(struct archive_entry *, __LA_INO_T);
0379 __LA_DECL void  archive_entry_set_link(struct archive_entry *, const char *);
0380 __LA_DECL void  archive_entry_set_link_utf8(struct archive_entry *, const char *);
0381 __LA_DECL void  archive_entry_copy_link(struct archive_entry *, const char *);
0382 __LA_DECL void  archive_entry_copy_link_w(struct archive_entry *, const wchar_t *);
0383 __LA_DECL int   archive_entry_update_link_utf8(struct archive_entry *, const char *);
0384 __LA_DECL void  archive_entry_set_mode(struct archive_entry *, __LA_MODE_T);
0385 __LA_DECL void  archive_entry_set_mtime(struct archive_entry *, __LA_TIME_T, long);
0386 __LA_DECL void  archive_entry_unset_mtime(struct archive_entry *);
0387 __LA_DECL void  archive_entry_set_nlink(struct archive_entry *, unsigned int);
0388 __LA_DECL void  archive_entry_set_pathname(struct archive_entry *, const char *);
0389 __LA_DECL void  archive_entry_set_pathname_utf8(struct archive_entry *, const char *);
0390 __LA_DECL void  archive_entry_copy_pathname(struct archive_entry *, const char *);
0391 __LA_DECL void  archive_entry_copy_pathname_w(struct archive_entry *, const wchar_t *);
0392 __LA_DECL int   archive_entry_update_pathname_utf8(struct archive_entry *, const char *);
0393 __LA_DECL void  archive_entry_set_perm(struct archive_entry *, __LA_MODE_T);
0394 __LA_DECL void  archive_entry_set_rdev(struct archive_entry *, __LA_DEV_T);
0395 __LA_DECL void  archive_entry_set_rdevmajor(struct archive_entry *, __LA_DEV_T);
0396 __LA_DECL void  archive_entry_set_rdevminor(struct archive_entry *, __LA_DEV_T);
0397 __LA_DECL void  archive_entry_set_size(struct archive_entry *, la_int64_t);
0398 __LA_DECL void  archive_entry_unset_size(struct archive_entry *);
0399 __LA_DECL void  archive_entry_copy_sourcepath(struct archive_entry *, const char *);
0400 __LA_DECL void  archive_entry_copy_sourcepath_w(struct archive_entry *, const wchar_t *);
0401 __LA_DECL void  archive_entry_set_symlink(struct archive_entry *, const char *);
0402 __LA_DECL void  archive_entry_set_symlink_type(struct archive_entry *, int);
0403 __LA_DECL void  archive_entry_set_symlink_utf8(struct archive_entry *, const char *);
0404 __LA_DECL void  archive_entry_copy_symlink(struct archive_entry *, const char *);
0405 __LA_DECL void  archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *);
0406 __LA_DECL int   archive_entry_update_symlink_utf8(struct archive_entry *, const char *);
0407 __LA_DECL void  archive_entry_set_uid(struct archive_entry *, la_int64_t);
0408 __LA_DECL void  archive_entry_set_uname(struct archive_entry *, const char *);
0409 __LA_DECL void  archive_entry_set_uname_utf8(struct archive_entry *, const char *);
0410 __LA_DECL void  archive_entry_copy_uname(struct archive_entry *, const char *);
0411 __LA_DECL void  archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *);
0412 __LA_DECL int   archive_entry_update_uname_utf8(struct archive_entry *, const char *);
0413 __LA_DECL void  archive_entry_set_is_data_encrypted(struct archive_entry *, char is_encrypted);
0414 __LA_DECL void  archive_entry_set_is_metadata_encrypted(struct archive_entry *, char is_encrypted);
0415 /*
0416  * Routines to bulk copy fields to/from a platform-native "struct
0417  * stat."  Libarchive used to just store a struct stat inside of each
0418  * archive_entry object, but this created issues when trying to
0419  * manipulate archives on systems different than the ones they were
0420  * created on.
0421  *
0422  * TODO: On Linux and other LFS systems, provide both stat32 and
0423  * stat64 versions of these functions and all of the macro glue so
0424  * that archive_entry_stat is magically defined to
0425  * archive_entry_stat32 or archive_entry_stat64 as appropriate.
0426  */
0427 __LA_DECL const struct stat *archive_entry_stat(struct archive_entry *);
0428 __LA_DECL void  archive_entry_copy_stat(struct archive_entry *, const struct stat *);
0429 
0430 /*
0431  * Storage for Mac OS-specific AppleDouble metadata information.
0432  * Apple-format tar files store a separate binary blob containing
0433  * encoded metadata with ACL, extended attributes, etc.
0434  * This provides a place to store that blob.
0435  */
0436 
0437 __LA_DECL const void * archive_entry_mac_metadata(struct archive_entry *, size_t *);
0438 __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const void *, size_t);
0439 
0440 /*
0441  * Digest routine. This is used to query the raw hex digest for the
0442  * given entry. The type of digest is provided as an argument.
0443  */
0444 #define ARCHIVE_ENTRY_DIGEST_MD5              0x00000001
0445 #define ARCHIVE_ENTRY_DIGEST_RMD160           0x00000002
0446 #define ARCHIVE_ENTRY_DIGEST_SHA1             0x00000003
0447 #define ARCHIVE_ENTRY_DIGEST_SHA256           0x00000004
0448 #define ARCHIVE_ENTRY_DIGEST_SHA384           0x00000005
0449 #define ARCHIVE_ENTRY_DIGEST_SHA512           0x00000006
0450 
0451 __LA_DECL const unsigned char * archive_entry_digest(struct archive_entry *, int /* type */);
0452 __LA_DECL int archive_entry_set_digest(struct archive_entry *, int, const unsigned char *);
0453 
0454 /*
0455  * ACL routines.  This used to simply store and return text-format ACL
0456  * strings, but that proved insufficient for a number of reasons:
0457  *   = clients need control over uname/uid and gname/gid mappings
0458  *   = there are many different ACL text formats
0459  *   = would like to be able to read/convert archives containing ACLs
0460  *     on platforms that lack ACL libraries
0461  *
0462  *  This last point, in particular, forces me to implement a reasonably
0463  *  complete set of ACL support routines.
0464  */
0465 
0466 /*
0467  * Permission bits.
0468  */
0469 #define ARCHIVE_ENTRY_ACL_EXECUTE             0x00000001
0470 #define ARCHIVE_ENTRY_ACL_WRITE               0x00000002
0471 #define ARCHIVE_ENTRY_ACL_READ                0x00000004
0472 #define ARCHIVE_ENTRY_ACL_READ_DATA           0x00000008
0473 #define ARCHIVE_ENTRY_ACL_LIST_DIRECTORY      0x00000008
0474 #define ARCHIVE_ENTRY_ACL_WRITE_DATA          0x00000010
0475 #define ARCHIVE_ENTRY_ACL_ADD_FILE            0x00000010
0476 #define ARCHIVE_ENTRY_ACL_APPEND_DATA         0x00000020
0477 #define ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY    0x00000020
0478 #define ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS    0x00000040
0479 #define ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS   0x00000080
0480 #define ARCHIVE_ENTRY_ACL_DELETE_CHILD        0x00000100
0481 #define ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES     0x00000200
0482 #define ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES    0x00000400
0483 #define ARCHIVE_ENTRY_ACL_DELETE              0x00000800
0484 #define ARCHIVE_ENTRY_ACL_READ_ACL            0x00001000
0485 #define ARCHIVE_ENTRY_ACL_WRITE_ACL           0x00002000
0486 #define ARCHIVE_ENTRY_ACL_WRITE_OWNER         0x00004000
0487 #define ARCHIVE_ENTRY_ACL_SYNCHRONIZE         0x00008000
0488 
0489 #define ARCHIVE_ENTRY_ACL_PERMS_POSIX1E         \
0490     (ARCHIVE_ENTRY_ACL_EXECUTE          \
0491         | ARCHIVE_ENTRY_ACL_WRITE           \
0492         | ARCHIVE_ENTRY_ACL_READ)
0493 
0494 #define ARCHIVE_ENTRY_ACL_PERMS_NFS4            \
0495     (ARCHIVE_ENTRY_ACL_EXECUTE          \
0496         | ARCHIVE_ENTRY_ACL_READ_DATA       \
0497         | ARCHIVE_ENTRY_ACL_LIST_DIRECTORY      \
0498         | ARCHIVE_ENTRY_ACL_WRITE_DATA      \
0499         | ARCHIVE_ENTRY_ACL_ADD_FILE        \
0500         | ARCHIVE_ENTRY_ACL_APPEND_DATA     \
0501         | ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY    \
0502         | ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS    \
0503         | ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS   \
0504         | ARCHIVE_ENTRY_ACL_DELETE_CHILD        \
0505         | ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES     \
0506         | ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES    \
0507         | ARCHIVE_ENTRY_ACL_DELETE          \
0508         | ARCHIVE_ENTRY_ACL_READ_ACL        \
0509         | ARCHIVE_ENTRY_ACL_WRITE_ACL       \
0510         | ARCHIVE_ENTRY_ACL_WRITE_OWNER     \
0511         | ARCHIVE_ENTRY_ACL_SYNCHRONIZE)
0512 
0513 /*
0514  * Inheritance values (NFS4 ACLs only); included in permset.
0515  */
0516 #define ARCHIVE_ENTRY_ACL_ENTRY_INHERITED                   0x01000000
0517 #define ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT                0x02000000
0518 #define ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT           0x04000000
0519 #define ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT        0x08000000
0520 #define ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY                0x10000000
0521 #define ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS           0x20000000
0522 #define ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS               0x40000000
0523 
0524 #define ARCHIVE_ENTRY_ACL_INHERITANCE_NFS4          \
0525     (ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT           \
0526         | ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT     \
0527         | ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT  \
0528         | ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY      \
0529         | ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS     \
0530         | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS     \
0531         | ARCHIVE_ENTRY_ACL_ENTRY_INHERITED)
0532 
0533 /* We need to be able to specify combinations of these. */
0534 #define ARCHIVE_ENTRY_ACL_TYPE_ACCESS   0x00000100  /* POSIX.1e only */
0535 #define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT  0x00000200  /* POSIX.1e only */
0536 #define ARCHIVE_ENTRY_ACL_TYPE_ALLOW    0x00000400 /* NFS4 only */
0537 #define ARCHIVE_ENTRY_ACL_TYPE_DENY 0x00000800 /* NFS4 only */
0538 #define ARCHIVE_ENTRY_ACL_TYPE_AUDIT    0x00001000 /* NFS4 only */
0539 #define ARCHIVE_ENTRY_ACL_TYPE_ALARM    0x00002000 /* NFS4 only */
0540 #define ARCHIVE_ENTRY_ACL_TYPE_POSIX1E  (ARCHIVE_ENTRY_ACL_TYPE_ACCESS \
0541         | ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)
0542 #define ARCHIVE_ENTRY_ACL_TYPE_NFS4 (ARCHIVE_ENTRY_ACL_TYPE_ALLOW \
0543         | ARCHIVE_ENTRY_ACL_TYPE_DENY \
0544         | ARCHIVE_ENTRY_ACL_TYPE_AUDIT \
0545         | ARCHIVE_ENTRY_ACL_TYPE_ALARM)
0546 
0547 /* Tag values mimic POSIX.1e */
0548 #define ARCHIVE_ENTRY_ACL_USER      10001   /* Specified user. */
0549 #define ARCHIVE_ENTRY_ACL_USER_OBJ  10002   /* User who owns the file. */
0550 #define ARCHIVE_ENTRY_ACL_GROUP     10003   /* Specified group. */
0551 #define ARCHIVE_ENTRY_ACL_GROUP_OBJ 10004   /* Group who owns the file. */
0552 #define ARCHIVE_ENTRY_ACL_MASK      10005   /* Modify group access (POSIX.1e only) */
0553 #define ARCHIVE_ENTRY_ACL_OTHER     10006   /* Public (POSIX.1e only) */
0554 #define ARCHIVE_ENTRY_ACL_EVERYONE  10107   /* Everyone (NFS4 only) */
0555 
0556 /*
0557  * Set the ACL by clearing it and adding entries one at a time.
0558  * Unlike the POSIX.1e ACL routines, you must specify the type
0559  * (access/default) for each entry.  Internally, the ACL data is just
0560  * a soup of entries.  API calls here allow you to retrieve just the
0561  * entries of interest.  This design (which goes against the spirit of
0562  * POSIX.1e) is useful for handling archive formats that combine
0563  * default and access information in a single ACL list.
0564  */
0565 __LA_DECL void   archive_entry_acl_clear(struct archive_entry *);
0566 __LA_DECL int    archive_entry_acl_add_entry(struct archive_entry *,
0567         int /* type */, int /* permset */, int /* tag */,
0568         int /* qual */, const char * /* name */);
0569 __LA_DECL int    archive_entry_acl_add_entry_w(struct archive_entry *,
0570         int /* type */, int /* permset */, int /* tag */,
0571         int /* qual */, const wchar_t * /* name */);
0572 
0573 /*
0574  * To retrieve the ACL, first "reset", then repeatedly ask for the
0575  * "next" entry.  The want_type parameter allows you to request only
0576  * certain types of entries.
0577  */
0578 __LA_DECL int    archive_entry_acl_reset(struct archive_entry *, int /* want_type */);
0579 __LA_DECL int    archive_entry_acl_next(struct archive_entry *, int /* want_type */,
0580         int * /* type */, int * /* permset */, int * /* tag */,
0581         int * /* qual */, const char ** /* name */);
0582 
0583 /*
0584  * Construct a text-format ACL.  The flags argument is a bitmask that
0585  * can include any of the following:
0586  *
0587  * Flags only for archive entries with POSIX.1e ACL:
0588  * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - Include POSIX.1e "access" entries.
0589  * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - Include POSIX.1e "default" entries.
0590  * ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT - Include "default:" before each
0591  *    default ACL entry.
0592  * ARCHIVE_ENTRY_ACL_STYLE_SOLARIS - Output only one colon after "other" and
0593  *    "mask" entries.
0594  *
0595  * Flags only for archive entries with NFSv4 ACL:
0596  * ARCHIVE_ENTRY_ACL_STYLE_COMPACT - Do not output the minus character for
0597  *    unset permissions and flags in NFSv4 ACL permission and flag fields
0598  *
0599  * Flags for for archive entries with POSIX.1e ACL or NFSv4 ACL:
0600  * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in
0601  *    each ACL entry.
0602  * ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA - Separate entries with comma
0603  *    instead of newline.
0604  */
0605 #define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID    0x00000001
0606 #define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT    0x00000002
0607 #define ARCHIVE_ENTRY_ACL_STYLE_SOLARIS     0x00000004
0608 #define ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA 0x00000008
0609 #define ARCHIVE_ENTRY_ACL_STYLE_COMPACT     0x00000010
0610 
0611 __LA_DECL wchar_t *archive_entry_acl_to_text_w(struct archive_entry *,
0612         la_ssize_t * /* len */, int /* flags */);
0613 __LA_DECL char *archive_entry_acl_to_text(struct archive_entry *,
0614         la_ssize_t * /* len */, int /* flags */);
0615 __LA_DECL int archive_entry_acl_from_text_w(struct archive_entry *,
0616         const wchar_t * /* wtext */, int /* type */);
0617 __LA_DECL int archive_entry_acl_from_text(struct archive_entry *,
0618         const char * /* text */, int /* type */);
0619 
0620 /* Deprecated constants */
0621 #define OLD_ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID        1024
0622 #define OLD_ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT    2048
0623 
0624 /* Deprecated functions */
0625 __LA_DECL const wchar_t *archive_entry_acl_text_w(struct archive_entry *,
0626             int /* flags */) __LA_DEPRECATED;
0627 __LA_DECL const char *archive_entry_acl_text(struct archive_entry *,
0628             int /* flags */) __LA_DEPRECATED;
0629 
0630 /* Return bitmask of ACL types in an archive entry */
0631 __LA_DECL int    archive_entry_acl_types(struct archive_entry *);
0632 
0633 /* Return a count of entries matching 'want_type' */
0634 __LA_DECL int    archive_entry_acl_count(struct archive_entry *, int /* want_type */);
0635 
0636 /* Return an opaque ACL object. */
0637 /* There's not yet anything clients can actually do with this... */
0638 struct archive_acl;
0639 __LA_DECL struct archive_acl *archive_entry_acl(struct archive_entry *);
0640 
0641 /*
0642  * extended attributes
0643  */
0644 
0645 __LA_DECL void   archive_entry_xattr_clear(struct archive_entry *);
0646 __LA_DECL void   archive_entry_xattr_add_entry(struct archive_entry *,
0647         const char * /* name */, const void * /* value */,
0648         size_t /* size */);
0649 
0650 /*
0651  * To retrieve the xattr list, first "reset", then repeatedly ask for the
0652  * "next" entry.
0653  */
0654 
0655 __LA_DECL int   archive_entry_xattr_count(struct archive_entry *);
0656 __LA_DECL int   archive_entry_xattr_reset(struct archive_entry *);
0657 __LA_DECL int   archive_entry_xattr_next(struct archive_entry *,
0658         const char ** /* name */, const void ** /* value */, size_t *);
0659 
0660 /*
0661  * sparse
0662  */
0663 
0664 __LA_DECL void   archive_entry_sparse_clear(struct archive_entry *);
0665 __LA_DECL void   archive_entry_sparse_add_entry(struct archive_entry *,
0666         la_int64_t /* offset */, la_int64_t /* length */);
0667 
0668 /*
0669  * To retrieve the xattr list, first "reset", then repeatedly ask for the
0670  * "next" entry.
0671  */
0672 
0673 __LA_DECL int   archive_entry_sparse_count(struct archive_entry *);
0674 __LA_DECL int   archive_entry_sparse_reset(struct archive_entry *);
0675 __LA_DECL int   archive_entry_sparse_next(struct archive_entry *,
0676         la_int64_t * /* offset */, la_int64_t * /* length */);
0677 
0678 /*
0679  * Utility to match up hardlinks.
0680  *
0681  * The 'struct archive_entry_linkresolver' is a cache of archive entries
0682  * for files with multiple links.  Here's how to use it:
0683  *   1. Create a lookup object with archive_entry_linkresolver_new()
0684  *   2. Tell it the archive format you're using.
0685  *   3. Hand each archive_entry to archive_entry_linkify().
0686  *      That function will return 0, 1, or 2 entries that should
0687  *      be written.
0688  *   4. Call archive_entry_linkify(resolver, NULL) until
0689  *      no more entries are returned.
0690  *   5. Call archive_entry_linkresolver_free(resolver) to free resources.
0691  *
0692  * The entries returned have their hardlink and size fields updated
0693  * appropriately.  If an entry is passed in that does not refer to
0694  * a file with multiple links, it is returned unchanged.  The intention
0695  * is that you should be able to simply filter all entries through
0696  * this machine.
0697  *
0698  * To make things more efficient, be sure that each entry has a valid
0699  * nlinks value.  The hardlink cache uses this to track when all links
0700  * have been found.  If the nlinks value is zero, it will keep every
0701  * name in the cache indefinitely, which can use a lot of memory.
0702  *
0703  * Note that archive_entry_size() is reset to zero if the file
0704  * body should not be written to the archive.  Pay attention!
0705  */
0706 struct archive_entry_linkresolver;
0707 
0708 /*
0709  * There are three different strategies for marking hardlinks.
0710  * The descriptions below name them after the best-known
0711  * formats that rely on each strategy:
0712  *
0713  * "Old cpio" is the simplest, it always returns any entry unmodified.
0714  *    As far as I know, only cpio formats use this.  Old cpio archives
0715  *    store every link with the full body; the onus is on the dearchiver
0716  *    to detect and properly link the files as they are restored.
0717  * "tar" is also pretty simple; it caches a copy the first time it sees
0718  *    any link.  Subsequent appearances are modified to be hardlink
0719  *    references to the first one without any body.  Used by all tar
0720  *    formats, although the newest tar formats permit the "old cpio" strategy
0721  *    as well.  This strategy is very simple for the dearchiver,
0722  *    and reasonably straightforward for the archiver.
0723  * "new cpio" is trickier.  It stores the body only with the last
0724  *    occurrence.  The complication is that we might not
0725  *    see every link to a particular file in a single session, so
0726  *    there's no easy way to know when we've seen the last occurrence.
0727  *    The solution here is to queue one link until we see the next.
0728  *    At the end of the session, you can enumerate any remaining
0729  *    entries by calling archive_entry_linkify(NULL) and store those
0730  *    bodies.  If you have a file with three links l1, l2, and l3,
0731  *    you'll get the following behavior if you see all three links:
0732  *           linkify(l1) => NULL   (the resolver stores l1 internally)
0733  *           linkify(l2) => l1     (resolver stores l2, you write l1)
0734  *           linkify(l3) => l2, l3 (all links seen, you can write both).
0735  *    If you only see l1 and l2, you'll get this behavior:
0736  *           linkify(l1) => NULL
0737  *           linkify(l2) => l1
0738  *           linkify(NULL) => l2   (at end, you retrieve remaining links)
0739  *    As the name suggests, this strategy is used by newer cpio variants.
0740  *    It's noticeably more complex for the archiver, slightly more complex
0741  *    for the dearchiver than the tar strategy, but makes it straightforward
0742  *    to restore a file using any link by simply continuing to scan until
0743  *    you see a link that is stored with a body.  In contrast, the tar
0744  *    strategy requires you to rescan the archive from the beginning to
0745  *    correctly extract an arbitrary link.
0746  */
0747 
0748 __LA_DECL struct archive_entry_linkresolver *archive_entry_linkresolver_new(void);
0749 __LA_DECL void archive_entry_linkresolver_set_strategy(
0750     struct archive_entry_linkresolver *, int /* format_code */);
0751 __LA_DECL void archive_entry_linkresolver_free(struct archive_entry_linkresolver *);
0752 __LA_DECL void archive_entry_linkify(struct archive_entry_linkresolver *,
0753     struct archive_entry **, struct archive_entry **);
0754 __LA_DECL struct archive_entry *archive_entry_partial_links(
0755     struct archive_entry_linkresolver *res, unsigned int *links);
0756 #ifdef __cplusplus
0757 }
0758 #endif
0759 
0760 /* This is meaningless outside of this header. */
0761 #undef __LA_DECL
0762 
0763 #endif /* !ARCHIVE_ENTRY_H_INCLUDED */