if (!FsOpenBootVolume())
{
- printf("Error opening boot partition for file access.\n");
- MachConsGetCh();
+ UiMessageBoxCritical("Error opening boot partition for file access.");
return;
}
if (!IniFileInitialize())
{
- printf("Press any key to reboot.\n");
- MachConsGetCh();
+ UiMessageBoxCritical("Error initializing .ini file");
return;
}
if (!IniOpenSection("FreeLoader", &SectionId))
{
- printf("Section [FreeLoader] not found in freeldr.ini.\n");
- MachConsGetCh();
+ UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
return;
}
TimeOut = GetTimeOut();
if (!UiInitialize(TimeOut))
{
- printf("Press any key to reboot.\n");
- MachConsGetCh();
+ UiMessageBoxCritical("Unable to initialize UI.");
return;
}
if (!InitOperatingSystemList(&OperatingSystemSectionNames, &OperatingSystemDisplayNames, &OperatingSystemCount))
{
- UiMessageBox("Press ENTER to reboot.\n");
+ UiMessageBox("Press ENTER to reboot.");
goto reboot;
}
// Show the operating system list menu
if (!UiDisplayMenu(OperatingSystemDisplayNames, OperatingSystemCount, DefaultOperatingSystem, TimeOut, &SelectedOperatingSystem, FALSE, MainBootMenuKeyPressFilter))
{
- UiMessageBox("Press ENTER to reboot.\n");
+ UiMessageBox("Press ENTER to reboot.");
goto reboot;
}
// Try to open the operating system section in the .ini file
if (!IniOpenSection(OperatingSystemSectionNames[SelectedOperatingSystem], &SectionId))
{
- sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", OperatingSystemSectionNames[SelectedOperatingSystem]);
+ sprintf(SettingName, "Section [%s] not found in freeldr.ini.", OperatingSystemSectionNames[SelectedOperatingSystem]);
UiMessageBox(SettingName);
continue;
}
// Try to read the boot type
if (!IniReadSettingByName(SectionId, "BootType", SettingValue, sizeof(SettingValue)))
{
- sprintf(SettingName, "BootType= line not found in section [%s] in freeldr.ini.\n", OperatingSystemSectionNames[SelectedOperatingSystem]);
+ sprintf(SettingName, "BootType= line not found in section [%s] in freeldr.ini.", OperatingSystemSectionNames[SelectedOperatingSystem]);
UiMessageBox(SettingName);
continue;
}
//
// Make sure the block list has entries before I start searching it.
//
- if (!RtlListIsEmpty((PLIST_ITEM)CacheDrive->CacheBlockHead))
+ if (!IsListEmpty(&CacheDrive->CacheBlockHead))
{
//
// Search the list and find the BIOS drive number
//
- CacheBlock = CacheDrive->CacheBlockHead;
+ CacheBlock = CONTAINING_RECORD(CacheDrive->CacheBlockHead.Flink, CACHE_BLOCK, ListEntry);
- while (CacheBlock != NULL)
+ while (&CacheBlock->ListEntry != &CacheDrive->CacheBlockHead)
{
//
// We found the block, so return it
return CacheBlock;
}
- CacheBlock = (PCACHE_BLOCK)RtlListGetNext((PLIST_ITEM)CacheBlock);
+ CacheBlock = CONTAINING_RECORD(CacheBlock->ListEntry.Flink, CACHE_BLOCK, ListEntry);
}
}
RtlCopyMemory(CacheBlock->BlockData, (PVOID)DISKREADBUFFER, CacheDrive->BlockSize * CacheDrive->BytesPerSector);
// Add it to our list of blocks managed by the cache
- if (CacheDrive->CacheBlockHead == NULL)
- {
- CacheDrive->CacheBlockHead = CacheBlock;
- }
- else
- {
- RtlListInsertTail((PLIST_ITEM)CacheDrive->CacheBlockHead, (PLIST_ITEM)CacheBlock);
- }
+ InsertTailList(&CacheDrive->CacheBlockHead, &CacheBlock->ListEntry);
// Update the cache data
CacheBlockCount++;
// Get a pointer to the last item in the block list
// that isn't forced to be in the cache and remove
// it from the list
- CacheBlockToFree = (PCACHE_BLOCK)RtlListGetTail((PLIST_ITEM)CacheDrive->CacheBlockHead);
- while (CacheBlockToFree != NULL && CacheBlockToFree->LockedInCache == TRUE)
+ CacheBlockToFree = CONTAINING_RECORD(CacheDrive->CacheBlockHead.Blink, CACHE_BLOCK, ListEntry);
+ while (&CacheBlockToFree->ListEntry != &CacheDrive->CacheBlockHead && CacheBlockToFree->LockedInCache == TRUE)
{
- CacheBlockToFree = (PCACHE_BLOCK)RtlListGetPrevious((PLIST_ITEM)CacheBlockToFree);
+ CacheBlockToFree = CONTAINING_RECORD(CacheBlockToFree->ListEntry.Blink, CACHE_BLOCK, ListEntry);
}
// No blocks left in cache that can be freed
// so just return
- if (CacheBlockToFree == NULL)
+ if (IsListEmpty(&CacheDrive->CacheBlockHead))
{
return FALSE;
}
- //
- // If we are freeing the head of the list then update it's pointer
- //
- if (CacheBlockToFree == CacheDrive->CacheBlockHead)
- {
- CacheDrive->CacheBlockHead = (PCACHE_BLOCK)RtlListGetNext((PLIST_ITEM)CacheBlockToFree);
- }
-
- RtlListRemoveEntry((PLIST_ITEM)CacheBlockToFree);
+ RemoveEntryList(&CacheBlockToFree->ListEntry);
// Free the block memory and the block structure
MmFreeMemory(CacheBlockToFree->BlockData);
DbgPrint((DPRINT_CACHE, "CacheSizeLimit: %d.\n", CacheSizeLimit));
DbgPrint((DPRINT_CACHE, "CacheSizeCurrent: %d.\n", CacheSizeCurrent));
DbgPrint((DPRINT_CACHE, "CacheBlockCount: %d.\n", CacheBlockCount));
- DbgPrint((DPRINT_CACHE, "Dumping %d cache blocks.\n", RtlListCountEntries((PLIST_ITEM)CacheDrive->CacheBlockHead)));
- CacheBlock = CacheDrive->CacheBlockHead;
- while (CacheBlock != NULL)
+ CacheBlock = CONTAINING_RECORD(CacheDrive->CacheBlockHead.Flink, CACHE_BLOCK, ListEntry);
+ while (&CacheBlock->ListEntry != &CacheDrive->CacheBlockHead)
{
DbgPrint((DPRINT_CACHE, "Cache Block: CacheBlock: 0x%x\n", CacheBlock));
DbgPrint((DPRINT_CACHE, "Cache Block: Block Number: %d\n", CacheBlock->BlockNumber));
BugCheck((DPRINT_CACHE, "What the heck?!?\n"));
}
- CacheBlock = (PCACHE_BLOCK)RtlListGetNext((PLIST_ITEM)CacheBlock);
+ CacheBlock = CONTAINING_RECORD(CacheBlock->ListEntry.Flink, CACHE_BLOCK, ListEntry);
}
}
DbgPrint((DPRINT_CACHE, "CacheInternalOptimizeBlockList()\n"));
// Don't do this if this block is already at the head of the list
- if (CacheBlock != CacheDrive->CacheBlockHead)
+ if (&CacheBlock->ListEntry != CacheDrive->CacheBlockHead.Flink)
{
// Remove this item from the block list
- RtlListRemoveEntry((PLIST_ITEM)CacheBlock);
+ RemoveEntryList(&CacheBlock->ListEntry);
// Re-insert it at the head of the list
- RtlListInsertHead((PLIST_ITEM)CacheDrive->CacheBlockHead, (PLIST_ITEM)CacheBlock);
-
- // Update the head pointer
- CacheDrive->CacheBlockHead = CacheBlock;
+ InsertHeadList(&CacheDrive->CacheBlockHead, &CacheBlock->ListEntry);
}
}
//
// Loop through and free the cache blocks
//
- while (CacheManagerDrive.CacheBlockHead != NULL)
+ while (!IsListEmpty(&CacheManagerDrive.CacheBlockHead))
{
- NextCacheBlock = (PCACHE_BLOCK)RtlListGetNext((PLIST_ITEM)CacheManagerDrive.CacheBlockHead);
+ NextCacheBlock = CONTAINING_RECORD(RemoveHeadList(&CacheManagerDrive.CacheBlockHead),
+ CACHE_BLOCK,
+ ListEntry);
- MmFreeMemory(CacheManagerDrive.CacheBlockHead->BlockData);
- MmFreeMemory(CacheManagerDrive.CacheBlockHead);
-
- CacheManagerDrive.CacheBlockHead = NextCacheBlock;
+ MmFreeMemory(NextCacheBlock->BlockData);
+ MmFreeMemory(NextCacheBlock);
}
}
// Initialize the structure
RtlZeroMemory(&CacheManagerDrive, sizeof(CACHE_DRIVE));
+ InitializeListHead(&CacheManagerDrive.CacheBlockHead);
CacheManagerDrive.DriveNumber = DriveNumber;
if (!MachDiskGetDriveGeometry(DriveNumber, &DriveGeometry))
{
</directory>
<directory name="rtl">
<file>libsupp.c</file>
- <file>list.c</file>
</directory>
<directory name="ui">
<file>gui.c</file>
///////////////////////////////////////////////////////////////////////////////////////
typedef struct
{
- LIST_ITEM ListEntry; // Doubly linked list synchronization member
+ LIST_ENTRY ListEntry; // Doubly linked list synchronization member
ULONG BlockNumber; // Track index for CHS, 64k block index for LBA
BOOLEAN LockedInCache; // Indicates that this block is locked in cache memory
ULONG BytesPerSector;
ULONG BlockSize; // Block size (in sectors)
- PCACHE_BLOCK CacheBlockHead;
+ LIST_ENTRY CacheBlockHead; // Contains CACHE_BLOCK structures
} CACHE_DRIVE, *PCACHE_DRIVE;
// Name=Value
typedef struct
{
- LIST_ITEM ListEntry;
+ LIST_ENTRY ListEntry;
PCHAR ItemName;
PCHAR ItemValue;
// one INI_SECTION_ITEM for each line in the section
typedef struct
{
- LIST_ITEM ListEntry;
+ LIST_ENTRY ListEntry;
PCHAR SectionName;
ULONG SectionItemCount;
- PINI_SECTION_ITEM SectionItemList;
+ LIST_ENTRY SectionItemList; // Contains PINI_SECTION_ITEM structures
} INI_SECTION, *PINI_SECTION;
-extern PINI_SECTION IniFileSectionListHead;
+extern LIST_ENTRY IniFileSectionListHead;
+extern BOOLEAN IniFileSectionInitialized;
extern ULONG IniFileSectionCount;
extern ULONG IniFileSettingCount;
void delay(unsigned msec);
void sound(int freq);
-///////////////////////////////////////////////////////////////////////////////////////
-//
-// List Functions
-//
-///////////////////////////////////////////////////////////////////////////////////////
-
-typedef struct _LIST_ITEM
-{
- struct _LIST_ITEM* ListPrev;
- struct _LIST_ITEM* ListNext;
-
-} LIST_ITEM, *PLIST_ITEM;
-
-VOID RtlListInitializeHead(PLIST_ITEM ListHead); // Initializes a doubly linked list
-VOID RtlListInsertHead(PLIST_ITEM ListHead, PLIST_ITEM Entry); // Inserts an entry at the head of the list
-VOID RtlListInsertTail(PLIST_ITEM ListHead, PLIST_ITEM Entry); // Inserts an entry at the tail of the list
-PLIST_ITEM RtlListRemoveHead(PLIST_ITEM ListHead); // Removes the entry at the head of the list
-PLIST_ITEM RtlListRemoveTail(PLIST_ITEM ListHead); // Removes the entry at the tail of the list
-PLIST_ITEM RtlListGetHead(PLIST_ITEM ListHead); // Returns the entry at the head of the list
-PLIST_ITEM RtlListGetTail(PLIST_ITEM ListHead); // Returns the entry at the tail of the list
-BOOLEAN RtlListIsEmpty(PLIST_ITEM ListHead); // Indicates whether a doubly linked list is empty
-ULONG RtlListCountEntries(PLIST_ITEM ListHead); // Counts the entries in a doubly linked list
-PLIST_ITEM RtlListGetPrevious(PLIST_ITEM ListEntry); // Returns the previous item in the list
-PLIST_ITEM RtlListGetNext(PLIST_ITEM ListEntry); // Returns the next item in the list
-PLIST_ITEM RtlListRemoveEntry(PLIST_ITEM ListEntry); // Removes the entry from the list
-VOID RtlListInsertEntry(PLIST_ITEM InsertAfter, PLIST_ITEM ListEntry); // Inserts a new list entry right after the specified one
-VOID RtlListMoveEntryPrevious(PLIST_ITEM ListEntry); // Moves the list entry to before the previous entry
-VOID RtlListMoveEntryNext(PLIST_ITEM ListEntry); // Moves the list entry to after the next entry
-
-
#endif // defined __STDLIB_H
if (Freeldr_Ini == NULL)
{
- printf("Error opening freeldr.ini or file not found.\n");
- printf("You need to re-install FreeLoader.\n");
+ UiMessageBoxCritical("Error opening freeldr.ini or file not found.\nYou need to re-install FreeLoader.");
return FALSE;
}
// If we are out of memory then return FALSE
if (FreeLoaderIniFileData == NULL)
{
- printf("Out of memory while loading freeldr.ini.\n");
+ UiMessageBoxCritical("Out of memory while loading freeldr.ini.");
FsCloseFile(Freeldr_Ini);
return FALSE;
}
DbgPrint((DPRINT_INIFILE, "IniOpenSection() SectionName = %s\n", SectionName));
- if (!IniFileSectionListHead)
+ if (!IniFileSectionInitialized)
return FALSE;
// Loop through each section and find the one they want
- Section = (PINI_SECTION)RtlListGetHead((PLIST_ITEM)IniFileSectionListHead);
- while (Section != NULL)
+ Section = CONTAINING_RECORD(IniFileSectionListHead.Flink, INI_SECTION, ListEntry);
+ while (&Section->ListEntry != &IniFileSectionListHead)
{
// Compare against the section name
if (_stricmp(SectionName, Section->SectionName) == 0)
}
// Get the next section in the list
- Section = (PINI_SECTION)RtlListGetNext((PLIST_ITEM)Section);
+ Section = CONTAINING_RECORD(Section->ListEntry.Flink, INI_SECTION, ListEntry);
}
DbgPrint((DPRINT_INIFILE, "IniOpenSection() Section not found.\n"));
return Section->SectionItemCount;
}
+PINI_SECTION_ITEM IniGetSettingByNumber(ULONG SectionId, ULONG SettingNumber)
+{
+ PINI_SECTION Section = (PINI_SECTION)SectionId;
+ PINI_SECTION_ITEM SectionItem;
+
+ // Loop through each section item and find the one they want
+ SectionItem = CONTAINING_RECORD(Section->SectionItemList.Flink, INI_SECTION_ITEM, ListEntry);
+ while (&SectionItem->ListEntry != &Section->SectionItemList)
+ {
+ // Check to see if this is the setting they want
+ if (SettingNumber == 0)
+ {
+ return SectionItem;
+ }
+
+ // Nope, keep going
+ SettingNumber--;
+
+ // Get the next section item in the list
+ SectionItem = CONTAINING_RECORD(SectionItem->ListEntry.Flink, INI_SECTION_ITEM, ListEntry);
+ }
+ return NULL;
+}
+
ULONG IniGetSectionSettingNameSize(ULONG SectionId, ULONG SettingIndex)
{
- PINI_SECTION Section = (PINI_SECTION)SectionId;
+ PINI_SECTION_ITEM SectionItem;
+
+ // Retrieve requested setting
+ SectionItem = IniGetSettingByNumber(SectionId, SettingIndex);
+ if (!SectionItem)
+ return 0;
// Return the size of the string plus 1 for the null-terminator
- return (strlen(Section->SectionItemList[SettingIndex].ItemName) + 1);
+ return (strlen(SectionItem->ItemName) + 1);
}
ULONG IniGetSectionSettingValueSize(ULONG SectionId, ULONG SettingIndex)
{
- PINI_SECTION Section = (PINI_SECTION)SectionId;
+ PINI_SECTION_ITEM SectionItem;
+
+ // Retrieve requested setting
+ SectionItem = IniGetSettingByNumber(SectionId, SettingIndex);
+ if (!SectionItem)
+ return 0;
// Return the size of the string plus 1 for the null-terminator
- return (strlen(Section->SectionItemList[SettingIndex].ItemValue) + 1);
+ return (strlen(SectionItem->ItemValue) + 1);
}
BOOLEAN IniReadSettingByNumber(ULONG SectionId, ULONG SettingNumber, PCHAR SettingName, ULONG NameSize, PCHAR SettingValue, ULONG ValueSize)
{
- PINI_SECTION Section = (PINI_SECTION)SectionId;
PINI_SECTION_ITEM SectionItem;
- ULONG RealSettingNumber = SettingNumber;
DbgPrint((DPRINT_INIFILE, ".001 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() SectionId = 0x%x\n", SectionId));
- // Loop through each section item and find the one they want
- DbgPrint((DPRINT_INIFILE, ".01 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
- SectionItem = (PINI_SECTION_ITEM)RtlListGetHead((PLIST_ITEM)Section->SectionItemList);
- while (SectionItem != NULL)
+ // Retrieve requested setting
+ SectionItem = IniGetSettingByNumber(SectionId, SettingNumber);
+ if (!SectionItem)
{
- DbgPrint((DPRINT_INIFILE, ".1 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
- // Check to see if this is the setting they want
- if (SettingNumber == 0)
- {
- DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting number %d found.\n", RealSettingNumber));
- DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting name = %s\n", SectionItem->ItemName));
- DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting value = %s\n", SectionItem->ItemValue));
-
- DbgPrint((DPRINT_INIFILE, "1 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
- DbgPrint((DPRINT_INIFILE, "2 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
- strncpy(SettingName, SectionItem->ItemName, NameSize - 1);
- SettingName[NameSize - 1] = '\0';
- DbgPrint((DPRINT_INIFILE, "3 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
- strncpy(SettingValue, SectionItem->ItemValue, ValueSize - 1);
- SettingValue[ValueSize - 1] = '\0';
- DbgPrint((DPRINT_INIFILE, "4 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
- DbgDumpBuffer(DPRINT_INIFILE, SettingName, NameSize);
- DbgDumpBuffer(DPRINT_INIFILE, SettingValue, ValueSize);
-
- return TRUE;
- }
-
- // Nope, keep going
- SettingNumber--;
-
- // Get the next section item in the list
- SectionItem = (PINI_SECTION_ITEM)RtlListGetNext((PLIST_ITEM)SectionItem);
+ DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting number %d not found.\n", SettingNumber));
+ return FALSE;
}
- DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting number %d not found.\n", RealSettingNumber));
+ DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting number %d found.\n", SettingNumber));
+ DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting name = %s\n", SectionItem->ItemName));
+ DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting value = %s\n", SectionItem->ItemValue));
+
+ DbgPrint((DPRINT_INIFILE, "1 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
+ DbgPrint((DPRINT_INIFILE, "2 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
+ strncpy(SettingName, SectionItem->ItemName, NameSize - 1);
+ SettingName[NameSize - 1] = '\0';
+ DbgPrint((DPRINT_INIFILE, "3 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
+ strncpy(SettingValue, SectionItem->ItemValue, ValueSize - 1);
+ SettingValue[ValueSize - 1] = '\0';
+ DbgPrint((DPRINT_INIFILE, "4 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
+ DbgDumpBuffer(DPRINT_INIFILE, SettingName, NameSize);
+ DbgDumpBuffer(DPRINT_INIFILE, SettingValue, ValueSize);
- return FALSE;
+ return TRUE;
}
BOOLEAN IniReadSettingByName(ULONG SectionId, PCSTR SettingName, PCHAR Buffer, ULONG BufferSize)
DbgPrint((DPRINT_INIFILE, "IniReadSettingByName() SectionId = 0x%x\n", SectionId));
// Loop through each section item and find the one they want
- SectionItem = (PINI_SECTION_ITEM)RtlListGetHead((PLIST_ITEM)Section->SectionItemList);
- while (SectionItem != NULL)
+ SectionItem = CONTAINING_RECORD(Section->SectionItemList.Flink, INI_SECTION_ITEM, ListEntry);
+ while (&SectionItem->ListEntry != &Section->SectionItemList)
{
// Check to see if this is the setting they want
if (_stricmp(SettingName, SectionItem->ItemName) == 0)
}
// Get the next section item in the list
- SectionItem = (PINI_SECTION_ITEM)RtlListGetNext((PLIST_ITEM)SectionItem);
+ SectionItem = CONTAINING_RECORD(SectionItem->ListEntry.Flink, INI_SECTION_ITEM, ListEntry);
}
DbgPrint((DPRINT_INIFILE, "IniReadSettingByName() Setting \'%s\' not found.\n", SettingName));
// Add it to the section list head
IniFileSectionCount++;
- if (IniFileSectionListHead == NULL)
- {
- IniFileSectionListHead = Section;
- }
- else
- {
- RtlListInsertTail((PLIST_ITEM)IniFileSectionListHead, (PLIST_ITEM)Section);
- }
+ InsertHeadList(&IniFileSectionListHead, &Section->ListEntry);
*SectionId = (ULONG)Section;
// Add it to the current section
Section->SectionItemCount++;
- if (Section->SectionItemList == NULL)
- {
- Section->SectionItemList = SectionItem;
- }
- else
- {
- RtlListInsertTail((PLIST_ITEM)Section->SectionItemList, (PLIST_ITEM)SectionItem);
- }
+ InsertTailList(&Section->SectionItemList, &SectionItem->ListEntry);
return TRUE;
}
#include <freeldr.h>
#include <debug.h>
-PINI_SECTION IniFileSectionListHead = NULL;
+LIST_ENTRY IniFileSectionListHead;
+BOOLEAN IniFileSectionInitialized = FALSE;
ULONG IniFileSectionCount = 0;
ULONG IniFileSettingCount = 0;
DbgPrint((DPRINT_INIFILE, "IniParseFile() IniFileSize: %d\n", IniFileSize));
+ if (!IniFileSectionInitialized)
+ {
+ InitializeListHead(&IniFileSectionListHead);
+ IniFileSectionInitialized = TRUE;
+ }
+
// Start with an 80-byte buffer
IniFileLineSize = 80;
IniFileLine = MmAllocateMemory(IniFileLineSize);
// Get the section name
IniExtractSectionName(CurrentSection->SectionName, IniFileLine, LineLength);
+ InitializeListHead(&CurrentSection->SectionItemList);
// Add it to the section list head
IniFileSectionCount++;
- if (IniFileSectionListHead == NULL)
- {
- IniFileSectionListHead = CurrentSection;
- }
- else
- {
- RtlListInsertTail((PLIST_ITEM)IniFileSectionListHead, (PLIST_ITEM)CurrentSection);
- }
+ InsertTailList(&IniFileSectionListHead, &CurrentSection->ListEntry);
CurrentLineNumber++;
continue;
// Add it to the current section
IniFileSettingCount++;
CurrentSection->SectionItemCount++;
- if (CurrentSection->SectionItemList == NULL)
- {
- CurrentSection->SectionItemList = CurrentItem;
- }
- else
- {
- RtlListInsertTail((PLIST_ITEM)CurrentSection->SectionItemList, (PLIST_ITEM)CurrentItem);
- }
+ InsertTailList(&CurrentSection->SectionItemList, &CurrentItem->ListEntry);
CurrentLineNumber++;
continue;
+++ /dev/null
-/*
- * FreeLoader
- * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <freeldr.h>
-
-VOID RtlListInitializeHead(PLIST_ITEM ListHead)
-{
- ListHead->ListPrev = NULL;
- ListHead->ListNext = NULL;
-}
-
-VOID RtlListInsertHead(PLIST_ITEM ListHead, PLIST_ITEM Entry)
-{
- ListHead = RtlListGetHead(ListHead);
- ListHead->ListPrev = Entry;
- Entry->ListNext = ListHead;
- Entry->ListPrev = NULL;
-}
-
-VOID RtlListInsertTail(PLIST_ITEM ListHead, PLIST_ITEM Entry)
-{
- ListHead = RtlListGetTail(ListHead);
- ListHead->ListNext = Entry;
- Entry->ListNext = NULL;
- Entry->ListPrev = ListHead;
-}
-
-PLIST_ITEM RtlListRemoveHead(PLIST_ITEM ListHead)
-{
- PLIST_ITEM OldListHead = RtlListGetHead(ListHead);
-
- ListHead = ListHead->ListNext;
- ListHead->ListPrev = NULL;
-
- return OldListHead;
-}
-
-PLIST_ITEM RtlListRemoveTail(PLIST_ITEM ListHead)
-{
- PLIST_ITEM ListTail;
-
- ListTail = RtlListGetTail(ListHead);
- ListHead = ListTail->ListPrev;
- ListHead->ListNext = NULL;
-
- return ListTail;
-}
-
-PLIST_ITEM RtlListGetHead(PLIST_ITEM ListHead)
-{
- while (ListHead->ListPrev != NULL)
- {
- ListHead = ListHead->ListPrev;
- }
-
- return ListHead;
-}
-
-PLIST_ITEM RtlListGetTail(PLIST_ITEM ListHead)
-{
- while (ListHead->ListNext != NULL)
- {
- ListHead = ListHead->ListNext;
- }
-
- return ListHead;
-}
-
-BOOLEAN RtlListIsEmpty(PLIST_ITEM ListHead)
-{
- if (ListHead == NULL)
- {
- return TRUE;
- }
-
- return (ListHead->ListNext == NULL);
-}
-
-ULONG RtlListCountEntries(PLIST_ITEM ListHead)
-{
- ULONG Count = 0;
-
- while (ListHead != NULL)
- {
- Count++;
- ListHead = ListHead->ListNext;
- }
-
- return Count;
-}
-
-PLIST_ITEM RtlListGetPrevious(PLIST_ITEM ListEntry)
-{
- return ListEntry->ListPrev;
-}
-
-PLIST_ITEM RtlListGetNext(PLIST_ITEM ListEntry)
-{
- return ListEntry->ListNext;
-}
-
-PLIST_ITEM RtlListRemoveEntry(PLIST_ITEM ListEntry)
-{
- PLIST_ITEM ListNext = RtlListGetNext(ListEntry);
- PLIST_ITEM ListPrev = RtlListGetPrevious(ListEntry);
-
- if (ListPrev != NULL)
- {
- ListPrev->ListNext = ListNext;
- }
-
- if (ListNext != NULL)
- {
- ListNext->ListPrev = ListPrev;
- }
-
- return ListNext;
-}
-
-VOID RtlListInsertEntry(PLIST_ITEM InsertAfter, PLIST_ITEM ListEntry)
-{
- PLIST_ITEM ListNext = RtlListGetNext(InsertAfter);
-
- InsertAfter->ListNext = ListEntry;
- ListEntry->ListPrev = InsertAfter;
- ListEntry->ListNext = ListNext;
-}
-
-VOID RtlListMoveEntryPrevious(PLIST_ITEM ListEntry)
-{
- PLIST_ITEM ListPrev = RtlListGetPrevious(ListEntry);
-
- if (ListPrev == NULL)
- {
- return;
- }
-
- //
- // Move the previous entry after this one
- //
- RtlListRemoveEntry(ListPrev);
- RtlListInsertEntry(ListEntry, ListPrev);
-}
-
-VOID RtlListMoveEntryNext(PLIST_ITEM ListEntry)
-{
- PLIST_ITEM ListNext = RtlListGetNext(ListEntry);
-
- if (ListNext == NULL)
- {
- return;
- }
-
- //
- // Move this entry after the next entry
- //
- RtlListRemoveEntry(ListEntry);
- RtlListInsertEntry(ListNext, ListEntry);
-}
-