]> wimlib.net Git - wimlib/blobdiff - src/error.c
Improve random number generation
[wimlib] / src / error.c
index 627d1c2776ecabec10e49796ac42e91277a197ae..26fc10a4511e395b16b7faec8a6ebb785d888f1f 100644 (file)
 
 #include "wimlib.h"
 #include "wimlib/error.h"
+#include "wimlib/test_support.h"
 #include "wimlib/util.h"
-#ifdef __WIN32__
-#  include "wimlib/win32.h"
-#endif
+#include "wimlib/win32.h"
 
 #ifdef ENABLE_ERROR_MESSAGES
 bool wimlib_print_errors = false;
 FILE *wimlib_error_file = NULL; /* Set in wimlib_global_init() */
 static bool wimlib_owns_error_file = false;
-#endif
 
-#if defined(ENABLE_ERROR_MESSAGES) || defined(ENABLE_DEBUG)
 static void
-wimlib_vmsg(const tchar *tag, const tchar *format,
-           va_list va, bool perror)
+wimlib_vmsg(const tchar *tag, const tchar *format, va_list va, bool perror)
 {
-#if !defined(ENABLE_DEBUG)
-       if (wimlib_print_errors)
-#endif
-       {
-               int errno_save = errno;
-               fflush(stdout);
-               tfputs(tag, wimlib_error_file);
-               tvfprintf(wimlib_error_file, format, va);
-               if (perror && errno_save != 0) {
-                       tchar buf[64];
-                       int res;
-                       res = tstrerror_r(errno_save, buf, ARRAY_LEN(buf));
-                       if (res) {
-                               tsprintf(buf,
-                                        T("unknown error (errno=%d)"),
-                                        errno_save);
-                       }
-               #ifdef WIN32
-                       if (errno_save == EBUSY)
-                               tstrcpy(buf, T("Resource busy"));
-               #endif
-                       tfprintf(wimlib_error_file, T(": %"TS), buf);
+       if (!wimlib_print_errors)
+               return;
+       int errno_save = errno;
+       fflush(stdout);
+       tfputs(tag, wimlib_error_file);
+       tvfprintf(wimlib_error_file, format, va);
+       if (perror && errno_save != 0) {
+               tchar buf[64];
+               int res;
+               res = tstrerror_r(errno_save, buf, ARRAY_LEN(buf));
+               if (res) {
+                       tsprintf(buf,
+                                T("unknown error (errno=%d)"),
+                                errno_save);
                }
-               tputc(T('\n'), wimlib_error_file);
-               fflush(wimlib_error_file);
-               errno = errno_save;
+       #ifdef WIN32
+               if (errno_save == EBUSY)
+                       tstrcpy(buf, T("Resource busy"));
+       #endif
+               tfprintf(wimlib_error_file, T(": %"TS), buf);
        }
+       tputc(T('\n'), wimlib_error_file);
+       fflush(wimlib_error_file);
+       errno = errno_save;
 }
-#endif
 
-#ifdef ENABLE_ERROR_MESSAGES
 void
 wimlib_error(const tchar *format, ...)
 {
@@ -128,22 +119,7 @@ wimlib_warning_with_errno(const tchar *format, ...)
        wimlib_vmsg(T("\r[WARNING] "), format, va, true);
        va_end(va);
 }
-
-#endif
-
-#ifdef ENABLE_DEBUG
-void wimlib_debug(const tchar *filename, int line, const char *func,
-                 const tchar *format, ...)
-{
-       va_list va;
-       tchar buf[tstrlen(filename) + strlen(func) + 30];
-
-       tsprintf(buf, T("[%"TS" %d] %s(): "), filename, line, func);
-       va_start(va, format);
-       wimlib_vmsg(buf, format, va, false);
-       va_end(va);
-}
-#endif
+#endif /* ENABLE_ERROR_MESSAGES */
 
 void
 print_byte_field(const u8 *field, size_t len, FILE *out)
@@ -206,14 +182,11 @@ static const tchar * const error_strings[] = {
        [WIMLIB_ERR_ALREADY_LOCKED]
                = T("The WIM is already locked for writing"),
        [WIMLIB_ERR_DECOMPRESSION]
-               = T("Failed to decompress compressed data"),
+               = T("The WIM contains invalid compressed data"),
        [WIMLIB_ERR_FUSE]
                = T("An error was returned by fuse_main()"),
        [WIMLIB_ERR_GLOB_HAD_NO_MATCHES]
                = T("The provided file glob did not match any files"),
-       [WIMLIB_ERR_ICONV_NOT_AVAILABLE]
-               = T("The iconv() function does not seem to work. "
-                 "Maybe check to make sure the directory /usr/lib/gconv exists"),
        [WIMLIB_ERR_IMAGE_COUNT]
                = T("Inconsistent image count among the metadata "
                        "resources, the WIM header, and/or the XML data"),
@@ -224,7 +197,7 @@ static const tchar * const error_strings[] = {
        [WIMLIB_ERR_INTEGRITY]
                = T("The WIM file is corrupted (failed integrity check)"),
        [WIMLIB_ERR_INVALID_CAPTURE_CONFIG]
-               = T("The capture configuration string was invalid"),
+               = T("The contents of the capture configuration file were invalid"),
        [WIMLIB_ERR_INVALID_CHUNK_SIZE]
                = T("The compression chunk size was unrecognized"),
        [WIMLIB_ERR_INVALID_COMPRESSION_TYPE]
@@ -239,8 +212,6 @@ static const tchar * const error_strings[] = {
                = T("An entry in the WIM's lookup table is invalid"),
        [WIMLIB_ERR_INVALID_METADATA_RESOURCE]
                = T("The metadata resource is invalid"),
-       [WIMLIB_ERR_INVALID_MULTIBYTE_STRING]
-               = T("A string was not valid in the current locale's character encoding"),
        [WIMLIB_ERR_INVALID_OVERLAY]
                = T("Conflicting files in overlay when creating a WIM image"),
        [WIMLIB_ERR_INVALID_PARAM]
@@ -252,23 +223,20 @@ static const tchar * const error_strings[] = {
        [WIMLIB_ERR_INVALID_REPARSE_DATA]
                = T("The reparse data of a reparse point was invalid"),
        [WIMLIB_ERR_INVALID_RESOURCE_HASH]
-               = T("The SHA1 message digest of a WIM resource did not match the expected value"),
+               = T("The SHA-1 message digest of a WIM resource did not match the expected value"),
        [WIMLIB_ERR_INVALID_UTF8_STRING]
-               = T("A string provided as input by the user was not a valid UTF-8 string"),
+               = T("A string was not a valid UTF-8 string"),
        [WIMLIB_ERR_INVALID_UTF16_STRING]
-               = T("A string in a WIM dentry is not a valid UTF-16LE string"),
+               = T("A string was not a valid UTF-16 string"),
        [WIMLIB_ERR_IS_DIRECTORY]
                = T("One of the specified paths to delete was a directory"),
        [WIMLIB_ERR_IS_SPLIT_WIM]
                = T("The WIM is part of a split WIM, which is not supported for this operation"),
-       [WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE]
-               = T("libxml2 was unable to find a character encoding conversion handler "
-                 "for UTF-16LE"),
        [WIMLIB_ERR_LINK]
                = T("Failed to create a hard or symbolic link when extracting "
                        "a file from the WIM"),
        [WIMLIB_ERR_METADATA_NOT_FOUND]
-               = T("A required metadata resource could not be located"),
+               = T("The WIM does not contain image metadata; it only contains file data"),
        [WIMLIB_ERR_MKDIR]
                = T("Failed to create a directory"),
        [WIMLIB_ERR_MQUEUE]
@@ -291,7 +259,7 @@ static const tchar * const error_strings[] = {
                = T("The WIM was not captured such that it can be "
                    "applied from a pipe"),
        [WIMLIB_ERR_NTFS_3G]
-               = T("NTFS-3g encountered an error (check errno)"),
+               = T("NTFS-3G encountered an error (check errno)"),
        [WIMLIB_ERR_OPEN]
                = T("Failed to open a file"),
        [WIMLIB_ERR_OPENDIR]
@@ -358,6 +326,26 @@ static const tchar * const error_strings[] = {
                = T("The current user does not have permission to unmount the WIM image"),
        [WIMLIB_ERR_FVE_LOCKED_VOLUME]
                = T("The volume must be unlocked before it can be used"),
+       [WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG]
+               = T("The capture configuration file could not be read"),
+       [WIMLIB_ERR_WIM_IS_INCOMPLETE]
+               = T("The WIM file is incomplete"),
+       [WIMLIB_ERR_COMPACTION_NOT_POSSIBLE]
+               = T("The WIM file cannot be compacted because of its format, "
+                   "its layout, or the write parameters specified by the user"),
+       [WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES]
+               = T("The WIM image cannot be modified because it is currently "
+                   "referenced from multiple places"),
+       [WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE]
+               = T("The destination WIM already contains one of the source images"),
+       [WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED]
+               = T("A file being added to a WIM image was concurrently modified"),
+       [WIMLIB_ERR_SNAPSHOT_FAILURE]
+               = T("Unable to create a filesystem snapshot"),
+#ifdef ENABLE_TEST_SUPPORT
+       [WIMLIB_ERR_IMAGES_ARE_DIFFERENT]
+               = T("A difference was detected between the two images being compared"),
+#endif
 };
 
 WIMLIBAPI const tchar *