]> wimlib.net Git - wimlib/blob - include/wimlib.h
Remove WIMLIB_WRITE_FLAG_NO_PACK_STREAMS
[wimlib] / include / wimlib.h
1 /**
2  * @file wimlib.h
3  * @brief External header for wimlib.
4  *
5  * This file contains extensive comments for generating documentation with
6  * Doxygen.  The built HTML documentation can be viewed at
7  * http://wimlib.sourceforge.net.  Make sure to see the <a
8  * href="modules.html">Modules page</a> to make more sense of the declarations
9  * in this header.
10  */
11
12 /*
13  * Copyright (C) 2012, 2013 Eric Biggers
14  *
15  * This file is part of wimlib, a library for working with WIM files.
16  *
17  * wimlib is free software; you can redistribute it and/or modify it under the
18  * terms of the GNU General Public License as published by the Free
19  * Software Foundation; either version 3 of the License, or (at your option)
20  * any later version.
21  *
22  * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
23  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
24  * A PARTICULAR PURPOSE. See the GNU General Public License for more
25  * details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with wimlib; if not, see http://www.gnu.org/licenses/.
29  */
30
31 /**
32  * @mainpage
33  *
34  * @section sec_intro Introduction
35  *
36  * This is the documentation for the library interface of wimlib 1.5.3, a C
37  * library for creating, modifying, extracting, and mounting files in the
38  * Windows Imaging Format.  This documentation is intended for developers only.
39  * If you have installed wimlib and want to know how to use the @b wimlib-imagex
40  * program, please see the README file or manual pages.
41  *
42  * @section sec_installing_and_compiling Installing and Compiling
43  *
44  * wimlib uses the GNU autotools, so, on UNIX-like systems, it should be easy to
45  * install with <code>configure && make && sudo make install</code>; however,
46  * please see the README for more information about installing it.
47  *
48  * To use wimlib in your program after installing it, include wimlib.h and link
49  * your program with @c -lwim.
50  *
51  * As of wimlib 1.5.0, wimlib.h is also compatible with C++.
52  *
53  * Note: before calling any other function declared in wimlib.h,
54  * wimlib_global_init() can (and in some cases, must) be called.  See its
55  * documentation for more details.
56  *
57  * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
58  *
59  * wimlib wraps up a WIM file in an opaque ::WIMStruct structure.   There are
60  * two ways to create such a structure: wimlib_open_wim(), which opens a WIM
61  * file and creates a ::WIMStruct representing it, and wimlib_create_new_wim(),
62  * which creates a new ::WIMStruct that initially contains no images and does
63  * not yet have a backing on-disk file.  See @ref G_creating_and_opening_wims
64  * for more details.
65  *
66  * A WIM file, represented by a ::WIMStruct, contains zero or more images.
67  * Images can be extracted (or "applied") using wimlib_extract_image(), added
68  * (or "captured" or "appended") using wimlib_add_image(), deleted using
69  * wimlib_delete_image(), exported using wimlib_export_image(), and updated or
70  * modified using wimlib_update_image().  However, changes made to a WIM
71  * represented by a ::WIMStruct have no persistent effect until the WIM is
72  * actually written to an on-disk file.  This can be done using wimlib_write(),
73  * but if the WIM was originally opened using wimlib_open_wim(), then
74  * wimlib_overwrite() can be used instead.  See @ref G_extracting_wims, @ref
75  * G_modifying_wims, and @ref G_writing_and_overwriting_wims for more details.
76  *
77  * Note that with this ::WIMStruct abstraction, performing many tasks on WIM
78  * files is a multi-step process.  For example, to add, or "append" an image to
79  * an existing stand-alone WIM file in a way similar to <b>wimlib-imagex
80  * append</b>, you must call the following functions:
81  *
82  * 1. wimlib_open_wim()
83  * 2. wimlib_add_image()
84  * 3. wimlib_overwrite()
85  *
86  * This design is very much on purpose as it makes the library more useful in
87  * general by allowing functions to be composed in different ways.  For example,
88  * you can make multiple changes to a WIM and commit them all to the underlying
89  * file in only one overwrite operation, which is more efficient.
90  *
91  * @section sec_cleaning_up Cleaning up
92  *
93  * After you are done with any ::WIMStruct, you can call wimlib_free() to free
94  * all resources associated with it.  Also, when you are completely done with
95  * using wimlib in your program, you can call wimlib_global_cleanup() to free
96  * any other resources allocated by the library.
97  *
98  * @section sec_error_handling Error Handling
99  *
100  * Most functions in wimlib return 0 on success and a positive error code on
101  * failure.  Use wimlib_get_error_string() to get a string that describes an
102  * error code.  wimlib also can print error messages to standard error itself
103  * when an error happens, and these may be more informative than the error code;
104  * to enable this, call wimlib_set_print_errors().  Please note that this is for
105  * convenience only, and some errors can occur without a message being printed.
106  * Currently, error messages and strings (as well as all documentation, for that
107  * matter) are only available in English.
108  *
109  * @section sec_encodings Locales and character encodings
110  *
111  * To support Windows as well as UNIX-like systems, wimlib's API typically takes
112  * and returns strings of ::wimlib_tchar, which are in a platform-dependent
113  * encoding.
114  *
115  * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
116  * and the encoding is UTF-16LE.
117  *
118  * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
119  * and the encoding is the locale-dependent multibyte encoding.  I recommend you
120  * set your locale to a UTF-8 capable locale to avoid any issues.  Also, by
121  * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
122  * call wimlib_global_init() after having set your desired locale.
123  *
124  * @section sec_advanced Additional information and features
125  *
126  *
127  * @subsection subsec_mounting_wim_images Mounting WIM images
128  *
129  * See @ref G_mounting_wim_images.
130  *
131  * @subsection subsec_progress_functions Progress Messages
132  *
133  * See @ref G_progress.
134  *
135  * @subsection subsec_non_standalone_wims Non-standalone WIMs
136  *
137  * See @ref G_nonstandalone_wims.
138  *
139  * @subsection subsec_pipable_wims Pipable WIMs
140  *
141  * wimlib supports a special "pipable" WIM format which unfortunately is @b not
142  * compatible with Microsoft's software.  To create a pipable WIM, call
143  * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
144  * ::WIMLIB_WRITE_FLAG_PIPABLE specified.  Pipable WIMs are pipable in both
145  * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
146  * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
147  * a pipable WIM.  wimlib can also transparently open and operate on pipable WIM
148  * s using a seekable file descriptor using the regular function calls (e.g.
149  * wimlib_open_wim(), wimlib_extract_image()).
150  *
151  * See the documentation for the <b>--pipable</b> flag of <b>wimlib-imagex
152  * capture</b> for more information about pipable WIMs.
153  *
154  * @subsection subsec_thread_safety Thread Safety
155  *
156  * wimlib is thread-safe, with the following exceptions:
157  * - Different threads cannot operate on the same ::WIMStruct at the same time;
158  *   they must use different ::WIMStruct's.
159  * - You must call wimlib_global_init() in one thread before calling any other
160  *   functions.
161  * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
162  * - wimlib_mount_image(), while it can be used to mount multiple WIMs
163  *   concurrently in the same process, will daemonize the entire process when it
164  *   does so for the first time.  This includes changing the working directory
165  *   to the root directory.
166  *
167  * @subsection subsec_limitations Limitations
168  *
169  * This section documents some technical limitations of wimlib not already
170  * documented in the man page for @b wimlib-imagex.
171  *
172  * - The old WIM format from Vista pre-releases is not supported.
173  * - wimlib does not provide a clone of the @b PEImg tool, or the @b Dism
174  *   functionality other than that already present in @b ImageX, that allows you
175  *   to make certain Windows-specific modifications to a Windows PE image, such
176  *   as adding a driver or Windows component.  Such a tool could be implemented
177  *   on top of wimlib.
178  *
179  * @subsection more_info More information
180  *
181  * You are advised to read the README as well as the manual pages for
182  * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
183  * the API documentation.
184  */
185
186 /** @defgroup G_general General
187  *
188  * @brief Declarations and structures shared across the library.
189  */
190
191 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
192  *
193  * @brief Create new WIMs and open existing WIMs.
194  */
195
196 /** @defgroup G_wim_information Retrieving WIM information and directory listings
197  *
198  * @brief Retrieve information about a WIM or WIM image.
199  */
200
201 /** @defgroup G_modifying_wims Modifying WIMs
202  *
203  * @brief Make changes to a WIM.
204  *
205  * @section sec_adding_images Capturing and adding WIM images
206  *
207  * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
208  * appending an image to an existing WIM is a multi-step process, but at its
209  * core is wimlib_add_image() or an equivalent function.  Normally,
210  * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
211  * ::WIMStruct as a new image.  However, when supported by the build of the
212  * library, there is also a special NTFS volume capture mode (entered when
213  * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
214  * from an unmounted NTFS volume.
215  *
216  * Another function, wimlib_add_image_multisource() is also provided.  It
217  * generalizes wimlib_add_image() to allow combining multiple files or directory
218  * trees into a single WIM image in a configurable way.
219  *
220  * For maximum customization of WIM image creation, it is also possible to add a
221  * completely empty WIM image with wimlib_add_empty_image(), then update it with
222  * wimlib_update_image().  (This is in fact what wimlib_add_image() and
223  * wimlib_add_image_multisource() do internally.)
224  *
225  * Note that some details of how image addition/capture works are documented
226  * more fully in the manual page for <b>wimlib-imagex capture</b>.
227  *
228  * @section sec_deleting_images Deleting WIM images
229  *
230  * wimlib_delete_image() can delete an image from a ::WIMStruct.  But as usual,
231  * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
232  * be made persistent in an on-disk WIM file.
233  *
234  * @section sec_exporting_images Exporting WIM images
235  *
236  * wimlib_export_image() can copy, or "export", an image from one WIM to
237  * another.
238  *
239  * @section sec_other_modifications Other modifications
240  *
241  * wimlib_update_image() can add, delete, and rename files in a WIM image.
242  *
243  * wimlib_set_image_name(), wimlib_set_image_descripton(), and
244  * wimlib_set_image_flags() can change other image metadata.
245  *
246  * wimlib_set_wim_info() can change information about the WIM file itself, such
247  * as the boot index.
248  */
249
250 /** @defgroup G_extracting_wims Extracting WIMs
251  *
252  * @brief Extract files, directories, and images from a WIM.
253  *
254  * wimlib_extract_image() extracts, or "applies", an image from a WIM
255  * (represented, as usual, by a ::WIMStruct).  This normally extracts the image
256  * to a directory, but when supported by the build of the library there is also
257  * a special NTFS volume extraction mode (entered when
258  * ::WIMLIB_EXTRACT_FLAG_NTFS is specified) that allows extracting a WIM image
259  * directly to an unmounted NTFS volume.  Various other flags allow further
260  * customization of image extraction.
261  *
262  * Another function, wimlib_extract_files(), is also provided.  It can extract
263  * certain files or directories from a WIM image, instead of a full image.
264  *
265  * A third function, wimlib_extract_image_from_pipe(), allows an image to be
266  * extracted from a pipable WIM sent over a pipe; see @ref subsec_pipable_wims.
267  *
268  * Note that some details of how image extraction/application works are
269  * documented more fully in the manual pages for <b>wimlib-imagex apply</b> and
270  * <b>wimlib-imagex extract</b>.
271  */
272
273 /** @defgroup G_mounting_wim_images Mounting WIM images
274  *
275  * @brief Mount and unmount WIM images.
276  *
277  * On UNIX-like systems supporting FUSE (such as Linux), wimlib supports
278  * mounting images from WIM files either read-only or read-write.  To mount an
279  * image, call wimlib_mount_image().  To unmount an image, call
280  * wimlib_unmount_image().  Mounting can be done without root privileges because
281  * it is implemented using FUSE (Filesystem in Userspace).  If wimlib is
282  * compiled with the <code>--without-fuse</code> flag, these functions will be
283  * available but will fail with ::WIMLIB_ERR_UNSUPPORTED.  Note that mounting an
284  * image read-write is an alternative to calling wimlib_update_image().
285  */
286
287 /** @defgroup G_progress Progress Messages
288  *
289  * @brief Track the progress of long WIM operations.
290  *
291  * When operating on large archives, operations such as extraction will
292  * naturally take a while to complete.  Because of this and to improve the
293  * potential user-friendliness of library clients, a number of functions take a
294  * pointer to a progress function of type ::wimlib_progress_func_t.  This
295  * function will be called periodically during the WIM operation(s) to report on
296  * the progress of the operation (for example, how many bytes have been written
297  * so far).
298  */
299
300 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
301  *
302  * @brief Write and overwrite on-disk WIM files.
303  *
304  * As described in @ref sec_basic_wim_handling_concepts, these functions are
305  * critical to the design of the library as they allow new or modified WIMs to
306  * actually be written to on-disk files.  Generally, wimlib_write() is the
307  * function you need to call to write a new WIM file, and wimlib_overwrite() is
308  * the function you need to call to persistently update an existing WIM file.
309  */
310
311 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
312  *
313  * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
314  *
315  * Normally, ::WIMStruct represents a WIM file, but there's a bit more to it
316  * than that.  Normally, WIM files are "standalone".  However, WIM files can
317  * also be arranged in non-standalone ways, such as a set of on-disk files that
318  * together form a single "split WIM" or "delta WIM".  Such arrangements are
319  * fully supported by wimlib.  However, as a result, in such cases a ::WIMStruct
320  * created from one of these on-disk files initially only partially represents
321  * the full WIM and needs to, in effect, be logically combined with other
322  * ::WIMStruct's before performing certain operations, such as extracting files
323  * with wimlib_extract_image() or wimlib_extract_files().  This is done by
324  * calling wimlib_reference_resource_files() or wimlib_reference_resources().
325  *
326  * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
327  * specialized function (wimlib_split()) is needed to create a split WIM.
328  */
329
330 #ifndef _WIMLIB_H
331 #define _WIMLIB_H
332
333 #include <stdio.h>
334 #include <stddef.h>
335 #include <stdbool.h>
336 #include <inttypes.h>
337 #include <time.h>
338
339 /** @ingroup G_general
340  * @{ */
341
342 /** Major version of the library (for example, the 1 in 1.2.5).  */
343 #define WIMLIB_MAJOR_VERSION 1
344
345 /** Minor version of the library (for example, the 2 in 1.2.5). */
346 #define WIMLIB_MINOR_VERSION 5
347
348 /** Patch version of the library (for example, the 5 in 1.2.5). */
349 #define WIMLIB_PATCH_VERSION 3
350
351 #ifdef __cplusplus
352 extern "C" {
353 #endif
354
355 /** @} */
356 /** @ingroup G_general
357  * @{ */
358
359 /**
360  * Opaque structure that represents a WIM file.  This is an in-memory structure
361  * and need not correspond to a specific on-disk file.  However, a ::WIMStruct
362  * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
363  * continuing to exist so that data can be read from it as needed.
364  *
365  * Most functions in this library will work the same way regardless of whether a
366  * given ::WIMStruct was obtained through wimlib_open_wim() or
367  * wimlib_create_new_wim().  Exceptions are documented.
368  *
369  * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
370  * file from a ::WIMStruct.
371  *
372  * See @ref sec_basic_wim_handling_concepts for more information.
373  */
374 #ifndef WIMLIB_WIMSTRUCT_DECLARED
375 typedef struct WIMStruct WIMStruct;
376 #define WIMLIB_WIMSTRUCT_DECLARED
377 #endif
378
379 #ifdef __WIN32__
380 typedef wchar_t wimlib_tchar;
381 #else
382 /** See @ref sec_encodings */
383 typedef char wimlib_tchar;
384 #endif
385
386 #ifdef __WIN32__
387 /** Path separator for WIM paths passed back to progress callbacks. */
388 #  define WIMLIB_WIM_PATH_SEPARATOR '\\'
389 #  define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
390 #else
391 /** Path separator for WIM paths passed back to progress callbacks. */
392 #  define WIMLIB_WIM_PATH_SEPARATOR '/'
393 #  define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
394 #endif
395
396 #ifdef __GNUC__
397 #  define _wimlib_deprecated __attribute__((deprecated))
398 #else
399 #  define _wimlib_deprecated
400 #endif
401
402 #define WIMLIB_GUID_LEN 16
403
404 /**
405  * Specifies the compression type of a WIM file.
406  */
407 enum wimlib_compression_type {
408         /** An invalid compression type. */
409         WIMLIB_COMPRESSION_TYPE_INVALID = -1,
410
411         /** The WIM does not include any compressed resources. */
412         WIMLIB_COMPRESSION_TYPE_NONE = 0,
413
414         /** Compressed resources in the WIM use LZX compression. */
415         WIMLIB_COMPRESSION_TYPE_LZX = 1,
416
417         /** Compressed resources in the WIM use XPRESS compression. */
418         WIMLIB_COMPRESSION_TYPE_XPRESS = 2,
419
420         /** Compressed resources in the WIM use LZMS compression.  Note: LZMS
421          * compression is only compatible with wimlib v1.6.0 and later and with
422          * WIMGAPI Windows 8 and later (and some restrictions apply on the
423          * latter).  */
424         WIMLIB_COMPRESSION_TYPE_LZMS = 3,
425 };
426
427 /** @} */
428 /** @ingroup G_progress
429  * @{ */
430
431 /** Possible values of the first parameter to the user-supplied
432  * ::wimlib_progress_func_t progress function */
433 enum wimlib_progress_msg {
434
435         /** A WIM image is about to be extracted.  @p info will point to
436          * ::wimlib_progress_info.extract. */
437         WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
438
439         /** A file or directory tree within a WIM image (not the full image) is
440          * about to be extracted.  @p info will point to
441          * ::wimlib_progress_info.extract. */
442         WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
443
444         /** The directory structure of the WIM image is about to be extracted.
445          * @p info will point to ::wimlib_progress_info.extract. */
446         WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
447
448         /** The directory structure of the WIM image has been successfully
449          * extracted.  @p info will point to ::wimlib_progress_info.extract. */
450         WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
451
452         /** The WIM image's files resources are currently being extracted.  @p
453          * info will point to ::wimlib_progress_info.extract. */
454         WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
455
456         /** Starting to read a new part of a split pipable WIM over the pipe.
457          * @p info will point to ::wimlib_progress_info.extract.  */
458         WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
459
460         /** All the WIM files and directories have been extracted, and
461          * timestamps are about to be applied.  @p info will point to
462          * ::wimlib_progress_info.extract. */
463         WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS,
464
465         /** A WIM image has been successfully extracted.  @p info will point to
466          * ::wimlib_progress_info.extract. */
467         WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END,
468
469         /** A file or directory tree within a WIM image (not the full image) has
470          * been successfully extracted.  @p info will point to
471          * ::wimlib_progress_info.extract. */
472         WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END,
473
474         /** The directory or NTFS volume is about to be scanned to build a tree
475          * of WIM dentries in-memory.  @p info will point to
476          * ::wimlib_progress_info.scan. */
477         WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
478
479         /** A directory or file is being scanned.  @p info will point to
480          * ::wimlib_progress_info.scan, and its @p cur_path member will be
481          * valid.  This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE
482          * is passed to wimlib_add_image(). */
483         WIMLIB_PROGRESS_MSG_SCAN_DENTRY,
484
485         /** The directory or NTFS volume has been successfully scanned, and a
486          * tree of WIM dentries has been built in-memory. @p info will point to
487          * ::wimlib_progress_info.scan. */
488         WIMLIB_PROGRESS_MSG_SCAN_END,
489
490         /**
491          * File resources are currently being written to the WIM.
492          * @p info will point to ::wimlib_progress_info.write_streams. */
493         WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
494
495         /**
496          * The metadata resource for each image is about to be written to the
497          * WIM. @p info will not be valid. */
498         WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
499
500         /**
501          * The metadata resource for each image has successfully been writen to
502          * the WIM.  @p info will not be valid. */
503         WIMLIB_PROGRESS_MSG_WRITE_METADATA_END,
504
505         /**
506          * The temporary file has successfully been renamed to the original WIM
507          * file.  Only happens when wimlib_overwrite() is called and the
508          * overwrite is not done in-place.
509          * @p info will point to ::wimlib_progress_info.rename. */
510         WIMLIB_PROGRESS_MSG_RENAME,
511
512         /** The contents of the WIM are being checked against the integrity
513          * table.  Only happens when wimlib_open_wim() is called with the
514          * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag.  @p info will point to
515          * ::wimlib_progress_info.integrity. */
516         WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY,
517
518         /** An integrity table is being calculated for the WIM being written.
519          * Only happens when wimlib_write() or wimlib_overwrite() is called with
520          * the ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag.  @p info will point to
521          * ::wimlib_progress_info.integrity. */
522         WIMLIB_PROGRESS_MSG_CALC_INTEGRITY,
523
524         /** Reserved.  (Previously used for WIMLIB_PROGRESS_MSG_JOIN_STREAMS,
525          * but in wimlib v1.5.0 this was removed to simplify the code and now
526          * you'll get ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages instead.)  */
527         WIMLIB_PROGRESS_MSG_RESERVED,
528
529         /** A wimlib_split() operation is in progress, and a new split part is
530          * about to be started.  @p info will point to
531          * ::wimlib_progress_info.split. */
532         WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART,
533
534         /** A wimlib_split() operation is in progress, and a split part has been
535          * finished. @p info will point to ::wimlib_progress_info.split. */
536         WIMLIB_PROGRESS_MSG_SPLIT_END_PART,
537
538         /**
539          * A WIM update command is just about to be executed; @p info will point
540          * to ::wimlib_progress_info.update.
541          */
542         WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND,
543
544         /**
545          * A WIM update command has just been executed; @p info will point to
546          * ::wimlib_progress_info.update.
547          */
548         WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND,
549
550 };
551
552 /** A pointer to this union is passed to the user-supplied
553  * ::wimlib_progress_func_t progress function.  One (or none) of the structures
554  * contained in this union will be applicable for the operation
555  * (::wimlib_progress_msg) indicated in the first argument to the progress
556  * function. */
557 union wimlib_progress_info {
558
559         /* N.B. I wanted these to be anonymous structs, but Doxygen won't
560          * document them if they aren't given a name... */
561
562         /** Valid on messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. */
563         struct wimlib_progress_info_write_streams {
564                 /** Number of bytes that are going to be written for all the
565                  * streams combined.  This is the amount in uncompressed data.
566                  * (The actual number of bytes will be less if the data is being
567                  * written compressed.) */
568                 uint64_t total_bytes;
569
570                 /** Number of streams that are going to be written. */
571                 uint64_t total_streams;
572
573                 /** Number of uncompressed bytes that have been written so far.
574                  * Will be 0 initially, and equal to @p total_bytes at the end.
575                  * */
576                 uint64_t completed_bytes;
577
578                 /** Number of streams that have been written.  Will be 0
579                  * initially, and equal to @p total_streams at the end. */
580                 uint64_t completed_streams;
581
582                 /** Number of threads that are being used to compress resources
583                  * (if applicable).  */
584                 unsigned num_threads;
585
586                 /** The compression type being used to write the streams; either
587                  * ::WIMLIB_COMPRESSION_TYPE_NONE,
588                  * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or
589                  * ::WIMLIB_COMPRESSION_TYPE_LZX. */
590                 int      compression_type;
591
592                 /** Number of split WIM parts from which streams are being
593                  * written (may be 0 if irrelevant).  */
594                 unsigned total_parts;
595
596                 /** Number of split WIM parts from which streams have been
597                  * written (may be 0 if irrelevant).  */
598                 unsigned completed_parts;
599         } write_streams;
600
601         /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
602          * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
603         struct wimlib_progress_info_scan {
604                 /** Directory or NTFS volume that is being scanned. */
605                 const wimlib_tchar *source;
606
607                 /** Path to the file or directory that is about to be scanned,
608                  * relative to the root of the image capture or the NTFS volume.
609                  * */
610                 const wimlib_tchar *cur_path;
611
612                 enum {
613                         /** File or directory looks okay and will be captured.  */
614                         WIMLIB_SCAN_DENTRY_OK = 0,
615
616                         /** File or directory is being excluded from capture due
617                          * to the capture configuration file, or being an
618                          * absolute symbolic link that points outside of the
619                          * capture directory without ::WIMLIB_ADD_FLAG_NORPFIX.
620                          */
621                         WIMLIB_SCAN_DENTRY_EXCLUDED,
622
623                         /** File or directory is being excluded from capture due
624                          * to being unsupported (e.g. an encrypted or device
625                          * file).  */
626                         WIMLIB_SCAN_DENTRY_UNSUPPORTED,
627                 } status;
628
629                 /** Target path in the WIM.  Only valid on messages
630                  * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
631                  * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
632                 const wimlib_tchar *wim_target_path;
633
634                 /** Number of directories scanned so far, including the root
635                  * directory but excluding any unsupported/excluded directories.
636                  * */
637                 uint64_t num_dirs_scanned;
638
639                 /** Number of non-directories scanned so far, excluding any
640                  * unsupported/excluded files.  */
641                 uint64_t num_nondirs_scanned;
642
643                 /** Number of bytes of file data that have been detected so far.
644                  * This data may not actually have been read yet, and it will
645                  * not actually be written to the WIM file until wimlib_write()
646                  * or wimlib_overwrite() has been called.  */
647                 uint64_t num_bytes_scanned;
648         } scan;
649
650         /** Valid on messages ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
651          * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
652          * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
653          * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, and
654          * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END. */
655         struct wimlib_progress_info_extract {
656                 /** Number of the image being extracted (1-based). */
657                 int image;
658
659                 /** Flags passed to to wimlib_extract_image() */
660                 int extract_flags;
661
662                 /** Full path to the WIM file being extracted. */
663                 const wimlib_tchar *wimfile_name;
664
665                 /** Name of the image being extracted. */
666                 const wimlib_tchar *image_name;
667
668                 /** Directory or NTFS volume to which the image is being
669                  * extracted. */
670                 const wimlib_tchar *target;
671
672                 /** Reserved.  */
673                 const wimlib_tchar *cur_path;
674
675                 /** Number of bytes of uncompressed data that will be extracted.
676                  * Takes into account hard links (they are not counted for each
677                  * link.)  */
678                 uint64_t total_bytes;
679
680                 /** Number of bytes that have been written so far.  Will be 0
681                  * initially, and equal to @p total_bytes at the end. */
682                 uint64_t completed_bytes;
683
684                 /** Number of streams that will be extracted.  This may more or
685                  * less than the number of "files" to be extracted due to
686                  * special cases (hard links, symbolic links, and alternate data
687                  * streams.) */
688                 uint64_t num_streams;
689
690                 /** Path to the root dentry within the WIM for the tree that is
691                  * being extracted.  Will be the empty string when extracting a
692                  * full image. */
693                 const wimlib_tchar *extract_root_wim_source_path;
694
695                 /** Currently only used for
696                  * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.  */
697
698                 unsigned part_number;
699
700                 /** Currently only used for
701                  * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.  */
702                 unsigned total_parts;
703
704                 /** Currently only used for
705                  * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.  */
706                 uint8_t guid[WIMLIB_GUID_LEN];
707         } extract;
708
709         /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
710         struct wimlib_progress_info_rename {
711                 /** Name of the temporary file that the WIM was written to. */
712                 const wimlib_tchar *from;
713
714                 /** Name of the original WIM file to which the temporary file is
715                  * being renamed. */
716                 const wimlib_tchar *to;
717         } rename;
718
719         /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
720          * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
721         struct wimlib_progress_info_update {
722                 /** Pointer to the update command that will be executed or has
723                  * just been executed. */
724                 const struct wimlib_update_command *command;
725
726                 /** Number of update commands that have been completed so far.
727                  */
728                 size_t completed_commands;
729
730                 /** Number of update commands that are being executed as part of
731                  * this call to wimlib_update_image(). */
732                 size_t total_commands;
733         } update;
734
735         /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
736          * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
737         struct wimlib_progress_info_integrity {
738                 /** Number of bytes from the end of the WIM header to the end of
739                  * the lookup table (the area that is covered by the SHA1
740                  * integrity checks.) */
741                 uint64_t total_bytes;
742
743                 /** Number of bytes that have been SHA1-summed so far.  Will be
744                  * 0 initially, and equal @p total_bytes at the end. */
745                 uint64_t completed_bytes;
746
747                 /** Number of chunks that the checksummed region is divided
748                  * into. */
749                 uint32_t total_chunks;
750
751                 /** Number of chunks that have been SHA1-summed so far.   Will
752                  * be 0 initially, and equal to @p total_chunks at the end. */
753                 uint32_t completed_chunks;
754
755                 /** Size of the chunks used for the integrity calculation. */
756                 uint32_t chunk_size;
757
758                 /** Filename of the WIM (only valid if the message is
759                  * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
760                 const wimlib_tchar *filename;
761         } integrity;
762
763         /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
764          * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
765         struct wimlib_progress_info_split {
766                 /** Total size of the original WIM's file and metadata resources
767                  * (compressed). */
768                 uint64_t total_bytes;
769
770                 /** Number of bytes of file and metadata resources that have
771                  * been copied out of the original WIM so far.  Will be 0
772                  * initially, and equal to @p total_bytes at the end. */
773                 uint64_t completed_bytes;
774
775                 /** Number of the split WIM part that is about to be started
776                  * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
777                  * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
778                 unsigned cur_part_number;
779
780                 /** Total number of split WIM parts that are being written.  */
781                 unsigned total_parts;
782
783                 /** Name of the split WIM part that is about to be started
784                  * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
785                  * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
786                 const wimlib_tchar *part_name;
787         } split;
788 };
789
790 /** A user-supplied function that will be called periodically during certain WIM
791  * operations.  The first argument will be the type of operation that is being
792  * performed or is about to be started or has been completed.  The second
793  * argument will be a pointer to one of a number of structures depending on the
794  * first argument.  It may be @c NULL for some message types.
795  *
796  * The return value of the progress function is currently ignored, but it may do
797  * something in the future.  (Set it to 0 for now.)
798  */
799 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
800                                       const union wimlib_progress_info *info);
801
802 /** @} */
803 /** @ingroup G_modifying_wims
804  * @{ */
805
806 /** An array of these structures is passed to wimlib_add_image_multisource() to
807  * specify the sources from which to create a WIM image. */
808 struct wimlib_capture_source {
809         /** Absolute or relative path to a file or directory on the external
810          * filesystem to be included in the WIM image. */
811         wimlib_tchar *fs_source_path;
812
813         /** Destination path in the WIM image.  Leading and trailing slashes are
814          * ignored.  The empty string or @c NULL means the root directory of the
815          * WIM image. */
816         wimlib_tchar *wim_target_path;
817
818         /** Reserved; set to 0. */
819         long reserved;
820 };
821
822 /** Structure that specifies a list of path patterns. */
823 struct wimlib_pattern_list {
824         /** Array of patterns.  The patterns may be modified by library code,
825          * but the @p pats pointer itself will not.  See the man page for
826          * <b>wimlib-imagex capture</b> for more information about allowed
827          * patterns. */
828         wimlib_tchar **pats;
829
830         /** Number of patterns in the @p pats array. */
831         size_t num_pats;
832
833         /** Ignored; may be used by the calling code. */
834         size_t num_allocated_pats;
835 };
836
837 /** A structure that contains lists of wildcards that match paths to treat
838  * specially when capturing a WIM image. */
839 struct wimlib_capture_config {
840         /** Paths matching any pattern this list are excluded from being
841          * captured, except if the same path appears in @p
842          * exclusion_exception_pats. */
843         struct wimlib_pattern_list exclusion_pats;
844
845         /** Paths matching any pattern in this list are never excluded from
846          * being captured. */
847         struct wimlib_pattern_list exclusion_exception_pats;
848
849         /** Reserved for future capture configuration options. */
850         struct wimlib_pattern_list reserved1;
851
852         /** Reserved for future capture configuration options. */
853         struct wimlib_pattern_list reserved2;
854
855         /** Library internal use only. */
856         wimlib_tchar *_prefix;
857
858         /** Library internal use only. */
859         size_t _prefix_num_tchars;
860 };
861
862 /** Set or unset the WIM header flag that marks it read-only
863  * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
864  * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter.  This
865  * is distinct from basic file permissions; this flag can be set on a WIM file
866  * that is physically writable.  If this flag is set, all further operations to
867  * modify the WIM will fail, except calling wimlib_overwrite() with
868  * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
869  * allows you to set this flag persistently on the underlying WIM file.
870  */
871 #define WIMLIB_CHANGE_READONLY_FLAG             0x00000001
872
873 /** Set the GUID (globally unique identifier) of the WIM file to the value
874  * specified in ::wimlib_wim_info.guid of the @p info parameter. */
875 #define WIMLIB_CHANGE_GUID                      0x00000002
876
877 /** Change the bootable image of the WIM to the value specified in
878  * ::wimlib_wim_info.boot_index of the @p info parameter.  */
879 #define WIMLIB_CHANGE_BOOT_INDEX                0x00000004
880
881 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
882  * in ::wimlib_wim_info.has_rpfix of the @p info parameter.  This flag generally
883  * indicates whether an image in the WIM has been captured with reparse-point
884  * fixups enabled.  wimlib also treats this flag as specifying whether to do
885  * reparse-point fixups by default when capturing or applying WIM images.  */
886 #define WIMLIB_CHANGE_RPFIX_FLAG                0x00000008
887
888 /** @} */
889 /** @ingroup G_wim_information
890  * @{ */
891
892 /** General information about a WIM file. */
893 struct wimlib_wim_info {
894
895         /** Globally unique identifier for the WIM file.  Note: all parts of a
896          * split WIM should have an identical value in this field.  */
897         uint8_t  guid[WIMLIB_GUID_LEN];
898
899         /** Number of images in the WIM.  */
900         uint32_t image_count;
901
902         /** 1-based index of the bootable image in the WIM, or 0 if no image is
903          * bootable.  */
904         uint32_t boot_index;
905
906         /** Version of the WIM file.  */
907         uint32_t wim_version;
908
909         /** Chunk size used for compression.  */
910         uint32_t chunk_size;
911
912         /** For split WIMs, the 1-based index of this part within the split WIM;
913          * otherwise 1.  */
914         uint16_t part_number;
915
916         /** For split WIMs, the total number of parts in the split WIM;
917          * otherwise 1.  */
918         uint16_t total_parts;
919
920         /** One of the ::wimlib_compression_type values that specifies the
921          * method used to compress resources in the WIM.  */
922         int32_t  compression_type;
923
924         /** Size of the WIM file in bytes, excluding the XML data and integrity
925          * table.  */
926         uint64_t total_bytes;
927
928         /** 1 if the WIM has an integrity table.  Note: if the ::WIMStruct was
929          * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
930          * this will always be 0, even if the ::WIMStruct was written to
931          * somewhere by calling wimlib_write() with the
932          * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
933         uint32_t has_integrity_table : 1;
934
935         /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
936          * wimlib_create_new_wim(). */
937         uint32_t opened_from_file : 1;
938
939         /** 1 if the WIM is considered readonly for any reason. */
940         uint32_t is_readonly : 1;
941
942         /** 1 if reparse-point fixups are supposedly enabled for one or more
943          * images in the WIM.  */
944         uint32_t has_rpfix : 1;
945
946         /** 1 if the WIM is marked as read-only.  */
947         uint32_t is_marked_readonly : 1;
948
949         /** 1 if the WIM is part of a spanned set.  */
950         uint32_t spanned : 1;
951
952         uint32_t write_in_progress : 1;
953         uint32_t metadata_only : 1;
954         uint32_t resource_only : 1;
955
956         /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE).  */
957         uint32_t pipable : 1;
958         uint32_t reserved_flags : 22;
959         uint32_t reserved[9];
960 };
961
962 /** Information about a unique stream in the WIM file.  (A stream is the same
963  * thing as a "resource", except in the case of packed resources.)  */
964 struct wimlib_resource_entry {
965         /** Uncompressed size of the stream in bytes. */
966         uint64_t uncompressed_size;
967
968         /** Compressed size of the stream in bytes.  This will be the same as @p
969          * uncompressed_size if the stream is uncompressed.  Or, if @p
970          * is_packed_streams is 1, this will be 0.  */
971         uint64_t compressed_size;
972
973         /** Offset, in bytes, of this stream from the start of the WIM file.  Or
974          * if @p packed is 1, then this is actually the offset at which this
975          * stream begins in the uncompressed contents of the packed resource.
976          */
977         uint64_t offset;
978
979         /** SHA1 message digest of the stream's uncompressed contents.  */
980         uint8_t sha1_hash[20];
981
982         /** Which part number of the split WIM this stream is in.  This should
983          * be the same as the part number provided by wimlib_get_wim_info().  */
984         uint32_t part_number;
985
986         /** Number of times this stream is referenced over all WIM images.  */
987         uint32_t reference_count;
988
989         /** 1 if this stream is compressed.  */
990         uint32_t is_compressed : 1;
991
992         /** 1 if this stream is a metadata resource rather than a file resource.
993          * */
994         uint32_t is_metadata : 1;
995
996         uint32_t is_free : 1;
997         uint32_t is_spanned : 1;
998
999         /** 1 if this stream was not found in the lookup table of the
1000          * ::WIMStruct.  This normally implies a missing call to
1001          * wimlib_reference_resource_files() or wimlib_reference_resources().
1002          * */
1003         uint32_t is_missing : 1;
1004
1005         /** 1 if this stream is located in a packed resource which may contain
1006          * other streams (all compressed together) as well.  */
1007         uint32_t packed : 1;
1008
1009         uint32_t reserved_flags : 26;
1010
1011         /** If @p packed is 1, then this will specify the offset of the packed
1012          * resource in the WIM.  */
1013         uint64_t raw_resource_offset_in_wim;
1014
1015         /** If @p is_packed_streams is 1, then this will specify the compressed
1016          * size of the packed resource in the WIM.  */
1017         uint64_t raw_resource_compressed_size;
1018
1019         uint64_t reserved[2];
1020 };
1021
1022 /** A stream of a file in the WIM.  */
1023 struct wimlib_stream_entry {
1024         /** Name of the stream, or NULL if the stream is unnamed. */
1025         const wimlib_tchar *stream_name;
1026         /** Location, size, etc. of the stream within the WIM file.  */
1027         struct wimlib_resource_entry resource;
1028         uint64_t reserved[4];
1029 };
1030
1031 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1032  * Roughly, the information about a "file" in the WIM--- but really a directory
1033  * entry ("dentry") because hard links are allowed.  The hard_link_group_id
1034  * field can be used to distinguish actual file inodes.  */
1035 struct wimlib_dir_entry {
1036         /** Name of the file, or NULL if this file is unnamed (only possible for
1037          * the root directory) */
1038         const wimlib_tchar *filename;
1039
1040         /** 8.3 DOS name of this file, or NULL if this file has no such name.
1041          * */
1042         const wimlib_tchar *dos_name;
1043
1044         /** Full path to this file within the WIM image.  */
1045         const wimlib_tchar *full_path;
1046
1047         /** Depth of this directory entry, where 0 is the root, 1 is the root's
1048          * children, ..., etc. */
1049         size_t depth;
1050
1051         /** Pointer to the security descriptor for this file, in Windows
1052          * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1053          * security descriptor.  */
1054         const char *security_descriptor;
1055
1056         /** Length of the above security descriptor.  */
1057         size_t security_descriptor_size;
1058
1059 #define WIMLIB_FILE_ATTRIBUTE_READONLY            0x00000001
1060 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN              0x00000002
1061 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM              0x00000004
1062 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY           0x00000010
1063 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE             0x00000020
1064 #define WIMLIB_FILE_ATTRIBUTE_DEVICE              0x00000040
1065 #define WIMLIB_FILE_ATTRIBUTE_NORMAL              0x00000080
1066 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY           0x00000100
1067 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE         0x00000200
1068 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT       0x00000400
1069 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED          0x00000800
1070 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE             0x00001000
1071 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1072 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED           0x00004000
1073 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL             0x00010000
1074         /** File attributes, such as whether the file is a directory or not.
1075          * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1076          * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1077          * on other platforms.  */
1078         uint32_t attributes;
1079
1080 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO        0x00000000
1081 #define WIMLIB_REPARSE_TAG_RESERVED_ONE         0x00000001
1082 #define WIMLIB_REPARSE_TAG_MOUNT_POINT          0xA0000003
1083 #define WIMLIB_REPARSE_TAG_HSM                  0xC0000004
1084 #define WIMLIB_REPARSE_TAG_HSM2                 0x80000006
1085 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER      0x80000005
1086 #define WIMLIB_REPARSE_TAG_SIS                  0x80000007
1087 #define WIMLIB_REPARSE_TAG_DFS                  0x8000000A
1088 #define WIMLIB_REPARSE_TAG_DFSR                 0x80000012
1089 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER       0x8000000B
1090 #define WIMLIB_REPARSE_TAG_SYMLINK              0xA000000C
1091         /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
1092          * attributes), this will give the reparse tag.  This tells you whether
1093          * the reparse point is a symbolic link, junction point, or some other,
1094          * more unusual kind of reparse point.  */
1095         uint32_t reparse_tag;
1096
1097         /*  Number of (hard) links to this file.  */
1098         uint32_t num_links;
1099
1100         /** Number of named data streams that this file has.  Normally 0.  */
1101         uint32_t num_named_streams;
1102
1103         /** Roughly, the inode number of this file.  However, it may be 0 if
1104          * @p num_links == 1.  */
1105         uint64_t hard_link_group_id;
1106
1107         /** Time this file was created.  */
1108         struct timespec creation_time;
1109
1110         /** Time this file was last written to.  */
1111         struct timespec last_write_time;
1112
1113         /** Time this file was last accessed.  */
1114         struct timespec last_access_time;
1115         uint64_t reserved[16];
1116
1117         /** Array of streams that make up this file.  The first entry will
1118          * always exist and will correspond to the unnamed data stream (default
1119          * file contents), so it will have @p stream_name == @c NULL.  There
1120          * will then be @p num_named_streams additional entries that specify the
1121          * named data streams, if any, each of which will have @p stream_name !=
1122          * @c NULL.  */
1123         struct wimlib_stream_entry streams[];
1124 };
1125
1126 /**
1127  * Type of a callback function to wimlib_iterate_dir_tree().  Must return 0 on
1128  * success.
1129  */
1130 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1131                                                   void *user_ctx);
1132
1133 /**
1134  * Type of a callback function to wimlib_iterate_lookup_table().  Must return 0
1135  * on success.
1136  */
1137 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1138                                                       void *user_ctx);
1139
1140 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1141  * just on the specified path. */
1142 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1143
1144 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1145  * itself; only its children (in the case of a non-empty directory) */
1146 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN  0x00000002
1147
1148 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1149  * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1150  * table of the ::WIMStruct.  The default behavior without this flag is to fill
1151  * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1152  * wimlib_resource_entry::is_missing "is_missing" flag.  */
1153 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED  0x00000004
1154
1155
1156 /** @} */
1157 /** @ingroup G_modifying_wims
1158  * @{ */
1159
1160 /** Directly capture a NTFS volume rather than a generic directory.  This flag
1161  * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1162  * ::WIMLIB_ADD_FLAG_UNIX_DATA.   */
1163 #define WIMLIB_ADD_FLAG_NTFS                    0x00000001
1164
1165 /** Follow symlinks; archive and dump the files they point to.  Cannot be used
1166  * with ::WIMLIB_ADD_FLAG_NTFS. */
1167 #define WIMLIB_ADD_FLAG_DEREFERENCE             0x00000002
1168
1169 /** Call the progress function with the message
1170  * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file is starting to
1171  * be scanned, or when a directory or file is being excluded from capture.  */
1172 #define WIMLIB_ADD_FLAG_VERBOSE                 0x00000004
1173
1174 /** Mark the image being added as the bootable image of the WIM. */
1175 #define WIMLIB_ADD_FLAG_BOOT                    0x00000008
1176
1177 /** Store the UNIX owner, group, and mode.  This is done by adding a special
1178  * alternate data stream to each regular file, symbolic link, and directory to
1179  * contain this information.  Please note that this flag is for convenience
1180  * only; Microsoft's @a imagex.exe will not understand this special information.
1181  * This flag cannot be combined with ::WIMLIB_ADD_FLAG_NTFS.  */
1182 #define WIMLIB_ADD_FLAG_UNIX_DATA               0x00000010
1183
1184 /** Do not capture security descriptors.  Only has an effect in NTFS capture
1185  * mode, or in Win32 native builds. */
1186 #define WIMLIB_ADD_FLAG_NO_ACLS                 0x00000020
1187
1188 /** Fail immediately if the full security descriptor of any file or directory
1189  * cannot be accessed.  Only has an effect in Win32 native builds.  The default
1190  * behavior without this flag is to first try omitting the SACL from the
1191  * security descriptor, then to try omitting the security descriptor entirely.
1192  * */
1193 #define WIMLIB_ADD_FLAG_STRICT_ACLS             0x00000040
1194
1195 /** Call the progress function with the message
1196  * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1197  * capture.  This is a subset of the messages provided by
1198  * ::WIMLIB_ADD_FLAG_VERBOSE. */
1199 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE         0x00000080
1200
1201 /** Reparse-point fixups:  Modify absolute symbolic links (or junction points,
1202  * in the case of Windows) that point inside the directory being captured to
1203  * instead be absolute relative to the directory being captured, rather than the
1204  * current root; also exclude absolute symbolic links that point outside the
1205  * directory tree being captured.
1206  *
1207  * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
1208  * the WIM header or if this is the first image being added.
1209  * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
1210  * reparse point fixups enabled and currently cannot be unset. */
1211 #define WIMLIB_ADD_FLAG_RPFIX                   0x00000100
1212
1213 /** Don't do reparse point fixups.  The default behavior is described in the
1214  * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
1215 #define WIMLIB_ADD_FLAG_NORPFIX                 0x00000200
1216
1217 /** Do not automatically exclude unsupported files or directories from capture;
1218  * e.g. encrypted directories in NTFS-3g capture mode, or device files and FIFOs
1219  * on UNIX-like systems.  Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
1220  * such a file is encountered.  */
1221 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE  0x00000400
1222
1223 /** Automatically select a capture configuration appropriate for capturing
1224  * filesystems containing Windows operating systems.  When this flag is
1225  * specified, the corresponding @p config parameter or member must be @c NULL.
1226  *
1227  * Currently, selecting this capture configuration will cause the following
1228  * files and directories to be excluded from capture:
1229  *
1230  * - "\$ntfs.log"
1231  * - "\hiberfil.sys"
1232  * - "\pagefile.sys"
1233  * - "\System Volume Information"
1234  * - "\RECYCLER"
1235  * - "\Windows\CSC"
1236  *
1237  * Note that the default behavior--- that is, when this flag is not specified
1238  * and @p config is @c NULL--- is to use no capture configuration, meaning that
1239  * no files are excluded from capture.
1240  */
1241 #define WIMLIB_ADD_FLAG_WINCONFIG               0x00000800
1242
1243 #define WIMLIB_ADD_IMAGE_FLAG_NTFS              WIMLIB_ADD_FLAG_NTFS
1244 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE       WIMLIB_ADD_FLAG_DEREFERENCE
1245 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE           WIMLIB_ADD_FLAG_VERBOSE
1246 #define WIMLIB_ADD_IMAGE_FLAG_BOOT              WIMLIB_ADD_FLAG_BOOT
1247 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA         WIMLIB_ADD_FLAG_UNIX_DATA
1248 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS           WIMLIB_ADD_FLAG_NO_ACLS
1249 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS       WIMLIB_ADD_FLAG_STRICT_ACLS
1250 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE   WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1251 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX             WIMLIB_ADD_FLAG_RPFIX
1252 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX           WIMLIB_ADD_FLAG_NORPFIX
1253 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1254                                                 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1255 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG         WIMLIB_ADD_FLAG_WINCONFIG
1256
1257 /** @} */
1258 /** @ingroup G_modifying_wims
1259  * @{ */
1260
1261 /** Do not issue an error if the path to delete does not exist. */
1262 #define WIMLIB_DELETE_FLAG_FORCE                        0x00000001
1263
1264 /** Delete the file or directory tree recursively; if not specified, an error is
1265  * issued if the path to delete is a directory. */
1266 #define WIMLIB_DELETE_FLAG_RECURSIVE                    0x00000002
1267
1268 /** @} */
1269 /** @ingroup G_modifying_wims
1270  * @{ */
1271
1272 /**
1273  * If a single image is being exported, mark it bootable in the destination WIM.
1274  * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1275  * the image in the source WIM (if any) that is marked as bootable is also
1276  * marked as bootable in the destination WIM.
1277  */
1278 #define WIMLIB_EXPORT_FLAG_BOOT                         0x00000001
1279
1280 /** Give the exported image(s) no names.  Avoids problems with image name
1281  * collisions.
1282  */
1283 #define WIMLIB_EXPORT_FLAG_NO_NAMES                     0x00000002
1284
1285 /** Give the exported image(s) no descriptions.  */
1286 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS              0x00000004
1287
1288 /** @} */
1289 /** @ingroup G_extracting_wims
1290  * @{ */
1291
1292 /** Extract the image directly to a NTFS volume rather than a generic directory.
1293  * This mode is only available if wimlib was compiled with libntfs-3g support;
1294  * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned.  In this mode, the
1295  * extraction target will be interpreted as the path to a NTFS volume image (as
1296  * a regular file or block device) rather than a directory.  It will be opened
1297  * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1298  * root directory.  Note: this flag cannot be used when wimlib_extract_image()
1299  * is called with ::WIMLIB_ALL_IMAGES as the @p image.  */
1300 #define WIMLIB_EXTRACT_FLAG_NTFS                        0x00000001
1301
1302 /** When identical files are extracted from the WIM, always hard link them
1303  * together.  */
1304 #define WIMLIB_EXTRACT_FLAG_HARDLINK                    0x00000002
1305
1306 /** When identical files are extracted from the WIM, always symlink them
1307  * together.  */
1308 #define WIMLIB_EXTRACT_FLAG_SYMLINK                     0x00000004
1309
1310 /** This flag no longer does anything but is reserved for future use.  */
1311 #define WIMLIB_EXTRACT_FLAG_VERBOSE                     0x00000008
1312
1313 /** Read the WIM file sequentially while extracting the image.  As of wimlib
1314  * v1.6.0 this is the default behavior, and this flag no longer does anything.
1315  */
1316 #define WIMLIB_EXTRACT_FLAG_SEQUENTIAL                  0x00000010
1317
1318 /** Extract special UNIX data captured with ::WIMLIB_ADD_FLAG_UNIX_DATA.  Only
1319  * valid on UNIX-like platforms, and when ::WIMLIB_EXTRACT_FLAG_NTFS was not
1320  * specified.  */
1321 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA                   0x00000020
1322
1323 /** Do not extract security descriptors.  */
1324 #define WIMLIB_EXTRACT_FLAG_NO_ACLS                     0x00000040
1325
1326 /** Fail immediately if the full security descriptor of any file or directory
1327  * cannot be set exactly as specified in the WIM file.  On Windows, the default
1328  * behavior without this flag is to fall back to setting the security descriptor
1329  * with the SACL omitted, then only the default inherited security descriptor,
1330  * if we do not have permission to set the desired one.  */
1331 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS                 0x00000080
1332
1333 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX.  This forces
1334  * reparse-point fixups on, so absolute symbolic links or junction points will
1335  * be fixed to be absolute relative to the actual extraction root.  Reparse
1336  * point fixups are done by default if WIM_HDR_FLAG_RP_FIX is set in the WIM
1337  * header.  This flag may only be specified when extracting a full image (not a
1338  * file or directory tree within one).  */
1339 #define WIMLIB_EXTRACT_FLAG_RPFIX                       0x00000100
1340
1341 /** Force reparse-point fixups on extraction off, regardless of the state of the
1342  * WIM_HDR_FLAG_RP_FIX flag in the WIM header.  */
1343 #define WIMLIB_EXTRACT_FLAG_NORPFIX                     0x00000200
1344
1345 /** Extract the specified file to standard output.  This is only valid in an
1346  * extraction command that specifies the extraction of a regular file in the WIM
1347  * image.  */
1348 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT                   0x00000400
1349
1350 /** Instead of ignoring files and directories with names that cannot be
1351  * represented on the current platform (note: Windows has more restrictions on
1352  * filenames than POSIX-compliant systems), try to replace characters or append
1353  * junk to the names so that they can be extracted in some form.  */
1354 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES   0x00000800
1355
1356 /** On Windows, when there exist two or more files with the same case
1357  * insensitive name but different case sensitive names, try to extract them all
1358  * by appending junk to the end of them, rather than arbitrarily extracting only
1359  * one.  */
1360 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS          0x00001000
1361
1362 /** Do not ignore failure to set timestamps on extracted files.  */
1363 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS           0x00002000
1364
1365 /** Do not ignore failure to set short names on extracted files.  */
1366 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES          0x00004000
1367
1368 /** Do not ignore failure to extract symbolic links (and junction points, on
1369  * Windows) due to permissions problems.  By default, such failures are ignored
1370  * since the default configuration of Windows only allows the Administrator to
1371  * create symbolic links.  */
1372 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS             0x00008000
1373
1374 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1375  * behavior is currently less than satisfactory.  Do not use (yet).  */
1376 #define WIMLIB_EXTRACT_FLAG_RESUME                      0x00010000
1377
1378 /** Perform the extraction ordered by the tree of files to extract rather than
1379  * how the underlying streams are arranged in the WIM file.  For regular WIM
1380  * files this may decrease or increase performance, depending on various
1381  * factors.  For WIM files containing packed streams this will decrease
1382  * performance.  */
1383 #define WIMLIB_EXTRACT_FLAG_FILE_ORDER                  0x00020000
1384
1385 /** @} */
1386 /** @ingroup G_mounting_wim_images
1387  * @{ */
1388
1389 /** Mount the WIM image read-write rather than the default of read-only. */
1390 #define WIMLIB_MOUNT_FLAG_READWRITE                     0x00000001
1391
1392 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1393 #define WIMLIB_MOUNT_FLAG_DEBUG                         0x00000002
1394
1395 /** Do not allow accessing alternate data streams in the mounted WIM image. */
1396 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE         0x00000004
1397
1398 /** Access alternate data streams in the mounted WIM image through extended file
1399  * attributes.  This is the default mode. */
1400 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR        0x00000008
1401
1402 /** Access alternate data streams in the mounted WIM image by specifying the
1403  * file name, a colon, then the alternate file stream name. */
1404 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS      0x00000010
1405
1406 /** Use UNIX file owners, groups, and modes if available in the WIM (see
1407  * ::WIMLIB_ADD_FLAG_UNIX_DATA). */
1408 #define WIMLIB_MOUNT_FLAG_UNIX_DATA                     0x00000020
1409
1410 /** Allow other users to see the mounted filesystem.  (this passes the @c
1411  * allow_other option to FUSE mount) */
1412 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER                   0x00000040
1413
1414 /** @} */
1415 /** @ingroup G_creating_and_opening_wims
1416  * @{ */
1417
1418 /** Verify the WIM contents against the WIM's integrity table, if present.  This
1419  * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1420  * checksummed and checked against the SHA1 message digests specified in the
1421  * integrity table.  ::WIMLIB_ERR_INTEGRITY is returned if there are any
1422  * mismatches (or, ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE is returned if the
1423  * integrity table is invalid).  */
1424 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY                0x00000001
1425
1426 /** Issue an error if the WIM is part of a split WIM.  Software can provide
1427  * this flag for convenience if it explicitly does not want to support split
1428  * WIMs.  */
1429 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT                 0x00000002
1430
1431 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
1432  * is not.  A WIM is considered writable only if it is writable at the
1433  * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
1434  * header, and is not part of a spanned set.  It is not required to provide this
1435  * flag before attempting to make changes to the WIM, but with this flag you get
1436  * an error sooner rather than later. */
1437 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS                   0x00000004
1438
1439 /** @} */
1440 /** @ingroup G_mounting_wim_images
1441  * @{ */
1442
1443 /** See ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY.  */
1444 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY             0x00000001
1445
1446 /** Unless this flag is given, changes to a read-write mounted WIM are
1447  * discarded.  Ignored for read-only mounts.  */
1448 #define WIMLIB_UNMOUNT_FLAG_COMMIT                      0x00000002
1449
1450 /** See ::WIMLIB_WRITE_FLAG_REBUILD.  */
1451 #define WIMLIB_UNMOUNT_FLAG_REBUILD                     0x00000004
1452
1453 /** See ::WIMLIB_WRITE_FLAG_RECOMPRESS */
1454 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS                  0x00000008
1455
1456 /** Do a "lazy" unmount (detach filesystem immediately, even if busy).  */
1457 #define WIMLIB_UNMOUNT_FLAG_LAZY                        0x00000010
1458
1459 /** @} */
1460 /** @ingroup G_modifying_wims
1461  * @{ */
1462
1463 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1464  * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages.  */
1465 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS                0x00000001
1466
1467 /** @} */
1468 /** @ingroup G_writing_and_overwriting_wims
1469  * @{ */
1470
1471 /** Include an integrity table in the WIM.
1472  *
1473  * For WIMs created with wimlib_open_wim(), the default behavior is to include
1474  * an integrity table if and only if one was present before.  For WIMs created
1475  * with wimlib_create_new_wim(), the default behavior is to not include an
1476  * integrity table.  */
1477 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY               0x00000001
1478
1479 /** Do not include an integrity table in the new WIM file.  This is the default
1480  * behavior, unless the WIM already included an integrity table.  */
1481 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY            0x00000002
1482
1483 /** Write the WIM as "pipable".  After writing a WIM with this flag specified,
1484  * images from it can be applied directly from a pipe using
1485  * wimlib_extract_image_from_pipe().  See the documentation for the --pipable
1486  * flag of `wimlib-imagex capture' for more information.  Beware: WIMs written
1487  * with this flag will not be compatible with Microsoft's software.
1488  *
1489  * For WIMs created with wimlib_open_wim(), the default behavior is to write the
1490  * WIM as pipable if and only if it was pipable before.  For WIMs created with
1491  * wimlib_create_new_wim(), the default behavior is to write the WIM as
1492  * non-pipable.  */
1493 #define WIMLIB_WRITE_FLAG_PIPABLE                       0x00000004
1494
1495 /** Do not write the WIM as "pipable".  This is the default behavior, unless the
1496  * WIM was pipable already.  */
1497 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE                   0x00000008
1498
1499 /** Recompress all resources, even if they could otherwise be copied from a
1500  * different WIM with the same compression type (in the case of
1501  * wimlib_export_image() being called previously).  This flag is also valid in
1502  * the @p wim_write_flags of wimlib_join(), in which case all resources included
1503  * in the joined WIM file will be recompressed.  */
1504 #define WIMLIB_WRITE_FLAG_RECOMPRESS                    0x00000010
1505
1506 /** Call fsync() just before the WIM file is closed.  */
1507 #define WIMLIB_WRITE_FLAG_FSYNC                         0x00000020
1508
1509 /** wimlib_overwrite() only:  Re-build the entire WIM file rather than appending
1510  * data to it if possible.  */
1511 #define WIMLIB_WRITE_FLAG_REBUILD                       0x00000040
1512
1513 /** wimlib_overwrite() only:  Specifying this flag overrides the default
1514  * behavior of wimlib_overwrite() after one or more calls to
1515  * wimlib_delete_image(), which is to rebuild the entire WIM.  With this flag,
1516  * only minimal changes to correctly remove the image from the WIM will be
1517  * taken.  In particular, all streams will be left alone, even if they are no
1518  * longer referenced.  This is probably not what you want, because almost no
1519  * space will be saved by deleting an image in this way.  */
1520 #define WIMLIB_WRITE_FLAG_SOFT_DELETE                   0x00000080
1521
1522 /** wimlib_overwrite() only:  Allow overwriting the WIM even if the readonly
1523  * flag is set in the WIM header.  This can be used in combination with
1524  * wimlib_set_wim_info() with the ::WIMLIB_CHANGE_READONLY_FLAG flag to actually
1525  * set the readonly flag on the on-disk WIM file.  */
1526 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG          0x00000100
1527
1528 /** Do not include non-metadata resources already present in other WIMs.  This
1529  * flag can be used to write a "delta" WIM after resources from the WIM on which
1530  * the delta is to be based were referenced with
1531  * wimlib_reference_resource_files() or wimlib_reference_resources().  */
1532 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS            0x00000200
1533
1534 /** Asserts that for writes of all WIM images, all streams needed for the WIM
1535  * are already present (not in external resource WIMs) and their reference
1536  * counts are correct, so the code does not need to recalculate which streams
1537  * are referenced.  This is for optimization purposes only, since with this flag
1538  * specified, the metadata resources may not need to be decompressed and parsed.
1539  *
1540  * This flag can be passed to wimlib_write() and wimlib_write_to_fd(), but is
1541  * already implied for wimlib_overwrite().  */
1542 #define WIMLIB_WRITE_FLAG_STREAMS_OK                    0x00000400
1543
1544 #define WIMLIB_WRITE_FLAG_RESERVED                      0x00000800
1545
1546 /**
1547  * When writing streams in the resulting WIM file, pack multiple streams into a
1548  * single WIM resource instead of compressing them independently.  This tends to
1549  * produce a better compression ratio at the cost of less random access.
1550  * However, WIMs created with this flag are only compatible with wimlib v1.6.0
1551  * or later and WIMGAPI Windows 8 or later, seemingly for Windows Setup only and
1552  * <b>not including ImageX and Dism</b>.  WIMs created with this flag must use
1553  * version number 3584 in their header instead of 68864.
1554  *
1555  * If this flag is passed to wimlib_overwrite() and the WIM did not previously
1556  * contain packed streams, the WIM's version number will be changed to 3584 and
1557  * the new streams will be written packed.  Use ::WIMLIB_WRITE_FLAG_REBUILD to
1558  * force the WIM to be fully rebuilt.  */
1559 #define WIMLIB_WRITE_FLAG_PACK_STREAMS                  0x00001000
1560
1561 /** @} */
1562 /** @ingroup G_general
1563  * @{ */
1564
1565 /** Assume that strings are represented in UTF-8, even if this is not the
1566  * locale's character encoding.  This flag is ignored on Windows, where wimlib
1567  * always uses UTF-16LE.  */
1568 #define WIMLIB_INIT_FLAG_ASSUME_UTF8                    0x00000001
1569
1570 /** Windows-only: do not attempt to acquire additional privileges (currently
1571  * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1572  * SeTakeOwnershipPrivilege) when initializing the library.  This is intended
1573  * for the case where the calling program manages these privileges itself.
1574  * Note: no error is issued if privileges cannot be acquired, although related
1575  * errors may be reported later, depending on if the operations performed
1576  * actually require additional privileges or not.  */
1577 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES        0x00000002
1578
1579 /** Windows only:  If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1580  * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1581  * to read all possible data and metadata for a capture operation could not be
1582  * acquired.  Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1583  */
1584 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES      0x00000004
1585
1586 /** Windows only:  If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1587  * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1588  * to restore all possible data and metadata for an apply operation could not be
1589  * acquired.  Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1590  */
1591 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES        0x00000008
1592
1593 /** @} */
1594 /** @ingroup G_nonstandalone_wims
1595  * @{ */
1596
1597 /** wimlib_reference_resource_files() only:  Enable shell-style filename
1598  * globbing.  */
1599 #define WIMLIB_REF_FLAG_GLOB_ENABLE             0x00000001
1600
1601 /** wimlib_reference_resource_files() only:  Issue an error
1602  * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files.  The
1603  * default behavior without this flag is to issue no error at that point, but
1604  * then attempt to open the glob as a literal path, which of course will fail
1605  * anyway if no file exists at that path.  No effect if
1606  * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified.  */
1607 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH     0x00000002
1608
1609 /** @} */
1610 /** @ingroup G_modifying_wims
1611  * @{ */
1612
1613 /** The specific type of update to perform. */
1614 enum wimlib_update_op {
1615         /** Add a new file or directory tree to the WIM image in a
1616          * certain location. */
1617         WIMLIB_UPDATE_OP_ADD = 0,
1618
1619         /** Delete a file or directory tree from the WIM image. */
1620         WIMLIB_UPDATE_OP_DELETE,
1621
1622         /** Rename a file or directory tree in the WIM image. */
1623         WIMLIB_UPDATE_OP_RENAME,
1624 };
1625
1626 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1627 struct wimlib_add_command {
1628         /** Filesystem path to the file or directory tree to
1629          * add. */
1630         wimlib_tchar *fs_source_path;
1631         /** Path, specified from the root of the WIM image, at
1632          * which to add the file or directory tree within the
1633          * WIM image. */
1634         wimlib_tchar *wim_target_path;
1635
1636         /** Configuration for excluded files.  @c NULL means
1637          * exclude no files (use no configuration), unless
1638          * ::WIMLIB_ADD_FLAG_WINCONFIG is specified in @p
1639          * add_flags.  */
1640         struct wimlib_capture_config *config;
1641
1642         /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1643         int add_flags;
1644 };
1645
1646 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1647 struct wimlib_delete_command {
1648         /** Path, specified from the root of the WIM image, for
1649          * the file or directory tree within the WIM image to be
1650          * deleted. */
1651         wimlib_tchar *wim_path;
1652         /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1653         int delete_flags;
1654 };
1655
1656 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1657 struct wimlib_rename_command {
1658         /** Path, specified from the root of the WIM image, for
1659          * the source file or directory tree within the WIM
1660          * image. */
1661         wimlib_tchar *wim_source_path;
1662         /** Path, specified from the root of the WIM image, for
1663          * the destination file or directory tree within the WIM
1664          * image. */
1665         wimlib_tchar *wim_target_path;
1666         /** Reserved; set to 0. */
1667         int rename_flags;
1668 };
1669
1670 /** Specification of an update to perform on a WIM image. */
1671 struct wimlib_update_command {
1672
1673         enum wimlib_update_op op;
1674
1675         union {
1676                 struct wimlib_add_command add;
1677                 struct wimlib_delete_command delete_; /* Underscore is for C++
1678                                                          compatibility.  */
1679                 struct wimlib_rename_command rename;
1680         };
1681 };
1682
1683 /** @} */
1684 /** @ingroup G_extracting_wims
1685  * @{ */
1686
1687 /** Specification of a file or directory tree to extract from a WIM image.  Used
1688  * in calls to wimlib_extract_files().  */
1689 struct wimlib_extract_command {
1690         /** Path to file or directory tree within the WIM image to extract.  It
1691          * must be provided as an absolute path from the root of the WIM image.
1692          * The path separators may be either forward slashes or backslashes. */
1693         wimlib_tchar *wim_source_path;
1694
1695         /** Filesystem path to extract the file or directory tree to. */
1696         wimlib_tchar *fs_dest_path;
1697
1698         /** Bitwise or of zero or more of the WIMLIB_EXTRACT_FLAG_* flags. */
1699         int extract_flags;
1700 };
1701
1702
1703 /** @} */
1704 /** @ingroup G_general
1705  * @{ */
1706
1707 /**
1708  * Possible values of the error code returned by many functions in wimlib.
1709  *
1710  * See the documentation for each wimlib function to see specifically what error
1711  * codes can be returned by a given function, and what they mean.
1712  */
1713 enum wimlib_error_code {
1714         WIMLIB_ERR_SUCCESS = 0,
1715         WIMLIB_ERR_ALREADY_LOCKED,
1716         WIMLIB_ERR_DECOMPRESSION,
1717         WIMLIB_ERR_DELETE_STAGING_DIR,
1718         WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED,
1719         WIMLIB_ERR_FORK,
1720         WIMLIB_ERR_FUSE,
1721         WIMLIB_ERR_FUSERMOUNT,
1722         WIMLIB_ERR_GLOB_HAD_NO_MATCHES,
1723         WIMLIB_ERR_ICONV_NOT_AVAILABLE,
1724         WIMLIB_ERR_IMAGE_COUNT,
1725         WIMLIB_ERR_IMAGE_NAME_COLLISION,
1726         WIMLIB_ERR_INSUFFICIENT_PRIVILEGES,
1727         WIMLIB_ERR_INTEGRITY,
1728         WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
1729         WIMLIB_ERR_INVALID_CHUNK_SIZE,
1730         WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
1731         WIMLIB_ERR_INVALID_HEADER,
1732         WIMLIB_ERR_INVALID_IMAGE,
1733         WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
1734         WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
1735         WIMLIB_ERR_INVALID_METADATA_RESOURCE,
1736         WIMLIB_ERR_INVALID_MULTIBYTE_STRING,
1737         WIMLIB_ERR_INVALID_OVERLAY,
1738         WIMLIB_ERR_INVALID_PARAM,
1739         WIMLIB_ERR_INVALID_PART_NUMBER,
1740         WIMLIB_ERR_INVALID_PIPABLE_WIM,
1741         WIMLIB_ERR_INVALID_REPARSE_DATA,
1742         WIMLIB_ERR_INVALID_RESOURCE_HASH,
1743         WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE,
1744         WIMLIB_ERR_INVALID_UTF16_STRING,
1745         WIMLIB_ERR_INVALID_UTF8_STRING,
1746         WIMLIB_ERR_IS_DIRECTORY,
1747         WIMLIB_ERR_IS_SPLIT_WIM,
1748         WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE,
1749         WIMLIB_ERR_LINK,
1750         WIMLIB_ERR_METADATA_NOT_FOUND,
1751         WIMLIB_ERR_MKDIR,
1752         WIMLIB_ERR_MQUEUE,
1753         WIMLIB_ERR_NOMEM,
1754         WIMLIB_ERR_NOTDIR,
1755         WIMLIB_ERR_NOTEMPTY,
1756         WIMLIB_ERR_NOT_A_REGULAR_FILE,
1757         WIMLIB_ERR_NOT_A_WIM_FILE,
1758         WIMLIB_ERR_NOT_PIPABLE,
1759         WIMLIB_ERR_NO_FILENAME,
1760         WIMLIB_ERR_NTFS_3G,
1761         WIMLIB_ERR_OPEN,
1762         WIMLIB_ERR_OPENDIR,
1763         WIMLIB_ERR_PATH_DOES_NOT_EXIST,
1764         WIMLIB_ERR_READ,
1765         WIMLIB_ERR_READLINK,
1766         WIMLIB_ERR_RENAME,
1767         WIMLIB_ERR_REOPEN,
1768         WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED,
1769         WIMLIB_ERR_RESOURCE_NOT_FOUND,
1770         WIMLIB_ERR_RESOURCE_ORDER,
1771         WIMLIB_ERR_SET_ATTRIBUTES,
1772         WIMLIB_ERR_SET_REPARSE_DATA,
1773         WIMLIB_ERR_SET_SECURITY,
1774         WIMLIB_ERR_SET_SHORT_NAME,
1775         WIMLIB_ERR_SET_TIMESTAMPS,
1776         WIMLIB_ERR_SPLIT_INVALID,
1777         WIMLIB_ERR_STAT,
1778         WIMLIB_ERR_TIMEOUT,
1779         WIMLIB_ERR_UNEXPECTED_END_OF_FILE,
1780         WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE,
1781         WIMLIB_ERR_UNKNOWN_VERSION,
1782         WIMLIB_ERR_UNSUPPORTED,
1783         WIMLIB_ERR_UNSUPPORTED_FILE,
1784         WIMLIB_ERR_VOLUME_LACKS_FEATURES,
1785         WIMLIB_ERR_WIM_IS_READONLY,
1786         WIMLIB_ERR_WRITE,
1787         WIMLIB_ERR_XML,
1788 };
1789
1790
1791 /** Used to indicate no WIM image or an invalid WIM image. */
1792 #define WIMLIB_NO_IMAGE         0
1793
1794 /** Used to specify all images in the WIM. */
1795 #define WIMLIB_ALL_IMAGES       (-1)
1796
1797 /**
1798  * @ingroup G_modifying_wims
1799  *
1800  * Appends an empty image to a WIM file.  This empty image will initially
1801  * contain no files or directories, although if written without further
1802  * modifications, a root directory will be created automatically for it.  After
1803  * calling this function, you can use wimlib_update_image() to add files to the
1804  * new WIM image.  This gives you slightly more control over making the new
1805  * image compared to calling wimlib_add_image() or
1806  * wimlib_add_image_multisource() directly.
1807  *
1808  * @param wim
1809  *      Pointer to the ::WIMStruct for the WIM file to which the image is to be
1810  *      added.
1811  * @param name
1812  *      Name to give the new image.  If @c NULL or empty, the new image is given
1813  *      no name.  If nonempty, it must specify a name that does not already
1814  *      exist in @p wim.
1815  * @param new_idx_ret
1816  *      If non-<code>NULL</code>, the index of the newly added image is returned
1817  *      in this location.
1818  *
1819  * @return 0 on success; nonzero on failure.  The possible error codes are:
1820  *
1821  * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1822  *      There is already an image in @p wim named @p name.
1823  * @retval ::WIMLIB_ERR_NOMEM
1824  *      Failed to allocate the memory needed to add the new image.
1825  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1826  *      The WIM file is considered read-only because of any of the reasons
1827  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1828  *      flag.
1829  */
1830 extern int
1831 wimlib_add_empty_image(WIMStruct *wim,
1832                        const wimlib_tchar *name,
1833                        int *new_idx_ret);
1834
1835 /**
1836  * @ingroup G_modifying_wims
1837  *
1838  * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
1839  *
1840  * The directory tree or NTFS volume is scanned immediately to load the dentry
1841  * tree into memory, and file attributes and symbolic links are read.  However,
1842  * actual file data is not read until wimlib_write() or wimlib_overwrite() is
1843  * called.
1844  *
1845  * See the manual page for the @b wimlib-imagex program for more information
1846  * about the "normal" capture mode versus the NTFS capture mode (entered by
1847  * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
1848  *
1849  * Note that @b no changes are committed to the underlying WIM file (if
1850  * any) until wimlib_write() or wimlib_overwrite() is called.
1851  *
1852  * @param wim
1853  *      Pointer to the ::WIMStruct for a WIM file to which the image will be
1854  *      added.
1855  * @param source
1856  *      A path to a directory or unmounted NTFS volume that will be captured as
1857  *      a WIM image.
1858  * @param name
1859  *      Name to give the new image.  If @c NULL or empty, the new image is given
1860  *      no name.  If nonempty, it must specify a name that does not already
1861  *      exist in @p wim.
1862  * @param config
1863  *      Capture configuration that specifies files, directories, or path globs
1864  *      to exclude from being captured.  If @c NULL, a dummy configuration where
1865  *      no paths are treated specially is used.
1866  * @param add_flags
1867  *      Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
1868  * @param progress_func
1869  *      If non-NULL, a function that will be called periodically with the
1870  *      progress of the current operation.  The progress messages that will be
1871  *      received are ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
1872  *      ::WIMLIB_PROGRESS_MSG_SCAN_END, and, if ::WIMLIB_ADD_FLAG_VERBOSE was
1873  *      included in @p add_flags, also ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
1874  *
1875  * @return 0 on success; nonzero on error.  On error, changes to @p wim are
1876  * discarded so that it appears to be in the same state as when this function
1877  * was called.
1878  *
1879  * This function is implemented by calling wimlib_add_empty_image(), then
1880  * calling wimlib_update_image() with a single "add" command, so any error code
1881  * returned by wimlib_add_empty_image() may be returned, as well as any error
1882  * codes returned by wimlib_update_image() other than ones documented as only
1883  * being returned specifically by an update involving delete or rename commands.
1884  */
1885 extern int
1886 wimlib_add_image(WIMStruct *wim,
1887                  const wimlib_tchar *source,
1888                  const wimlib_tchar *name,
1889                  const struct wimlib_capture_config *config,
1890                  int add_flags,
1891                  wimlib_progress_func_t progress_func);
1892
1893 /**
1894  * @ingroup G_modifying_wims
1895  *
1896  * This function is equivalent to wimlib_add_image() except it allows for
1897  * multiple sources to be combined into a single WIM image.  This is done by
1898  * specifying the @p sources and @p num_sources parameters instead of the @p
1899  * source parameter of wimlib_add_image().  The rest of the parameters are the
1900  * same as wimlib_add_image().  See the documentation for <b>wimlib-imagex
1901  * capture</b> for full details on how this mode works.
1902  *
1903  * In addition to the error codes that wimlib_add_image() can return,
1904  * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
1905  * when trying to overlay a non-directory on a directory or when otherwise
1906  * trying to overlay multiple conflicting files to the same location in the WIM
1907  * image.  It will also return ::WIMLIB_ERR_INVALID_PARAM if
1908  * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
1909  * was not exactly one capture source with the target being the root directory.
1910  * (In this respect, there is no advantage to using
1911  * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
1912  * NTFS mode.) */
1913 extern int
1914 wimlib_add_image_multisource(WIMStruct *wim,
1915                              const struct wimlib_capture_source *sources,
1916                              size_t num_sources,
1917                              const wimlib_tchar *name,
1918                              const struct wimlib_capture_config *config,
1919                              int add_flags,
1920                              wimlib_progress_func_t progress_func);
1921
1922 /**
1923  * @ingroup G_creating_and_opening_wims
1924  *
1925  * Creates a ::WIMStruct for a new WIM file.
1926  *
1927  * This only creates an in-memory structure for a WIM that initially contains no
1928  * images.  No on-disk file is created until wimlib_write() is called.
1929  *
1930  * @param ctype
1931  *      The type of compression to be used in the new WIM file.  Must be
1932  *      ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX, or
1933  *      ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1934  * @param wim_ret
1935  *      On success, a pointer to an opaque ::WIMStruct for the new WIM file is
1936  *      written to the memory location pointed to by this paramater.  The
1937  *      ::WIMStruct must be freed using using wimlib_free() when finished with
1938  *      it.
1939  * @return 0 on success; nonzero on error.
1940  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
1941  *      @p ctype was not ::WIMLIB_COMPRESSION_TYPE_NONE,
1942  *      ::WIMLIB_COMPRESSION_TYPE_LZX, or ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1943  * @retval ::WIMLIB_ERR_NOMEM
1944  *      Failed to allocate needed memory.
1945  */
1946 extern int
1947 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
1948
1949 /**
1950  * @ingroup G_modifying_wims
1951  *
1952  * Deletes an image, or all images, from a WIM file.
1953  *
1954  * All streams referenced by the image(s) being deleted are removed from the
1955  * lookup table of the WIM if they are not referenced by any other images in the
1956  * WIM.
1957  *
1958  * Please note that @b no changes are committed to the underlying WIM file (if
1959  * any) until wimlib_write() or wimlib_overwrite() is called.
1960  *
1961  * @param wim
1962  *      Pointer to the ::WIMStruct for the WIM file that contains the image(s)
1963  *      being deleted.
1964  * @param image
1965  *      The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
1966  *      images.
1967  * @return 0 on success; nonzero on failure.  On failure, @p wim is guaranteed
1968  * to be left unmodified only if @p image specified a single image.  If instead
1969  * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
1970  * possible for some but not all of the images to have been deleted when a
1971  * failure status is returned.
1972  *
1973  * @retval ::WIMLIB_ERR_INVALID_IMAGE
1974  *      @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
1975  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1976  *      The WIM file is considered read-only because of any of the reasons
1977  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1978  *      flag.
1979  *
1980  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
1981  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
1982  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
1983  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
1984  * different reasons) to read the metadata resource for an image that needed to
1985  * be deleted.
1986  */
1987 extern int
1988 wimlib_delete_image(WIMStruct *wim, int image);
1989
1990 /**
1991  * @ingroup G_modifying_wims
1992  *
1993  * Exports an image, or all the images, from a WIM file, into another WIM file.
1994  *
1995  * The destination image is made to share the same dentry tree and security data
1996  * structure as the source image.  This places some restrictions on additional
1997  * functions that may be called.  wimlib_mount_image() may not be called on
1998  * either the source image or the destination image without an intervening call
1999  * to a function that un-shares the images, such as wimlib_free() on @p
2000  * dest_wim, or wimlib_delete_image() on either the source or destination image.
2001  * Furthermore, you may not call wimlib_free() on @p src_wim before calling
2002  * wimlib_write() or wimlib_overwrite() on @p dest_wim because @p dest_wim will
2003  * have references back to @p src_wim.
2004  *
2005  * If this function fails, all changes to @p dest_wim are rolled back.
2006  *
2007  * Please note that no changes are committed to the underlying WIM file of @p
2008  * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2009  *
2010  * @param src_wim
2011  *      The WIM from which to export the images, specified as a pointer to the
2012  *      ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2013  *      split WIM.  In the case of a WIM file that is not standalone, this
2014  *      ::WIMStruct must have had any needed external resources previously
2015  *      referenced using wimlib_reference_resources() or
2016  *      wimlib_reference_resource_files().
2017  * @param src_image
2018  *      The image to export from @p src_wim, as either a 1-based image index to
2019  *      export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2020  * @param dest_wim
2021  *      Pointer to the ::WIMStruct for a WIM that will receive the images being
2022  *      exported.
2023  * @param dest_name
2024  *      For single-image exports, the name to give the exported image in @p
2025  *      dest_wim.  If left @c NULL, the name from @p src_wim is used.  For
2026  *      ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2027  *      that case, the names are all taken from @p src_wim.  This parameter is
2028  *      overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2029  * @param dest_description
2030  *      For single-image exports, the description to give the exported image in
2031  *      the new WIM file.  If left @c NULL, the description from @p src_wim is
2032  *      used.  For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2033  *      NULL; in that case, the description are all taken from @p src_wim.  This
2034  *      parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2035  * @param export_flags
2036  *      Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2037  * @param progress_func
2038  *      Currently ignored, but reserved for a function that will be called with
2039  *      information about the operation.  Use NULL if no additional information
2040  *      is desired.
2041  *
2042  * @return 0 on success; nonzero on error.
2043  * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2044  *      One or more of the names being given to an exported image was already in
2045  *      use in the destination WIM.
2046  * @retval ::WIMLIB_ERR_INVALID_IMAGE
2047  *      @p src_image does not exist in @p src_wim and was not
2048  *      ::WIMLIB_ALL_IMAGES.
2049  * @retval ::WIMLIB_ERR_INVALID_PARAM
2050  *      @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2051  *      ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2052  *      @c NULL.
2053  * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2054  *      Either @p src_wim or @p dest_wim did not contain metadata resources; for
2055  *      example, one of them was a non-first part of a split WIM.
2056  * @retval ::WIMLIB_ERR_NOMEM
2057  *      Failed to allocate needed memory.
2058  * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2059  *      A resource that needed to be exported could not be found in either the
2060  *      source or destination WIMs.  This error can occur if, for example, @p
2061  *      src_wim is part of a split WIM but needed resources from the other split
2062  *      WIM parts were not referenced with wimlib_reference_resources() or
2063  *      wimlib_reference_resource_files() before the call to
2064  *      wimlib_export_image().
2065  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2066  *      @p dest_wim is considered read-only because of any of the reasons
2067  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2068  *      flag.
2069  *
2070  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2071  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2072  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2073  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2074  * different reasons) to read the metadata resource for an image in @p src_wim
2075  * that needed to be exported.
2076  */
2077 extern int
2078 wimlib_export_image(WIMStruct *src_wim, int src_image,
2079                     WIMStruct *dest_wim,
2080                     const wimlib_tchar *dest_name,
2081                     const wimlib_tchar *dest_description,
2082                     int export_flags,
2083                     wimlib_progress_func_t progress_func);
2084
2085 /**
2086  * @ingroup G_extracting_wims
2087  *
2088  * Extract zero or more files or directory trees from a WIM image.
2089  *
2090  * This generalizes the single-image extraction functionality of
2091  * wimlib_extract_image() to allow extracting only the specified subsets of the
2092  * image.
2093  *
2094  * @param wim
2095  *      The WIM from which to extract the files, specified as a pointer to the
2096  *      ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2097  *      split WIM.  In the case of a WIM file that is not standalone, this
2098  *      ::WIMStruct must have had any needed external resources previously
2099  *      referenced using wimlib_reference_resources() or
2100  *      wimlib_reference_resource_files().
2101  *
2102  * @param image
2103  *      The 1-based number of the image in @p wim from which the files or
2104  *      directory trees are to be extracted.  It cannot be ::WIMLIB_ALL_IMAGES.
2105  *
2106  * @param cmds
2107  *      An array of ::wimlib_extract_command structures that specifies the
2108  *      extractions to perform.
2109  *
2110  * @param num_cmds
2111  *      Number of commands in the @p cmds array.
2112  *
2113  * @param default_extract_flags
2114  *      Default extraction flags; the behavior shall be as if these flags had
2115  *      been specified in the ::wimlib_extract_command.extract_flags member in
2116  *      each extraction command, in combination with any flags already present.
2117  *
2118  * @param progress_func
2119  *      If non-NULL, a function that will be called periodically with the
2120  *      progress of the current operation.
2121  *
2122  * @return 0 on success; nonzero on error.  The possible error codes include
2123  * most of those documented as returned by wimlib_extract_image() as well as the
2124  * following additional error codes:
2125  *
2126  * @retval ::WIMLIB_ERR_INVALID_IMAGE
2127  *      @p image was ::WIMLIB_ALL_IMAGES (or was not otherwise a valid image in
2128  *      the WIM file).
2129  * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2130  *      The ::wimlib_extract_command.wim_source_path member in one of the
2131  *      extract commands did not exist in the WIM.
2132  * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2133  *      ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified for an extraction command
2134  *      in which ::wimlib_extract_command.wim_source_path existed but was not a
2135  *      regular file or directory.
2136  * @retval ::WIMLIB_ERR_INVALID_PARAM
2137  *      ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK was
2138  *      specified for some commands but not all; or
2139  *      ::wimlib_extract_command.fs_dest_path was @c NULL or the empty string
2140  *      for one or more commands; or ::WIMLIB_EXTRACT_FLAG_RPFIX was specified
2141  *      for a command in which ::wimlib_extract_command.wim_source_path did not
2142  *      specify the root directory of the WIM image.
2143  */
2144 extern int
2145 wimlib_extract_files(WIMStruct *wim,
2146                      int image,
2147                      const struct wimlib_extract_command *cmds,
2148                      size_t num_cmds,
2149                      int default_extract_flags,
2150                      wimlib_progress_func_t progress_func);
2151
2152 /**
2153  * @ingroup G_extracting_wims
2154  *
2155  * Extracts an image, or all images, from a WIM to a directory or directly to a
2156  * NTFS volume image.
2157  *
2158  * The exact behavior of how wimlib extracts files from a WIM image is
2159  * controllable by the @p extract_flags parameter, but there also are
2160  * differences depending on the platform (UNIX-like vs Windows).  See the manual
2161  * page for <b>wimlib-imagex apply</b> for more information, including about the
2162  * special "NTFS volume extraction mode" entered by providing
2163  * ::WIMLIB_EXTRACT_FLAG_NTFS.
2164  *
2165  * All extracted data is SHA1-summed, and ::WIMLIB_ERR_INVALID_RESOURCE_HASH is
2166  * returned if any resulting SHA1 message digests do not match the values
2167  * provided in the WIM file.  Therefore, if this function is successful, you can
2168  * be fairly sure that any compressed data in the WIM was uncompressed
2169  * correctly.
2170  *
2171  * @param wim
2172  *      The WIM from which to extract the image(s), specified as a pointer to
2173  *      the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2174  *      of a split WIM.  In the case of a WIM file that is not standalone, this
2175  *      ::WIMStruct must have had any needed external resources previously
2176  *      referenced using wimlib_reference_resources() or
2177  *      wimlib_reference_resource_files().
2178  * @param image
2179  *      The image to extract.  Can be the number of an image, or ::WIMLIB_ALL_IMAGES
2180  *      to specify that all images are to be extracted.  ::WIMLIB_ALL_IMAGES cannot
2181  *      be used if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2182  * @param target
2183  *      Directory to extract the WIM image(s) to (created if it does not already
2184  *      exist); or, with ::WIMLIB_EXTRACT_FLAG_NTFS in @p extract_flags, the
2185  *      path to the unmounted NTFS volume to extract the image to.
2186  * @param extract_flags
2187  *      Bitwise OR of the flags prefixed with WIMLIB_EXTRACT_FLAG.
2188  * @param progress_func
2189  *      If non-NULL, a function that will be called periodically with the
2190  *      progress of the current operation.
2191  *
2192  * @return 0 on success; nonzero on error.
2193  * @retval ::WIMLIB_ERR_DECOMPRESSION
2194  *      Failed to decompress a resource to be extracted.
2195  * @retval ::WIMLIB_ERR_INVALID_PARAM
2196  *      Both ::WIMLIB_EXTRACT_FLAG_HARDLINK and ::WIMLIB_EXTRACT_FLAG_SYMLINK
2197  *      were specified in @p extract_flags; or both
2198  *      ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS and ::WIMLIB_EXTRACT_FLAG_NO_ACLS were
2199  *      specified in @p extract_flags; or both ::WIMLIB_EXTRACT_FLAG_RPFIX and
2200  *      ::WIMLIB_EXTRACT_FLAG_NORPFIX were specified in @p extract_flags; or
2201  *      ::WIMLIB_EXTRACT_FLAG_RESUME was specified in @p extract_flags; or if
2202  *      ::WIMLIB_EXTRACT_FLAG_NTFS was specified in @p extract_flags and
2203  *      @p image was ::WIMLIB_ALL_IMAGES.
2204  * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2205  *      The SHA1 message digest of an extracted stream did not match the SHA1
2206  *      message digest given in the WIM file.
2207  * @retval ::WIMLIB_ERR_LINK
2208  *      Failed to create a symbolic link or a hard link.
2209  * @retval ::WIMLIB_ERR_MKDIR
2210  *      Failed create a directory.
2211  * @retval ::WIMLIB_ERR_NOMEM
2212  *      Failed to allocate needed memory.
2213  * @retval ::WIMLIB_ERR_OPEN
2214  *      Could not create a file, or failed to open an already-extracted file.
2215  * @retval ::WIMLIB_ERR_READ
2216  *      Failed to read data from the WIM file associated with @p wim.
2217  * @retval ::WIMLIB_ERR_READLINK
2218  *      Failed to determine the target of a symbolic link in the WIM.
2219  * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2220  *      Failed to fix the target of an absolute symbolic link (e.g. if the
2221  *      target would have exceeded the maximum allowed length).  (Only if
2222  *      reparse data was supported by the extraction mode and
2223  *      ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p extract_flags.)
2224  * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2225  *      One of the files or directories that needed to be extracted referenced a
2226  *      stream not present in the WIM's lookup table (or in any of the lookup
2227  *      tables of the split WIM parts).
2228  * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2229  *      Failed to set attributes on a file.
2230  * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2231  *      Failed to set reparse data on a file (only if reparse data was supported
2232  *      by the extraction mode).
2233  * @retval ::WIMLIB_ERR_SET_SECURITY
2234  *      Failed to set security descriptor on a file
2235  *      (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2236  *      extract_flags).
2237  * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2238  *      Failed to set the short name of a file (only if
2239  *      ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2240  * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2241  *      Failed to set timestamps on a file (only if
2242  *      ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2243  * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2244  *      Unexpected end-of-file occurred when reading data from the WIM file
2245  *      associated with @p wim.
2246  * @retval ::WIMLIB_ERR_UNSUPPORTED
2247  *      A requested extraction flag, or the data or metadata that must be
2248  *      extracted to support it, is unsupported in the build and configuration
2249  *      of wimlib, or on the current platform or extraction mode or target
2250  *      volume.  Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2251  *      ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2252  *      ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2253  *      ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS,
2254  *      ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS, ::WIMLIB_EXTRACT_FLAG_SYMLINK,
2255  *      and ::WIMLIB_EXTRACT_FLAG_HARDLINK.  For example, if
2256  *      ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2257  *      extract_flags,
2258  *      ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM image contains one
2259  *      or more files with short names, but extracting short names is not
2260  *      supported --- on Windows, this occurs if the target volume does not
2261  *      support short names, while on non-Windows, this occurs if
2262  *      ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2263  * @retval ::WIMLIB_ERR_WRITE
2264  *      Failed to write data to a file being extracted.
2265  *
2266  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2267  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2268  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2269  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2270  * different reasons) to read the metadata resource for an image that needed to
2271  * be extracted.
2272  */
2273 extern int
2274 wimlib_extract_image(WIMStruct *wim, int image,
2275                      const wimlib_tchar *target,
2276                      int extract_flags,
2277                      wimlib_progress_func_t progress_func);
2278
2279 /**
2280  * @ingroup G_extracting_wims
2281  *
2282  * Since wimlib v1.5.0:  Extract one or more images from a pipe on which a
2283  * pipable WIM is being sent.
2284  *
2285  * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2286  * about pipable WIMs.
2287  *
2288  * This function operates in a special way to read the WIM fully sequentially.
2289  * As a result, there is no ::WIMStruct is made visible to library users, and
2290  * you cannot call wimlib_open_wim() on the pipe.  (You can, however, use
2291  * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2292  * seekable file, not a pipe.)
2293  *
2294  * @param pipe_fd
2295  *      File descriptor, which may be a pipe, opened for reading and positioned
2296  *      at the start of the pipable WIM.
2297  * @param image_num_or_name
2298  *      String that specifies the 1-based index or name of the image to extract.
2299  *      It is translated to an image index using the same rules that
2300  *      wimlib_resolve_image() uses.  However, unlike wimlib_extract_image(),
2301  *      only a single image (not all images) can be specified.  Alternatively,
2302  *      specify @p NULL here to use the first image in the WIM if it contains
2303  *      exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2304  * @param target
2305  *      Same as the corresponding parameter to wimlib_extract_image().
2306  * @param extract_flags
2307  *      Same as the corresponding parameter to wimlib_extract_image(), except
2308  *      for the following exceptions:  ::WIMLIB_EXTRACT_FLAG_SEQUENTIAL is
2309  *      always implied, since data is always read from @p pipe_fd sequentially
2310  *      in this mode; also, ::WIMLIB_EXTRACT_FLAG_TO_STDOUT is invalid and will
2311  *      result in ::WIMLIB_ERR_INVALID_PARAM being returned.
2312  * @param progress_func
2313  *      Same as the corresponding parameter to wimlib_extract_image(), except
2314  *      ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN messages will also be
2315  *      received.
2316  *
2317  * @return 0 on success; nonzero on error.  The possible error codes include
2318  * those returned by wimlib_extract_image() as well as the following:
2319  *
2320  * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2321  *      Data read from the pipable WIM was invalid.
2322  * @retval ::WIMLIB_ERR_NOT_PIPABLE
2323  *      The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2324  */
2325 extern int
2326 wimlib_extract_image_from_pipe(int pipe_fd,
2327                                const wimlib_tchar *image_num_or_name,
2328                                const wimlib_tchar *target, int extract_flags,
2329                                wimlib_progress_func_t progress_func);
2330
2331 /**
2332  * @ingroup G_wim_information
2333  *
2334  * Extracts the XML data of a WIM file to a file stream.  Every WIM file
2335  * includes a string of XML that describes the images contained in the WIM.
2336  *
2337  * See wimlib_get_xml_data() to read the XML data into memory instead.
2338  *
2339  * @param wim
2340  *      Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2341  *      have to be standalone (e.g. it could be part of a split WIM).
2342  * @param fp
2343  *      @c stdout, or a FILE* opened for writing, to extract the data to.
2344  *
2345  * @return 0 on success; nonzero on error.
2346  * @retval ::WIMLIB_ERR_INVALID_PARAM
2347  *      @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2348  * @retval ::WIMLIB_ERR_NOMEM
2349  * @retval ::WIMLIB_ERR_READ
2350  * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2351  *      Failed to read the XML data from the WIM.
2352  * @retval ::WIMLIB_ERR_WRITE
2353  *      Failed to completely write the XML data to @p fp.
2354  */
2355 extern int
2356 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2357
2358 /**
2359  * @ingroup G_general
2360  *
2361  * Frees all memory allocated for a WIMStruct and closes all files associated
2362  * with it.
2363  *
2364  * @param wim
2365  *      Pointer to the ::WIMStruct for a WIM file.
2366  *
2367  * @return This function has no return value.
2368  */
2369 extern void
2370 wimlib_free(WIMStruct *wim);
2371
2372 /**
2373  * @ingroup G_general
2374  *
2375  * Converts a ::wimlib_compression_type value into a string.
2376  *
2377  * @param ctype
2378  *      ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX,
2379  *      ::WIMLIB_COMPRESSION_TYPE_XPRESS, or another value.
2380  *
2381  * @return
2382  *      A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
2383  *      respectively.
2384  */
2385 extern const wimlib_tchar *
2386 wimlib_get_compression_type_string(int ctype);
2387
2388 /**
2389  * @ingroup G_general
2390  *
2391  * Converts an error code into a string describing it.
2392  *
2393  * @param code
2394  *      The error code returned by one of wimlib's functions.
2395  *
2396  * @return
2397  *      Pointer to a statically allocated string describing the error code,
2398  *      or @c NULL if the error code is not valid.
2399  */
2400 extern const wimlib_tchar *
2401 wimlib_get_error_string(enum wimlib_error_code code);
2402
2403 /**
2404  * @ingroup G_wim_information
2405  *
2406  * Returns the description of the specified image.
2407  *
2408  * @param wim
2409  *      Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2410  *      to be standalone (e.g. it could be part of a split WIM).
2411  * @param image
2412  *      The number of the image, numbered starting at 1.
2413  *
2414  * @return
2415  *      The description of the image, or @c NULL if there is no such image, or
2416  *      @c NULL if the specified image has no description.  The description
2417  *      string is in library-internal memory and may not be modified or freed;
2418  *      in addition, the string will become invalid if the description of the
2419  *      image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2420  */
2421 extern const wimlib_tchar *
2422 wimlib_get_image_description(const WIMStruct *wim, int image);
2423
2424 /**
2425  * @ingroup G_wim_information
2426  *
2427  * Returns the name of the specified image.
2428  *
2429  * @param wim
2430  *      Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2431  *      to be standalone (e.g. it could be part of a split WIM).
2432  * @param image
2433  *      The number of the image, numbered starting at 1.
2434  *
2435  * @return
2436  *      The name of the image, or @c NULL if there is no such image, or an empty
2437  *      string if the image is unnamed.  The name string is in
2438  *      library-internal memory and may not be modified or freed; in addition,
2439  *      the string will become invalid if the name of the image is changed, the
2440  *      image is deleted, or the ::WIMStruct is destroyed.
2441  */
2442 extern const wimlib_tchar *
2443 wimlib_get_image_name(const WIMStruct *wim, int image);
2444
2445
2446 /**
2447  * @ingroup G_wim_information
2448  *
2449  * Get basic information about a WIM file.
2450  *
2451  * @param wim
2452  *      Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2453  *      to be standalone (e.g. it could be part of a split WIM).
2454  * @param info
2455  *      A ::wimlib_wim_info structure that will be filled in with information
2456  *      about the WIM file.
2457  * @return
2458  *      0
2459  */
2460 extern int
2461 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2462
2463 /**
2464  * @ingroup G_wim_information
2465  *
2466  * Read the XML data of a WIM file into an in-memory buffer.  Every WIM file
2467  * includes a string of XML that describes the images contained in the WIM.
2468  *
2469  * See wimlib_extract_xml_data() to extract the XML data to a file stream
2470  * instead.
2471  *
2472  * @param wim
2473  *      Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2474  *      have to be standalone (e.g. it could be part of a split WIM).
2475  * @param buf_ret
2476  *      On success, a pointer to an allocated buffer containing the raw UTF16-LE
2477  *      XML data is written to this location.
2478  * @param bufsize_ret
2479  *      The size of the XML data in bytes is written to this location.
2480  *
2481  * @return 0 on success; nonzero on error.
2482  * @retval ::WIMLIB_ERR_INVALID_PARAM
2483  *      @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
2484  *      @p buf_ret or @p bufsize_ret was @c NULL.
2485  * @retval ::WIMLIB_ERR_NOMEM
2486  * @retval ::WIMLIB_ERR_READ
2487  * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2488  *      Failed to read the XML data from the WIM.
2489  */
2490 extern int
2491 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
2492
2493 /**
2494  * @ingroup G_general
2495  *
2496  * Initialization function for wimlib.  Call before using any other wimlib
2497  * function except wimlib_set_print_errors().  If not done manually, this
2498  * function will be called automatically with @p init_flags set to
2499  * ::WIMLIB_INIT_FLAG_ASSUME_UTF8.
2500  *
2501  * @param init_flags
2502  *      Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2503  *
2504  * @return 0 on success; nonzero on failure.  Currently, only the following
2505  * error code is defined:
2506  *
2507  * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2508  *      ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2509  *      ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2510  *      init_flags, but the corresponding privileges could not be acquired.
2511  */
2512 extern int
2513 wimlib_global_init(int init_flags);
2514
2515 /**
2516  * @ingroup G_general
2517  *
2518  * Cleanup function for wimlib.  You are not required to call this function, but
2519  * it will release any global resources allocated by the library.
2520  */
2521 extern void
2522 wimlib_global_cleanup(void);
2523
2524 /**
2525  * @ingroup G_wim_information
2526  *
2527  * Determines if an image name is already used by some image in the WIM.
2528  *
2529  * @param wim
2530  *      Pointer to the ::WIMStruct for a WIM file.
2531  * @param name
2532  *      The name to check.
2533  *
2534  * @return
2535  *      @c true if there is already an image in @p wim named @p name; @c false
2536  *      if there is no image named @p name in @p wim.  If @p name is @c NULL or
2537  *      the empty string, @c false is returned.
2538  */
2539 extern bool
2540 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2541
2542 /**
2543  * @ingroup G_wim_information
2544  *
2545  * Iterate through a file or directory tree in the WIM image.  By specifying
2546  * appropriate flags and a callback function, you can get the attributes of a
2547  * file in the WIM, get a directory listing, or even get a listing of the entire
2548  * WIM image.
2549  *
2550  * @param wim
2551  *      The WIM containing the image(s) over which to iterate, specified as a
2552  *      pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
2553  *      or part 1 of a split WIM.  In the case of a WIM file that is not
2554  *      standalone, this ::WIMStruct should have had any needed external
2555  *      resources previously referenced using wimlib_reference_resources() or
2556  *      wimlib_reference_resource_files().  If not, see
2557  *      ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
2558  *      the behavior when resources are missing.
2559  *
2560  * @param image
2561  *      The 1-based number of the image in @p wim that contains the files or
2562  *      directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
2563  *      iteration on all images in the WIM.
2564  *
2565  * @param path
2566  *      Path in the WIM image at which to do the iteration.
2567  *
2568  * @param flags
2569  *      Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
2570  *
2571  * @param cb
2572  *      A callback function that will receive each directory entry.
2573  *
2574  * @param user_ctx
2575  *      An extra parameter that will always be passed to the callback function
2576  *      @p cb.
2577  *
2578  * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
2579  * first nonzero value that was returned from @p cb.  However, additional error
2580  * codes may be returned, including the following:
2581  *
2582  * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2583  *      @p path did not exist in the WIM image.
2584  * @retval ::WIMLIB_ERR_NOMEM
2585  *      Failed to allocate memory needed to create a ::wimlib_dir_entry.
2586  *
2587  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2588  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2589  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2590  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2591  * different reasons) to read the metadata resource for an image over which
2592  * iteration needed to be done.
2593  */
2594 extern int
2595 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
2596                         int flags,
2597                         wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
2598
2599 /**
2600  * @ingroup G_wim_information
2601  *
2602  * Iterate through the lookup table of a WIM file.  This can be used to directly
2603  * get a listing of the unique resources contained in a WIM file over all
2604  * images.  Both file resources and metadata resources are included.  However,
2605  * only resources actually included in the file represented by @a wim, plus
2606  * explicitly referenced external resources (via wimlib_reference_resources() or
2607  * wimlib_reference_resource_files()) are included in the iteration.  For
2608  * example, if @p wim represents just one part of a split WIM, then only
2609  * resources in that part will be included, unless other resources were
2610  * explicitly referenced.
2611  *
2612  * @param wim
2613  *      Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2614  *      to be standalone (e.g. it could be part of a split WIM).
2615  *
2616  * @param flags
2617  *      Reserved; set to 0.
2618  *
2619  * @param cb
2620  *      A callback function that will receive each resource.
2621  *
2622  * @param user_ctx
2623  *      An extra parameter that will always be passed to the callback function
2624  *      @p cb.
2625  *
2626  * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
2627  * that was returned from @p cb.
2628  */
2629 extern int
2630 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
2631                             wimlib_iterate_lookup_table_callback_t cb,
2632                             void *user_ctx);
2633
2634 /**
2635  * @ingroup G_nonstandalone_wims
2636  *
2637  * Joins a split WIM into a stand-alone one-part WIM.
2638  *
2639  * @param swms
2640  *      An array of strings that gives the filenames of all parts of the split
2641  *      WIM.  No specific order is required, but all parts must be included with
2642  *      no duplicates.
2643  * @param num_swms
2644  *      Number of filenames in @p swms.
2645  * @param swm_open_flags
2646  *      Open flags for the split WIM parts (e.g.
2647  *      ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
2648  * @param wim_write_flags
2649  *      Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
2650  *      be used to write the joined WIM.
2651  * @param output_path
2652  *      The path to write the joined WIM file to.
2653  * @param progress_func
2654  *      If non-NULL, a function that will be called periodically with the
2655  *      progress of the current operation.
2656  *
2657  * @return 0 on success; nonzero on error.  This function may return most error
2658  * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
2659  * as the following error code:
2660  *
2661  * @retval ::WIMLIB_ERR_SPLIT_INVALID
2662  *      The split WIMs do not form a valid WIM because they do not include all
2663  *      the parts of the original WIM, there are duplicate parts, or not all the
2664  *      parts have the same GUID and compression type.
2665  *
2666  * Note: wimlib is generalized enough that this function is not actually needed
2667  * to join a split WIM; instead, you could open the first part of the split WIM,
2668  * then reference the other parts with wimlib_reference_resource_files(), then
2669  * write the joined WIM using wimlib_write().  However, wimlib_join() provides
2670  * an easy-to-use wrapper around this that has some advantages (e.g.  extra
2671  * sanity checks).
2672  */
2673 extern int
2674 wimlib_join(const wimlib_tchar * const *swms,
2675             unsigned num_swms,
2676             const wimlib_tchar *output_path,
2677             int swm_open_flags,
2678             int wim_write_flags,
2679             wimlib_progress_func_t progress_func);
2680
2681
2682 /**
2683  * @ingroup G_mounting_wim_images
2684  *
2685  * Mounts an image in a WIM file on a directory read-only or read-write.
2686  *
2687  * As this is implemented using FUSE (Filesystme in UserSpacE), this is not
2688  * supported if wimlib was configured with @c --without-fuse.  This includes
2689  * Windows builds of wimlib; ::WIMLIB_ERR_UNSUPPORTED will be returned in such
2690  * cases.
2691  *
2692  * Calling this function daemonizes the process, unless
2693  * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early occur occurs.  If the
2694  * mount is read-write (::WIMLIB_MOUNT_FLAG_READWRITE specified), modifications
2695  * to the WIM are staged in a temporary directory.
2696  *
2697  * It is safe to mount multiple images from the same underlying WIM file
2698  * read-only at the same time, but only if different ::WIMStruct's are used.  It
2699  * is @b not safe to mount multiple images from the same WIM file read-write at
2700  * the same time.
2701  *
2702  * wimlib_mount_image() cannot be used on an image that was exported with
2703  * wimlib_export_image() while the dentry trees for both images are still in
2704  * memory.  In addition, wimlib_mount_image() may not be used to mount an image
2705  * that already has modifications pending (e.g. an image added with
2706  * wimlib_add_image()).
2707  *
2708  * @param wim
2709  *      Pointer to the ::WIMStruct containing the image to be mounted.
2710  * @param image
2711  *      The number of the image to mount, indexed starting from it.  It must be
2712  *      an existing, single image.
2713  * @param dir
2714  *      The path to an existing empty directory to mount the image on.
2715  * @param mount_flags
2716  *      Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG.
2717  * @param staging_dir
2718  *      If non-NULL, the name of a directory in which the staging directory will
2719  *      be created.  Ignored if ::WIMLIB_MOUNT_FLAG_READWRITE is not specified
2720  *      in @p mount_flags.  If left @c NULL, the staging directory is created in
2721  *      the same directory as the WIM file that @p wim was originally read from.
2722  *
2723  * @return 0 on success; nonzero on error.
2724  *
2725  * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2726  *      A read-write mount was requested, but an an exclusive advisory lock on
2727  *      the on-disk WIM file could not be acquired because another thread or
2728  *      process has mounted an image from the WIM read-write or is currently
2729  *      modifying the WIM in-place.
2730  * @retval ::WIMLIB_ERR_FUSE
2731  *      A non-zero status was returned by @c fuse_main().
2732  * @retval ::WIMLIB_ERR_INVALID_IMAGE
2733  *      @p image does not specify an existing, single image in @p wim.
2734  * @retval ::WIMLIB_ERR_INVALID_PARAM
2735  *      @p image is shared among multiple ::WIMStruct's as a result of a call to
2736  *      wimlib_export_image(), or @p image has been added with
2737  *      wimlib_add_image().
2738  * @retval ::WIMLIB_ERR_MKDIR
2739  *      ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
2740  *      staging directory could not be created.
2741  * @retval ::WIMLIB_ERR_NOTDIR
2742  *      Could not determine the current working directory.
2743  * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2744  *      One of the dentries in the image referenced a stream not present in the
2745  *      WIM's lookup table (or in any of the lookup tables of the split WIM
2746  *      parts).
2747  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2748  *      ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but @p
2749  *      wim is considered read-only because of any of the reasons mentioned in
2750  *      the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2751  * @retval ::WIMLIB_ERR_UNSUPPORTED
2752  *      Mounting is not supported, either because the platform is Windows, or
2753  *      because the platform is UNIX-like and wimlib was compiled with @c
2754  *      --without-fuse.
2755  *
2756  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2757  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2758  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2759  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2760  * different reasons) to read the metadata resource for the image to mount.
2761  */
2762 extern int
2763 wimlib_mount_image(WIMStruct *wim,
2764                    int image,
2765                    const wimlib_tchar *dir,
2766                    int mount_flags,
2767                    const wimlib_tchar *staging_dir);
2768
2769 /**
2770  * @ingroup G_creating_and_opening_wims
2771  *
2772  * Opens a WIM file and creates a ::WIMStruct for it.
2773  *
2774  * @param wim_file
2775  *      The path to the WIM file to open.
2776  *
2777  * @param open_flags
2778  *      Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
2779  *
2780  * @param progress_func
2781  *      If non-NULL, a function that will be called periodically with the
2782  *      progress of the current operation.  Currently, the only messages sent
2783  *      will be ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY, and only if
2784  *      ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags.
2785  *
2786  * @param wim_ret
2787  *      On success, a pointer to an opaque ::WIMStruct for the opened WIM file
2788  *      is written to the memory location pointed to by this parameter.  The
2789  *      ::WIMStruct can be freed using using wimlib_free() when finished with
2790  *      it.
2791  *
2792  * @return 0 on success; nonzero on error.
2793  * @retval ::WIMLIB_ERR_IMAGE_COUNT
2794  *      The WIM is not the non-first part of a split WIM, and the number of
2795  *      metadata resources found in the WIM did not match the image count given
2796  *      in the WIM header, or the number of &lt;IMAGE&gt; elements in the XML
2797  *      data for the WIM did not match the image count given in the WIM header.
2798  * @retval ::WIMLIB_ERR_INTEGRITY
2799  *      ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
2800  *      wim_file contains an integrity table, but the SHA1 message digest for a
2801  *      chunk of the WIM does not match the corresponding message digest given
2802  *      in the integrity table.
2803  * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
2804  *      Resources in @p wim_file are compressed, but the chunk size was invalid
2805  *      for the WIM's compression format.
2806  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2807  *      The header of @p wim_file says that resources in the WIM are compressed,
2808  *      but the header flag indicating LZX or XPRESS compression is not set.
2809  * @retval ::WIMLIB_ERR_INVALID_HEADER
2810  *      The header of @p wim_file was otherwise invalid.
2811  * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
2812  *      ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
2813  *      wim_file contains an integrity table, but the integrity table is
2814  *      invalid.
2815  * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
2816  *      The lookup table for the WIM contained duplicate entries that are not
2817  *      for metadata resources, or it contained an entry with a SHA1 message
2818  *      digest of all 0's.
2819  * @retval ::WIMLIB_ERR_INVALID_PARAM
2820  *      @p wim_ret was @c NULL.
2821  * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
2822  *      @p wim_file is a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
2823  *      specified in @p open_flags.
2824  * @retval ::WIMLIB_ERR_NOMEM
2825  *      Failed to allocated needed memory.
2826  * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
2827  *      @p wim_file does not begin with the expected magic characters.
2828  * @retval ::WIMLIB_ERR_OPEN
2829  *      Failed to open the file @p wim_file for reading.
2830  * @retval ::WIMLIB_ERR_READ
2831  *      Failed to read data from @p wim_file.
2832  * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2833  *      Unexpected end-of-file while reading data from @p wim_file.
2834  * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
2835  *      A number other than 0x10d00 is written in the version field of the WIM
2836  *      header of @p wim_file.  (May be a pre-Vista WIM.)
2837  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2838  *      ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
2839  *      considered read-only because of any of the reasons mentioned in the
2840  *      documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2841  * @retval ::WIMLIB_ERR_XML
2842  *      The XML data for @p wim_file is invalid.
2843  */
2844 extern int
2845 wimlib_open_wim(const wimlib_tchar *wim_file,
2846                 int open_flags,
2847                 WIMStruct **wim_ret,
2848                 wimlib_progress_func_t progress_func);
2849
2850 /**
2851  * @ingroup G_writing_and_overwriting_wims
2852  *
2853  * Overwrites the file that the WIM was originally read from, with changes made.
2854  * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
2855  * rather than wimlib_create_new_wim().
2856  *
2857  * There are two ways that a WIM may be overwritten.  The first is to do a full
2858  * rebuild.  In this mode, the new WIM is written to a temporary file and then
2859  * renamed to the original file after it is has been completely written.  The
2860  * temporary file is made in the same directory as the original WIM file.  A
2861  * full rebuild may take a while, but can be used even if images have been
2862  * modified or deleted, will produce a WIM with no holes, and has little chance
2863  * of unintentional data loss because the temporary WIM is fsync()ed before
2864  * being renamed to the original WIM.
2865  *
2866  * The second way to overwrite a WIM is by appending to the end of it and
2867  * overwriting the header.  This can be much faster than a full rebuild, but the
2868  * disadvantage is that some space will be wasted.  Writing a WIM in this mode
2869  * begins with writing any new file resources *after* everything in the old WIM,
2870  * even though this will leave a hole where the old lookup table, XML data, and
2871  * integrity were.  This is done so that the WIM remains valid even if the
2872  * operation is aborted mid-write.  The WIM header is only overwritten at the
2873  * very last moment, and up until that point the WIM will be seen as the old
2874  * version.
2875  *
2876  * By default, wimlib_overwrite() does the append-style overwrite described
2877  * above, unless resources in the WIM are arranged in an unusual way or if
2878  * images have been deleted from the WIM.  Use the flag
2879  * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
2880  * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
2881  * images have been deleted from the WIM.
2882  *
2883  * In the temporary-file overwrite mode, no changes are made to the WIM on
2884  * failure, and the temporary file is deleted if possible.  Abnormal termination
2885  * of the program will result in the temporary file being orphaned.  In the
2886  * direct append mode, the WIM is truncated to the original length on failure;
2887  * and while abnormal termination of the program will result in extra data
2888  * appended to the original WIM, it should still be a valid WIM.
2889  *
2890  * If this function completes successfully, no more functions should be called
2891  * on @p wim other than wimlib_free().  You must use wimlib_open_wim() to read
2892  * the WIM file anew.
2893  *
2894  * @param wim
2895  *      Pointer to the ::WIMStruct for the WIM file to write.  There may have
2896  *      been in-memory changes made to it, which are then reflected in the
2897  *      output file.
2898  * @param write_flags
2899  *      Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
2900  * @param num_threads
2901  *      Number of threads to use for compression (see wimlib_write()).
2902  * @param progress_func
2903  *      If non-NULL, a function that will be called periodically with the
2904  *      progress of the current operation.
2905  *
2906  * @return 0 on success; nonzero on error.  This function may return most error
2907  * codes returned by wimlib_write() as well as the following error codes:
2908  *
2909  * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2910  *      The WIM was going to be modified in-place (with no temporary file), but
2911  *      an exclusive advisory lock on the on-disk WIM file could not be acquired
2912  *      because another thread or process has mounted an image from the WIM
2913  *      read-write or is currently modifying the WIM in-place.
2914  * @retval ::WIMLIB_ERR_NO_FILENAME
2915  *      @p wim corresponds to a WIM created with wimlib_create_new_wim() rather
2916  *      than a WIM read with wimlib_open_wim().
2917  * @retval ::WIMLIB_ERR_RENAME
2918  *      The temporary file that the WIM was written to could not be renamed to
2919  *      the original filename of @p wim.
2920  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2921  *      The WIM file is considered read-only because of any of the reasons
2922  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2923  *      flag.
2924  */
2925 extern int
2926 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads,
2927                  wimlib_progress_func_t progress_func);
2928
2929 /**
2930  * @ingroup G_wim_information
2931  *
2932  * Prints information about one image, or all images, contained in a WIM.
2933  *
2934  * @param wim
2935  *      Pointer to the ::WIMStruct for a WIM file.
2936  * @param image
2937  *      The image about which to print information.  Can be the number of an
2938  *      image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
2939  *      WIM.
2940  *
2941  * @return This function has no return value.  No error checking is done when
2942  * printing the information.  If @p image is invalid, an error message is
2943  * printed.
2944  */
2945 extern void
2946 wimlib_print_available_images(const WIMStruct *wim, int image);
2947
2948 /**
2949  * @ingroup G_wim_information
2950  *
2951  * Deprecated in favor of wimlib_get_wim_info(), which provides the information
2952  * in a way that can be accessed programatically.
2953  */
2954 extern void
2955 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
2956
2957 /**
2958  * @ingroup G_wim_information
2959  *
2960  * Deprecated in favor of wimlib_iterate_dir_tree(), which provides the
2961  * information in a way that can be accessed programatically.
2962  */
2963 extern int
2964 wimlib_print_metadata(WIMStruct *wim, int image) _wimlib_deprecated;
2965
2966 /**
2967  * @ingroup G_nonstandalone_wims
2968  *
2969  * Reference resources from other WIM files or split WIM parts.  This function
2970  * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
2971  * to load needed resources (that is, "streams" keyed by SHA1 message digest)
2972  * from other files, before calling a function such as wimlib_extract_image()
2973  * that requires the resources to be present.
2974  *
2975  * @param wim
2976  *      The ::WIMStruct for a WIM that contains metadata resources, but is not
2977  *      necessarily "standalone".  In the case of split WIMs, this should be the
2978  *      first part, since only the first part contains the metadata resources.
2979  *      In the case of delta WIMs, this should be the delta WIM rather than the
2980  *      WIM on which it is based.
2981  * @param resource_wimfiles_or_globs
2982  *      Array of paths to WIM files and/or split WIM parts to reference.
2983  *      Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
2984  *      ref_flags, these are treated as globs rather than literal paths.  That
2985  *      is, using this function you can specify zero or more globs, each of
2986  *      which expands to one or more literal paths.
2987  * @param count
2988  *      Number of entries in @p resource_wimfiles_or_globs.
2989  * @param ref_flags
2990  *      Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
2991  *      ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
2992  * @param open_flags
2993  *      Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
2994  *      pass to internal calls to wimlib_open_wim() on the reference files.
2995  * @param progress_func
2996  *      Passed to internal calls to wimlib_open_wim() on the reference files.
2997  *
2998  * @return 0 on success; nonzero on error.
2999  *
3000  * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3001  *      One of the specified globs did not match any paths (only with both
3002  *      ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3003  *      specified in @p ref_flags).
3004  * @retval ::WIMLIB_ERR_NOMEM
3005  *      Failed to allocate memory.
3006  * @retval ::WIMLIB_ERR_READ
3007  *      I/O or permissions error while processing a file glob.
3008  *
3009  * This function can additionally return most values that can be returned by
3010  * wimlib_open_wim().
3011  */
3012 extern int
3013 wimlib_reference_resource_files(WIMStruct *wim,
3014                                 const wimlib_tchar * const *resource_wimfiles_or_globs,
3015                                 unsigned count,
3016                                 int ref_flags,
3017                                 int open_flags,
3018                                 wimlib_progress_func_t progress_func);
3019
3020 /**
3021  * @ingroup G_nonstandalone_wims
3022  *
3023  * Similar to wimlib_reference_resource_files(), but operates at a lower level
3024  * where the caller must open the ::WIMStruct for each referenced file itself.
3025  *
3026  * @param wim
3027  *      The ::WIMStruct for a WIM that contains metadata resources, but is not
3028  *      necessarily "standalone".  In the case of split WIMs, this should be the
3029  *      first part, since only the first part contains the metadata resources.
3030  * @param resource_wims
3031  *      Array of pointers to the ::WIMStruct's for additional resource WIMs or
3032  *      split WIM parts to reference.
3033  * @param num_resource_wims
3034  *      Number of entries in @p resource_wims.
3035  * @param ref_flags
3036  *      Currently ignored (set to 0).
3037  *
3038  * @return 0 on success; nonzero on error.  On success, the ::WIMStruct's of the
3039  * @p resource_wims are referenced internally by @p wim and must not be freed
3040  * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3041  * been freed with wimlib_free(), or immediately before freeing @p wim with
3042  * wimlib_free().
3043  *
3044  * @retval ::WIMLIB_ERR_INVALID_PARAM
3045  *      @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3046  *      resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3047  * @retval ::WIMLIB_ERR_NOMEM
3048  *      Failed to allocate memory.
3049  */
3050 extern int
3051 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3052                            unsigned num_resource_wims, int ref_flags);
3053
3054 /**
3055  * @ingroup G_modifying_wims
3056  *
3057  * Declares that a newly added image is mostly the same as a prior image, but
3058  * captured at a later point in time, possibly with some modifications in the
3059  * intervening time.  This is designed to be used in incremental backups of the
3060  * same filesystem or directory tree.
3061  *
3062  * This function compares the metadata of the directory tree of the newly added
3063  * image against that of the old image.  Any files that are present in both the
3064  * newly added image and the old image and have timestamps that indicate they
3065  * haven't been modified are deemed not to have been modified and have their
3066  * SHA1 message digest copied from the old image.  Because of this and because
3067  * WIM uses single-instance streams, such files need not be read from the
3068  * filesystem when the WIM is being written or overwritten.  Note that these
3069  * unchanged files will still be "archived" and will be logically present in the
3070  * new image; the optimization is that they don't need to actually be read from
3071  * the filesystem because the WIM already contains them.
3072  *
3073  * This function is provided to optimize incremental backups.  The resulting WIM
3074  * file will still be the same regardless of whether this function is called.
3075  * (This is, however, assuming that timestamps have not been manipulated or
3076  * unmaintained as to trick this function into thinking a file has not been
3077  * modified when really it has.  To partly guard against such cases, other
3078  * metadata such as file sizes will be checked as well.)
3079  *
3080  * This function must be called after adding the new image (e.g. with
3081  * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3082  * wimlib_overwrite()).
3083  *
3084  * @param wim
3085  *      Pointer to the ::WIMStruct for a WIM.
3086  * @param new_image
3087  *      1-based index in the WIM of the newly added image.  This image can have
3088  *      been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3089  *      wimlib_add_empty_image() followed by wimlib_update_image().
3090  * @param template_wim
3091  *      The ::WIMStruct for the WIM containing the template image.  This can be
3092  *      the same as @p wim, or it can be a different ::WIMStruct.
3093  * @param template_image
3094  *      1-based index in the WIM of a template image that reflects a prior state
3095  *      of the directory tree being captured.
3096  * @param flags
3097  *      Reserved; must be 0.
3098  * @param progress_func
3099  *      Currently ignored, but reserved for a function that will be called with
3100  *      information about the operation.  Use NULL if no additional information
3101  *      is desired.
3102  *
3103  * @return 0 on success; nonzero on error.
3104  *
3105  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3106  *      @p new_image and/or @p template_image were not a valid image indices in
3107  *      the WIM.
3108  * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3109  *      The specified ::WIMStruct did not actually contain the metadata resource
3110  *      for the new or template image; for example, it was a non-first part of a
3111  *      split WIM.
3112  * @retval ::WIMLIB_ERR_NOMEM
3113  *      Failed to allocate needed memory.
3114  * @retval ::WIMLIB_ERR_INVALID_PARAM
3115  *      @p new_image was equal to @p template_image, or @p new_image specified
3116  *      an image that had not been modified since opening the WIM.
3117  *
3118  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3119  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3120  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3121  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3122  * different reasons) to read the metadata resource for the template image.
3123  */
3124 extern int
3125 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3126                                 WIMStruct *template_wim, int template_image,
3127                                 int flags, wimlib_progress_func_t progress_func);
3128
3129 /**
3130  * @ingroup G_wim_information
3131  *
3132  * Translates a string specifying the name or number of an image in the WIM into
3133  * the number of the image.  The images are numbered starting at 1.
3134  *
3135  * @param wim
3136  *      Pointer to the ::WIMStruct for a WIM.
3137  * @param image_name_or_num
3138  *      A string specifying the name or number of an image in the WIM.  If it
3139  *      parses to a positive integer, this integer is taken to specify the
3140  *      number of the image, indexed starting at 1.  Otherwise, it is taken to
3141  *      be the name of an image, as given in the XML data for the WIM file.  It
3142  *      also may be the keyword "all" or the string "*", both of which will
3143  *      resolve to ::WIMLIB_ALL_IMAGES.
3144  *      <br/> <br/>
3145  *      There is no way to search for an image actually named "all", "*", or an
3146  *      integer number, or an image that has no name.  However, you can use
3147  *      wimlib_get_image_name() to get the name of any image.
3148  *
3149  * @return
3150  *      If the string resolved to a single existing image, the number of that
3151  *      image, indexed starting at 1, is returned.  If the keyword "all" or "*"
3152  *      was specified, ::WIMLIB_ALL_IMAGES is returned.  Otherwise,
3153  *      ::WIMLIB_NO_IMAGE is returned.  If @p image_name_or_num was @c NULL or
3154  *      the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3155  *      images in @p wim has no name.
3156  */
3157 extern int
3158 wimlib_resolve_image(WIMStruct *wim,
3159                      const wimlib_tchar *image_name_or_num);
3160
3161 /**
3162  * @ingroup G_modifying_wims
3163  *
3164  * Changes the description of an image in the WIM.
3165  *
3166  * @param wim
3167  *      Pointer to the ::WIMStruct for a WIM.
3168  * @param image
3169  *      The number of the image for which to change the description.
3170  * @param description
3171  *      The new description to give the image.  It may be @c NULL, which
3172  *      indicates that the image is to be given no description.
3173  *
3174  * @return 0 on success; nonzero on error.
3175  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3176  *      @p image does not specify a single existing image in @p wim.
3177  * @retval ::WIMLIB_ERR_NOMEM
3178  *      Failed to allocate the memory needed to duplicate the @p description
3179  *      string.
3180  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3181  *      @p wim is considered read-only because of any of the reasons mentioned
3182  *      in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3183  */
3184 extern int
3185 wimlib_set_image_descripton(WIMStruct *wim, int image,
3186                             const wimlib_tchar *description);
3187
3188 /**
3189  * @ingroup G_writing_and_overwriting_wims
3190  *
3191  * Set the compression chunk size of a WIM to use in subsequent calls to
3192  * wimlib_write() or wimlib_overwrite().
3193  *
3194  * A compression chunk size will result in a greater compression ratio, but the
3195  * speed of random access to the WIM will be reduced, and the effect of an
3196  * increased compression chunk size is limited by the size of each file being
3197  * compressed.
3198  *
3199  * <b>WARNING: Microsoft's software is seemingly incompatible with LZX chunk
3200  * sizes other than 32768.  Chunk sizes other than 32768 (for any format) are
3201  * also incompatible with wimlib v1.5.3 and earlier.</b>
3202  *
3203  * @param wim
3204  *      ::WIMStruct for a WIM.
3205  * @param out_chunk_size
3206  *      The chunk size (in bytes) to set.  The valid chunk sizes are dependent
3207  *      on the compression format.  The XPRESS compression format supports chunk
3208  *      sizes that are powers of 2 with exponents between 15 and 26 inclusively,
3209  *      whereas the LZX compression format supports chunk sizes that are powers
3210  *      of 2 with exponents between 15 and 21 inclusively.  As a special case,
3211  *      if @p out_chunk_size is specified as 0, the chunk size is set to the
3212  *      default for the currently selected output compression type.
3213  *
3214  * @return 0 on success; nonzero on error.
3215  *
3216  * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3217  *      @p ctype is not a supported chunk size.
3218  */
3219 extern int
3220 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3221
3222 /**
3223  * @ingroup G_writing_and_overwriting_wims
3224  *
3225  * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3226  * packed streams.
3227  */
3228 extern int
3229 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3230
3231 /**
3232  * @ingroup G_writing_and_overwriting_wims
3233  *
3234  * Set the compression type of a WIM to use in subsequent calls to
3235  * wimlib_write() or wimlib_overwrite().
3236  *
3237  * @param wim
3238  *      ::WIMStruct for a WIM.
3239  * @param ctype
3240  *      The compression type to set (one of ::wimlib_compression_type).  If this
3241  *      compression type is incompatible with the current output chunk size
3242  *      (either the default or as set with wimlib_set_output_chunk_size()), the
3243  *      output chunk size is reset to the default for that compression type.
3244  *
3245  * @return 0 on success; nonzero on error.
3246  *
3247  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3248  *      @p ctype did not specify a valid compression type.
3249  */
3250 extern int
3251 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3252
3253 /**
3254  * @ingroup G_writing_and_overwriting_wims
3255  *
3256  * Similar to wimlib_set_output_compression_type(), but set the compression type
3257  * for writing packed streams.
3258  */
3259 extern int
3260 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3261
3262 /**
3263  * @ingroup G_modifying_wims
3264  *
3265  * Set basic information about a WIM.
3266  *
3267  * @param wim
3268  *      Pointer to the ::WIMStruct for a WIM.
3269  * @param info
3270  *      A struct ::wimlib_wim_info that contains the information to set.  Only
3271  *      the information explicitly specified in the @p which flags need be
3272  *      valid.
3273  * @param which
3274  *      Flags that specify which information to set.  This is a bitwise OR of
3275  *      ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3276  *      ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3277  *
3278  * @return 0 on success; nonzero on failure.
3279  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3280  *      The WIM file is considered read-only because of any of the reasons
3281  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3282  *      flag.  However, as a special case, if you are using
3283  *      ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3284  *      function will not fail due to the readonly flag being previously set.
3285  * @retval ::WIMLIB_ERR_IMAGE_COUNT
3286  *      ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3287  *      ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3288  *      index in the WIM.
3289  */
3290 extern int
3291 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3292                     int which);
3293
3294 /**
3295  * @ingroup G_modifying_wims
3296  *
3297  * Changes what is written in the \<FLAGS\> element in the WIM XML data
3298  * (something like "Core" or "Ultimate")
3299  *
3300  * @param wim
3301  *      Pointer to the ::WIMStruct for a WIM.
3302  * @param image
3303  *      The number of the image for which to change the description.
3304  * @param flags
3305  *      The new \<FLAGS\> element to give the image.  It may be @c NULL, which
3306  *      indicates that the image is to be given no \<FLAGS\> element.
3307  *
3308  * @return 0 on success; nonzero on error.
3309  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3310  *      @p image does not specify a single existing image in @p wim.
3311  * @retval ::WIMLIB_ERR_NOMEM
3312  *      Failed to allocate the memory needed to duplicate the @p flags string.
3313  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3314  *      @p wim is considered read-only because of any of the reasons mentioned
3315  *      in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3316  */
3317 extern int
3318 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3319
3320 /**
3321  * @ingroup G_modifying_wims
3322  *
3323  * Changes the name of an image in the WIM.
3324  *
3325  * @param wim
3326  *      Pointer to the ::WIMStruct for a WIM.
3327  * @param image
3328  *      The number of the image for which to change the name.
3329  * @param name
3330  *      New name to give the new image.  If @c NULL or empty, the new image is
3331  *      given no name.  If nonempty, it must specify a name that does not
3332  *      already exist in @p wim.
3333  *
3334  * @return 0 on success; nonzero on error.
3335  * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3336  *      There is already an image named @p name in @p wim.
3337  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3338  *      @p image does not specify a single existing image in @p wim.
3339  * @retval ::WIMLIB_ERR_NOMEM
3340  *      Failed to allocate the memory needed to duplicate the @p name string.
3341  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3342  *      @p wim is considered read-only because of any of the reasons mentioned
3343  *      in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3344  */
3345 extern int
3346 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3347
3348 /**
3349  * @ingroup G_general
3350  *
3351  * Set the functions that wimlib uses to allocate and free memory.
3352  *
3353  * These settings are global and not per-WIM.
3354  *
3355  * The default is to use the default @c malloc() and @c free() from the C
3356  * library.
3357  *
3358  * Please note that some external functions, such as those in @c libntfs-3g, may
3359  * use the standard memory allocation functions.
3360  *
3361  * @param malloc_func
3362  *      A function equivalent to @c malloc() that wimlib will use to allocate
3363  *      memory.  If @c NULL, the allocator function is set back to the default
3364  *      @c malloc() from the C library.
3365  * @param free_func
3366  *      A function equivalent to @c free() that wimlib will use to free memory.
3367  *      If @c NULL, the free function is set back to the default @c free() from
3368  *      the C library.
3369  * @param realloc_func
3370  *      A function equivalent to @c realloc() that wimlib will use to reallocate
3371  *      memory.  If @c NULL, the free function is set back to the default @c
3372  *      realloc() from the C library.
3373  * @return 0
3374  */
3375 extern int
3376 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
3377                             void (*free_func)(void *),
3378                             void *(*realloc_func)(void *, size_t));
3379
3380 /**
3381  * @ingroup G_general
3382  *
3383  * Sets whether wimlib is to print error messages to @c stderr when a function
3384  * fails.  These error messages may provide information that cannot be
3385  * determined only from the error code that is returned.  Not every error will
3386  * result in an error message being printed.
3387  *
3388  * This setting is global and not per-WIM.
3389  *
3390  * By default, error messages are not printed.
3391  *
3392  * This can be called before wimlib_global_init().
3393  *
3394  * @param show_messages
3395  *      @c true if error messages are to be printed; @c false if error messages
3396  *      are not to be printed.
3397  *
3398  * @return 0 on success; nonzero on error.
3399  * @retval ::WIMLIB_ERR_UNSUPPORTED
3400  *      @p show_messages was @c true, but wimlib was compiled with the @c
3401  *      --without-error-messages option.   Therefore, error messages cannot be
3402  *      shown.
3403  */
3404 extern int
3405 wimlib_set_print_errors(bool show_messages);
3406
3407 /**
3408  * @ingroup G_nonstandalone_wims
3409  *
3410  * Splits a WIM into multiple parts.
3411  *
3412  * @param wim
3413  *      The ::WIMStruct for the WIM to split.
3414  * @param swm_name
3415  *      Name of the SWM file to create.  This will be the name of the first
3416  *      part.  The other parts will have the same name with 2, 3, 4, ..., etc.
3417  *      appended before the suffix.
3418  * @param part_size
3419  *      The maximum size per part, in bytes.  Unfortunately, it is not
3420  *      guaranteed that this will really be the maximum size per part, because
3421  *      some file resources in the WIM may be larger than this size, and the WIM
3422  *      file format provides no way to split up file resources among multiple
3423  *      WIMs.
3424  * @param write_flags
3425  *      Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG.  These
3426  *      flags will be used to write each split WIM part.  Specify 0 here to get
3427  *      the default behavior.
3428  * @param progress_func
3429  *      If non-NULL, a function that will be called periodically with the
3430  *      progress of the current operation
3431  *      (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
3432  *      ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
3433  *
3434  * @return 0 on success; nonzero on error.  This function may return most error
3435  * codes that can be returned by wimlib_write() as well as the following error
3436  * codes:
3437  *
3438  * @retval ::WIMLIB_ERR_INVALID_PARAM
3439  *      @p swm_name was not a nonempty string, or @p part_size was 0.
3440  *
3441  * Note: the WIM's uncompressed and compressed resources are not checksummed
3442  * when they are copied from the joined WIM to the split WIM parts, nor are
3443  * compressed resources re-compressed (unless explicitly requested with
3444  * ::WIMLIB_WRITE_FLAG_RECOMPRESS).
3445  */
3446 extern int
3447 wimlib_split(WIMStruct *wim,
3448              const wimlib_tchar *swm_name,
3449              uint64_t part_size,
3450              int write_flags,
3451              wimlib_progress_func_t progress_func);
3452
3453 /**
3454  * @ingroup G_mounting_wim_images
3455  *
3456  * Unmounts a WIM image that was mounted using wimlib_mount_image().
3457  *
3458  * The image to unmount is specified by the path to the mountpoint, not the
3459  * original ::WIMStruct passed to wimlib_mount_image(), which should not be
3460  * touched and also may have been allocated in a different process.
3461  *
3462  * To unmount the image, the process calling this function communicates with the
3463  * process that is managing the mounted WIM image.  This function blocks until it
3464  * is known whether the unmount succeeded or failed.  In the case of a
3465  * read-write mounted WIM, the unmount is not considered to have succeeded until
3466  * all changes have been saved to the underlying WIM file.
3467  *
3468  * @param dir
3469  *      The directory that the WIM image was mounted on.
3470  * @param unmount_flags
3471  *      Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY,
3472  *      ::WIMLIB_UNMOUNT_FLAG_COMMIT, ::WIMLIB_UNMOUNT_FLAG_REBUILD, and/or
3473  *      ::WIMLIB_UNMOUNT_FLAG_RECOMPRESS.  None of these flags affect read-only
3474  *      mounts.
3475  * @param progress_func
3476  *      If non-NULL, a function that will be called periodically with the
3477  *      progress of the current operation.  Currently, only
3478  *      ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS will be sent.
3479  *
3480  * @return 0 on success; nonzero on error.
3481  *
3482  * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
3483  *      The filesystem daemon was unable to remove the staging directory and the
3484  *      temporary files that it contains.
3485  * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
3486  *      The filesystem daemon appears to have terminated before sending an exit
3487  *      status.
3488  * @retval ::WIMLIB_ERR_FORK
3489  *      Could not @c fork() the process.
3490  * @retval ::WIMLIB_ERR_FUSERMOUNT
3491  *      The @b fusermount program could not be executed or exited with a failure
3492  *      status.
3493  * @retval ::WIMLIB_ERR_MQUEUE
3494  *      Could not open a POSIX message queue to communicate with the filesystem
3495  *      daemon servicing the mounted filesystem, could not send a message
3496  *      through the queue, or could not receive a message through the queue.
3497  * @retval ::WIMLIB_ERR_NOMEM
3498  *      Failed to allocate needed memory.
3499  * @retval ::WIMLIB_ERR_OPEN
3500  *      The filesystem daemon could not open a temporary file for writing the
3501  *      new WIM.
3502  * @retval ::WIMLIB_ERR_READ
3503  *      A read error occurred when the filesystem daemon tried to a file from
3504  *      the staging directory
3505  * @retval ::WIMLIB_ERR_RENAME
3506  *      The filesystem daemon failed to rename the newly written WIM file to the
3507  *      original WIM file.
3508  * @retval ::WIMLIB_ERR_UNSUPPORTED
3509  *      Mounting is not supported, either because the platform is Windows, or
3510  *      because the platform is UNIX-like and wimlib was compiled with @c
3511  *      --without-fuse.
3512  * @retval ::WIMLIB_ERR_WRITE
3513  *      A write error occurred when the filesystem daemon was writing to the new
3514  *      WIM file, or the filesystem daemon was unable to flush changes that had
3515  *      been made to files in the staging directory.
3516  */
3517 extern int
3518 wimlib_unmount_image(const wimlib_tchar *dir,
3519                      int unmount_flags,
3520                      wimlib_progress_func_t progress_func);
3521
3522 /**
3523  * @ingroup G_modifying_wims
3524  *
3525  * Update a WIM image by adding, deleting, and/or renaming files or directories.
3526  *
3527  * @param wim
3528  *      Pointer to the ::WIMStruct for the WIM file to update.
3529  * @param image
3530  *      The 1-based index of the image in the WIM to update.  It cannot be
3531  *      ::WIMLIB_ALL_IMAGES.
3532  * @param cmds
3533  *      An array of ::wimlib_update_command's that specify the update operations
3534  *      to perform.
3535  * @param num_cmds
3536  *      Number of commands in @p cmds.
3537  * @param update_flags
3538  *      ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
3539  * @param progress_func
3540  *      If non-NULL, a function that will be called periodically with the
3541  *      progress of the current operation.
3542  *
3543  * @return 0 on success; nonzero on error.  On failure, some but not all of the
3544  * update commands may have been executed.  No individual update command will
3545  * have been partially executed.  Possible error codes include:
3546  *
3547  * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
3548  *      The capture configuration structure specified for an add command was
3549  *      invalid.
3550  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3551  *      @p image did not specify a single, existing image in @p wim.
3552  * @retval ::WIMLIB_ERR_INVALID_OVERLAY
3553  *      Attempted to perform an add command that conflicted with previously
3554  *      existing files in the WIM when an overlay was attempted.
3555  * @retval ::WIMLIB_ERR_INVALID_PARAM
3556  *      An unknown operation type was specified in the update commands; or,
3557  *      attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
3558  *      in the @p add_flags, but the same image had previously already been
3559  *      added from a NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
3560  *      ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
3561  *      command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
3562  *      specified in the @p add_flags for an add command in which @p
3563  *      wim_target_path was not the root directory of the WIM image.
3564  * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
3565  *      (Windows only):  While executing an add command, tried to capture a
3566  *      reparse point with invalid data.
3567  * @retval ::WIMLIB_ERR_IS_DIRECTORY
3568  *      A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
3569  *      for a WIM path that corresponded to a directory; or, a rename command
3570  *      attempted to rename a directory to a non-directory.
3571  * @retval ::WIMLIB_ERR_NOMEM
3572  *      Failed to allocate needed memory.
3573  * @retval ::WIMLIB_ERR_NOTDIR
3574  *      A rename command attempted to rename a directory to a non-directory; or,
3575  *      an add command was executed that attempted to set the root of the WIM
3576  *      image as a non-directory; or, a path component used as a directory in a
3577  *      rename command was not, in fact, a directory.
3578  * @retval ::WIMLIB_ERR_NOTEMPTY
3579  *      A rename command attempted to rename a directory to a non-empty
3580  *      directory.
3581  * @retval ::WIMLIB_ERR_NTFS_3G
3582  *      While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
3583  *      error occurred while reading data from the NTFS volume using libntfs-3g.
3584  * @retval ::WIMLIB_ERR_OPEN
3585  *      Failed to open a file to be captured while executing an add command.
3586  * @retval ::WIMLIB_ERR_OPENDIR
3587  *      Failed to open a directory to be captured while executing an add command.
3588  * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3589  *      A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
3590  *      WIM path that did not exist; or, a rename command attempted to rename a
3591  *      file that does not exist.
3592  * @retval ::WIMLIB_ERR_READ
3593  *      While executing an add command, failed to read data from a file or
3594  *      directory to be captured.
3595  * @retval ::WIMLIB_ERR_READLINK
3596  *      While executing an add command, failed to read the target of a symbolic
3597  *      link or junction point.
3598  * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
3599  *      (Windows only) Failed to perform a reparse point fixup because of
3600  *      problems with the data of a reparse point.
3601  * @retval ::WIMLIB_ERR_STAT
3602  *      While executing an add command, failed to get attributes for a file or
3603  *      directory.
3604  * @retval ::WIMLIB_ERR_UNSUPPORTED
3605  *      ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
3606  *      command, but wimlib was configured with the @c --without-ntfs-3g flag;
3607  *      or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
3608  *      or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
3609  *      add_flags for an update command.
3610  * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
3611  *      While executing an add command, attempted to capture a file that was not
3612  *      a supported file type (e.g. a device file).  Only if
3613  *      ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
3614  *      for an update command.
3615  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3616  *      The WIM file is considered read-only because of any of the reasons
3617  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3618  *      flag.
3619  *
3620  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3621  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3622  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3623  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3624  * different reasons) to read the metadata resource for an image that needed to
3625  * be updated.
3626  */
3627 extern int
3628 wimlib_update_image(WIMStruct *wim,
3629                     int image,
3630                     const struct wimlib_update_command *cmds,
3631                     size_t num_cmds,
3632                     int update_flags,
3633                     wimlib_progress_func_t progress_func);
3634
3635 /**
3636  * @ingroup G_writing_and_overwriting_wims
3637  *
3638  * Writes a WIM to a file.
3639  *
3640  * This brings in resources from any external locations, such as directory trees
3641  * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
3642  * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
3643  *
3644  * By default, the new WIM file is written as stand-alone.  Using the
3645  * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
3646  * instead.  However, this function cannot directly write a "split" WIM; use
3647  * wimlib_split() for that.
3648  *
3649  * @param wim
3650  *      Pointer to the ::WIMStruct for a WIM.  There may have been in-memory
3651  *      changes made to it, which are then reflected in the output file.
3652  * @param path
3653  *      The path to the file to write the WIM to.
3654  * @param image
3655  *      Normally, specify ::WIMLIB_ALL_IMAGES here.  This indicates that all
3656  *      images are to be included in the new on-disk WIM file.  If for some
3657  *      reason you only want to include a single image, specify the index of
3658  *      that image instead.
3659  * @param write_flags
3660  *      Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
3661  * @param num_threads
3662  *      Number of threads to use for compressing data.  If 0, the number of
3663  *      threads is taken to be the number of online processors.  Note: if no
3664  *      data compression needs to be done, no additional threads will be created
3665  *      regardless of this parameter (e.g. if writing an uncompressed WIM, or
3666  *      exporting an image from a compressed WIM to another WIM of the same
3667  *      compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
3668  *      write_flags).
3669  * @param progress_func
3670  *      If non-NULL, a function that will be called periodically with the
3671  *      progress of the current operation.  The possible messages are
3672  *      ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
3673  *      ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END, and
3674  *      ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS.
3675  *
3676  * @return 0 on success; nonzero on error.
3677  *
3678  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3679  *      @p image does not specify a single existing image in @p wim, and is not
3680  *      ::WIMLIB_ALL_IMAGES.
3681  * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
3682  *      A file that had previously been scanned for inclusion in the WIM by
3683  *      wimlib_add_image() was concurrently modified, so it failed the SHA1
3684  *      message digest check.
3685  * @retval ::WIMLIB_ERR_INVALID_PARAM
3686  *      @p path was @c NULL.
3687  * @retval ::WIMLIB_ERR_NOMEM
3688  *      Failed to allocate needed memory.
3689  * @retval ::WIMLIB_ERR_OPEN
3690  *      Failed to open @p path for writing, or some file resources in @p wim
3691  *      refer to files in the outside filesystem, and one of these files could
3692  *      not be opened for reading.
3693  * @retval ::WIMLIB_ERR_READ
3694  *      An error occurred when trying to read data from the WIM file associated
3695  *      with @p wim, or some file resources in @p wim refer to files in the
3696  *      outside filesystem, and a read error occurred when reading one of these
3697  *      files.
3698  * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3699  *      A stream that needed to be written could not be found in the stream
3700  *      lookup table of @p wim.  This error can occur if, for example, @p wim is
3701  *      part of a split WIM but needed resources from the other split WIM parts
3702  *      were not referenced with wimlib_reference_resources() or
3703  *      wimlib_reference_resource_files() before the call to wimlib_write().
3704  * @retval ::WIMLIB_ERR_WRITE
3705  *      An error occurred when trying to write data to the new WIM file.
3706  *
3707  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3708  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3709  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3710  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3711  * different reasons) to read the metadata resource for an image that needed to
3712  * be written.
3713  */
3714 extern int
3715 wimlib_write(WIMStruct *wim,
3716              const wimlib_tchar *path,
3717              int image,
3718              int write_flags,
3719              unsigned num_threads,
3720              wimlib_progress_func_t progress_func);
3721
3722 /**
3723  * @ingroup G_writing_and_overwriting_wims
3724  *
3725  * Since wimlib v1.5.0:  Same as wimlib_write(), but write the WIM directly to a
3726  * file descriptor, which need not be seekable if the write is done in a special
3727  * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
3728  * write_flags.  This can, for example, allow capturing a WIM image and
3729  * streaming it over the network.  See the documentation for
3730  * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
3731  *
3732  * The file descriptor @p fd will @b not be closed when the write is complete;
3733  * the calling code is responsible for this.
3734  *
3735  * Returns 0 on success; nonzero on failure.  The possible error codes include
3736  * those that can be returned by wimlib_write() as well as the following:
3737  *
3738  * @retval ::WIMLIB_ERR_INVALID_PARAM
3739  *      @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
3740  *      specified in @p write_flags.
3741  */
3742 extern int
3743 wimlib_write_to_fd(WIMStruct *wim,
3744                    int fd,
3745                    int image,
3746                    int write_flags,
3747                    unsigned num_threads,
3748                    wimlib_progress_func_t progress_func);
3749
3750 /**
3751  * @defgroup G_compression Compression and decompression functions
3752  *
3753  * @brief Functions for LZX, XPRESS, and LZMS compression and decompression,
3754  * exported for convenience only, as they are already used by wimlib internally
3755  * when appropriate.
3756  *
3757  * These functions can be used for general-purpose lossless data compression,
3758  * but some limitations apply; for example, none of the compressors or
3759  * decompressors currently support sliding windows, and there also exist
3760  * slightly different variants of these formats that are not supported
3761  * unmodified.
3762  */
3763
3764 /**
3765  * @ingroup G_compression
3766  * @{
3767  */
3768
3769 /** Header for compression parameters to pass to wimlib_create_compressor() or
3770  * wimlib_set_default_compressor_params().  */
3771 struct wimlib_compressor_params_header {
3772         /** Size of the parameters, in bytes.  */
3773         uint32_t size;
3774 };
3775
3776 /** Header for decompression parameters to pass to wimlib_create_decompressor()
3777  * or wimlib_set_default_decompressor_params() */
3778 struct wimlib_decompressor_params_header {
3779         /** Size of the parameters, in bytes.  */
3780         uint32_t size;
3781 };
3782
3783 /** LZX compression parameters that can optionally be passed to
3784  * wimlib_create_compressor() with the compression type
3785  * ::WIMLIB_COMPRESSION_TYPE_LZX.  */
3786 struct wimlib_lzx_compressor_params {
3787         /** hdr.size Must be set to the size of this structure, in bytes.  */
3788         struct wimlib_compressor_params_header hdr;
3789
3790         /** Relatively fast LZX compression algorithm with a decent compression
3791          * ratio; the suggested default.  */
3792 #define WIMLIB_LZX_ALGORITHM_FAST 0
3793
3794         /** Slower LZX compression algorithm that provides a better compression
3795          * ratio.  */
3796 #define WIMLIB_LZX_ALGORITHM_SLOW 1
3797
3798         /** Algorithm to use to perform the compression: either
3799          * ::WIMLIB_LZX_ALGORITHM_FAST or ::WIMLIB_LZX_ALGORITHM_SLOW.  The
3800          * format is still LZX; this refers to the method the code will use to
3801          * perform LZX-compatible compression.  */
3802         uint32_t algorithm : 3;
3803
3804         /** If set to 1, the default parameters for the specified algorithm are
3805          * used rather than the ones specified in the following union.  */
3806         uint32_t use_defaults : 1;
3807
3808         union {
3809                 /** Parameters for the fast algorithm.  */
3810                 struct wimlib_lzx_fast_params {
3811                         uint32_t fast_reserved1[10];
3812                 } fast;
3813
3814                 /** Parameters for the slow algorithm.  */
3815                 struct wimlib_lzx_slow_params {
3816                         /** If set to 1, the compressor can output length 2
3817                          * matches.  If set 0, the compressor only outputs
3818                          * matches of length 3 or greater.  Suggested value: 1
3819                          */
3820                         uint32_t use_len2_matches : 1;
3821
3822                         uint32_t slow_reserved1 : 31;
3823
3824                         /** Matches with length (in bytes) longer than this
3825                          * value are immediately taken without spending time on
3826                          * minimum-cost measurements.  Suggested value: 32.  */
3827                         uint32_t num_fast_bytes;
3828
3829                         /** Number of passes to compute a match/literal sequence
3830                          * for each LZX block.  This is for an iterative
3831                          * algorithm that attempts to minimize the cost of the
3832                          * match/literal sequence by using a cost model provided
3833                          * by the previous iteration.  Must be at least 1.
3834                          * Suggested value: 2.  */
3835                         uint32_t num_optim_passes;
3836
3837                         /** Reserved; set to 0.  */
3838                         uint32_t slow_reserved_blocksplit;
3839
3840                         /** Maximum depth to search for matches at each
3841                          * position.  Suggested value: 50.  */
3842                         uint32_t max_search_depth;
3843
3844                         /** Maximum number of potentially good matches to
3845                          * consider for each position.  Suggested value: 3.  */
3846                         uint32_t max_matches_per_pos;
3847
3848                         uint32_t slow_reserved2[2];
3849
3850                         /** Assumed cost of a main symbol with zero frequency.
3851                          * Must be at least 1 and no more than 16.  Suggested
3852                          * value: 15.  */
3853                         uint8_t main_nostat_cost;
3854
3855                         /** Assumed cost of a length symbol with zero frequency.
3856                          * Must be at least 1 and no more than 16.  Suggested
3857                          * value: 15.  */
3858                         uint8_t len_nostat_cost;
3859
3860                         /** Assumed cost of an aligned symbol with zero
3861                          * frequency.  Must be at least 1 and no more than 8.
3862                          * Suggested value: 7.  */
3863                         uint8_t aligned_nostat_cost;
3864
3865                         uint8_t slow_reserved3[5];
3866                 } slow;
3867         } alg_params;
3868 };
3869
3870 /** Opaque compressor handle.  */
3871 struct wimlib_compressor;
3872
3873 /** Opaque decompressor handle.  */
3874 struct wimlib_decompressor;
3875
3876 /**
3877  * Set the default compression parameters for the specified compression type.
3878  * This will affect both explicit and wimlib-internal calls to
3879  * wimlib_create_compressor().
3880  *
3881  * @param ctype
3882  *      Compression type for which to set the default compression parameters.
3883  * @param params
3884  *      Compression-type specific parameters.  This may be @c NULL, in which
3885  *      case the "default default" parameters are restored.
3886  *
3887  * @return 0 on success; nonzero on error.
3888  *
3889  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3890  *      @p ctype was not a supported compression type.
3891  * @retval ::WIMLIB_ERR_NOMEM
3892  *      Not enough memory to duplicate the parameters (perhaps @c params->size
3893  *      was invalid).
3894  */
3895 extern int
3896 wimlib_set_default_compressor_params(enum wimlib_compression_type ctype,
3897                                      const struct wimlib_compressor_params_header *params);
3898
3899 /**
3900  * Allocate a compressor for the specified compression type using the specified
3901  * parameters.
3902  *
3903  * @param ctype
3904  *      Compression type for which to create the compressor.
3905  * @param max_block_size
3906  *      Maximum block size to support.  The exact meaning and allowed values for
3907  *      this parameter depend on the compression type, but it at least specifies
3908  *      the maximum allowed value for @p uncompressed_size to wimlib_compress().
3909  * @param extra_params
3910  *      An optional pointer to extra compressor parameters for the specified
3911  *      compression type.  For LZX, a pointer to ::wimlib_lzx_compressor_params
3912  *      may be specified here.  If left @c NULL, the default parameters are
3913  *      used.
3914  * @param compressor_ret
3915  *      A location into which to return the pointer to the allocated compressor,
3916  *      which can be used for any number of calls to wimlib_compress() before
3917  *      being freed with wimlib_free_compressor().
3918  *
3919  * @return 0 on success; nonzero on error.
3920  *
3921  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3922  *      @p ctype was not a supported compression type.
3923  * @retval ::WIMLIB_ERR_INVALID_PARAM
3924  *      The compression parameters were invalid.
3925  * @retval ::WIMLIB_ERR_NOMEM
3926  *      Insufficient memory to allocate the compressor.
3927  */
3928 extern int
3929 wimlib_create_compressor(enum wimlib_compression_type ctype,
3930                          size_t max_block_size,
3931                          const struct wimlib_compressor_params_header *extra_params,
3932                          struct wimlib_compressor **compressor_ret);
3933
3934 /**
3935  * Losslessly compress a block of data using a compressor previously created
3936  * with wimlib_create_compressor().
3937  *
3938  * @param uncompressed_data
3939  *      Buffer containing the data to compress.
3940  * @param uncompressed_size
3941  *      Size, in bytes, of the data to compress.
3942  * @param compressed_data
3943  *      Buffer into which to write the compressed data.
3944  * @param compressed_size_avail
3945  *      Number of bytes available in @p compressed_data.
3946  * @param compressor
3947  *      A compressor previously allocated with wimlib_create_compressor().
3948  *
3949  * @return
3950  *      The size of the compressed data, in bytes, or 0 if the input data could
3951  *      not be compressed to @p compressed_size_avail or fewer bytes.
3952  */
3953 extern size_t
3954 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
3955                 void *compressed_data, size_t compressed_size_avail,
3956                 struct wimlib_compressor *compressor);
3957
3958 /**
3959  * Free a compressor previously allocated with wimlib_create_compressor().
3960  *
3961  * @param compressor
3962  *      The compressor to free.
3963  */
3964 extern void
3965 wimlib_free_compressor(struct wimlib_compressor *compressor);
3966
3967 /**
3968  * Set the default decompression parameters for the specified compression type.
3969  * This will affect both explicit and wimlib-internal calls to
3970  * wimlib_create_decompressor().
3971  *
3972  * @param ctype
3973  *      Compression type for which to set the default decompression parameters.
3974  * @param params
3975  *      Compression-type specific parameters.  This may be @c NULL, in which
3976  *      case the "default default" parameters are restored.
3977  *
3978  * @return 0 on success; nonzero on error.
3979  *
3980  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3981  *      @p ctype was not a supported compression type.
3982  * @retval ::WIMLIB_ERR_NOMEM
3983  *      Not enough memory to duplicate the parameters (perhaps @c params->size
3984  *      was invalid).
3985  */
3986 extern int
3987 wimlib_set_default_decompressor_params(enum wimlib_compression_type ctype,
3988                                        const struct wimlib_decompressor_params_header *params);
3989
3990 /**
3991  * Allocate a decompressor for the specified compression type using the
3992  * specified parameters.
3993  *
3994  * @param ctype
3995  *      Compression type for which to create the decompressor.
3996  * @param max_block_size
3997  *      Maximum block size to support.  The exact meaning and allowed values for
3998  *      this parameter depend on the compression type, but it at least specifies
3999  *      the maximum allowed value for @p uncompressed_size to
4000  *      wimlib_decompress().
4001  * @param extra_params
4002  *      An optional pointer to extra decompressor parameters for the specified
4003  *      compression type.  If @c NULL, the default parameters are used.
4004  * @param decompressor_ret
4005  *      A location into which to return the pointer to the allocated
4006  *      decompressor, which can be used for any number of calls to
4007  *      wimlib_decompress() before being freed with wimlib_free_decompressor().
4008  *
4009  * @return 0 on success; nonzero on error.
4010  *
4011  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4012  *      @p ctype was not a supported compression type.
4013  * @retval ::WIMLIB_ERR_INVALID_PARAM
4014  *      The decompression parameters were invalid.
4015  * @retval ::WIMLIB_ERR_NOMEM
4016  *      Insufficient memory to allocate the decompressor.
4017  */
4018 extern int
4019 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4020                            size_t max_block_size,
4021                            const struct wimlib_decompressor_params_header *extra_params,
4022                            struct wimlib_decompressor **decompressor_ret);
4023
4024 /**
4025  * Decompress a block of data using a decompressor previously created with
4026  * wimlib_create_decompressor().
4027  *
4028  * @param compressed_data
4029  *      Buffer containing the data to decompress.
4030  * @param compressed_size
4031  *      Size, in bytes, of the data to decompress.
4032  * @param uncompressed_data
4033  *      Buffer into which to write the uncompressed data.
4034  * @param uncompressed_size
4035  *      Size, in bytes, of the data when uncompressed.
4036  * @param decompressor
4037  *      A decompressor previously allocated with wimlib_create_decompressor().
4038  *
4039  * @return 0 on success; nonzero on error.
4040  */
4041 extern int
4042 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4043                   void *uncompressed_data, size_t uncompressed_size,
4044                   struct wimlib_decompressor *decompressor);
4045
4046 /**
4047  * Free a decompressor previously allocated with wimlib_create_decompressor().
4048  *
4049  * @param decompressor
4050  *      The decompressor to free.
4051  */
4052 extern void
4053 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4054
4055
4056 struct wimlib_lzx_params_old;
4057 struct wimlib_lzx_context_old;
4058
4059 /** Deprecated; do not use.  */
4060 extern int
4061 wimlib_lzx_set_default_params(const struct wimlib_lzx_params_old *params)
4062                 _wimlib_deprecated;
4063
4064 /** Deprecated; do not use.  */
4065 extern int
4066 wimlib_lzx_alloc_context(const struct wimlib_lzx_params_old *params,
4067                          struct wimlib_lzx_context_old **ctx_pp)
4068                 _wimlib_deprecated;
4069
4070 /** Deprecated; do not use.  */
4071 extern void
4072 wimlib_lzx_free_context(struct wimlib_lzx_context_old *ctx)
4073                 _wimlib_deprecated;
4074
4075 /** Deprecated; do not use.  */
4076 extern unsigned
4077 wimlib_lzx_compress2(const void *udata, unsigned ulen, void *cdata,
4078                      struct wimlib_lzx_context_old *ctx)
4079                 _wimlib_deprecated;
4080
4081 /** Deprecated; do not use.  */
4082 extern unsigned
4083 wimlib_lzx_compress(const void *udata, unsigned ulen, void *cdata)
4084                 _wimlib_deprecated;
4085
4086 /** Deprecated; do not use.  */
4087 extern unsigned
4088 wimlib_xpress_compress(const void *udata, unsigned ulen, void *cdata)
4089                 _wimlib_deprecated;
4090
4091 /** Deprecated; do not use.  */
4092 extern int
4093 wimlib_lzx_decompress(const void *cdata, unsigned clen,
4094                       void *udata, unsigned ulen)
4095                 _wimlib_deprecated;
4096
4097 /** Deprecated; do not use.  */
4098 extern int
4099 wimlib_xpress_decompress(const void *cdata, unsigned clen,
4100                          void *udata, unsigned ulen)
4101                 _wimlib_deprecated;
4102
4103 /** @} */
4104
4105
4106
4107 #ifdef __cplusplus
4108 }
4109 #endif
4110
4111 #endif /* _WIMLIB_H */