From 1e121d2025fffd348d64cc75ac570768651a0457 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 22 May 2014 22:46:36 +0100 Subject: [PATCH] [misc] simplify the declaration of extensions for FileDialog() * Also update the Changelog --- ChangeLog.txt | 11 +++++++++++ src/rufus.c | 13 +++---------- src/rufus.h | 37 +++++++++++++++++++++++++------------ src/rufus.rc | 12 ++++++------ src/stdlg.c | 4 +--- 5 files changed, 46 insertions(+), 31 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 99248dd4..209e5601 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,14 @@ +o Version 1.4.8 (2014.06.??) + Add KolibriOS ISO support + Add VHD support (as *uncompressed* image source) + Add Arabic translation, courtesy of عمر الصمد + Add Croatian translation, courtesy of Dario Komar + Add Danish translation, courtesy of Jens Hansen + Add Latvian translation, courtesy of Aldis Tutins + Report the detected USB speed in the log + Fix support for pure UEFI bootable disk images + Various other fixes and improvements + o Version 1.4.7 (2014.04.22) Add VHD support as a target, courtesy of Scott Add ReFS support (only for Windows 8.1 or later and only for fixed drives) diff --git a/src/rufus.c b/src/rufus.c index 28391058..1aa36574 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -766,10 +766,7 @@ BOOL CALLBACK LogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) long lfHeight; DWORD log_size; char *log_buffer = NULL, *filepath; - const char* log_x[] = { "*.log" }; - const char* log_d[] = { lmprintf(MSG_108) }; - ext_t log_ext = {ARRAYSIZE(log_x), "rufus.log", log_x, log_d }; - + EXT_DECL(log_ext, "rufus.log", __VA_GROUP__("*.log"), __VA_GROUP__("Rufus log")); switch (message) { case WM_INITDIALOG: apply_localization(IDD_LOG, hDlg); @@ -1509,12 +1506,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA static MY_SHChangeNotifyEntry NotifyEntry; loc_cmd* lcmd = NULL; // TODO: Add "*.img;*.vhd" / "All Supported Images" to the list below and use a generic "%s Image" in the .loc - const char* img_x[] = { "*.img", "*.vhd" }; - const char* img_d[] = { lmprintf(MSG_095), "VHD Image" }; - ext_t img_ext = {ARRAYSIZE(img_x), NULL, img_x, img_d}; - const char* iso_x[] = { "*.iso" }; - const char* iso_d[] = { lmprintf(MSG_036) }; - ext_t iso_ext = {ARRAYSIZE(iso_x), NULL, iso_x, iso_d }; + EXT_DECL(img_ext, NULL, __VA_GROUP__("*.img", "*.vhd"), __VA_GROUP__(lmprintf(MSG_095), "VHD Image")); + EXT_DECL(iso_ext, NULL, __VA_GROUP__("*.iso"), __VA_GROUP__(lmprintf(MSG_036))); switch (message) { diff --git a/src/rufus.h b/src/rufus.h index 02e9d457..cbfbed98 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -263,6 +263,29 @@ typedef struct { char* release_notes; } RUFUS_UPDATE; +/* + * Structure and macros used for the extensions specification of FileDialog() + * You can use: + * EXT_DECL(my_extensions, "default.std", __VA_GROUP__("*.std", "*.other"), __VA_GROUP__("Standard type", "Other Type")); + * to define an 'ext_t my_extensions' variable initialized with the relevant attributes. + */ +typedef struct ext_t { + const size_t count; + const char* filename; + const char** extension; + const char** description; +} ext_t; + +#ifndef __VA_GROUP__ +#define __VA_GROUP__(...) __VA_ARGS__ +#endif +#define EXT_X(prefix, ...) const char* _##prefix##_x[] = { __VA_ARGS__ } +#define EXT_D(prefix, ...) const char* _##prefix##_d[] = { __VA_ARGS__ } +#define EXT_DECL(var, filename, extensions, descriptions) \ + EXT_X(var, extensions); \ + EXT_D(var, descriptions); \ + ext_t var = { ARRAYSIZE(_##var##_x), filename, _##var##_x, _##var##_d } + /* Duplication of the TBPFLAG enum for Windows 7 taskbar progress */ typedef enum TASKBAR_PROGRESS_FLAGS { @@ -286,14 +309,6 @@ enum WindowsVersion { WINDOWS_MAX }; -/* Extensions structure used by FileDialog() */ -typedef struct ext_t { - const size_t count; - const char* filename; - const char** extension; - const char** description; -} ext_t; - /* * Globals @@ -375,14 +390,12 @@ extern BOOL WimExtractFile(const char* wim_image, int index, const char* src, co extern BOOL IsHDImage(const char* path); extern int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid); -static __inline BOOL UnlockDrive(HANDLE hDrive) -{ +static __inline BOOL UnlockDrive(HANDLE hDrive) { DWORD size; return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL); } -static __inline void *_reallocf(void *ptr, size_t size) -{ +static __inline void *_reallocf(void *ptr, size_t size) { void *ret = realloc(ptr, size); if (!ret) free(ptr); diff --git a/src/rufus.rc b/src/rufus.rc index fdbdb856..bc32f59a 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rufus 1.4.8.482" +CAPTION "Rufus 1.4.8.483" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -165,7 +165,7 @@ END RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL -CAPTION "Rufus 1.4.8.482" +CAPTION "Rufus 1.4.8.483" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -427,8 +427,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,8,482 - PRODUCTVERSION 1,4,8,482 + FILEVERSION 1,4,8,483 + PRODUCTVERSION 1,4,8,483 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -445,13 +445,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.4.8.482" + VALUE "FileVersion", "1.4.8.483" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.4.8.482" + VALUE "ProductVersion", "1.4.8.483" END END BLOCK "VarFileInfo" diff --git a/src/stdlg.c b/src/stdlg.c index a735cda3..fa4af701 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -1187,9 +1187,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR STARTUPINFOA si; PROCESS_INFORMATION pi; HFONT hyperlink_font = NULL; - const char* dl_x[] = { "*.exe" }; - const char* dl_d[] = { lmprintf(MSG_037) }; - ext_t dl_ext = { ARRAYSIZE(dl_x), "rufus.log", dl_x, dl_d }; + EXT_DECL(dl_ext, NULL, __VA_GROUP__("*.exe"), __VA_GROUP__(lmprintf(MSG_037))); switch (message) { case WM_INITDIALOG: