Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenoslist.c
Go to the documentation of this file.
00001 /* 00002 * FreeLoader 00003 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #include <freeldr.h> 00021 00022 static PCSTR CopyString(PCSTR Source) 00023 { 00024 PSTR Dest; 00025 00026 if (!Source) 00027 return NULL; 00028 Dest = MmHeapAlloc(strlen(Source) + 1); 00029 if (Dest) 00030 { 00031 strcpy(Dest, Source); 00032 } 00033 00034 return Dest; 00035 } 00036 00037 OperatingSystemItem* InitOperatingSystemList(ULONG* OperatingSystemCountPointer) 00038 { 00039 ULONG Idx; 00040 CHAR SettingName[260]; 00041 CHAR SettingValue[260]; 00042 ULONG_PTR SectionId; 00043 PCHAR TitleStart, TitleEnd; 00044 PCSTR OsLoadOptions; 00045 ULONG Count; 00046 OperatingSystemItem* Items; 00047 00048 // 00049 // Open the [FreeLoader] section 00050 // 00051 if (!IniOpenSection("Operating Systems", &SectionId)) 00052 { 00053 return NULL; 00054 } 00055 00056 // 00057 // Count number of operating systems in the section 00058 // 00059 Count = IniGetNumSectionItems(SectionId); 00060 00061 // 00062 // Allocate memory to hold operating system lists 00063 // 00064 Items = MmHeapAlloc(Count * sizeof(OperatingSystemItem)); 00065 if (!Items) 00066 { 00067 return NULL; 00068 } 00069 00070 // 00071 // Now loop through and read the operating system section and display names 00072 // 00073 for (Idx = 0; Idx < Count; Idx++) 00074 { 00075 IniReadSettingByNumber(SectionId, Idx, SettingName, sizeof(SettingName), SettingValue, sizeof(SettingValue)); 00076 00077 // 00078 // Search start and end of the title 00079 // 00080 OsLoadOptions = NULL; 00081 TitleStart = SettingValue; 00082 while (*TitleStart == ' ' || *TitleStart == '"') 00083 TitleStart++; 00084 TitleEnd = TitleStart; 00085 if (*TitleEnd != ANSI_NULL) 00086 TitleEnd++; 00087 while (*TitleEnd != ANSI_NULL && *TitleEnd != '"') 00088 TitleEnd++; 00089 if (*TitleEnd != ANSI_NULL) 00090 { 00091 *TitleEnd = ANSI_NULL; 00092 OsLoadOptions = TitleEnd + 1; 00093 } 00094 00095 // 00096 // Copy the system partition, identifier and options 00097 // 00098 Items[Idx].SystemPartition = CopyString(SettingName); 00099 Items[Idx].LoadIdentifier = CopyString(TitleStart); 00100 Items[Idx].OsLoadOptions = CopyString(OsLoadOptions); 00101 } 00102 00103 // 00104 // Return success 00105 // 00106 *OperatingSystemCountPointer = Count; 00107 return Items; 00108 } Generated on Sat May 26 2012 04:18:03 for ReactOS by
1.7.6.1
|