Merge from vendor branch BIND:
[dragonfly.git] / contrib / libarchive-2 / libarchive / archive_entry_private.h
1 /*-
2  * Copyright (c) 2003-2007 Tim Kientzle
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * $FreeBSD: src/lib/libarchive/archive_entry_private.h,v 1.1 2007/05/29 01:00:18 kientzle Exp $
26  */
27
28 #ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
29 #define ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
30
31 /*
32  * Handle wide character (i.e., Unicode) and non-wide character
33  * strings transparently.
34  *
35  */
36
37 struct aes {
38         const char *aes_mbs;
39         char *aes_mbs_alloc;
40         const wchar_t *aes_wcs;
41         wchar_t *aes_wcs_alloc;
42 };
43
44 struct ae_acl {
45         struct ae_acl *next;
46         int     type;                   /* E.g., access or default */
47         int     tag;                    /* E.g., user/group/other/mask */
48         int     permset;                /* r/w/x bits */
49         int     id;                     /* uid/gid for user/group */
50         struct aes name;                /* uname/gname */
51 };
52
53 struct ae_xattr {
54         struct ae_xattr *next;
55
56         char    *name;
57         void    *value;
58         size_t  size;
59 };
60
61 /*
62  * Description of an archive entry.
63  *
64  * Basically, this is a "struct stat" with a few text fields added in.
65  *
66  * TODO: Add "comment", "charset", and possibly other entries
67  * that are supported by "pax interchange" format.  However, GNU, ustar,
68  * cpio, and other variants don't support these features, so they're not an
69  * excruciatingly high priority right now.
70  *
71  * TODO: "pax interchange" format allows essentially arbitrary
72  * key/value attributes to be attached to any entry.  Supporting
73  * such extensions may make this library useful for special
74  * applications (e.g., a package manager could attach special
75  * package-management attributes to each entry).  There are tricky
76  * API issues involved, so this is not going to happen until
77  * there's a real demand for it.
78  *
79  * TODO: Design a good API for handling sparse files.
80  */
81 struct archive_entry {
82         /*
83          * Note that ae_stat.st_mode & AE_IFMT  can be  0!
84          *
85          * This occurs when the actual file type of the object is not
86          * in the archive.  For example, 'tar' archives store
87          * hardlinks without marking the type of the underlying
88          * object.
89          */
90
91         /*
92          * Read archive_entry_copy_stat.c for an explanation of why I
93          * don't just use "struct stat" instead of "struct aest" here
94          * and why I have this odd pointer to a separately-allocated
95          * struct stat.
96          */
97         void *stat;
98         int  stat_valid; /* Set to 0 whenever a field in aest changes. */
99
100         struct aest {
101                 int64_t         aest_atime;
102                 uint32_t        aest_atime_nsec;
103                 int64_t         aest_ctime;
104                 uint32_t        aest_ctime_nsec;
105                 int64_t         aest_mtime;
106                 uint32_t        aest_mtime_nsec;
107                 gid_t           aest_gid;
108                 ino_t           aest_ino;
109                 mode_t          aest_mode;
110                 uint32_t        aest_nlink;
111                 uint64_t        aest_size;
112                 uid_t           aest_uid;
113                 /*
114                  * Because converting between device codes and
115                  * major/minor values is platform-specific and
116                  * inherently a bit risky, we only do that conversion
117                  * lazily.  That way, we will do a better job of
118                  * preserving information in those cases where no
119                  * conversion is actually required.
120                  */
121                 int             aest_dev_is_broken_down;
122                 dev_t           aest_dev;
123                 dev_t           aest_devmajor;
124                 dev_t           aest_devminor;
125                 int             aest_rdev_is_broken_down;
126                 dev_t           aest_rdev;
127                 dev_t           aest_rdevmajor;
128                 dev_t           aest_rdevminor;
129         } ae_stat;
130
131
132
133         /*
134          * Use aes here so that we get transparent mbs<->wcs conversions.
135          */
136         struct aes ae_fflags_text;      /* Text fflags per fflagstostr(3) */
137         unsigned long ae_fflags_set;            /* Bitmap fflags */
138         unsigned long ae_fflags_clear;
139         struct aes ae_gname;            /* Name of owning group */
140         struct aes ae_hardlink; /* Name of target for hardlink */
141         struct aes ae_pathname; /* Name of entry */
142         struct aes ae_symlink;          /* symlink contents */
143         struct aes ae_uname;            /* Name of owner */
144
145         struct ae_acl   *acl_head;
146         struct ae_acl   *acl_p;
147         int              acl_state;     /* See acl_next for details. */
148         wchar_t         *acl_text_w;
149
150         struct ae_xattr *xattr_head;
151         struct ae_xattr *xattr_p;
152 };
153
154
155 #endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */