1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[syslinux] fix missing syslinux.cfg creation

* Issue was introduced with 299506056a
* Also improve StrArray definition
This commit is contained in:
Pete Batard 2014-01-22 01:28:25 +00:00
parent 3ae7ec4af5
commit 3c2873bbdc
5 changed files with 35 additions and 36 deletions

View file

@ -580,17 +580,17 @@ out:
// If multiple config files exist, choose the one with the shortest path // If multiple config files exist, choose the one with the shortest path
// (so that a '/syslinux.cfg' is preferred over a '/isolinux/isolinux.cfg') // (so that a '/syslinux.cfg' is preferred over a '/isolinux/isolinux.cfg')
if (!IsStrArrayEmpty(config_path)) { if (!IsStrArrayEmpty(config_path)) {
safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.Table[0]); safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.String[0]);
for (i=1; i<config_path.Index; i++) { for (i=1; i<config_path.Index; i++) {
if (safe_strlen(iso_report.cfg_path) > safe_strlen(config_path.Table[i])) if (safe_strlen(iso_report.cfg_path) > safe_strlen(config_path.String[i]))
safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.Table[i]); safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.String[i]);
} }
uprintf("Will use %s for Syslinux\n", iso_report.cfg_path); uprintf("Will use %s for Syslinux\n", iso_report.cfg_path);
// Extract all of the isolinux.bin files we found to identify their versions // Extract all of the isolinux.bin files we found to identify their versions
for (i=0; i<isolinux_path.Index; i++) { for (i=0; i<isolinux_path.Index; i++) {
size = (size_t)ExtractISOFile(src_iso, isolinux_path.Table[i], dot_isolinux_bin); size = (size_t)ExtractISOFile(src_iso, isolinux_path.String[i], dot_isolinux_bin);
if (size == 0) { if (size == 0) {
uprintf("Could not access %s\n", isolinux_path.Table[i]); uprintf("Could not access %s\n", isolinux_path.String[i]);
} else { } else {
buf = (char*)calloc(size, 1); buf = (char*)calloc(size, 1);
if (buf == NULL) break; if (buf == NULL) break;
@ -610,8 +610,8 @@ out:
j = (int)i; j = (int)i;
} else if (iso_report.sl_version != sl_version) { } else if (iso_report.sl_version != sl_version) {
uprintf("Found conflicting %s versions:\n '%s' (v%d.%02d) vs '%s' (v%d.%02d)\n", isolinux_bin, uprintf("Found conflicting %s versions:\n '%s' (v%d.%02d) vs '%s' (v%d.%02d)\n", isolinux_bin,
isolinux_path.Table[j], SL_MAJOR(iso_report.sl_version), SL_MINOR(iso_report.sl_version), isolinux_path.String[j], SL_MAJOR(iso_report.sl_version), SL_MINOR(iso_report.sl_version),
isolinux_path.Table[i], SL_MAJOR(sl_version), SL_MINOR(sl_version)); isolinux_path.String[i], SL_MAJOR(sl_version), SL_MINOR(sl_version));
} }
break; break;
} }
@ -624,7 +624,7 @@ out:
static_sprintf(iso_report.sl_version_str, "v%d.%02d", static_sprintf(iso_report.sl_version_str, "v%d.%02d",
SL_MAJOR(iso_report.sl_version), SL_MINOR(iso_report.sl_version)); SL_MAJOR(iso_report.sl_version), SL_MINOR(iso_report.sl_version));
uprintf("Detected Isolinux version: %s (from '%s')", uprintf("Detected Isolinux version: %s (from '%s')",
iso_report.sl_version_str, isolinux_path.Table[j]); iso_report.sl_version_str, isolinux_path.String[j]);
if ( (has_ldlinux_c32 && (SL_MAJOR(iso_report.sl_version) < 5)) if ( (has_ldlinux_c32 && (SL_MAJOR(iso_report.sl_version) < 5))
|| (!has_ldlinux_c32 && (SL_MAJOR(iso_report.sl_version) >= 5)) ) || (!has_ldlinux_c32 && (SL_MAJOR(iso_report.sl_version) >= 5)) )
uprintf("Warning: Conflict between Isolinux version and the presence of ldlinux.c32...\n"); uprintf("Warning: Conflict between Isolinux version and the presence of ldlinux.c32...\n");
@ -656,7 +656,7 @@ out:
} }
StrArrayDestroy(&config_path); StrArrayDestroy(&config_path);
StrArrayDestroy(&isolinux_path); StrArrayDestroy(&isolinux_path);
} else if (!IsStrArrayEmpty(config_path)) { } else if (HAS_SYSLINUX(iso_report)) {
safe_sprintf(path, sizeof(path), "%s\\syslinux.cfg", dest_dir); safe_sprintf(path, sizeof(path), "%s\\syslinux.cfg", dest_dir);
// Create a /syslinux.cfg (if none exists) that points to the existing isolinux cfg // Create a /syslinux.cfg (if none exists) that points to the existing isolinux cfg
fd = fopen(path, "r"); fd = fopen(path, "r");

View file

@ -589,7 +589,7 @@ static BOOL PopulateProperties(int ComboIndex)
SetTargetSystem(); SetTargetSystem();
SetFSFromISO(); SetFSFromISO();
EnableBootOptions(TRUE); EnableBootOptions(TRUE);
device_tooltip = (char*) malloc(safe_strlen(DriveID.Table[ComboIndex]) + 16); device_tooltip = (char*) malloc(safe_strlen(DriveID.String[ComboIndex]) + 16);
// Set a proposed label according to the size (eg: "256MB", "8GB") // Set a proposed label according to the size (eg: "256MB", "8GB")
if (HumanReadableSize < 1.0) { if (HumanReadableSize < 1.0) {
@ -601,14 +601,14 @@ static BOOL PopulateProperties(int ComboIndex)
safe_sprintf(SelectedDrive.proposed_label, sizeof(SelectedDrive.proposed_label), safe_sprintf(SelectedDrive.proposed_label, sizeof(SelectedDrive.proposed_label),
"%0.0f%s", ceil(HumanReadableSize), lmprintf(MSG_020+i)); "%0.0f%s", ceil(HumanReadableSize), lmprintf(MSG_020+i));
if (device_tooltip != NULL) if (device_tooltip != NULL)
safe_sprintf(device_tooltip, safe_strlen(DriveID.Table[ComboIndex]) + 16, safe_sprintf(device_tooltip, safe_strlen(DriveID.String[ComboIndex]) + 16,
"%s (%0.0f%s)", DriveID.Table[ComboIndex], ceil(HumanReadableSize), lmprintf(MSG_020+i)); "%s (%0.0f%s)", DriveID.String[ComboIndex], ceil(HumanReadableSize), lmprintf(MSG_020+i));
} else { } else {
safe_sprintf(SelectedDrive.proposed_label, sizeof(SelectedDrive.proposed_label), safe_sprintf(SelectedDrive.proposed_label, sizeof(SelectedDrive.proposed_label),
"%0.2f%s", HumanReadableSize, lmprintf(MSG_020+i)); "%0.2f%s", HumanReadableSize, lmprintf(MSG_020+i));
if (device_tooltip != NULL) if (device_tooltip != NULL)
safe_sprintf(device_tooltip, safe_strlen(DriveID.Table[ComboIndex]) + 16, safe_sprintf(device_tooltip, safe_strlen(DriveID.String[ComboIndex]) + 16,
"%s (%0.2f%s)", DriveID.Table[ComboIndex], HumanReadableSize, lmprintf(MSG_020+i)); "%s (%0.2f%s)", DriveID.String[ComboIndex], HumanReadableSize, lmprintf(MSG_020+i));
} }
// Add a tooltip (with the size of the device in parenthesis) // Add a tooltip (with the size of the device in parenthesis)
@ -618,11 +618,11 @@ static BOOL PopulateProperties(int ComboIndex)
// If no existing label is available and no ISO is selected, propose one according to the size (eg: "256MB", "8GB") // If no existing label is available and no ISO is selected, propose one according to the size (eg: "256MB", "8GB")
if ((iso_path == NULL) || (iso_report.label[0] == 0)) { if ((iso_path == NULL) || (iso_report.label[0] == 0)) {
if ( (safe_stricmp(no_label, DriveLabel.Table[ComboIndex]) == 0) if ( (safe_stricmp(no_label, DriveLabel.String[ComboIndex]) == 0)
|| (safe_stricmp(lmprintf(MSG_207), DriveLabel.Table[ComboIndex]) == 0) ) { || (safe_stricmp(lmprintf(MSG_207), DriveLabel.String[ComboIndex]) == 0) ) {
SetWindowTextU(hLabel, SelectedDrive.proposed_label); SetWindowTextU(hLabel, SelectedDrive.proposed_label);
} else { } else {
SetWindowTextU(hLabel, DriveLabel.Table[ComboIndex]); SetWindowTextU(hLabel, DriveLabel.String[ComboIndex]);
} }
} else { } else {
SetWindowTextU(hLabel, iso_report.label); SetWindowTextU(hLabel, iso_report.label);

View file

@ -369,8 +369,7 @@ static __inline void *_reallocf(void *ptr, size_t size)
/* Basic String Array */ /* Basic String Array */
typedef struct { typedef struct {
// TODO: rename 'Table' to 'String' char** String;
char** Table;
size_t Index; // Current array size size_t Index; // Current array size
size_t Max; // Maximum array size size_t Max; // Maximum array size
} StrArray; } StrArray;

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329 IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.4.3.387" CAPTION "Rufus v1.4.3.388"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -288,8 +288,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,3,387 FILEVERSION 1,4,3,388
PRODUCTVERSION 1,4,3,387 PRODUCTVERSION 1,4,3,388
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -306,13 +306,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.3.387" VALUE "FileVersion", "1.4.3.388"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.4.3.387" VALUE "ProductVersion", "1.4.3.388"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -1,7 +1,7 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* Standard Windows function calls * Standard Windows function calls
* Copyright © 2013 Pete Batard <pete@akeo.ie> * Copyright © 2013-2014 Pete Batard <pete@akeo.ie>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -151,28 +151,28 @@ void StrArrayCreate(StrArray* arr, size_t initial_size)
{ {
if (arr == NULL) return; if (arr == NULL) return;
arr->Max = initial_size; arr->Index = 0; arr->Max = initial_size; arr->Index = 0;
arr->Table = (char**)calloc(arr->Max, sizeof(char*)); arr->String = (char**)calloc(arr->Max, sizeof(char*));
if (arr->Table == NULL) if (arr->String == NULL)
uprintf("Could not allocate string array\n"); uprintf("Could not allocate string array\n");
} }
void StrArrayAdd(StrArray* arr, const char* str) void StrArrayAdd(StrArray* arr, const char* str)
{ {
char** old_table; char** old_table;
if ((arr == NULL) || (arr->Table == NULL)) if ((arr == NULL) || (arr->String == NULL))
return; return;
if (arr->Index == arr->Max) { if (arr->Index == arr->Max) {
arr->Max *= 2; arr->Max *= 2;
old_table = arr->Table; old_table = arr->String;
arr->Table = (char**)realloc(arr->Table, arr->Max*sizeof(char*)); arr->String = (char**)realloc(arr->String, arr->Max*sizeof(char*));
if (arr->Table == NULL) { if (arr->String == NULL) {
free(old_table); free(old_table);
uprintf("Could not reallocate string array\n"); uprintf("Could not reallocate string array\n");
return; return;
} }
} }
arr->Table[arr->Index] = safe_strdup(str); arr->String[arr->Index] = safe_strdup(str);
if (arr->Table[arr->Index++] == NULL) { if (arr->String[arr->Index++] == NULL) {
uprintf("Could not store string in array\n"); uprintf("Could not store string in array\n");
} }
} }
@ -180,10 +180,10 @@ void StrArrayAdd(StrArray* arr, const char* str)
void StrArrayClear(StrArray* arr) void StrArrayClear(StrArray* arr)
{ {
size_t i; size_t i;
if ((arr == NULL) || (arr->Table == NULL)) if ((arr == NULL) || (arr->String == NULL))
return; return;
for (i=0; i<arr->Index; i++) { for (i=0; i<arr->Index; i++) {
safe_free(arr->Table[i]); safe_free(arr->String[i]);
} }
arr->Index = 0; arr->Index = 0;
} }
@ -192,7 +192,7 @@ void StrArrayDestroy(StrArray* arr)
{ {
StrArrayClear(arr); StrArrayClear(arr);
if (arr != NULL) if (arr != NULL)
safe_free(arr->Table); safe_free(arr->String);
} }
/* /*