]> wimlib.net Git - wimlib/blobdiff - include/wimlib.h
decompress_common.h: Add back check for buffer overrun
[wimlib] / include / wimlib.h
index 17e5957401a236446f85db7cefcea06a51e5a985..db8d5d5208b1fd654bc91fc1d019d80d9df15b61 100644 (file)
@@ -626,6 +626,19 @@ enum wimlib_progress_msg {
         * ::wimlib_progress_info.done_with_file.  This message is only received
         * if ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES was provided.  */
        WIMLIB_PROGRESS_MSG_DONE_WITH_FILE = 26,
+
+       /** wimlib_verify_wim() is starting to verify the metadata for an image.
+        * @p info will point to ::wimlib_progress_info.verify_image.  */
+       WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE = 27,
+
+       /** wimlib_verify_wim() has finished verifying the metadata for an
+        * image.  @p info will point to ::wimlib_progress_info.verify_image.
+        */
+       WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE = 28,
+
+       /** wimlib_verify_wim() is verifying stream integrity.  @p info will
+        * point to ::wimlib_progress_info.verify_streams.  */
+       WIMLIB_PROGRESS_MSG_VERIFY_STREAMS = 29,
 };
 
 /** Valid return values from user-provided progress functions
@@ -1053,6 +1066,23 @@ union wimlib_progress_info {
                 */
                const wimlib_tchar *path_to_file;
        } done_with_file;
+
+       /** Valid on messages ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE and
+        * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE.  */
+       struct wimlib_progress_info_verify_image {
+               const wimlib_tchar *wimfile;
+               uint32_t total_images;
+               uint32_t current_image;
+       } verify_image;
+
+       /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS.  */
+       struct wimlib_progress_info_verify_streams {
+               const wimlib_tchar *wimfile;
+               uint64_t total_streams;
+               uint64_t total_bytes;
+               uint64_t completed_streams;
+               uint64_t completed_bytes;
+       } verify_streams;
 };
 
 /**
@@ -2868,8 +2898,9 @@ wimlib_get_compression_type_string(int ctype);
  *     The error code returned by one of wimlib's functions.
  *
  * @return
- *     Pointer to a statically allocated string describing the error code,
- *     or @c NULL if the error code is not valid.
+ *     Pointer to a statically allocated string describing the error code.  If
+ *     the error code is for some reason not recognized by the library, the
+ *     string will be "Unknown error".
  */
 extern const wimlib_tchar *
 wimlib_get_error_string(enum wimlib_error_code code);
@@ -3678,6 +3709,8 @@ wimlib_resolve_image(WIMStruct *wim,
                     const wimlib_tchar *image_name_or_num);
 
 /**
+ * @ingroup G_general
+ *
  * Sets the file to which the library will print error and warning messages.
  *
  * This version of the function takes a C library <c>FILE *</c> opened for
@@ -3695,6 +3728,8 @@ extern int
 wimlib_set_error_file(FILE *fp);
 
 /**
+ * @ingroup G_general
+ *
  * Sets the path to the file to which the library will print error and warning
  * messages.  The library will open this file for appending.
  *
@@ -3991,6 +4026,45 @@ wimlib_split(WIMStruct *wim,
             uint64_t part_size,
             int write_flags);
 
+/**
+ * @ingroup G_general
+ *
+ * Perform verification checks on a WIM file.
+ *
+ * @param wim
+ *     The ::WIMStruct for the WIM file to verify.  Note: for an extra layer of
+ *     verification, it is a good idea to have used
+ *     ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY when you opened the file.
+ *     <br/>
+ *     If verifying a split WIM, specify the first part of the split WIM here,
+ *     and reference the other parts using wimlib_reference_resource_files()
+ *     before calling this function.
+ *
+ * @param verify_flags
+ *     Reserved; must be 0.
+ *
+ * @retval 0 if the WIM file was successfully verified; nonzero if it failed
+ * verification or another error occurred.  Some of the possible error codes
+ * are:
+ *
+ * @retval ::WIMLIB_ERR_DECOMPRESSION
+ *     A compressed resource could not be decompressed.
+ * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
+ *     The metadata resource for an image is invalid.
+ * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
+ *     One of the files did not decompress to its original data, as given by a
+ *     cryptographic checksum.
+ * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
+ *     One of the files referenced by an image could not be located.
+ *
+ * If a progress function is registered with @p wim, it will receive the
+ * following progress messages: ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE,
+ * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE, and
+ * ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS.
+ */
+extern int
+wimlib_verify_wim(WIMStruct *wim, int verify_flags);
+
 /**
  * @ingroup G_mounting_wim_images
  *
@@ -4291,9 +4365,10 @@ struct wimlib_decompressor;
  * wimlib_create_compressor().
  *
  * @param ctype
- *     Compression type for which to set the default compression level.  Or, if
- *     this is the special value -1, the default compression levels for all
- *     known compression types will be set.
+ *     Compression type for which to set the default compression level, as one
+ *     of the ::wimlib_compression_type constants.  Or, if this is the special
+ *     value -1, the default compression levels for all known compression types
+ *     will be set.
  * @param compression_level
  *     The default compression level to set.  If 0, the "default default" level
  *     is restored.  Otherwise, a higher value indicates higher compression.
@@ -4306,8 +4381,7 @@ struct wimlib_decompressor;
  *     @p ctype was neither a supported compression type nor -1.
  */
 extern int
-wimlib_set_default_compression_level(enum wimlib_compression_type ctype,
-                                    unsigned int compression_level);
+wimlib_set_default_compression_level(int ctype, unsigned int compression_level);
 
 /**
  * Returns the approximate number of bytes needed to allocate a compressor with