diff --git a/TIMBER/Analyzer.py b/TIMBER/Analyzer.py index fc47d79..43f3f36 100755 --- a/TIMBER/Analyzer.py +++ b/TIMBER/Analyzer.py @@ -5,7 +5,7 @@ """ from TIMBER.Utilities.CollectionGen import BuildCollectionDict, GetKeyValForBranch, StructDef, StructObj -from TIMBER.Tools.Common import GetHistBinningTuple, CompileCpp, ConcatCols, GetStandardFlags +from TIMBER.Tools.Common import GetHistBinningTuple, CompileCpp, ConcatCols, GetStandardFlags, ExecuteCmd from clang import cindex from collections import OrderedDict @@ -146,7 +146,7 @@ def __init__(self,fileName,eventsTreeName="Events",runTreeName="Runs", createAll continue else: break - self.lhaid = str(int(self.lhaid)-1) if self.lhaid[-1] == 1 else self.lhaid + self.lhaid = str(int(self.lhaid)-1) if self.lhaid[-1] == "1" else self.lhaid print ('LHA ID: '+self.lhaid) self.ActiveNode = self.BaseNode @@ -222,6 +222,27 @@ def Snapshot(self,columns,outfilename,treename,lazy=False,openOption='RECREATE') '''@see Node#Snapshot''' self.ActiveNode.Snapshot(columns,outfilename,treename,lazy,openOption) + def SaveRunChain(self,filename,merge=True): + '''Save the Run tree (chain of all input files) to filename. + If filename already exists, some staging will occur to properly + merge the files via hadd. + + @param filename (str): Output file name. + @param merge (bool, optional): Whether to merge with a file that already exists. Defaults to True. + + Returns: + None + ''' + if (not os.path.exists(filename)) or (not merge): # If it doesn't already exist, nothing special + self.RunChain.Merge(filename) + elif merge: + merge_filename = filename.replace('.root','_temp1.root') + current_filename = filename.replace('.root','_temp2.root') + ExecuteCmd('cp %s %s'%(filename, current_filename)) # copy existing file to _temp2.root + self.RunChain.Merge(merge_filename) # create merged tree as _temp1.root + ExecuteCmd('hadd -f %s %s %s'%(filename,merge_filename,current_filename)) # hadd them together into original filename (force overwrite not the greatest) + ExecuteCmd('rm %s %s'%(merge_filename,current_filename)) # clean up + def Range(self,*argv): '''@see Node#Range''' return self.SetActiveNode(self.ActiveNode.Range(*argv)) @@ -840,6 +861,29 @@ def MakeWeightCols(self,name='',node=None,correctionNames=None,dropList=[]): # self.TrackNode(returnNode) return self.SetActiveNode(returnNode) + def GetWeightName(self,corr,variation,name=""): + '''Return the branch/column name of the requested weight + + @param corr (str,Correction): Either the correction object or the name of the correction. + @param variation (str): "up" or "down". + @param name (str,optional): Name given MakeWeightCols to denote group of weight columns. Defaults to "". + + Raises: + NameError: If weight name does not exist in the columns. + + Returns: + str: Name of the requested weight branch/column. + ''' + if isinstance(corr,Correction): + corrname = corr.name + elif isinstance(corr,str): + corrname = corr + namemod = '' if name == '' else '_'+name + weightname = 'weight%s__%s_%s'%(namemod,corrname,variation) + if weightname not in self.DataFrame.GetColumnNames(): + raise NameError("The weight name `%s` does not exist in the current columns. Are you sure the correction has been made and MakeWeightCols has been called?"%weightname) + return weightname + def MakeTemplateHistos(self,templateHist,variables,node=None): '''Generates the uncertainty template histograms based on the weights created by #MakeWeightCols(). diff --git a/activate_ext.csh b/activate_ext.csh new file mode 100644 index 0000000..fec490c --- /dev/null +++ b/activate_ext.csh @@ -0,0 +1,6 @@ +if (`echo "$PATH" | grep "$TIMBERPATH"` == "") then + setenv PATH ${PATH}:${TIMBERPATH} + echo 'TIMBER added to PATH' +else + echo 'TIMBER already on PATH' +endif diff --git a/docs/archive_8h_source.html b/docs/archive_8h_source.html new file mode 100644 index 0000000..0d3a583 --- /dev/null +++ b/docs/archive_8h_source.html @@ -0,0 +1,87 @@ + + + + + + + +TIMBER: bin/libarchive/include/archive.h Source File + + + + + + + + + + + +
+
+ + + + + + + +
+
TIMBER +  beta +
+
Tree Interface for Making Binned Events with RDataFrame
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
archive.h
+
+
+
1 /*-
2  * Copyright (c) 2003-2010 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.h.in,v 1.50 2008/05/26 17:00:22 kientzle Exp $
26  */
27 
28 #ifndef ARCHIVE_H_INCLUDED
29 #define ARCHIVE_H_INCLUDED
30 
31 /*
32  * The version number is expressed as a single integer that makes it
33  * easy to compare versions at build time: for version a.b.c, the
34  * version number is printf("%d%03d%03d",a,b,c). For example, if you
35  * know your application requires version 2.12.108 or later, you can
36  * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
37  */
38 /* Note: Compiler will complain if this does not match archive_entry.h! */
39 #define ARCHIVE_VERSION_NUMBER 3005002
40 
41 #include <sys/stat.h>
42 #include <stddef.h> /* for wchar_t */
43 #include <stdio.h> /* For FILE * */
44 #include <time.h> /* For time_t */
45 
46 /*
47  * Note: archive.h is for use outside of libarchive; the configuration
48  * headers (config.h, archive_platform.h, etc.) are purely internal.
49  * Do NOT use HAVE_XXX configuration macros to control the behavior of
50  * this header! If you must conditionalize, use predefined compiler and/or
51  * platform macros.
52  */
53 #if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
54 # include <stdint.h>
55 #elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__) && !defined(__CLANG_INTTYPES_H)
56 # include <inttypes.h>
57 #endif
58 
59 /* Get appropriate definitions of 64-bit integer */
60 #if !defined(__LA_INT64_T_DEFINED)
61 /* Older code relied on the __LA_INT64_T macro; after 4.0 we'll switch to the typedef exclusively. */
62 # if ARCHIVE_VERSION_NUMBER < 4000000
63 #define __LA_INT64_T la_int64_t
64 # endif
65 #define __LA_INT64_T_DEFINED
66 # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
67 typedef __int64 la_int64_t;
68 # else
69 # include <unistd.h> /* ssize_t */
70 # if defined(_SCO_DS) || defined(__osf__)
71 typedef long long la_int64_t;
72 # else
73 typedef int64_t la_int64_t;
74 # endif
75 # endif
76 #endif
77 
78 /* The la_ssize_t should match the type used in 'struct stat' */
79 #if !defined(__LA_SSIZE_T_DEFINED)
80 /* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */
81 # if ARCHIVE_VERSION_NUMBER < 4000000
82 #define __LA_SSIZE_T la_ssize_t
83 # endif
84 #define __LA_SSIZE_T_DEFINED
85 # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
86 # if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
87 typedef ssize_t la_ssize_t;
88 # elif defined(_WIN64)
89 typedef __int64 la_ssize_t;
90 # else
91 typedef long la_ssize_t;
92 # endif
93 # else
94 # include <unistd.h> /* ssize_t */
95 typedef ssize_t la_ssize_t;
96 # endif
97 #endif
98 
99 /* Large file support for Android */
100 #ifdef __ANDROID__
101 #include "android_lf.h"
102 #endif
103 
104 /*
105  * On Windows, define LIBARCHIVE_STATIC if you're building or using a
106  * .lib. The default here assumes you're building a DLL. Only
107  * libarchive source should ever define __LIBARCHIVE_BUILD.
108  */
109 #if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
110 # ifdef __LIBARCHIVE_BUILD
111 # ifdef __GNUC__
112 # define __LA_DECL __attribute__((dllexport)) extern
113 # else
114 # define __LA_DECL __declspec(dllexport)
115 # endif
116 # else
117 # ifdef __GNUC__
118 # define __LA_DECL
119 # else
120 # define __LA_DECL __declspec(dllimport)
121 # endif
122 # endif
123 #else
124 /* Static libraries or non-Windows needs no special declaration. */
125 # define __LA_DECL
126 #endif
127 
128 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__MINGW32__)
129 #define __LA_PRINTF(fmtarg, firstvararg) \
130  __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
131 #else
132 #define __LA_PRINTF(fmtarg, firstvararg) /* nothing */
133 #endif
134 
135 #if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1
136 # define __LA_DEPRECATED __attribute__((deprecated))
137 #else
138 # define __LA_DEPRECATED
139 #endif
140 
141 #ifdef __cplusplus
142 extern "C" {
143 #endif
144 
145 /*
146  * The version number is provided as both a macro and a function.
147  * The macro identifies the installed header; the function identifies
148  * the library version (which may not be the same if you're using a
149  * dynamically-linked version of the library). Of course, if the
150  * header and library are very different, you should expect some
151  * strangeness. Don't do that.
152  */
153 __LA_DECL int archive_version_number(void);
154 
155 /*
156  * Textual name/version of the library, useful for version displays.
157  */
158 #define ARCHIVE_VERSION_ONLY_STRING "3.5.2dev"
159 #define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
160 __LA_DECL const char * archive_version_string(void);
161 
162 /*
163  * Detailed textual name/version of the library and its dependencies.
164  * This has the form:
165  * "libarchive x.y.z zlib/a.b.c liblzma/d.e.f ... etc ..."
166  * the list of libraries described here will vary depending on how
167  * libarchive was compiled.
168  */
169 __LA_DECL const char * archive_version_details(void);
170 
171 /*
172  * Returns NULL if libarchive was compiled without the associated library.
173  * Otherwise, returns the version number that libarchive was compiled
174  * against.
175  */
176 __LA_DECL const char * archive_zlib_version(void);
177 __LA_DECL const char * archive_liblzma_version(void);
178 __LA_DECL const char * archive_bzlib_version(void);
179 __LA_DECL const char * archive_liblz4_version(void);
180 __LA_DECL const char * archive_libzstd_version(void);
181 
182 /* Declare our basic types. */
183 struct archive;
184 struct archive_entry;
185 
186 /*
187  * Error codes: Use archive_errno() and archive_error_string()
188  * to retrieve details. Unless specified otherwise, all functions
189  * that return 'int' use these codes.
190  */
191 #define ARCHIVE_EOF 1 /* Found end of archive. */
192 #define ARCHIVE_OK 0 /* Operation was successful. */
193 #define ARCHIVE_RETRY (-10) /* Retry might succeed. */
194 #define ARCHIVE_WARN (-20) /* Partial success. */
195 /* For example, if write_header "fails", then you can't push data. */
196 #define ARCHIVE_FAILED (-25) /* Current operation cannot complete. */
197 /* But if write_header is "fatal," then this archive is dead and useless. */
198 #define ARCHIVE_FATAL (-30) /* No more operations are possible. */
199 
200 /*
201  * As far as possible, archive_errno returns standard platform errno codes.
202  * Of course, the details vary by platform, so the actual definitions
203  * here are stored in "archive_platform.h". The symbols are listed here
204  * for reference; as a rule, clients should not need to know the exact
205  * platform-dependent error code.
206  */
207 /* Unrecognized or invalid file format. */
208 /* #define ARCHIVE_ERRNO_FILE_FORMAT */
209 /* Illegal usage of the library. */
210 /* #define ARCHIVE_ERRNO_PROGRAMMER_ERROR */
211 /* Unknown or unclassified error. */
212 /* #define ARCHIVE_ERRNO_MISC */
213 
214 /*
215  * Callbacks are invoked to automatically read/skip/write/open/close the
216  * archive. You can provide your own for complex tasks (like breaking
217  * archives across multiple tapes) or use standard ones built into the
218  * library.
219  */
220 
221 /* Returns pointer and size of next block of data from archive. */
222 typedef la_ssize_t archive_read_callback(struct archive *,
223  void *_client_data, const void **_buffer);
224 
225 /* Skips at most request bytes from archive and returns the skipped amount.
226  * This may skip fewer bytes than requested; it may even skip zero bytes.
227  * If you do skip fewer bytes than requested, libarchive will invoke your
228  * read callback and discard data as necessary to make up the full skip.
229  */
230 typedef la_int64_t archive_skip_callback(struct archive *,
231  void *_client_data, la_int64_t request);
232 
233 /* Seeks to specified location in the file and returns the position.
234  * Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h.
235  * Return ARCHIVE_FATAL if the seek fails for any reason.
236  */
237 typedef la_int64_t archive_seek_callback(struct archive *,
238  void *_client_data, la_int64_t offset, int whence);
239 
240 /* Returns size actually written, zero on EOF, -1 on error. */
241 typedef la_ssize_t archive_write_callback(struct archive *,
242  void *_client_data,
243  const void *_buffer, size_t _length);
244 
245 typedef int archive_open_callback(struct archive *, void *_client_data);
246 
247 typedef int archive_close_callback(struct archive *, void *_client_data);
248 
249 typedef int archive_free_callback(struct archive *, void *_client_data);
250 
251 /* Switches from one client data object to the next/prev client data object.
252  * This is useful for reading from different data blocks such as a set of files
253  * that make up one large file.
254  */
255 typedef int archive_switch_callback(struct archive *, void *_client_data1,
256  void *_client_data2);
257 
258 /*
259  * Returns a passphrase used for encryption or decryption, NULL on nothing
260  * to do and give it up.
261  */
262 typedef const char *archive_passphrase_callback(struct archive *,
263  void *_client_data);
264 
265 /*
266  * Codes to identify various stream filters.
267  */
268 #define ARCHIVE_FILTER_NONE 0
269 #define ARCHIVE_FILTER_GZIP 1
270 #define ARCHIVE_FILTER_BZIP2 2
271 #define ARCHIVE_FILTER_COMPRESS 3
272 #define ARCHIVE_FILTER_PROGRAM 4
273 #define ARCHIVE_FILTER_LZMA 5
274 #define ARCHIVE_FILTER_XZ 6
275 #define ARCHIVE_FILTER_UU 7
276 #define ARCHIVE_FILTER_RPM 8
277 #define ARCHIVE_FILTER_LZIP 9
278 #define ARCHIVE_FILTER_LRZIP 10
279 #define ARCHIVE_FILTER_LZOP 11
280 #define ARCHIVE_FILTER_GRZIP 12
281 #define ARCHIVE_FILTER_LZ4 13
282 #define ARCHIVE_FILTER_ZSTD 14
283 
284 #if ARCHIVE_VERSION_NUMBER < 4000000
285 #define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE
286 #define ARCHIVE_COMPRESSION_GZIP ARCHIVE_FILTER_GZIP
287 #define ARCHIVE_COMPRESSION_BZIP2 ARCHIVE_FILTER_BZIP2
288 #define ARCHIVE_COMPRESSION_COMPRESS ARCHIVE_FILTER_COMPRESS
289 #define ARCHIVE_COMPRESSION_PROGRAM ARCHIVE_FILTER_PROGRAM
290 #define ARCHIVE_COMPRESSION_LZMA ARCHIVE_FILTER_LZMA
291 #define ARCHIVE_COMPRESSION_XZ ARCHIVE_FILTER_XZ
292 #define ARCHIVE_COMPRESSION_UU ARCHIVE_FILTER_UU
293 #define ARCHIVE_COMPRESSION_RPM ARCHIVE_FILTER_RPM
294 #define ARCHIVE_COMPRESSION_LZIP ARCHIVE_FILTER_LZIP
295 #define ARCHIVE_COMPRESSION_LRZIP ARCHIVE_FILTER_LRZIP
296 #endif
297 
298 /*
299  * Codes returned by archive_format.
300  *
301  * Top 16 bits identifies the format family (e.g., "tar"); lower
302  * 16 bits indicate the variant. This is updated by read_next_header.
303  * Note that the lower 16 bits will often vary from entry to entry.
304  * In some cases, this variation occurs as libarchive learns more about
305  * the archive (for example, later entries might utilize extensions that
306  * weren't necessary earlier in the archive; in this case, libarchive
307  * will change the format code to indicate the extended format that
308  * was used). In other cases, it's because different tools have
309  * modified the archive and so different parts of the archive
310  * actually have slightly different formats. (Both tar and cpio store
311  * format codes in each entry, so it is quite possible for each
312  * entry to be in a different format.)
313  */
314 #define ARCHIVE_FORMAT_BASE_MASK 0xff0000
315 #define ARCHIVE_FORMAT_CPIO 0x10000
316 #define ARCHIVE_FORMAT_CPIO_POSIX (ARCHIVE_FORMAT_CPIO | 1)
317 #define ARCHIVE_FORMAT_CPIO_BIN_LE (ARCHIVE_FORMAT_CPIO | 2)
318 #define ARCHIVE_FORMAT_CPIO_BIN_BE (ARCHIVE_FORMAT_CPIO | 3)
319 #define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4)
320 #define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5)
321 #define ARCHIVE_FORMAT_CPIO_AFIO_LARGE (ARCHIVE_FORMAT_CPIO | 6)
322 #define ARCHIVE_FORMAT_SHAR 0x20000
323 #define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1)
324 #define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2)
325 #define ARCHIVE_FORMAT_TAR 0x30000
326 #define ARCHIVE_FORMAT_TAR_USTAR (ARCHIVE_FORMAT_TAR | 1)
327 #define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE (ARCHIVE_FORMAT_TAR | 2)
328 #define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED (ARCHIVE_FORMAT_TAR | 3)
329 #define ARCHIVE_FORMAT_TAR_GNUTAR (ARCHIVE_FORMAT_TAR | 4)
330 #define ARCHIVE_FORMAT_ISO9660 0x40000
331 #define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE (ARCHIVE_FORMAT_ISO9660 | 1)
332 #define ARCHIVE_FORMAT_ZIP 0x50000
333 #define ARCHIVE_FORMAT_EMPTY 0x60000
334 #define ARCHIVE_FORMAT_AR 0x70000
335 #define ARCHIVE_FORMAT_AR_GNU (ARCHIVE_FORMAT_AR | 1)
336 #define ARCHIVE_FORMAT_AR_BSD (ARCHIVE_FORMAT_AR | 2)
337 #define ARCHIVE_FORMAT_MTREE 0x80000
338 #define ARCHIVE_FORMAT_RAW 0x90000
339 #define ARCHIVE_FORMAT_XAR 0xA0000
340 #define ARCHIVE_FORMAT_LHA 0xB0000
341 #define ARCHIVE_FORMAT_CAB 0xC0000
342 #define ARCHIVE_FORMAT_RAR 0xD0000
343 #define ARCHIVE_FORMAT_7ZIP 0xE0000
344 #define ARCHIVE_FORMAT_WARC 0xF0000
345 #define ARCHIVE_FORMAT_RAR_V5 0x100000
346 
347 /*
348  * Codes returned by archive_read_format_capabilities().
349  *
350  * This list can be extended with values between 0 and 0xffff.
351  * The original purpose of this list was to let different archive
352  * format readers expose their general capabilities in terms of
353  * encryption.
354  */
355 #define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */
356 #define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */
357 #define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */
358 
359 /*
360  * Codes returned by archive_read_has_encrypted_entries().
361  *
362  * In case the archive does not support encryption detection at all
363  * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader
364  * for some other reason (e.g. not enough bytes read) cannot say if
365  * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW
366  * is returned.
367  */
368 #define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2
369 #define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1
370 
371 /*-
372  * Basic outline for reading an archive:
373  * 1) Ask archive_read_new for an archive reader object.
374  * 2) Update any global properties as appropriate.
375  * In particular, you'll certainly want to call appropriate
376  * archive_read_support_XXX functions.
377  * 3) Call archive_read_open_XXX to open the archive
378  * 4) Repeatedly call archive_read_next_header to get information about
379  * successive archive entries. Call archive_read_data to extract
380  * data for entries of interest.
381  * 5) Call archive_read_free to end processing.
382  */
383 __LA_DECL struct archive *archive_read_new(void);
384 
385 /*
386  * The archive_read_support_XXX calls enable auto-detect for this
387  * archive handle. They also link in the necessary support code.
388  * For example, if you don't want bzlib linked in, don't invoke
389  * support_compression_bzip2(). The "all" functions provide the
390  * obvious shorthand.
391  */
392 
393 #if ARCHIVE_VERSION_NUMBER < 4000000
394 __LA_DECL int archive_read_support_compression_all(struct archive *)
395  __LA_DEPRECATED;
396 __LA_DECL int archive_read_support_compression_bzip2(struct archive *)
397  __LA_DEPRECATED;
398 __LA_DECL int archive_read_support_compression_compress(struct archive *)
399  __LA_DEPRECATED;
400 __LA_DECL int archive_read_support_compression_gzip(struct archive *)
401  __LA_DEPRECATED;
402 __LA_DECL int archive_read_support_compression_lzip(struct archive *)
403  __LA_DEPRECATED;
404 __LA_DECL int archive_read_support_compression_lzma(struct archive *)
405  __LA_DEPRECATED;
406 __LA_DECL int archive_read_support_compression_none(struct archive *)
407  __LA_DEPRECATED;
408 __LA_DECL int archive_read_support_compression_program(struct archive *,
409  const char *command) __LA_DEPRECATED;
410 __LA_DECL int archive_read_support_compression_program_signature
411  (struct archive *, const char *,
412  const void * /* match */, size_t) __LA_DEPRECATED;
413 
414 __LA_DECL int archive_read_support_compression_rpm(struct archive *)
415  __LA_DEPRECATED;
416 __LA_DECL int archive_read_support_compression_uu(struct archive *)
417  __LA_DEPRECATED;
418 __LA_DECL int archive_read_support_compression_xz(struct archive *)
419  __LA_DEPRECATED;
420 #endif
421 
422 __LA_DECL int archive_read_support_filter_all(struct archive *);
423 __LA_DECL int archive_read_support_filter_by_code(struct archive *, int);
424 __LA_DECL int archive_read_support_filter_bzip2(struct archive *);
425 __LA_DECL int archive_read_support_filter_compress(struct archive *);
426 __LA_DECL int archive_read_support_filter_gzip(struct archive *);
427 __LA_DECL int archive_read_support_filter_grzip(struct archive *);
428 __LA_DECL int archive_read_support_filter_lrzip(struct archive *);
429 __LA_DECL int archive_read_support_filter_lz4(struct archive *);
430 __LA_DECL int archive_read_support_filter_lzip(struct archive *);
431 __LA_DECL int archive_read_support_filter_lzma(struct archive *);
432 __LA_DECL int archive_read_support_filter_lzop(struct archive *);
433 __LA_DECL int archive_read_support_filter_none(struct archive *);
434 __LA_DECL int archive_read_support_filter_program(struct archive *,
435  const char *command);
436 __LA_DECL int archive_read_support_filter_program_signature
437  (struct archive *, const char * /* cmd */,
438  const void * /* match */, size_t);
439 __LA_DECL int archive_read_support_filter_rpm(struct archive *);
440 __LA_DECL int archive_read_support_filter_uu(struct archive *);
441 __LA_DECL int archive_read_support_filter_xz(struct archive *);
442 __LA_DECL int archive_read_support_filter_zstd(struct archive *);
443 
444 __LA_DECL int archive_read_support_format_7zip(struct archive *);
445 __LA_DECL int archive_read_support_format_all(struct archive *);
446 __LA_DECL int archive_read_support_format_ar(struct archive *);
447 __LA_DECL int archive_read_support_format_by_code(struct archive *, int);
448 __LA_DECL int archive_read_support_format_cab(struct archive *);
449 __LA_DECL int archive_read_support_format_cpio(struct archive *);
450 __LA_DECL int archive_read_support_format_empty(struct archive *);
451 __LA_DECL int archive_read_support_format_gnutar(struct archive *);
452 __LA_DECL int archive_read_support_format_iso9660(struct archive *);
453 __LA_DECL int archive_read_support_format_lha(struct archive *);
454 __LA_DECL int archive_read_support_format_mtree(struct archive *);
455 __LA_DECL int archive_read_support_format_rar(struct archive *);
456 __LA_DECL int archive_read_support_format_rar5(struct archive *);
457 __LA_DECL int archive_read_support_format_raw(struct archive *);
458 __LA_DECL int archive_read_support_format_tar(struct archive *);
459 __LA_DECL int archive_read_support_format_warc(struct archive *);
460 __LA_DECL int archive_read_support_format_xar(struct archive *);
461 /* archive_read_support_format_zip() enables both streamable and seekable
462  * zip readers. */
463 __LA_DECL int archive_read_support_format_zip(struct archive *);
464 /* Reads Zip archives as stream from beginning to end. Doesn't
465  * correctly handle SFX ZIP files or ZIP archives that have been modified
466  * in-place. */
467 __LA_DECL int archive_read_support_format_zip_streamable(struct archive *);
468 /* Reads starting from central directory; requires seekable input. */
469 __LA_DECL int archive_read_support_format_zip_seekable(struct archive *);
470 
471 /* Functions to manually set the format and filters to be used. This is
472  * useful to bypass the bidding process when the format and filters to use
473  * is known in advance.
474  */
475 __LA_DECL int archive_read_set_format(struct archive *, int);
476 __LA_DECL int archive_read_append_filter(struct archive *, int);
477 __LA_DECL int archive_read_append_filter_program(struct archive *,
478  const char *);
479 __LA_DECL int archive_read_append_filter_program_signature
480  (struct archive *, const char *, const void * /* match */, size_t);
481 
482 /* Set various callbacks. */
483 __LA_DECL int archive_read_set_open_callback(struct archive *,
484  archive_open_callback *);
485 __LA_DECL int archive_read_set_read_callback(struct archive *,
486  archive_read_callback *);
487 __LA_DECL int archive_read_set_seek_callback(struct archive *,
488  archive_seek_callback *);
489 __LA_DECL int archive_read_set_skip_callback(struct archive *,
490  archive_skip_callback *);
491 __LA_DECL int archive_read_set_close_callback(struct archive *,
492  archive_close_callback *);
493 /* Callback used to switch between one data object to the next */
494 __LA_DECL int archive_read_set_switch_callback(struct archive *,
495  archive_switch_callback *);
496 
497 /* This sets the first data object. */
498 __LA_DECL int archive_read_set_callback_data(struct archive *, void *);
499 /* This sets data object at specified index */
500 __LA_DECL int archive_read_set_callback_data2(struct archive *, void *,
501  unsigned int);
502 /* This adds a data object at the specified index. */
503 __LA_DECL int archive_read_add_callback_data(struct archive *, void *,
504  unsigned int);
505 /* This appends a data object to the end of list */
506 __LA_DECL int archive_read_append_callback_data(struct archive *, void *);
507 /* This prepends a data object to the beginning of list */
508 __LA_DECL int archive_read_prepend_callback_data(struct archive *, void *);
509 
510 /* Opening freezes the callbacks. */
511 __LA_DECL int archive_read_open1(struct archive *);
512 
513 /* Convenience wrappers around the above. */
514 __LA_DECL int archive_read_open(struct archive *, void *_client_data,
515  archive_open_callback *, archive_read_callback *,
516  archive_close_callback *);
517 __LA_DECL int archive_read_open2(struct archive *, void *_client_data,
518  archive_open_callback *, archive_read_callback *,
519  archive_skip_callback *, archive_close_callback *);
520 
521 /*
522  * A variety of shortcuts that invoke archive_read_open() with
523  * canned callbacks suitable for common situations. The ones that
524  * accept a block size handle tape blocking correctly.
525  */
526 /* Use this if you know the filename. Note: NULL indicates stdin. */
527 __LA_DECL int archive_read_open_filename(struct archive *,
528  const char *_filename, size_t _block_size);
529 /* Use this for reading multivolume files by filenames.
530  * NOTE: Must be NULL terminated. Sorting is NOT done. */
531 __LA_DECL int archive_read_open_filenames(struct archive *,
532  const char **_filenames, size_t _block_size);
533 __LA_DECL int archive_read_open_filename_w(struct archive *,
534  const wchar_t *_filename, size_t _block_size);
535 /* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */
536 __LA_DECL int archive_read_open_file(struct archive *,
537  const char *_filename, size_t _block_size) __LA_DEPRECATED;
538 /* Read an archive that's stored in memory. */
539 __LA_DECL int archive_read_open_memory(struct archive *,
540  const void * buff, size_t size);
541 /* A more involved version that is only used for internal testing. */
542 __LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff,
543  size_t size, size_t read_size);
544 /* Read an archive that's already open, using the file descriptor. */
545 __LA_DECL int archive_read_open_fd(struct archive *, int _fd,
546  size_t _block_size);
547 /* Read an archive that's already open, using a FILE *. */
548 /* Note: DO NOT use this with tape drives. */
549 __LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);
550 
551 /* Parses and returns next entry header. */
552 __LA_DECL int archive_read_next_header(struct archive *,
553  struct archive_entry **);
554 
555 /* Parses and returns next entry header using the archive_entry passed in */
556 __LA_DECL int archive_read_next_header2(struct archive *,
557  struct archive_entry *);
558 
559 /*
560  * Retrieve the byte offset in UNCOMPRESSED data where last-read
561  * header started.
562  */
563 __LA_DECL la_int64_t archive_read_header_position(struct archive *);
564 
565 /*
566  * Returns 1 if the archive contains at least one encrypted entry.
567  * If the archive format not support encryption at all
568  * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
569  * If for any other reason (e.g. not enough data read so far)
570  * we cannot say whether there are encrypted entries, then
571  * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
572  * In general, this function will return values below zero when the
573  * reader is uncertain or totally incapable of encryption support.
574  * When this function returns 0 you can be sure that the reader
575  * supports encryption detection but no encrypted entries have
576  * been found yet.
577  *
578  * NOTE: If the metadata/header of an archive is also encrypted, you
579  * cannot rely on the number of encrypted entries. That is why this
580  * function does not return the number of encrypted entries but#
581  * just shows that there are some.
582  */
583 __LA_DECL int archive_read_has_encrypted_entries(struct archive *);
584 
585 /*
586  * Returns a bitmask of capabilities that are supported by the archive format reader.
587  * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
588  */
589 __LA_DECL int archive_read_format_capabilities(struct archive *);
590 
591 /* Read data from the body of an entry. Similar to read(2). */
592 __LA_DECL la_ssize_t archive_read_data(struct archive *,
593  void *, size_t);
594 
595 /* Seek within the body of an entry. Similar to lseek(2). */
596 __LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int);
597 
598 /*
599  * A zero-copy version of archive_read_data that also exposes the file offset
600  * of each returned block. Note that the client has no way to specify
601  * the desired size of the block. The API does guarantee that offsets will
602  * be strictly increasing and that returned blocks will not overlap.
603  */
604 __LA_DECL int archive_read_data_block(struct archive *a,
605  const void **buff, size_t *size, la_int64_t *offset);
606 
607 /*-
608  * Some convenience functions that are built on archive_read_data:
609  * 'skip': skips entire entry
610  * 'into_buffer': writes data into memory buffer that you provide
611  * 'into_fd': writes data to specified filedes
612  */
613 __LA_DECL int archive_read_data_skip(struct archive *);
614 __LA_DECL int archive_read_data_into_fd(struct archive *, int fd);
615 
616 /*
617  * Set read options.
618  */
619 /* Apply option to the format only. */
620 __LA_DECL int archive_read_set_format_option(struct archive *_a,
621  const char *m, const char *o,
622  const char *v);
623 /* Apply option to the filter only. */
624 __LA_DECL int archive_read_set_filter_option(struct archive *_a,
625  const char *m, const char *o,
626  const char *v);
627 /* Apply option to both the format and the filter. */
628 __LA_DECL int archive_read_set_option(struct archive *_a,
629  const char *m, const char *o,
630  const char *v);
631 /* Apply option string to both the format and the filter. */
632 __LA_DECL int archive_read_set_options(struct archive *_a,
633  const char *opts);
634 
635 /*
636  * Add a decryption passphrase.
637  */
638 __LA_DECL int archive_read_add_passphrase(struct archive *, const char *);
639 __LA_DECL int archive_read_set_passphrase_callback(struct archive *,
640  void *client_data, archive_passphrase_callback *);
641 
642 
643 /*-
644  * Convenience function to recreate the current entry (whose header
645  * has just been read) on disk.
646  *
647  * This does quite a bit more than just copy data to disk. It also:
648  * - Creates intermediate directories as required.
649  * - Manages directory permissions: non-writable directories will
650  * be initially created with write permission enabled; when the
651  * archive is closed, dir permissions are edited to the values specified
652  * in the archive.
653  * - Checks hardlinks: hardlinks will not be extracted unless the
654  * linked-to file was also extracted within the same session. (TODO)
655  */
656 
657 /* The "flags" argument selects optional behavior, 'OR' the flags you want. */
658 
659 /* Default: Do not try to set owner/group. */
660 #define ARCHIVE_EXTRACT_OWNER (0x0001)
661 /* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */
662 #define ARCHIVE_EXTRACT_PERM (0x0002)
663 /* Default: Do not restore mtime/atime. */
664 #define ARCHIVE_EXTRACT_TIME (0x0004)
665 /* Default: Replace existing files. */
666 #define ARCHIVE_EXTRACT_NO_OVERWRITE (0x0008)
667 /* Default: Try create first, unlink only if create fails with EEXIST. */
668 #define ARCHIVE_EXTRACT_UNLINK (0x0010)
669 /* Default: Do not restore ACLs. */
670 #define ARCHIVE_EXTRACT_ACL (0x0020)
671 /* Default: Do not restore fflags. */
672 #define ARCHIVE_EXTRACT_FFLAGS (0x0040)
673 /* Default: Do not restore xattrs. */
674 #define ARCHIVE_EXTRACT_XATTR (0x0080)
675 /* Default: Do not try to guard against extracts redirected by symlinks. */
676 /* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */
677 #define ARCHIVE_EXTRACT_SECURE_SYMLINKS (0x0100)
678 /* Default: Do not reject entries with '..' as path elements. */
679 #define ARCHIVE_EXTRACT_SECURE_NODOTDOT (0x0200)
680 /* Default: Create parent directories as needed. */
681 #define ARCHIVE_EXTRACT_NO_AUTODIR (0x0400)
682 /* Default: Overwrite files, even if one on disk is newer. */
683 #define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (0x0800)
684 /* Detect blocks of 0 and write holes instead. */
685 #define ARCHIVE_EXTRACT_SPARSE (0x1000)
686 /* Default: Do not restore Mac extended metadata. */
687 /* This has no effect except on Mac OS. */
688 #define ARCHIVE_EXTRACT_MAC_METADATA (0x2000)
689 /* Default: Use HFS+ compression if it was compressed. */
690 /* This has no effect except on Mac OS v10.6 or later. */
691 #define ARCHIVE_EXTRACT_NO_HFS_COMPRESSION (0x4000)
692 /* Default: Do not use HFS+ compression if it was not compressed. */
693 /* This has no effect except on Mac OS v10.6 or later. */
694 #define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000)
695 /* Default: Do not reject entries with absolute paths */
696 #define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000)
697 /* Default: Do not clear no-change flags when unlinking object */
698 #define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS (0x20000)
699 /* Default: Do not extract atomically (using rename) */
700 #define ARCHIVE_EXTRACT_SAFE_WRITES (0x40000)
701 
702 __LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
703  int flags);
704 __LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
705  struct archive * /* dest */);
706 __LA_DECL void archive_read_extract_set_progress_callback(struct archive *,
707  void (*_progress_func)(void *), void *_user_data);
708 
709 /* Record the dev/ino of a file that will not be written. This is
710  * generally set to the dev/ino of the archive being read. */
711 __LA_DECL void archive_read_extract_set_skip_file(struct archive *,
712  la_int64_t, la_int64_t);
713 
714 /* Close the file and release most resources. */
715 __LA_DECL int archive_read_close(struct archive *);
716 /* Release all resources and destroy the object. */
717 /* Note that archive_read_free will call archive_read_close for you. */
718 __LA_DECL int archive_read_free(struct archive *);
719 #if ARCHIVE_VERSION_NUMBER < 4000000
720 /* Synonym for archive_read_free() for backwards compatibility. */
721 __LA_DECL int archive_read_finish(struct archive *) __LA_DEPRECATED;
722 #endif
723 
724 /*-
725  * To create an archive:
726  * 1) Ask archive_write_new for an archive writer object.
727  * 2) Set any global properties. In particular, you should set
728  * the compression and format to use.
729  * 3) Call archive_write_open to open the file (most people
730  * will use archive_write_open_file or archive_write_open_fd,
731  * which provide convenient canned I/O callbacks for you).
732  * 4) For each entry:
733  * - construct an appropriate struct archive_entry structure
734  * - archive_write_header to write the header
735  * - archive_write_data to write the entry data
736  * 5) archive_write_close to close the output
737  * 6) archive_write_free to cleanup the writer and release resources
738  */
739 __LA_DECL struct archive *archive_write_new(void);
740 __LA_DECL int archive_write_set_bytes_per_block(struct archive *,
741  int bytes_per_block);
742 __LA_DECL int archive_write_get_bytes_per_block(struct archive *);
743 /* XXX This is badly misnamed; suggestions appreciated. XXX */
744 __LA_DECL int archive_write_set_bytes_in_last_block(struct archive *,
745  int bytes_in_last_block);
746 __LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);
747 
748 /* The dev/ino of a file that won't be archived. This is used
749  * to avoid recursively adding an archive to itself. */
750 __LA_DECL int archive_write_set_skip_file(struct archive *,
751  la_int64_t, la_int64_t);
752 
753 #if ARCHIVE_VERSION_NUMBER < 4000000
754 __LA_DECL int archive_write_set_compression_bzip2(struct archive *)
755  __LA_DEPRECATED;
756 __LA_DECL int archive_write_set_compression_compress(struct archive *)
757  __LA_DEPRECATED;
758 __LA_DECL int archive_write_set_compression_gzip(struct archive *)
759  __LA_DEPRECATED;
760 __LA_DECL int archive_write_set_compression_lzip(struct archive *)
761  __LA_DEPRECATED;
762 __LA_DECL int archive_write_set_compression_lzma(struct archive *)
763  __LA_DEPRECATED;
764 __LA_DECL int archive_write_set_compression_none(struct archive *)
765  __LA_DEPRECATED;
766 __LA_DECL int archive_write_set_compression_program(struct archive *,
767  const char *cmd) __LA_DEPRECATED;
768 __LA_DECL int archive_write_set_compression_xz(struct archive *)
769  __LA_DEPRECATED;
770 #endif
771 
772 /* A convenience function to set the filter based on the code. */
773 __LA_DECL int archive_write_add_filter(struct archive *, int filter_code);
774 __LA_DECL int archive_write_add_filter_by_name(struct archive *,
775  const char *name);
776 __LA_DECL int archive_write_add_filter_b64encode(struct archive *);
777 __LA_DECL int archive_write_add_filter_bzip2(struct archive *);
778 __LA_DECL int archive_write_add_filter_compress(struct archive *);
779 __LA_DECL int archive_write_add_filter_grzip(struct archive *);
780 __LA_DECL int archive_write_add_filter_gzip(struct archive *);
781 __LA_DECL int archive_write_add_filter_lrzip(struct archive *);
782 __LA_DECL int archive_write_add_filter_lz4(struct archive *);
783 __LA_DECL int archive_write_add_filter_lzip(struct archive *);
784 __LA_DECL int archive_write_add_filter_lzma(struct archive *);
785 __LA_DECL int archive_write_add_filter_lzop(struct archive *);
786 __LA_DECL int archive_write_add_filter_none(struct archive *);
787 __LA_DECL int archive_write_add_filter_program(struct archive *,
788  const char *cmd);
789 __LA_DECL int archive_write_add_filter_uuencode(struct archive *);
790 __LA_DECL int archive_write_add_filter_xz(struct archive *);
791 __LA_DECL int archive_write_add_filter_zstd(struct archive *);
792 
793 
794 /* A convenience function to set the format based on the code or name. */
795 __LA_DECL int archive_write_set_format(struct archive *, int format_code);
796 __LA_DECL int archive_write_set_format_by_name(struct archive *,
797  const char *name);
798 /* To minimize link pollution, use one or more of the following. */
799 __LA_DECL int archive_write_set_format_7zip(struct archive *);
800 __LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
801 __LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
802 __LA_DECL int archive_write_set_format_cpio(struct archive *);
803 __LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
804 __LA_DECL int archive_write_set_format_gnutar(struct archive *);
805 __LA_DECL int archive_write_set_format_iso9660(struct archive *);
806 __LA_DECL int archive_write_set_format_mtree(struct archive *);
807 __LA_DECL int archive_write_set_format_mtree_classic(struct archive *);
808 /* TODO: int archive_write_set_format_old_tar(struct archive *); */
809 __LA_DECL int archive_write_set_format_pax(struct archive *);
810 __LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
811 __LA_DECL int archive_write_set_format_raw(struct archive *);
812 __LA_DECL int archive_write_set_format_shar(struct archive *);
813 __LA_DECL int archive_write_set_format_shar_dump(struct archive *);
814 __LA_DECL int archive_write_set_format_ustar(struct archive *);
815 __LA_DECL int archive_write_set_format_v7tar(struct archive *);
816 __LA_DECL int archive_write_set_format_warc(struct archive *);
817 __LA_DECL int archive_write_set_format_xar(struct archive *);
818 __LA_DECL int archive_write_set_format_zip(struct archive *);
819 __LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename);
820 __LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
821 __LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
822 __LA_DECL int archive_write_zip_set_compression_store(struct archive *);
823 /* Deprecated; use archive_write_open2 instead */
824 __LA_DECL int archive_write_open(struct archive *, void *,
825  archive_open_callback *, archive_write_callback *,
826  archive_close_callback *);
827 __LA_DECL int archive_write_open2(struct archive *, void *,
828  archive_open_callback *, archive_write_callback *,
829  archive_close_callback *, archive_free_callback *);
830 __LA_DECL int archive_write_open_fd(struct archive *, int _fd);
831 __LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
832 __LA_DECL int archive_write_open_filename_w(struct archive *,
833  const wchar_t *_file);
834 /* A deprecated synonym for archive_write_open_filename() */
835 __LA_DECL int archive_write_open_file(struct archive *, const char *_file)
836  __LA_DEPRECATED;
837 __LA_DECL int archive_write_open_FILE(struct archive *, FILE *);
838 /* _buffSize is the size of the buffer, _used refers to a variable that
839  * will be updated after each write into the buffer. */
840 __LA_DECL int archive_write_open_memory(struct archive *,
841  void *_buffer, size_t _buffSize, size_t *_used);
842 
843 /*
844  * Note that the library will truncate writes beyond the size provided
845  * to archive_write_header or pad if the provided data is short.
846  */
847 __LA_DECL int archive_write_header(struct archive *,
848  struct archive_entry *);
849 __LA_DECL la_ssize_t archive_write_data(struct archive *,
850  const void *, size_t);
851 
852 /* This interface is currently only available for archive_write_disk handles. */
853 __LA_DECL la_ssize_t archive_write_data_block(struct archive *,
854  const void *, size_t, la_int64_t);
855 
856 __LA_DECL int archive_write_finish_entry(struct archive *);
857 __LA_DECL int archive_write_close(struct archive *);
858 /* Marks the archive as FATAL so that a subsequent free() operation
859  * won't try to close() cleanly. Provides a fast abort capability
860  * when the client discovers that things have gone wrong. */
861 __LA_DECL int archive_write_fail(struct archive *);
862 /* This can fail if the archive wasn't already closed, in which case
863  * archive_write_free() will implicitly call archive_write_close(). */
864 __LA_DECL int archive_write_free(struct archive *);
865 #if ARCHIVE_VERSION_NUMBER < 4000000
866 /* Synonym for archive_write_free() for backwards compatibility. */
867 __LA_DECL int archive_write_finish(struct archive *) __LA_DEPRECATED;
868 #endif
869 
870 /*
871  * Set write options.
872  */
873 /* Apply option to the format only. */
874 __LA_DECL int archive_write_set_format_option(struct archive *_a,
875  const char *m, const char *o,
876  const char *v);
877 /* Apply option to the filter only. */
878 __LA_DECL int archive_write_set_filter_option(struct archive *_a,
879  const char *m, const char *o,
880  const char *v);
881 /* Apply option to both the format and the filter. */
882 __LA_DECL int archive_write_set_option(struct archive *_a,
883  const char *m, const char *o,
884  const char *v);
885 /* Apply option string to both the format and the filter. */
886 __LA_DECL int archive_write_set_options(struct archive *_a,
887  const char *opts);
888 
889 /*
890  * Set a encryption passphrase.
891  */
892 __LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p);
893 __LA_DECL int archive_write_set_passphrase_callback(struct archive *,
894  void *client_data, archive_passphrase_callback *);
895 
896 /*-
897  * ARCHIVE_WRITE_DISK API
898  *
899  * To create objects on disk:
900  * 1) Ask archive_write_disk_new for a new archive_write_disk object.
901  * 2) Set any global properties. In particular, you probably
902  * want to set the options.
903  * 3) For each entry:
904  * - construct an appropriate struct archive_entry structure
905  * - archive_write_header to create the file/dir/etc on disk
906  * - archive_write_data to write the entry data
907  * 4) archive_write_free to cleanup the writer and release resources
908  *
909  * In particular, you can use this in conjunction with archive_read()
910  * to pull entries out of an archive and create them on disk.
911  */
912 __LA_DECL struct archive *archive_write_disk_new(void);
913 /* This file will not be overwritten. */
914 __LA_DECL int archive_write_disk_set_skip_file(struct archive *,
915  la_int64_t, la_int64_t);
916 /* Set flags to control how the next item gets created.
917  * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
918 __LA_DECL int archive_write_disk_set_options(struct archive *,
919  int flags);
920 /*
921  * The lookup functions are given uname/uid (or gname/gid) pairs and
922  * return a uid (gid) suitable for this system. These are used for
923  * restoring ownership and for setting ACLs. The default functions
924  * are naive, they just return the uid/gid. These are small, so reasonable
925  * for applications that don't need to preserve ownership; they
926  * are probably also appropriate for applications that are doing
927  * same-system backup and restore.
928  */
929 /*
930  * The "standard" lookup functions use common system calls to lookup
931  * the uname/gname, falling back to the uid/gid if the names can't be
932  * found. They cache lookups and are reasonably fast, but can be very
933  * large, so they are not used unless you ask for them. In
934  * particular, these match the specifications of POSIX "pax" and old
935  * POSIX "tar".
936  */
937 __LA_DECL int archive_write_disk_set_standard_lookup(struct archive *);
938 /*
939  * If neither the default (naive) nor the standard (big) functions suit
940  * your needs, you can write your own and register them. Be sure to
941  * include a cleanup function if you have allocated private data.
942  */
943 __LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
944  void * /* private_data */,
945  la_int64_t (*)(void *, const char *, la_int64_t),
946  void (* /* cleanup */)(void *));
947 __LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
948  void * /* private_data */,
949  la_int64_t (*)(void *, const char *, la_int64_t),
950  void (* /* cleanup */)(void *));
951 __LA_DECL la_int64_t archive_write_disk_gid(struct archive *, const char *, la_int64_t);
952 __LA_DECL la_int64_t archive_write_disk_uid(struct archive *, const char *, la_int64_t);
953 
954 /*
955  * ARCHIVE_READ_DISK API
956  *
957  * This is still evolving and somewhat experimental.
958  */
959 __LA_DECL struct archive *archive_read_disk_new(void);
960 /* The names for symlink modes here correspond to an old BSD
961  * command-line argument convention: -L, -P, -H */
962 /* Follow all symlinks. */
963 __LA_DECL int archive_read_disk_set_symlink_logical(struct archive *);
964 /* Follow no symlinks. */
965 __LA_DECL int archive_read_disk_set_symlink_physical(struct archive *);
966 /* Follow symlink initially, then not. */
967 __LA_DECL int archive_read_disk_set_symlink_hybrid(struct archive *);
968 /* TODO: Handle Linux stat32/stat64 ugliness. <sigh> */
969 __LA_DECL int archive_read_disk_entry_from_file(struct archive *,
970  struct archive_entry *, int /* fd */, const struct stat *);
971 /* Look up gname for gid or uname for uid. */
972 /* Default implementations are very, very stupid. */
973 __LA_DECL const char *archive_read_disk_gname(struct archive *, la_int64_t);
974 __LA_DECL const char *archive_read_disk_uname(struct archive *, la_int64_t);
975 /* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the
976  * results for performance. */
977 __LA_DECL int archive_read_disk_set_standard_lookup(struct archive *);
978 /* You can install your own lookups if you like. */
979 __LA_DECL int archive_read_disk_set_gname_lookup(struct archive *,
980  void * /* private_data */,
981  const char *(* /* lookup_fn */)(void *, la_int64_t),
982  void (* /* cleanup_fn */)(void *));
983 __LA_DECL int archive_read_disk_set_uname_lookup(struct archive *,
984  void * /* private_data */,
985  const char *(* /* lookup_fn */)(void *, la_int64_t),
986  void (* /* cleanup_fn */)(void *));
987 /* Start traversal. */
988 __LA_DECL int archive_read_disk_open(struct archive *, const char *);
989 __LA_DECL int archive_read_disk_open_w(struct archive *, const wchar_t *);
990 /*
991  * Request that current entry be visited. If you invoke it on every
992  * directory, you'll get a physical traversal. This is ignored if the
993  * current entry isn't a directory or a link to a directory. So, if
994  * you invoke this on every returned path, you'll get a full logical
995  * traversal.
996  */
997 __LA_DECL int archive_read_disk_descend(struct archive *);
998 __LA_DECL int archive_read_disk_can_descend(struct archive *);
999 __LA_DECL int archive_read_disk_current_filesystem(struct archive *);
1000 __LA_DECL int archive_read_disk_current_filesystem_is_synthetic(struct archive *);
1001 __LA_DECL int archive_read_disk_current_filesystem_is_remote(struct archive *);
1002 /* Request that the access time of the entry visited by traversal be restored. */
1003 __LA_DECL int archive_read_disk_set_atime_restored(struct archive *);
1004 /*
1005  * Set behavior. The "flags" argument selects optional behavior.
1006  */
1007 /* Request that the access time of the entry visited by traversal be restored.
1008  * This is the same as archive_read_disk_set_atime_restored. */
1009 #define ARCHIVE_READDISK_RESTORE_ATIME (0x0001)
1010 /* Default: Do not skip an entry which has nodump flags. */
1011 #define ARCHIVE_READDISK_HONOR_NODUMP (0x0002)
1012 /* Default: Skip a mac resource fork file whose prefix is "._" because of
1013  * using copyfile. */
1014 #define ARCHIVE_READDISK_MAC_COPYFILE (0x0004)
1015 /* Default: Traverse mount points. */
1016 #define ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS (0x0008)
1017 /* Default: Xattrs are read from disk. */
1018 #define ARCHIVE_READDISK_NO_XATTR (0x0010)
1019 /* Default: ACLs are read from disk. */
1020 #define ARCHIVE_READDISK_NO_ACL (0x0020)
1021 /* Default: File flags are read from disk. */
1022 #define ARCHIVE_READDISK_NO_FFLAGS (0x0040)
1023 
1024 __LA_DECL int archive_read_disk_set_behavior(struct archive *,
1025  int flags);
1026 
1027 /*
1028  * Set archive_match object that will be used in archive_read_disk to
1029  * know whether an entry should be skipped. The callback function
1030  * _excluded_func will be invoked when an entry is skipped by the result
1031  * of archive_match.
1032  */
1033 __LA_DECL int archive_read_disk_set_matching(struct archive *,
1034  struct archive *_matching, void (*_excluded_func)
1035  (struct archive *, void *, struct archive_entry *),
1036  void *_client_data);
1037 __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *,
1038  int (*_metadata_filter_func)(struct archive *, void *,
1039  struct archive_entry *), void *_client_data);
1040 
1041 /* Simplified cleanup interface;
1042  * This calls archive_read_free() or archive_write_free() as needed. */
1043 __LA_DECL int archive_free(struct archive *);
1044 
1045 /*
1046  * Accessor functions to read/set various information in
1047  * the struct archive object:
1048  */
1049 
1050 /* Number of filters in the current filter pipeline. */
1051 /* Filter #0 is the one closest to the format, -1 is a synonym for the
1052  * last filter, which is always the pseudo-filter that wraps the
1053  * client callbacks. */
1054 __LA_DECL int archive_filter_count(struct archive *);
1055 __LA_DECL la_int64_t archive_filter_bytes(struct archive *, int);
1056 __LA_DECL int archive_filter_code(struct archive *, int);
1057 __LA_DECL const char * archive_filter_name(struct archive *, int);
1058 
1059 #if ARCHIVE_VERSION_NUMBER < 4000000
1060 /* These don't properly handle multiple filters, so are deprecated and
1061  * will eventually be removed. */
1062 /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */
1063 __LA_DECL la_int64_t archive_position_compressed(struct archive *)
1064  __LA_DEPRECATED;
1065 /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */
1066 __LA_DECL la_int64_t archive_position_uncompressed(struct archive *)
1067  __LA_DEPRECATED;
1068 /* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */
1069 __LA_DECL const char *archive_compression_name(struct archive *)
1070  __LA_DEPRECATED;
1071 /* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */
1072 __LA_DECL int archive_compression(struct archive *)
1073  __LA_DEPRECATED;
1074 #endif
1075 
1076 __LA_DECL int archive_errno(struct archive *);
1077 __LA_DECL const char *archive_error_string(struct archive *);
1078 __LA_DECL const char *archive_format_name(struct archive *);
1079 __LA_DECL int archive_format(struct archive *);
1080 __LA_DECL void archive_clear_error(struct archive *);
1081 __LA_DECL void archive_set_error(struct archive *, int _err,
1082  const char *fmt, ...) __LA_PRINTF(3, 4);
1083 __LA_DECL void archive_copy_error(struct archive *dest,
1084  struct archive *src);
1085 __LA_DECL int archive_file_count(struct archive *);
1086 
1087 /*
1088  * ARCHIVE_MATCH API
1089  */
1090 __LA_DECL struct archive *archive_match_new(void);
1091 __LA_DECL int archive_match_free(struct archive *);
1092 
1093 /*
1094  * Test if archive_entry is excluded.
1095  * This is a convenience function. This is the same as calling all
1096  * archive_match_path_excluded, archive_match_time_excluded
1097  * and archive_match_owner_excluded.
1098  */
1099 __LA_DECL int archive_match_excluded(struct archive *,
1100  struct archive_entry *);
1101 
1102 /*
1103  * Test if pathname is excluded. The conditions are set by following functions.
1104  */
1105 __LA_DECL int archive_match_path_excluded(struct archive *,
1106  struct archive_entry *);
1107 /* Control recursive inclusion of directory content when directory is included. Default on. */
1108 __LA_DECL int archive_match_set_inclusion_recursion(struct archive *, int);
1109 /* Add exclusion pathname pattern. */
1110 __LA_DECL int archive_match_exclude_pattern(struct archive *, const char *);
1111 __LA_DECL int archive_match_exclude_pattern_w(struct archive *,
1112  const wchar_t *);
1113 /* Add exclusion pathname pattern from file. */
1114 __LA_DECL int archive_match_exclude_pattern_from_file(struct archive *,
1115  const char *, int _nullSeparator);
1116 __LA_DECL int archive_match_exclude_pattern_from_file_w(struct archive *,
1117  const wchar_t *, int _nullSeparator);
1118 /* Add inclusion pathname pattern. */
1119 __LA_DECL int archive_match_include_pattern(struct archive *, const char *);
1120 __LA_DECL int archive_match_include_pattern_w(struct archive *,
1121  const wchar_t *);
1122 /* Add inclusion pathname pattern from file. */
1123 __LA_DECL int archive_match_include_pattern_from_file(struct archive *,
1124  const char *, int _nullSeparator);
1125 __LA_DECL int archive_match_include_pattern_from_file_w(struct archive *,
1126  const wchar_t *, int _nullSeparator);
1127 /*
1128  * How to get statistic information for inclusion patterns.
1129  */
1130 /* Return the amount number of unmatched inclusion patterns. */
1131 __LA_DECL int archive_match_path_unmatched_inclusions(struct archive *);
1132 /* Return the pattern of unmatched inclusion with ARCHIVE_OK.
1133  * Return ARCHIVE_EOF if there is no inclusion pattern. */
1134 __LA_DECL int archive_match_path_unmatched_inclusions_next(
1135  struct archive *, const char **);
1136 __LA_DECL int archive_match_path_unmatched_inclusions_next_w(
1137  struct archive *, const wchar_t **);
1138 
1139 /*
1140  * Test if a file is excluded by its time stamp.
1141  * The conditions are set by following functions.
1142  */
1143 __LA_DECL int archive_match_time_excluded(struct archive *,
1144  struct archive_entry *);
1145 
1146 /*
1147  * Flags to tell a matching type of time stamps. These are used for
1148  * following functions.
1149  */
1150 /* Time flag: mtime to be tested. */
1151 #define ARCHIVE_MATCH_MTIME (0x0100)
1152 /* Time flag: ctime to be tested. */
1153 #define ARCHIVE_MATCH_CTIME (0x0200)
1154 /* Comparison flag: Match the time if it is newer than. */
1155 #define ARCHIVE_MATCH_NEWER (0x0001)
1156 /* Comparison flag: Match the time if it is older than. */
1157 #define ARCHIVE_MATCH_OLDER (0x0002)
1158 /* Comparison flag: Match the time if it is equal to. */
1159 #define ARCHIVE_MATCH_EQUAL (0x0010)
1160 /* Set inclusion time. */
1161 __LA_DECL int archive_match_include_time(struct archive *, int _flag,
1162  time_t _sec, long _nsec);
1163 /* Set inclusion time by a date string. */
1164 __LA_DECL int archive_match_include_date(struct archive *, int _flag,
1165  const char *_datestr);
1166 __LA_DECL int archive_match_include_date_w(struct archive *, int _flag,
1167  const wchar_t *_datestr);
1168 /* Set inclusion time by a particular file. */
1169 __LA_DECL int archive_match_include_file_time(struct archive *,
1170  int _flag, const char *_pathname);
1171 __LA_DECL int archive_match_include_file_time_w(struct archive *,
1172  int _flag, const wchar_t *_pathname);
1173 /* Add exclusion entry. */
1174 __LA_DECL int archive_match_exclude_entry(struct archive *,
1175  int _flag, struct archive_entry *);
1176 
1177 /*
1178  * Test if a file is excluded by its uid ,gid, uname or gname.
1179  * The conditions are set by following functions.
1180  */
1181 __LA_DECL int archive_match_owner_excluded(struct archive *,
1182  struct archive_entry *);
1183 /* Add inclusion uid, gid, uname and gname. */
1184 __LA_DECL int archive_match_include_uid(struct archive *, la_int64_t);
1185 __LA_DECL int archive_match_include_gid(struct archive *, la_int64_t);
1186 __LA_DECL int archive_match_include_uname(struct archive *, const char *);
1187 __LA_DECL int archive_match_include_uname_w(struct archive *,
1188  const wchar_t *);
1189 __LA_DECL int archive_match_include_gname(struct archive *, const char *);
1190 __LA_DECL int archive_match_include_gname_w(struct archive *,
1191  const wchar_t *);
1192 
1193 /* Utility functions */
1194 /* Convenience function to sort a NULL terminated list of strings */
1195 __LA_DECL int archive_utility_string_sort(char **);
1196 
1197 #ifdef __cplusplus
1198 }
1199 #endif
1200 
1201 /* These are meaningless outside of this header. */
1202 #undef __LA_DECL
1203 
1204 #endif /* !ARCHIVE_H_INCLUDED */
+ + + + diff --git a/docs/archive__entry_8h_source.html b/docs/archive__entry_8h_source.html new file mode 100644 index 0000000..f80e15c --- /dev/null +++ b/docs/archive__entry_8h_source.html @@ -0,0 +1,87 @@ + + + + + + + +TIMBER: bin/libarchive/include/archive_entry.h Source File + + + + + + + + + + + +
+
+ + + + + + + +
+
TIMBER +  beta +
+
Tree Interface for Making Binned Events with RDataFrame
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
archive_entry.h
+
+
+
1 /*-
2  * Copyright (c) 2003-2008 Tim Kientzle
3  * Copyright (c) 2016 Martin Matuska
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD: head/lib/libarchive/archive_entry.h 201096 2009-12-28 02:41:27Z kientzle $
27  */
28 
29 #ifndef ARCHIVE_ENTRY_H_INCLUDED
30 #define ARCHIVE_ENTRY_H_INCLUDED
31 
32 /* Note: Compiler will complain if this does not match archive.h! */
33 #define ARCHIVE_VERSION_NUMBER 3005002
34 
35 /*
36  * Note: archive_entry.h is for use outside of libarchive; the
37  * configuration headers (config.h, archive_platform.h, etc.) are
38  * purely internal. Do NOT use HAVE_XXX configuration macros to
39  * control the behavior of this header! If you must conditionalize,
40  * use predefined compiler and/or platform macros.
41  */
42 
43 #include <sys/types.h>
44 #include <stddef.h> /* for wchar_t */
45 #include <stdint.h>
46 #include <time.h>
47 
48 #if defined(_WIN32) && !defined(__CYGWIN__)
49 #include <windows.h>
50 #endif
51 
52 /* Get a suitable 64-bit integer type. */
53 #if !defined(__LA_INT64_T_DEFINED)
54 # if ARCHIVE_VERSION_NUMBER < 4000000
55 #define __LA_INT64_T la_int64_t
56 # endif
57 #define __LA_INT64_T_DEFINED
58 # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
59 typedef __int64 la_int64_t;
60 # else
61 #include <unistd.h>
62 # if defined(_SCO_DS) || defined(__osf__)
63 typedef long long la_int64_t;
64 # else
65 typedef int64_t la_int64_t;
66 # endif
67 # endif
68 #endif
69 
70 /* The la_ssize_t should match the type used in 'struct stat' */
71 #if !defined(__LA_SSIZE_T_DEFINED)
72 /* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */
73 # if ARCHIVE_VERSION_NUMBER < 4000000
74 #define __LA_SSIZE_T la_ssize_t
75 # endif
76 #define __LA_SSIZE_T_DEFINED
77 # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
78 # if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
79 typedef ssize_t la_ssize_t;
80 # elif defined(_WIN64)
81 typedef __int64 la_ssize_t;
82 # else
83 typedef long la_ssize_t;
84 # endif
85 # else
86 # include <unistd.h> /* ssize_t */
87 typedef ssize_t la_ssize_t;
88 # endif
89 #endif
90 
91 /* Get a suitable definition for mode_t */
92 #if ARCHIVE_VERSION_NUMBER >= 3999000
93 /* Switch to plain 'int' for libarchive 4.0. It's less broken than 'mode_t' */
94 # define __LA_MODE_T int
95 #elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
96 # define __LA_MODE_T unsigned short
97 #else
98 # define __LA_MODE_T mode_t
99 #endif
100 
101 /* Large file support for Android */
102 #ifdef __ANDROID__
103 #include "android_lf.h"
104 #endif
105 
106 /*
107  * On Windows, define LIBARCHIVE_STATIC if you're building or using a
108  * .lib. The default here assumes you're building a DLL. Only
109  * libarchive source should ever define __LIBARCHIVE_BUILD.
110  */
111 #if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
112 # ifdef __LIBARCHIVE_BUILD
113 # ifdef __GNUC__
114 # define __LA_DECL __attribute__((dllexport)) extern
115 # else
116 # define __LA_DECL __declspec(dllexport)
117 # endif
118 # else
119 # ifdef __GNUC__
120 # define __LA_DECL
121 # else
122 # define __LA_DECL __declspec(dllimport)
123 # endif
124 # endif
125 #else
126 /* Static libraries on all platforms and shared libraries on non-Windows. */
127 # define __LA_DECL
128 #endif
129 
130 #if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1
131 # define __LA_DEPRECATED __attribute__((deprecated))
132 #else
133 # define __LA_DEPRECATED
134 #endif
135 
136 #ifdef __cplusplus
137 extern "C" {
138 #endif
139 
140 /*
141  * Description of an archive entry.
142  *
143  * You can think of this as "struct stat" with some text fields added in.
144  *
145  * TODO: Add "comment", "charset", and possibly other entries that are
146  * supported by "pax interchange" format. However, GNU, ustar, cpio,
147  * and other variants don't support these features, so they're not an
148  * excruciatingly high priority right now.
149  *
150  * TODO: "pax interchange" format allows essentially arbitrary
151  * key/value attributes to be attached to any entry. Supporting
152  * such extensions may make this library useful for special
153  * applications (e.g., a package manager could attach special
154  * package-management attributes to each entry).
155  */
156 struct archive;
157 struct archive_entry;
158 
159 /*
160  * File-type constants. These are returned from archive_entry_filetype()
161  * and passed to archive_entry_set_filetype().
162  *
163  * These values match S_XXX defines on every platform I've checked,
164  * including Windows, AIX, Linux, Solaris, and BSD. They're
165  * (re)defined here because platforms generally don't define the ones
166  * they don't support. For example, Windows doesn't define S_IFLNK or
167  * S_IFBLK. Instead of having a mass of conditional logic and system
168  * checks to define any S_XXX values that aren't supported locally,
169  * I've just defined a new set of such constants so that
170  * libarchive-based applications can manipulate and identify archive
171  * entries properly even if the hosting platform can't store them on
172  * disk.
173  *
174  * These values are also used directly within some portable formats,
175  * such as cpio. If you find a platform that varies from these, the
176  * correct solution is to leave these alone and translate from these
177  * portable values to platform-native values when entries are read from
178  * or written to disk.
179  */
180 /*
181  * In libarchive 4.0, we can drop the casts here.
182  * They're needed to work around Borland C's broken mode_t.
183  */
184 #define AE_IFMT ((__LA_MODE_T)0170000)
185 #define AE_IFREG ((__LA_MODE_T)0100000)
186 #define AE_IFLNK ((__LA_MODE_T)0120000)
187 #define AE_IFSOCK ((__LA_MODE_T)0140000)
188 #define AE_IFCHR ((__LA_MODE_T)0020000)
189 #define AE_IFBLK ((__LA_MODE_T)0060000)
190 #define AE_IFDIR ((__LA_MODE_T)0040000)
191 #define AE_IFIFO ((__LA_MODE_T)0010000)
192 
193 /*
194  * Symlink types
195  */
196 #define AE_SYMLINK_TYPE_UNDEFINED 0
197 #define AE_SYMLINK_TYPE_FILE 1
198 #define AE_SYMLINK_TYPE_DIRECTORY 2
199 
200 /*
201  * Basic object manipulation
202  */
203 
204 __LA_DECL struct archive_entry *archive_entry_clear(struct archive_entry *);
205 /* The 'clone' function does a deep copy; all of the strings are copied too. */
206 __LA_DECL struct archive_entry *archive_entry_clone(struct archive_entry *);
207 __LA_DECL void archive_entry_free(struct archive_entry *);
208 __LA_DECL struct archive_entry *archive_entry_new(void);
209 
210 /*
211  * This form of archive_entry_new2() will pull character-set
212  * conversion information from the specified archive handle. The
213  * older archive_entry_new(void) form is equivalent to calling
214  * archive_entry_new2(NULL) and will result in the use of an internal
215  * default character-set conversion.
216  */
217 __LA_DECL struct archive_entry *archive_entry_new2(struct archive *);
218 
219 /*
220  * Retrieve fields from an archive_entry.
221  *
222  * There are a number of implicit conversions among these fields. For
223  * example, if a regular string field is set and you read the _w wide
224  * character field, the entry will implicitly convert narrow-to-wide
225  * using the current locale. Similarly, dev values are automatically
226  * updated when you write devmajor or devminor and vice versa.
227  *
228  * In addition, fields can be "set" or "unset." Unset string fields
229  * return NULL, non-string fields have _is_set() functions to test
230  * whether they've been set. You can "unset" a string field by
231  * assigning NULL; non-string fields have _unset() functions to
232  * unset them.
233  *
234  * Note: There is one ambiguity in the above; string fields will
235  * also return NULL when implicit character set conversions fail.
236  * This is usually what you want.
237  */
238 __LA_DECL time_t archive_entry_atime(struct archive_entry *);
239 __LA_DECL long archive_entry_atime_nsec(struct archive_entry *);
240 __LA_DECL int archive_entry_atime_is_set(struct archive_entry *);
241 __LA_DECL time_t archive_entry_birthtime(struct archive_entry *);
242 __LA_DECL long archive_entry_birthtime_nsec(struct archive_entry *);
243 __LA_DECL int archive_entry_birthtime_is_set(struct archive_entry *);
244 __LA_DECL time_t archive_entry_ctime(struct archive_entry *);
245 __LA_DECL long archive_entry_ctime_nsec(struct archive_entry *);
246 __LA_DECL int archive_entry_ctime_is_set(struct archive_entry *);
247 __LA_DECL dev_t archive_entry_dev(struct archive_entry *);
248 __LA_DECL int archive_entry_dev_is_set(struct archive_entry *);
249 __LA_DECL dev_t archive_entry_devmajor(struct archive_entry *);
250 __LA_DECL dev_t archive_entry_devminor(struct archive_entry *);
251 __LA_DECL __LA_MODE_T archive_entry_filetype(struct archive_entry *);
252 __LA_DECL void archive_entry_fflags(struct archive_entry *,
253  unsigned long * /* set */,
254  unsigned long * /* clear */);
255 __LA_DECL const char *archive_entry_fflags_text(struct archive_entry *);
256 __LA_DECL la_int64_t archive_entry_gid(struct archive_entry *);
257 __LA_DECL const char *archive_entry_gname(struct archive_entry *);
258 __LA_DECL const char *archive_entry_gname_utf8(struct archive_entry *);
259 __LA_DECL const wchar_t *archive_entry_gname_w(struct archive_entry *);
260 __LA_DECL const char *archive_entry_hardlink(struct archive_entry *);
261 __LA_DECL const char *archive_entry_hardlink_utf8(struct archive_entry *);
262 __LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *);
263 __LA_DECL la_int64_t archive_entry_ino(struct archive_entry *);
264 __LA_DECL la_int64_t archive_entry_ino64(struct archive_entry *);
265 __LA_DECL int archive_entry_ino_is_set(struct archive_entry *);
266 __LA_DECL __LA_MODE_T archive_entry_mode(struct archive_entry *);
267 __LA_DECL time_t archive_entry_mtime(struct archive_entry *);
268 __LA_DECL long archive_entry_mtime_nsec(struct archive_entry *);
269 __LA_DECL int archive_entry_mtime_is_set(struct archive_entry *);
270 __LA_DECL unsigned int archive_entry_nlink(struct archive_entry *);
271 __LA_DECL const char *archive_entry_pathname(struct archive_entry *);
272 __LA_DECL const char *archive_entry_pathname_utf8(struct archive_entry *);
273 __LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *);
274 __LA_DECL __LA_MODE_T archive_entry_perm(struct archive_entry *);
275 __LA_DECL dev_t archive_entry_rdev(struct archive_entry *);
276 __LA_DECL dev_t archive_entry_rdevmajor(struct archive_entry *);
277 __LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *);
278 __LA_DECL const char *archive_entry_sourcepath(struct archive_entry *);
279 __LA_DECL const wchar_t *archive_entry_sourcepath_w(struct archive_entry *);
280 __LA_DECL la_int64_t archive_entry_size(struct archive_entry *);
281 __LA_DECL int archive_entry_size_is_set(struct archive_entry *);
282 __LA_DECL const char *archive_entry_strmode(struct archive_entry *);
283 __LA_DECL const char *archive_entry_symlink(struct archive_entry *);
284 __LA_DECL const char *archive_entry_symlink_utf8(struct archive_entry *);
285 __LA_DECL int archive_entry_symlink_type(struct archive_entry *);
286 __LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *);
287 __LA_DECL la_int64_t archive_entry_uid(struct archive_entry *);
288 __LA_DECL const char *archive_entry_uname(struct archive_entry *);
289 __LA_DECL const char *archive_entry_uname_utf8(struct archive_entry *);
290 __LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *);
291 __LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *);
292 __LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *);
293 __LA_DECL int archive_entry_is_encrypted(struct archive_entry *);
294 
295 /*
296  * Set fields in an archive_entry.
297  *
298  * Note: Before libarchive 2.4, there were 'set' and 'copy' versions
299  * of the string setters. 'copy' copied the actual string, 'set' just
300  * stored the pointer. In libarchive 2.4 and later, strings are
301  * always copied.
302  */
303 
304 __LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long);
305 __LA_DECL void archive_entry_unset_atime(struct archive_entry *);
306 #if defined(_WIN32) && !defined(__CYGWIN__)
307 __LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, BY_HANDLE_FILE_INFORMATION *);
308 #endif
309 __LA_DECL void archive_entry_set_birthtime(struct archive_entry *, time_t, long);
310 __LA_DECL void archive_entry_unset_birthtime(struct archive_entry *);
311 __LA_DECL void archive_entry_set_ctime(struct archive_entry *, time_t, long);
312 __LA_DECL void archive_entry_unset_ctime(struct archive_entry *);
313 __LA_DECL void archive_entry_set_dev(struct archive_entry *, dev_t);
314 __LA_DECL void archive_entry_set_devmajor(struct archive_entry *, dev_t);
315 __LA_DECL void archive_entry_set_devminor(struct archive_entry *, dev_t);
316 __LA_DECL void archive_entry_set_filetype(struct archive_entry *, unsigned int);
317 __LA_DECL void archive_entry_set_fflags(struct archive_entry *,
318  unsigned long /* set */, unsigned long /* clear */);
319 /* Returns pointer to start of first invalid token, or NULL if none. */
320 /* Note that all recognized tokens are processed, regardless. */
321 __LA_DECL const char *archive_entry_copy_fflags_text(struct archive_entry *,
322  const char *);
323 __LA_DECL const wchar_t *archive_entry_copy_fflags_text_w(struct archive_entry *,
324  const wchar_t *);
325 __LA_DECL void archive_entry_set_gid(struct archive_entry *, la_int64_t);
326 __LA_DECL void archive_entry_set_gname(struct archive_entry *, const char *);
327 __LA_DECL void archive_entry_set_gname_utf8(struct archive_entry *, const char *);
328 __LA_DECL void archive_entry_copy_gname(struct archive_entry *, const char *);
329 __LA_DECL void archive_entry_copy_gname_w(struct archive_entry *, const wchar_t *);
330 __LA_DECL int archive_entry_update_gname_utf8(struct archive_entry *, const char *);
331 __LA_DECL void archive_entry_set_hardlink(struct archive_entry *, const char *);
332 __LA_DECL void archive_entry_set_hardlink_utf8(struct archive_entry *, const char *);
333 __LA_DECL void archive_entry_copy_hardlink(struct archive_entry *, const char *);
334 __LA_DECL void archive_entry_copy_hardlink_w(struct archive_entry *, const wchar_t *);
335 __LA_DECL int archive_entry_update_hardlink_utf8(struct archive_entry *, const char *);
336 __LA_DECL void archive_entry_set_ino(struct archive_entry *, la_int64_t);
337 __LA_DECL void archive_entry_set_ino64(struct archive_entry *, la_int64_t);
338 __LA_DECL void archive_entry_set_link(struct archive_entry *, const char *);
339 __LA_DECL void archive_entry_set_link_utf8(struct archive_entry *, const char *);
340 __LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *);
341 __LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *);
342 __LA_DECL int archive_entry_update_link_utf8(struct archive_entry *, const char *);
343 __LA_DECL void archive_entry_set_mode(struct archive_entry *, __LA_MODE_T);
344 __LA_DECL void archive_entry_set_mtime(struct archive_entry *, time_t, long);
345 __LA_DECL void archive_entry_unset_mtime(struct archive_entry *);
346 __LA_DECL void archive_entry_set_nlink(struct archive_entry *, unsigned int);
347 __LA_DECL void archive_entry_set_pathname(struct archive_entry *, const char *);
348 __LA_DECL void archive_entry_set_pathname_utf8(struct archive_entry *, const char *);
349 __LA_DECL void archive_entry_copy_pathname(struct archive_entry *, const char *);
350 __LA_DECL void archive_entry_copy_pathname_w(struct archive_entry *, const wchar_t *);
351 __LA_DECL int archive_entry_update_pathname_utf8(struct archive_entry *, const char *);
352 __LA_DECL void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T);
353 __LA_DECL void archive_entry_set_rdev(struct archive_entry *, dev_t);
354 __LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t);
355 __LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t);
356 __LA_DECL void archive_entry_set_size(struct archive_entry *, la_int64_t);
357 __LA_DECL void archive_entry_unset_size(struct archive_entry *);
358 __LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *);
359 __LA_DECL void archive_entry_copy_sourcepath_w(struct archive_entry *, const wchar_t *);
360 __LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *);
361 __LA_DECL void archive_entry_set_symlink_type(struct archive_entry *, int);
362 __LA_DECL void archive_entry_set_symlink_utf8(struct archive_entry *, const char *);
363 __LA_DECL void archive_entry_copy_symlink(struct archive_entry *, const char *);
364 __LA_DECL void archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *);
365 __LA_DECL int archive_entry_update_symlink_utf8(struct archive_entry *, const char *);
366 __LA_DECL void archive_entry_set_uid(struct archive_entry *, la_int64_t);
367 __LA_DECL void archive_entry_set_uname(struct archive_entry *, const char *);
368 __LA_DECL void archive_entry_set_uname_utf8(struct archive_entry *, const char *);
369 __LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *);
370 __LA_DECL void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *);
371 __LA_DECL int archive_entry_update_uname_utf8(struct archive_entry *, const char *);
372 __LA_DECL void archive_entry_set_is_data_encrypted(struct archive_entry *, char is_encrypted);
373 __LA_DECL void archive_entry_set_is_metadata_encrypted(struct archive_entry *, char is_encrypted);
374 /*
375  * Routines to bulk copy fields to/from a platform-native "struct
376  * stat." Libarchive used to just store a struct stat inside of each
377  * archive_entry object, but this created issues when trying to
378  * manipulate archives on systems different than the ones they were
379  * created on.
380  *
381  * TODO: On Linux and other LFS systems, provide both stat32 and
382  * stat64 versions of these functions and all of the macro glue so
383  * that archive_entry_stat is magically defined to
384  * archive_entry_stat32 or archive_entry_stat64 as appropriate.
385  */
386 __LA_DECL const struct stat *archive_entry_stat(struct archive_entry *);
387 __LA_DECL void archive_entry_copy_stat(struct archive_entry *, const struct stat *);
388 
389 /*
390  * Storage for Mac OS-specific AppleDouble metadata information.
391  * Apple-format tar files store a separate binary blob containing
392  * encoded metadata with ACL, extended attributes, etc.
393  * This provides a place to store that blob.
394  */
395 
396 __LA_DECL const void * archive_entry_mac_metadata(struct archive_entry *, size_t *);
397 __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const void *, size_t);
398 
399 /*
400  * Digest routine. This is used to query the raw hex digest for the
401  * given entry. The type of digest is provided as an argument.
402  */
403 #define ARCHIVE_ENTRY_DIGEST_MD5 0x00000001
404 #define ARCHIVE_ENTRY_DIGEST_RMD160 0x00000002
405 #define ARCHIVE_ENTRY_DIGEST_SHA1 0x00000003
406 #define ARCHIVE_ENTRY_DIGEST_SHA256 0x00000004
407 #define ARCHIVE_ENTRY_DIGEST_SHA384 0x00000005
408 #define ARCHIVE_ENTRY_DIGEST_SHA512 0x00000006
409 
410 __LA_DECL const unsigned char * archive_entry_digest(struct archive_entry *, int /* type */);
411 
412 /*
413  * ACL routines. This used to simply store and return text-format ACL
414  * strings, but that proved insufficient for a number of reasons:
415  * = clients need control over uname/uid and gname/gid mappings
416  * = there are many different ACL text formats
417  * = would like to be able to read/convert archives containing ACLs
418  * on platforms that lack ACL libraries
419  *
420  * This last point, in particular, forces me to implement a reasonably
421  * complete set of ACL support routines.
422  */
423 
424 /*
425  * Permission bits.
426  */
427 #define ARCHIVE_ENTRY_ACL_EXECUTE 0x00000001
428 #define ARCHIVE_ENTRY_ACL_WRITE 0x00000002
429 #define ARCHIVE_ENTRY_ACL_READ 0x00000004
430 #define ARCHIVE_ENTRY_ACL_READ_DATA 0x00000008
431 #define ARCHIVE_ENTRY_ACL_LIST_DIRECTORY 0x00000008
432 #define ARCHIVE_ENTRY_ACL_WRITE_DATA 0x00000010
433 #define ARCHIVE_ENTRY_ACL_ADD_FILE 0x00000010
434 #define ARCHIVE_ENTRY_ACL_APPEND_DATA 0x00000020
435 #define ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY 0x00000020
436 #define ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS 0x00000040
437 #define ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS 0x00000080
438 #define ARCHIVE_ENTRY_ACL_DELETE_CHILD 0x00000100
439 #define ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES 0x00000200
440 #define ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES 0x00000400
441 #define ARCHIVE_ENTRY_ACL_DELETE 0x00000800
442 #define ARCHIVE_ENTRY_ACL_READ_ACL 0x00001000
443 #define ARCHIVE_ENTRY_ACL_WRITE_ACL 0x00002000
444 #define ARCHIVE_ENTRY_ACL_WRITE_OWNER 0x00004000
445 #define ARCHIVE_ENTRY_ACL_SYNCHRONIZE 0x00008000
446 
447 #define ARCHIVE_ENTRY_ACL_PERMS_POSIX1E \
448  (ARCHIVE_ENTRY_ACL_EXECUTE \
449  | ARCHIVE_ENTRY_ACL_WRITE \
450  | ARCHIVE_ENTRY_ACL_READ)
451 
452 #define ARCHIVE_ENTRY_ACL_PERMS_NFS4 \
453  (ARCHIVE_ENTRY_ACL_EXECUTE \
454  | ARCHIVE_ENTRY_ACL_READ_DATA \
455  | ARCHIVE_ENTRY_ACL_LIST_DIRECTORY \
456  | ARCHIVE_ENTRY_ACL_WRITE_DATA \
457  | ARCHIVE_ENTRY_ACL_ADD_FILE \
458  | ARCHIVE_ENTRY_ACL_APPEND_DATA \
459  | ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY \
460  | ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS \
461  | ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS \
462  | ARCHIVE_ENTRY_ACL_DELETE_CHILD \
463  | ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES \
464  | ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES \
465  | ARCHIVE_ENTRY_ACL_DELETE \
466  | ARCHIVE_ENTRY_ACL_READ_ACL \
467  | ARCHIVE_ENTRY_ACL_WRITE_ACL \
468  | ARCHIVE_ENTRY_ACL_WRITE_OWNER \
469  | ARCHIVE_ENTRY_ACL_SYNCHRONIZE)
470 
471 /*
472  * Inheritance values (NFS4 ACLs only); included in permset.
473  */
474 #define ARCHIVE_ENTRY_ACL_ENTRY_INHERITED 0x01000000
475 #define ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT 0x02000000
476 #define ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT 0x04000000
477 #define ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT 0x08000000
478 #define ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY 0x10000000
479 #define ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS 0x20000000
480 #define ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS 0x40000000
481 
482 #define ARCHIVE_ENTRY_ACL_INHERITANCE_NFS4 \
483  (ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT \
484  | ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT \
485  | ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT \
486  | ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY \
487  | ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS \
488  | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS \
489  | ARCHIVE_ENTRY_ACL_ENTRY_INHERITED)
490 
491 /* We need to be able to specify combinations of these. */
492 #define ARCHIVE_ENTRY_ACL_TYPE_ACCESS 0x00000100 /* POSIX.1e only */
493 #define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT 0x00000200 /* POSIX.1e only */
494 #define ARCHIVE_ENTRY_ACL_TYPE_ALLOW 0x00000400 /* NFS4 only */
495 #define ARCHIVE_ENTRY_ACL_TYPE_DENY 0x00000800 /* NFS4 only */
496 #define ARCHIVE_ENTRY_ACL_TYPE_AUDIT 0x00001000 /* NFS4 only */
497 #define ARCHIVE_ENTRY_ACL_TYPE_ALARM 0x00002000 /* NFS4 only */
498 #define ARCHIVE_ENTRY_ACL_TYPE_POSIX1E (ARCHIVE_ENTRY_ACL_TYPE_ACCESS \
499  | ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)
500 #define ARCHIVE_ENTRY_ACL_TYPE_NFS4 (ARCHIVE_ENTRY_ACL_TYPE_ALLOW \
501  | ARCHIVE_ENTRY_ACL_TYPE_DENY \
502  | ARCHIVE_ENTRY_ACL_TYPE_AUDIT \
503  | ARCHIVE_ENTRY_ACL_TYPE_ALARM)
504 
505 /* Tag values mimic POSIX.1e */
506 #define ARCHIVE_ENTRY_ACL_USER 10001 /* Specified user. */
507 #define ARCHIVE_ENTRY_ACL_USER_OBJ 10002 /* User who owns the file. */
508 #define ARCHIVE_ENTRY_ACL_GROUP 10003 /* Specified group. */
509 #define ARCHIVE_ENTRY_ACL_GROUP_OBJ 10004 /* Group who owns the file. */
510 #define ARCHIVE_ENTRY_ACL_MASK 10005 /* Modify group access (POSIX.1e only) */
511 #define ARCHIVE_ENTRY_ACL_OTHER 10006 /* Public (POSIX.1e only) */
512 #define ARCHIVE_ENTRY_ACL_EVERYONE 10107 /* Everyone (NFS4 only) */
513 
514 /*
515  * Set the ACL by clearing it and adding entries one at a time.
516  * Unlike the POSIX.1e ACL routines, you must specify the type
517  * (access/default) for each entry. Internally, the ACL data is just
518  * a soup of entries. API calls here allow you to retrieve just the
519  * entries of interest. This design (which goes against the spirit of
520  * POSIX.1e) is useful for handling archive formats that combine
521  * default and access information in a single ACL list.
522  */
523 __LA_DECL void archive_entry_acl_clear(struct archive_entry *);
524 __LA_DECL int archive_entry_acl_add_entry(struct archive_entry *,
525  int /* type */, int /* permset */, int /* tag */,
526  int /* qual */, const char * /* name */);
527 __LA_DECL int archive_entry_acl_add_entry_w(struct archive_entry *,
528  int /* type */, int /* permset */, int /* tag */,
529  int /* qual */, const wchar_t * /* name */);
530 
531 /*
532  * To retrieve the ACL, first "reset", then repeatedly ask for the
533  * "next" entry. The want_type parameter allows you to request only
534  * certain types of entries.
535  */
536 __LA_DECL int archive_entry_acl_reset(struct archive_entry *, int /* want_type */);
537 __LA_DECL int archive_entry_acl_next(struct archive_entry *, int /* want_type */,
538  int * /* type */, int * /* permset */, int * /* tag */,
539  int * /* qual */, const char ** /* name */);
540 
541 /*
542  * Construct a text-format ACL. The flags argument is a bitmask that
543  * can include any of the following:
544  *
545  * Flags only for archive entries with POSIX.1e ACL:
546  * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - Include POSIX.1e "access" entries.
547  * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - Include POSIX.1e "default" entries.
548  * ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT - Include "default:" before each
549  * default ACL entry.
550  * ARCHIVE_ENTRY_ACL_STYLE_SOLARIS - Output only one colon after "other" and
551  * "mask" entries.
552  *
553  * Flags only for archive entries with NFSv4 ACL:
554  * ARCHIVE_ENTRY_ACL_STYLE_COMPACT - Do not output the minus character for
555  * unset permissions and flags in NFSv4 ACL permission and flag fields
556  *
557  * Flags for for archive entries with POSIX.1e ACL or NFSv4 ACL:
558  * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in
559  * each ACL entry.
560  * ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA - Separate entries with comma
561  * instead of newline.
562  */
563 #define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 0x00000001
564 #define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 0x00000002
565 #define ARCHIVE_ENTRY_ACL_STYLE_SOLARIS 0x00000004
566 #define ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA 0x00000008
567 #define ARCHIVE_ENTRY_ACL_STYLE_COMPACT 0x00000010
568 
569 __LA_DECL wchar_t *archive_entry_acl_to_text_w(struct archive_entry *,
570  la_ssize_t * /* len */, int /* flags */);
571 __LA_DECL char *archive_entry_acl_to_text(struct archive_entry *,
572  la_ssize_t * /* len */, int /* flags */);
573 __LA_DECL int archive_entry_acl_from_text_w(struct archive_entry *,
574  const wchar_t * /* wtext */, int /* type */);
575 __LA_DECL int archive_entry_acl_from_text(struct archive_entry *,
576  const char * /* text */, int /* type */);
577 
578 /* Deprecated constants */
579 #define OLD_ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024
580 #define OLD_ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048
581 
582 /* Deprecated functions */
583 __LA_DECL const wchar_t *archive_entry_acl_text_w(struct archive_entry *,
584  int /* flags */) __LA_DEPRECATED;
585 __LA_DECL const char *archive_entry_acl_text(struct archive_entry *,
586  int /* flags */) __LA_DEPRECATED;
587 
588 /* Return bitmask of ACL types in an archive entry */
589 __LA_DECL int archive_entry_acl_types(struct archive_entry *);
590 
591 /* Return a count of entries matching 'want_type' */
592 __LA_DECL int archive_entry_acl_count(struct archive_entry *, int /* want_type */);
593 
594 /* Return an opaque ACL object. */
595 /* There's not yet anything clients can actually do with this... */
596 struct archive_acl;
597 __LA_DECL struct archive_acl *archive_entry_acl(struct archive_entry *);
598 
599 /*
600  * extended attributes
601  */
602 
603 __LA_DECL void archive_entry_xattr_clear(struct archive_entry *);
604 __LA_DECL void archive_entry_xattr_add_entry(struct archive_entry *,
605  const char * /* name */, const void * /* value */,
606  size_t /* size */);
607 
608 /*
609  * To retrieve the xattr list, first "reset", then repeatedly ask for the
610  * "next" entry.
611  */
612 
613 __LA_DECL int archive_entry_xattr_count(struct archive_entry *);
614 __LA_DECL int archive_entry_xattr_reset(struct archive_entry *);
615 __LA_DECL int archive_entry_xattr_next(struct archive_entry *,
616  const char ** /* name */, const void ** /* value */, size_t *);
617 
618 /*
619  * sparse
620  */
621 
622 __LA_DECL void archive_entry_sparse_clear(struct archive_entry *);
623 __LA_DECL void archive_entry_sparse_add_entry(struct archive_entry *,
624  la_int64_t /* offset */, la_int64_t /* length */);
625 
626 /*
627  * To retrieve the xattr list, first "reset", then repeatedly ask for the
628  * "next" entry.
629  */
630 
631 __LA_DECL int archive_entry_sparse_count(struct archive_entry *);
632 __LA_DECL int archive_entry_sparse_reset(struct archive_entry *);
633 __LA_DECL int archive_entry_sparse_next(struct archive_entry *,
634  la_int64_t * /* offset */, la_int64_t * /* length */);
635 
636 /*
637  * Utility to match up hardlinks.
638  *
639  * The 'struct archive_entry_linkresolver' is a cache of archive entries
640  * for files with multiple links. Here's how to use it:
641  * 1. Create a lookup object with archive_entry_linkresolver_new()
642  * 2. Tell it the archive format you're using.
643  * 3. Hand each archive_entry to archive_entry_linkify().
644  * That function will return 0, 1, or 2 entries that should
645  * be written.
646  * 4. Call archive_entry_linkify(resolver, NULL) until
647  * no more entries are returned.
648  * 5. Call archive_entry_linkresolver_free(resolver) to free resources.
649  *
650  * The entries returned have their hardlink and size fields updated
651  * appropriately. If an entry is passed in that does not refer to
652  * a file with multiple links, it is returned unchanged. The intention
653  * is that you should be able to simply filter all entries through
654  * this machine.
655  *
656  * To make things more efficient, be sure that each entry has a valid
657  * nlinks value. The hardlink cache uses this to track when all links
658  * have been found. If the nlinks value is zero, it will keep every
659  * name in the cache indefinitely, which can use a lot of memory.
660  *
661  * Note that archive_entry_size() is reset to zero if the file
662  * body should not be written to the archive. Pay attention!
663  */
664 struct archive_entry_linkresolver;
665 
666 /*
667  * There are three different strategies for marking hardlinks.
668  * The descriptions below name them after the best-known
669  * formats that rely on each strategy:
670  *
671  * "Old cpio" is the simplest, it always returns any entry unmodified.
672  * As far as I know, only cpio formats use this. Old cpio archives
673  * store every link with the full body; the onus is on the dearchiver
674  * to detect and properly link the files as they are restored.
675  * "tar" is also pretty simple; it caches a copy the first time it sees
676  * any link. Subsequent appearances are modified to be hardlink
677  * references to the first one without any body. Used by all tar
678  * formats, although the newest tar formats permit the "old cpio" strategy
679  * as well. This strategy is very simple for the dearchiver,
680  * and reasonably straightforward for the archiver.
681  * "new cpio" is trickier. It stores the body only with the last
682  * occurrence. The complication is that we might not
683  * see every link to a particular file in a single session, so
684  * there's no easy way to know when we've seen the last occurrence.
685  * The solution here is to queue one link until we see the next.
686  * At the end of the session, you can enumerate any remaining
687  * entries by calling archive_entry_linkify(NULL) and store those
688  * bodies. If you have a file with three links l1, l2, and l3,
689  * you'll get the following behavior if you see all three links:
690  * linkify(l1) => NULL (the resolver stores l1 internally)
691  * linkify(l2) => l1 (resolver stores l2, you write l1)
692  * linkify(l3) => l2, l3 (all links seen, you can write both).
693  * If you only see l1 and l2, you'll get this behavior:
694  * linkify(l1) => NULL
695  * linkify(l2) => l1
696  * linkify(NULL) => l2 (at end, you retrieve remaining links)
697  * As the name suggests, this strategy is used by newer cpio variants.
698  * It's noticeably more complex for the archiver, slightly more complex
699  * for the dearchiver than the tar strategy, but makes it straightforward
700  * to restore a file using any link by simply continuing to scan until
701  * you see a link that is stored with a body. In contrast, the tar
702  * strategy requires you to rescan the archive from the beginning to
703  * correctly extract an arbitrary link.
704  */
705 
706 __LA_DECL struct archive_entry_linkresolver *archive_entry_linkresolver_new(void);
707 __LA_DECL void archive_entry_linkresolver_set_strategy(
708  struct archive_entry_linkresolver *, int /* format_code */);
709 __LA_DECL void archive_entry_linkresolver_free(struct archive_entry_linkresolver *);
710 __LA_DECL void archive_entry_linkify(struct archive_entry_linkresolver *,
711  struct archive_entry **, struct archive_entry **);
712 __LA_DECL struct archive_entry *archive_entry_partial_links(
713  struct archive_entry_linkresolver *res, unsigned int *links);
714 #ifdef __cplusplus
715 }
716 #endif
717 
718 /* This is meaningless outside of this header. */
719 #undef __LA_DECL
720 
721 #endif /* !ARCHIVE_ENTRY_H_INCLUDED */
+ + + + diff --git a/docs/class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer-members.html b/docs/class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer-members.html index e3c976a..2920230 100644 --- a/docs/class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer-members.html +++ b/docs/class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer-members.html @@ -107,19 +107,21 @@ GetFlagString(self, flagList=GetStandardFlags())analyzer GetTrackedNodeNames(self)analyzer GetTriggerString(self, trigList)analyzer - isDataanalyzer - lhaidanalyzer - MakeHistsWithBinning(self, histDict, name='', weight=None)analyzer - MakeTemplateHistos(self, templateHist, variables, node=None)analyzer - MakeWeightCols(self, name='', node=None, correctionNames=None, dropList=[])analyzer - MergeCollections(self, name, collectionNames)analyzer - Nminus1(self, cutgroup, node=None)analyzer - ObjectFromCollection(self, name, basecoll, index, skip=[])analyzer - preV6analyzer - PrintNodeTree(self, outfilename, verbose=False, toSkip=[])analyzer - Range(self, argv)analyzer - ReorderCollection(self, name, basecoll, newOrderCol, skip=[])analyzer - RunChainanalyzer + GetWeightName(self, corr, variation, name="")analyzer + isDataanalyzer + lhaidanalyzer + MakeHistsWithBinning(self, histDict, name='', weight=None)analyzer + MakeTemplateHistos(self, templateHist, variables, node=None)analyzer + MakeWeightCols(self, name='', node=None, correctionNames=None, dropList=[])analyzer + MergeCollections(self, name, collectionNames)analyzer + Nminus1(self, cutgroup, node=None)analyzer + ObjectFromCollection(self, name, basecoll, index, skip=[])analyzer + preV6analyzer + PrintNodeTree(self, outfilename, verbose=False, toSkip=[])analyzer + Range(self, argv)analyzer + ReorderCollection(self, name, basecoll, newOrderCol, skip=[])analyzer + RunChainanalyzer + SaveRunChain(self, filename, merge=True)analyzer SetActiveNode(self, node)analyzer silentanalyzer Snapshot(self, columns, outfilename, treename, lazy=False, openOption='RECREATE')analyzer diff --git a/docs/class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html b/docs/class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html index d7051fd..3883618 100644 --- a/docs/class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html +++ b/docs/class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html @@ -110,6 +110,9 @@   def Snapshot (self, columns, outfilename, treename, lazy=False, openOption='RECREATE')   +def SaveRunChain (self, filename, merge=True) + Save the Run tree (chain of all input files) to filename. More...
+  def Range (self, argv)   def GetCollectionNames (self) @@ -181,6 +184,9 @@ def MakeWeightCols (self, name='', node=None, correctionNames=None, dropList=[])  Makes columns/variables to store total weights based on the Corrections that have been added. More...
  +def GetWeightName (self, corr, variation, name="") + Return the branch/column name of the requested weight. More...
+  def MakeTemplateHistos (self, templateHist, variables, node=None)  Generates the uncertainty template histograms based on the weights created by MakeWeightCols(). More...
  @@ -1167,6 +1173,65 @@

+

◆ GetWeightName()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
def GetWeightName ( self,
 corr,
 variation,
 name = "" 
)
+
+ +

Return the branch/column name of the requested weight.

+
Parameters
+ + + + +
corr(str,Correction): Either the correction object or the name of the correction.
variation(str): "up" or "down".
name(str,optional): Name given MakeWeightCols to denote group of weight columns. Defaults to "".
+
+
+
Exceptions
+ + +
NameErrorIf weight name does not exist in the columns.
+
+
+
Returns
+
+str Name of the requested weight branch/column.
+
@@ -1629,6 +1694,53 @@

Node New ActiveNode.

Examples

a = analyzer(...)

a.Define('NewFatJetIdxs','ReorderJets(...)')
a.ReorderCollection('ReorderedFatJets','FatJet','NewFatJetIdxs')
+ + + +

◆ SaveRunChain()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
def SaveRunChain ( self,
 filename,
 merge = True 
)
+
+ +

Save the Run tree (chain of all input files) to filename.

+

If filename already exists, some staging will occur to properly merge the files via hadd.

+
Parameters
+ + + +
filename(str): Output file name.
merge(bool, optional): Whether to merge with a file that already exists. Defaults to True.
+
+
+
Returns
+
+None
+
diff --git a/docs/dir_29c4cd31bf8db4a059992a825a23a308.html b/docs/dir_29c4cd31bf8db4a059992a825a23a308.html new file mode 100644 index 0000000..2315432 --- /dev/null +++ b/docs/dir_29c4cd31bf8db4a059992a825a23a308.html @@ -0,0 +1,91 @@ + + + + + + + +TIMBER: bin/libarchive Directory Reference + + + + + + + + + + + +
+
+ + + + + + + +
+
TIMBER +  beta +
+
Tree Interface for Making Binned Events with RDataFrame
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
libarchive Directory Reference
+
+
+ + +

+Directories

+
+ + + + diff --git a/docs/dir_2ea30aa2956a8db99dd22aa5e597f384.html b/docs/dir_2ea30aa2956a8db99dd22aa5e597f384.html new file mode 100644 index 0000000..a60d2f2 --- /dev/null +++ b/docs/dir_2ea30aa2956a8db99dd22aa5e597f384.html @@ -0,0 +1,87 @@ + + + + + + + +TIMBER: bin Directory Reference + + + + + + + + + + + +
+
+ + + + + + + +
+
TIMBER +  beta +
+
Tree Interface for Making Binned Events with RDataFrame
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
bin Directory Reference
+
+
+
+ + + + diff --git a/docs/dir_fa831c2f115bbdef41b4043b3bad12cb.html b/docs/dir_fa831c2f115bbdef41b4043b3bad12cb.html new file mode 100644 index 0000000..02bcb4b --- /dev/null +++ b/docs/dir_fa831c2f115bbdef41b4043b3bad12cb.html @@ -0,0 +1,87 @@ + + + + + + + +TIMBER: bin/libarchive/include Directory Reference + + + + + + + + + + + +
+
+ + + + + + + +
+
TIMBER +  beta +
+
Tree Interface for Making Binned Events with RDataFrame
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
include Directory Reference
+
+
+
+ + + + diff --git a/docs/search/all_12.js b/docs/search/all_12.js index b6f44ce..b6fad7f 100644 --- a/docs/search/all_12.js +++ b/docs/search/all_12.js @@ -1,5 +1,6 @@ var searchData= [ + ['saverunchain',['SaveRunChain',['../class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html#a71c3df3ecfe0afd1abe50caabea431c6',1,'TIMBER::Analyzer::analyzer']]], ['setactivenode',['SetActiveNode',['../class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html#a3f19f4e3f9344e283f5cf6ae2371fc70',1,'TIMBER::Analyzer::analyzer']]], ['setchild',['SetChild',['../class_t_i_m_b_e_r_1_1_analyzer_1_1_node.html#a82be871373e5ef1b41fd076630e72873',1,'TIMBER::Analyzer::Node']]], ['setchildren',['SetChildren',['../class_t_i_m_b_e_r_1_1_analyzer_1_1_node.html#add3a1faeeb9529ee59760ea265fdbade',1,'TIMBER::Analyzer::Node']]], diff --git a/docs/search/all_7.js b/docs/search/all_7.js index 7e0dd36..5bfa8f5 100644 --- a/docs/search/all_7.js +++ b/docs/search/all_7.js @@ -34,6 +34,7 @@ var searchData= ['gettxtfilestr',['GetTxtFileStr',['../class_j_e_spaths.html#a2c29bad825d3fa85e6c9c235d1d29491',1,'JESpaths']]], ['gettype',['GetType',['../class_t_i_m_b_e_r_1_1_analyzer_1_1_correction.html#afde9a246543a0b49710f9312d6020b7b',1,'TIMBER::Analyzer::Correction']]], ['getuncertainty',['GetUncertainty',['../class_jet_recalibrator.html#afa7f3c7cf9571beb929bdf0b4cc37782',1,'JetRecalibrator']]], + ['getweightname',['GetWeightName',['../class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html#a2f8118d1dc9a46dd6155791323a8ad63',1,'TIMBER::Analyzer::analyzer']]], ['group',['Group',['../class_t_i_m_b_e_r_1_1_analyzer_1_1_group.html',1,'TIMBER::Analyzer']]], ['getting_20a_20python_203_20compatible_20version_20of_20root',['Getting a Python 3 compatible version of ROOT',['../md_doxysetup__python3.html',1,'']]] ]; diff --git a/docs/search/functions_12.js b/docs/search/functions_12.js index b21ff60..cece48b 100644 --- a/docs/search/functions_12.js +++ b/docs/search/functions_12.js @@ -1,5 +1,6 @@ var searchData= [ + ['saverunchain',['SaveRunChain',['../class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html#a71c3df3ecfe0afd1abe50caabea431c6',1,'TIMBER::Analyzer::analyzer']]], ['setactivenode',['SetActiveNode',['../class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html#a3f19f4e3f9344e283f5cf6ae2371fc70',1,'TIMBER::Analyzer::analyzer']]], ['setchild',['SetChild',['../class_t_i_m_b_e_r_1_1_analyzer_1_1_node.html#a82be871373e5ef1b41fd076630e72873',1,'TIMBER::Analyzer::Node']]], ['setchildren',['SetChildren',['../class_t_i_m_b_e_r_1_1_analyzer_1_1_node.html#add3a1faeeb9529ee59760ea265fdbade',1,'TIMBER::Analyzer::Node']]], diff --git a/docs/search/functions_7.js b/docs/search/functions_7.js index b0bf2bc..06a1f0e 100644 --- a/docs/search/functions_7.js +++ b/docs/search/functions_7.js @@ -31,5 +31,6 @@ var searchData= ['gettriggerstring',['GetTriggerString',['../class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html#a818bf6c1ef57461de293ebf6a4c7ea6a',1,'TIMBER::Analyzer::analyzer']]], ['gettxtfilestr',['GetTxtFileStr',['../class_j_e_spaths.html#a2c29bad825d3fa85e6c9c235d1d29491',1,'JESpaths']]], ['gettype',['GetType',['../class_t_i_m_b_e_r_1_1_analyzer_1_1_correction.html#afde9a246543a0b49710f9312d6020b7b',1,'TIMBER::Analyzer::Correction']]], - ['getuncertainty',['GetUncertainty',['../class_jet_recalibrator.html#afa7f3c7cf9571beb929bdf0b4cc37782',1,'JetRecalibrator']]] + ['getuncertainty',['GetUncertainty',['../class_jet_recalibrator.html#afa7f3c7cf9571beb929bdf0b4cc37782',1,'JetRecalibrator']]], + ['getweightname',['GetWeightName',['../class_t_i_m_b_e_r_1_1_analyzer_1_1analyzer.html#a2f8118d1dc9a46dd6155791323a8ad63',1,'TIMBER::Analyzer::analyzer']]] ]; diff --git a/setup.csh b/setup.csh new file mode 100644 index 0000000..1f434f6 --- /dev/null +++ b/setup.csh @@ -0,0 +1,39 @@ +#!/usr/bin/env tcsh +if ("$VIRTUAL_ENV" == "") then + echo "ERROR: Create and activate a virtual environment and try again" + return +endif + +if (`command -v dot` == "") then + echo "dot (graphviz) could not be found. Please install it first... (on Ubuntu 'sudo apt-get install graphviz libgraphviz-dev')" + return +endif + +# python setup.py install +set activate_path=$VIRTUAL_ENV/bin/activate.csh +setenv TIMBERPATH "$PWD/" + +if (`grep -q $TIMBERPATH $activate_path` != "") then + echo "TIMBER path already in activate" +else + printf "\n\n" > activate_ext.csh.cpy + echo "setenv TIMBERPATH ${TIMBERPATH}" >> activate_ext.csh.cpy + cat activate_ext.csh >> activate_ext.csh.cpy + tcsh activate_ext.csh.cpy + cat activate_ext.csh.cpy >> $activate_path + rm activate_ext.csh.cpy +endif + +if ! (-d "bin/libarchive") then + git clone https://github.com/libarchive/libarchive.git + cd libarchive + cmake . -DCMAKE_INSTALL_PREFIX=../bin/libarchive + make + make install + cd .. + rm -rf libarchive +endif + +if !(-d "bin/libtimber") then + make +endif diff --git a/test/test_Analyzer.py b/test/test_Analyzer.py index b87f8ca..e79c5e9 100644 --- a/test/test_Analyzer.py +++ b/test/test_Analyzer.py @@ -41,11 +41,17 @@ def test_range(self): self.a.SetActiveNode(bookmark) assert nevents.GetValue() == 500 - def test_snapshot(self,tmp_path): + def test_snapshot(self): '''Makes a simple snapshot''' out_vars = ['nJet','test_define'] - self.a.GetActiveNode().Snapshot(out_vars,str(tmp_path)+'/ex1_out.root','test_snapshot',lazy=False,openOption='RECREATE') + self.a.GetActiveNode().Snapshot(out_vars,'test_out.root','test_snapshot',lazy=False,openOption='RECREATE') assert True + + # No Runs tree in test file currently + # def test_SaveRunChain(self): + # '''Save out RunChain''' + # self.a.SaveRunChain("test_out.root") + # assert True def test_Correction(self): c = Correction('testWeight','test/test_weight.cc') @@ -54,6 +60,7 @@ def test_Correction(self): self.a.MakeWeightCols() htemplate = ROOT.TH1F('th1','',100,0,1000) hgroup = self.a.MakeTemplateHistos(htemplate,'Jet_pt0') + print ('TESTING GetWeightName: %s'%(self.a.GetWeightName(c,'up',''))) print ([hgroup[h].GetName() for h in hgroup.keys()]) self.a.DrawTemplates(hgroup, './') pass