From 4498586932ab670cf4791d8cf991d9b3e0ce1545 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 17 Mar 2013 20:52:37 -0500 Subject: [PATCH] Clean up headers --- src/add_image.c | 2 ++ src/extract_image.c | 2 -- src/header.c | 14 +++++++------- src/mount_image.c | 26 +++++++++++++++----------- src/ntfs-capture.c | 15 +++++++++------ src/util.h | 8 ++++---- src/wim.c | 3 +++ src/win32.c | 27 +++++---------------------- src/win32.h | 9 +++++++-- 9 files changed, 52 insertions(+), 54 deletions(-) diff --git a/src/add_image.c b/src/add_image.c index 8af2b072..7c974992 100644 --- a/src/add_image.c +++ b/src/add_image.c @@ -598,6 +598,8 @@ static bool match_pattern(const char *path, const char *path_basename, string = path_basename; } + /* Warning: on Windows native builds, fnmatch() calls the + * replacement function in win32.c. */ if (fnmatch(pat, string, FNM_PATHNAME #ifdef FNM_CASEFOLD | FNM_CASEFOLD diff --git a/src/extract_image.c b/src/extract_image.c index 6279c490..dece5437 100644 --- a/src/extract_image.c +++ b/src/extract_image.c @@ -42,7 +42,6 @@ #include #include #include - #include #include "dentry.h" @@ -435,7 +434,6 @@ static int unix_do_apply_dentry_timestamps(const char *output_path, static int apply_dentry_normal(struct wim_dentry *dentry, void *arg) { struct apply_args *args = arg; - struct wim_inode *inode = dentry->d_inode; size_t len; char *output_path; diff --git a/src/header.c b/src/header.c index db791cc5..7ac84160 100644 --- a/src/header.c +++ b/src/header.c @@ -274,7 +274,7 @@ WIMLIBAPI void wimlib_print_header(const WIMStruct *w) printf("Lookup Table Size = %"PRIu64"\n", (u64)hdr->lookup_table_res_entry.size); printf("Lookup Table Flags = 0x%hhx\n", - hdr->lookup_table_res_entry.flags); + (u8)hdr->lookup_table_res_entry.flags); printf("Lookup Table Offset = %"PRIu64"\n", hdr->lookup_table_res_entry.offset); printf("Lookup Table Original_size = %"PRIu64"\n", @@ -282,7 +282,7 @@ WIMLIBAPI void wimlib_print_header(const WIMStruct *w) printf("XML Data Size = %"PRIu64"\n", (u64)hdr->xml_res_entry.size); printf("XML Data Flags = 0x%hhx\n", - hdr->xml_res_entry.flags); + (u8)hdr->xml_res_entry.flags); printf("XML Data Offset = %"PRIu64"\n", hdr->xml_res_entry.offset); printf("XML Data Original Size = %"PRIu64"\n", @@ -290,18 +290,18 @@ WIMLIBAPI void wimlib_print_header(const WIMStruct *w) printf("Boot Metadata Size = %"PRIu64"\n", (u64)hdr->boot_metadata_res_entry.size); printf("Boot Metadata Flags = 0x%hhx\n", - hdr->boot_metadata_res_entry.flags); + (u8)hdr->boot_metadata_res_entry.flags); printf("Boot Metadata Offset = %"PRIu64"\n", hdr->boot_metadata_res_entry.offset); printf("Boot Metadata Original Size = %"PRIu64"\n", hdr->boot_metadata_res_entry.original_size); printf("Boot Index = %u\n", hdr->boot_idx); printf("Integrity Size = %"PRIu64"\n", - (u64)hdr->integrity.size); + (u64)hdr->integrity.size); printf("Integrity Flags = 0x%hhx\n", - hdr->integrity.flags); + (u8)hdr->integrity.flags); printf("Integrity Offset = %"PRIu64"\n", - hdr->integrity.offset); + hdr->integrity.offset); printf("Integrity Original_size = %"PRIu64"\n", - hdr->integrity.original_size); + hdr->integrity.original_size); } diff --git a/src/mount_image.c b/src/mount_image.c index a17bf502..afb09050 100644 --- a/src/mount_image.c +++ b/src/mount_image.c @@ -30,24 +30,28 @@ #ifdef WITH_FUSE -#include "sha1.h" -#include "lookup_table.h" -#include "xml.h" #include "buffer_io.h" +#include "lookup_table.h" +#include "sha1.h" #include "timestamp.h" +#include "xml.h" + +#include +#include #include +#include +#include #include -#include -#include -#define FUSE_USE_VERSION 26 -#include #include +#include #include -#include -#include -#include +#include +#include +#include #include -#include + +#define FUSE_USE_VERSION 26 +#include #ifdef ENABLE_XATTR #include diff --git a/src/ntfs-capture.c b/src/ntfs-capture.c index 70ce59a9..d692633a 100644 --- a/src/ntfs-capture.c +++ b/src/ntfs-capture.c @@ -30,24 +30,27 @@ #include #include -#include "wimlib_internal.h" - - +#include "buffer_io.h" #include "dentry.h" #include "lookup_table.h" -#include "buffer_io.h" +#include "security.h" +#include "wimlib_internal.h" + #include #include #include #include #include -#include /* security.h before xattrs.h */ +#include /* ntfs-3g/security.h before ntfs-3g/xattrs.h */ #include #include #include #include #include -#include "security.h" + +#ifdef HAVE_ALLOCA_H +#include +#endif static inline ntfschar *attr_record_name(ATTR_RECORD *ar) { diff --git a/src/util.h b/src/util.h index b56fa4fa..c51fc710 100644 --- a/src/util.h +++ b/src/util.h @@ -108,10 +108,10 @@ extern void wimlib_warning_with_errno(const char *format, ...) # define WARNING wimlib_warning # define WARNING_WITH_ERRNO wimlib_warning #else -# define ERROR(format, ...) dummy_printf -# define ERROR_WITH_ERRNO(format, ...) dummy_printf -# define WARNING(format, ...) dummy_printf -# define WARNING_WITH_ERRNO(format, ...) dummy_printf +# define ERROR(format, ...) dummy_printf(format, ## __VA_ARGS__) +# define ERROR_WITH_ERRNO(format, ...) dummy_printf(format, ## __VA_ARGS__) +# define WARNING(format, ...) dummy_printf(format, ## __VA_ARGS__) +# define WARNING_WITH_ERRNO(format, ...) dummy_printf(format, ## __VA_ARGS__) #endif /* ENABLE_ERROR_MESSAGES */ #if defined(ENABLE_DEBUG) || defined(ENABLE_MORE_DEBUG) diff --git a/src/wim.c b/src/wim.c index 70e8e73b..60b2b57e 100644 --- a/src/wim.c +++ b/src/wim.c @@ -452,6 +452,9 @@ static int begin_read(WIMStruct *w, const char *in_wim_path, int open_flags, * * This will break if the full path to the WIM changes in the * intervening time... + * + * Warning: in Windows native builds, realpath() calls the replacement + * function in win32.c. */ w->filename = realpath(in_wim_path, NULL); if (!w->filename) { diff --git a/src/win32.c b/src/win32.c index 483518c9..16bdf79c 100644 --- a/src/win32.c +++ b/src/win32.c @@ -1,7 +1,7 @@ /* * win32.c * - * All the code specific to native Windows builds is in here. + * All the library code specific to native Windows builds is in here. */ /* @@ -31,16 +31,11 @@ #include #include #include -#include -#ifdef ERROR +#include /* shlwapi.h for PathMatchSpecA() */ +#ifdef ERROR /* windows.h defines this */ # undef ERROR #endif - -/* Microsoft's swprintf() violates the C standard and they require programmers - * to do this weird define to get the correct function. */ -#define swprintf _snwprintf - #include "win32.h" #include "dentry.h" #include "lookup_table.h" @@ -64,8 +59,6 @@ void win32_error(u32 err_code) LocalFree(buffer); } } -#else -#define win32_error(err_code) #endif void *win32_open_file_readonly(const void *path) @@ -191,16 +184,6 @@ static u64 FILETIME_to_u64(const FILETIME *ft) return ((u64)ft->dwHighDateTime << 32) | (u64)ft->dwLowDateTime; } - -int win32_build_dentry_tree(struct wim_dentry **root_ret, - const char *root_disk_path, - struct wim_lookup_table *lookup_table, - struct wim_security_data *sd, - const struct capture_config *config, - int add_image_flags, - wimlib_progress_func_t progress_func, - void *extra_arg); - static int win32_get_short_name(struct wim_dentry *dentry, const wchar_t *path_utf16) { @@ -260,7 +243,7 @@ static int win32_get_security_descriptor(struct wim_dentry *dentry, } /* Reads the directory entries of directory using a Win32 API and recursively - * calls build_dentry_tree() on them. */ + * calls win32_build_dentry_tree() on them. */ static int win32_recurse_directory(struct wim_dentry *root, const char *root_disk_path, struct wim_lookup_table *lookup_table, @@ -777,7 +760,7 @@ out: } /* Replacement for POSIX fnmatch() (partial functionality only) */ -extern int fnmatch(const char *pattern, const char *string, int flags) +int fnmatch(const char *pattern, const char *string, int flags) { if (PathMatchSpecA(string, pattern)) return 0; diff --git a/src/win32.h b/src/win32.h index 496ee5c3..5f4ff567 100644 --- a/src/win32.h +++ b/src/win32.h @@ -34,8 +34,6 @@ extern void win32_error(u32 err); #define FNM_NOMATCH 1 extern int fnmatch(const char *pattern, const char *string, int flags); -#define mkdir(name, mode) _mkdir(name) - extern int win32_do_apply_dentry(const char *output_path, size_t output_path_len, struct wim_dentry *dentry, @@ -52,4 +50,11 @@ extern unsigned win32_get_number_of_processors(); extern char *realpath(const char *path, char *resolved_path); +/* Microsoft's swprintf() violates the C standard and they require programmers + * to do this weird define to get the correct function. */ +#define swprintf _snwprintf + +/* Use Microsoft's weird _mkdir() function instead of mkdir() */ +#define mkdir(name, mode) _mkdir(name) + #endif /* _WIMLIB_WIN32_H */ -- 2.43.0