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