- Remove duplicated code in "rtl" and use libstring and librtl instead (their code is safe for freeldr).

- Fix a PCH bug.

svn path=/trunk/; revision=19192
This commit is contained in:
Alex Ionescu 2005-11-13 06:05:06 +00:00
parent 2e2179a2fe
commit df5138e0a0
30 changed files with 134 additions and 827 deletions

View file

@ -451,7 +451,7 @@ i386DiskGetBootPath(char *BootPath, unsigned Size)
static char Path[] = "multi(0)disk(0)";
char Device[4];
itoa(i386BootDrive, Device, 10);
_itoa(i386BootDrive, Device, 10);
if (Size <= sizeof(Path) + 6 + strlen(Device))
{
return FALSE;
@ -491,7 +491,7 @@ i386DiskNormalizeSystemPath(char *SystemPath, unsigned Size)
}
p = SystemPath;
while ('\0' != *p && 0 != strnicmp(p, "partition(", 10)) {
while ('\0' != *p && 0 != _strnicmp(p, "partition(", 10)) {
p++;
}
p = strchr(p, ')');

View file

@ -895,11 +895,11 @@ PcVideoSetDisplayMode(char *DisplayModeName, BOOL Init)
{
DbgPrint((DPRINT_UI, "VGA display adapter detected.\n"));
if (0 == stricmp(DisplayModeName, "NORMAL_VGA"))
if (0 == _stricmp(DisplayModeName, "NORMAL_VGA"))
{
VideoMode = VIDEOMODE_NORMAL_TEXT;
}
else if (0 == stricmp(DisplayModeName, "EXTENDED_VGA"))
else if (0 == _stricmp(DisplayModeName, "EXTENDED_VGA"))
{
VideoMode = VIDEOMODE_EXTENDED_TEXT;
}

View file

@ -120,23 +120,23 @@ NoGui:
// Install the drive mapper according to this sections drive mappings
DriveMapMapDrivesInSection(OperatingSystemSectionNames[SelectedOperatingSystem]);
if (stricmp(SettingValue, "ReactOS") == 0)
if (_stricmp(SettingValue, "ReactOS") == 0)
{
LoadAndBootReactOS(OperatingSystemSectionNames[SelectedOperatingSystem]);
}
else if (stricmp(SettingValue, "Linux") == 0)
else if (_stricmp(SettingValue, "Linux") == 0)
{
LoadAndBootLinux(OperatingSystemSectionNames[SelectedOperatingSystem], OperatingSystemDisplayNames[SelectedOperatingSystem]);
}
else if (stricmp(SettingValue, "BootSector") == 0)
else if (_stricmp(SettingValue, "BootSector") == 0)
{
LoadAndBootBootSector(OperatingSystemSectionNames[SelectedOperatingSystem]);
}
else if (stricmp(SettingValue, "Partition") == 0)
else if (_stricmp(SettingValue, "Partition") == 0)
{
LoadAndBootPartition(OperatingSystemSectionNames[SelectedOperatingSystem]);
}
else if (stricmp(SettingValue, "Drive") == 0)
else if (_stricmp(SettingValue, "Drive") == 0)
{
LoadAndBootDrive(OperatingSystemSectionNames[SelectedOperatingSystem]);
}
@ -174,7 +174,7 @@ ULONG GetDefaultOperatingSystem(PCSTR OperatingSystemList[], ULONG OperatingSy
{
for (Idx=0; Idx<OperatingSystemCount; Idx++)
{
if (stricmp(DefaultOSName, OperatingSystemList[Idx]) == 0)
if (_stricmp(DefaultOSName, OperatingSystemList[Idx]) == 0)
{
DefaultOS = Idx;
break;

View file

@ -92,11 +92,11 @@ CmdLineParse(char *CmdLine)
{
*s++ = '\0';
}
if (0 == stricmp(Name, "defaultos"))
if (0 == _stricmp(Name, "defaultos"))
{
CmdLineInfo.DefaultOperatingSystem = Value;
}
else if (0 == stricmp(Name, "timeout"))
else if (0 == _stricmp(Name, "timeout"))
{
CmdLineInfo.TimeOut = atoi(Value);
}

View file

@ -56,7 +56,7 @@ VOID DriveMapMapDrivesInSection(PCSTR SectionName)
// Get the next setting from the .ini file section
if (IniReadSettingByNumber(SectionId, Index, SettingName, 80, SettingValue, 80))
{
if (stricmp(SettingName, "DriveMap") == 0)
if (_stricmp(SettingName, "DriveMap") == 0)
{
// Make sure we haven't exceeded the drive map max count
if (DriveMapList.DriveMapCount >= 4)

View file

@ -5,4 +5,6 @@
<library>freeldr_base</library>
<library>freeldr_main</library>
<library>rossym</library>
<library>string</library>
<library>rtl</library>
</module>

View file

@ -3,7 +3,6 @@
<include base="freeldr_base">cache</include>
<include base="ntoskrnl">include</include>
<define name="__USE_W32API" />
<compilerflag>-nostdlib</compilerflag>
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>
@ -80,13 +79,6 @@
</directory>
<directory name="rtl">
<file>list.c</file>
<file>memcmp.c</file>
<file>memcpy.c</file>
<file>memmove.c</file>
<file>memset.c</file>
<file>print.c</file>
<file>stdlib.c</file>
<file>string.c</file>
</directory>
<directory name="ui">
<file>gui.c</file>

View file

@ -2,7 +2,6 @@
<include base="freeldr_base64k">include</include>
<include base="ntoskrnl">include</include>
<define name="__USE_W32API" />
<compilerflag>-nostdlib</compilerflag>
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>

View file

@ -2,7 +2,6 @@
<include base="freeldr_main">include</include>
<include base="ntoskrnl">include</include>
<define name="__USE_W32API" />
<compilerflag>-nostdlib</compilerflag>
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>
@ -15,5 +14,4 @@
<file>linuxboot.c</file>
<file>oslist.c</file>
<file>custom.c</file>
<pch>include/freeldr.h</pch>
</module>

View file

@ -2,7 +2,6 @@
<include base="freeldr_startup">include</include>
<include base="ntoskrnl">include</include>
<define name="__USE_W32API" />
<compilerflag>-nostdlib</compilerflag>
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>

View file

@ -306,7 +306,7 @@ BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize
DbgPrint((DPRINT_FILESYSTEM, "Dumping directory entry at offset %d:\n", CurrentOffset));
DbgDumpBuffer(DPRINT_FILESYSTEM, CurrentDirectoryEntry, CurrentDirectoryEntry->rec_len);
if ((strnicmp(FileName, CurrentDirectoryEntry->name, CurrentDirectoryEntry->name_len) == 0) &&
if ((_strnicmp(FileName, CurrentDirectoryEntry->name, CurrentDirectoryEntry->name_len) == 0) &&
(strlen(FileName) == CurrentDirectoryEntry->name_len))
{
RtlCopyMemory(DirectoryEntry, CurrentDirectoryEntry, sizeof(EXT2_DIR_ENTRY));

View file

@ -558,8 +558,8 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize,
//
// See if the file name matches either the short or long name
//
if (((strlen(FileName) == strlen(LfnNameBuffer)) && (stricmp(FileName, LfnNameBuffer) == 0)) ||
((strlen(FileName) == strlen(ShortNameBuffer)) && (stricmp(FileName, ShortNameBuffer) == 0))) {
if (((strlen(FileName) == strlen(LfnNameBuffer)) && (_stricmp(FileName, LfnNameBuffer) == 0)) ||
((strlen(FileName) == strlen(ShortNameBuffer)) && (_stricmp(FileName, ShortNameBuffer) == 0))) {
//
// We found the entry, now fill in the FAT_FILE_INFO struct
//
@ -633,7 +633,7 @@ static BOOL FatXSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG Direct
continue;
}
if (FileNameLen == DirEntry->FileNameSize &&
0 == strnicmp(FileName, DirEntry->FileName, FileNameLen))
0 == _strnicmp(FileName, DirEntry->FileName, FileNameLen))
{
/*
* We found the entry, now fill in the FAT_FILE_INFO struct

View file

@ -99,7 +99,7 @@ static BOOL IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG Directo
Name[i] = 0;
DbgPrint((DPRINT_FILESYSTEM, "Name '%s'\n", Name));
if (strlen(FileName) == strlen(Name) && stricmp(FileName, Name) == 0)
if (strlen(FileName) == strlen(Name) && _stricmp(FileName, Name) == 0)
{
IsoFileInfoPointer->FileStart = Record->ExtentLocationL;
IsoFileInfoPointer->FileSize = Record->DataLengthL;

View file

@ -217,7 +217,7 @@ InfpCacheFindSection (PINFCACHE Cache,
Section = Cache->FirstSection;
while (Section != NULL)
{
if (stricmp (Section->Name, Name) == 0)
if (_stricmp (Section->Name, Name) == 0)
{
return Section;
}
@ -374,7 +374,7 @@ InfpCacheFindKeyLine (PINFCACHESECTION Section,
Line = Section->FirstLine;
while (Line != NULL)
{
if (Line->Key != NULL && stricmp (Line->Key, Key) == 0)
if (Line->Key != NULL && _stricmp (Line->Key, Key) == 0)
{
return Line;
}
@ -1008,7 +1008,7 @@ InfFindFirstLine (HINF InfHandle,
// DPRINT("Comparing '%S' and '%S'\n", CacheSection->Name, Section);
/* Are the section names the same? */
if (stricmp(CacheSection->Name, Section) == 0)
if (_stricmp(CacheSection->Name, Section) == 0)
{
if (Key != NULL)
{
@ -1082,7 +1082,7 @@ InfFindFirstMatchLine (PINFCONTEXT ContextIn,
CacheLine = ((PINFCACHESECTION)(ContextIn->Section))->FirstLine;
while (CacheLine != NULL)
{
if (CacheLine->Key != NULL && stricmp (CacheLine->Key, Key) == 0)
if (CacheLine->Key != NULL && _stricmp (CacheLine->Key, Key) == 0)
{
if (ContextIn != ContextOut)
@ -1118,7 +1118,7 @@ InfFindNextMatchLine (PINFCONTEXT ContextIn,
CacheLine = (PINFCACHELINE)ContextIn->Line;
while (CacheLine != NULL)
{
if (CacheLine->Key != NULL && stricmp (CacheLine->Key, Key) == 0)
if (CacheLine->Key != NULL && _stricmp (CacheLine->Key, Key) == 0)
{
if (ContextIn != ContextOut)
@ -1160,7 +1160,7 @@ InfGetLineCount(HINF InfHandle,
// DPRINT("Comparing '%S' and '%S'\n", CacheSection->Name, Section);
/* Are the section names the same? */
if (stricmp(CacheSection->Name, Section) == 0)
if (_stricmp(CacheSection->Name, Section) == 0)
{
return CacheSection->LineCount;
}

View file

@ -36,7 +36,7 @@ BOOL IniOpenSection(PCSTR SectionName, ULONG* SectionId)
while (Section != NULL)
{
// Compare against the section name
if (stricmp(SectionName, Section->SectionName) == 0)
if (_stricmp(SectionName, Section->SectionName) == 0)
{
// We found it
*SectionId = (ULONG)Section;
@ -141,7 +141,7 @@ BOOL IniReadSettingByName(ULONG SectionId, PCSTR SettingName, PCHAR Buffer, ULON
while (SectionItem != NULL)
{
// Check to see if this is the setting they want
if (stricmp(SettingName, SectionItem->ItemName) == 0)
if (_stricmp(SettingName, SectionItem->ItemName) == 0)
{
DbgPrint((DPRINT_INIFILE, "IniReadSettingByName() Setting \'%s\' found.\n", SettingName));
DbgPrint((DPRINT_INIFILE, "IniReadSettingByName() Setting value = %s\n", SectionItem->ItemValue));

View file

@ -25,11 +25,11 @@ BOOL DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* Boot
{
char *p;
if (strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0)
if (_strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0)
return FALSE;
p = ArcPath + 15;
if (strnicmp(p, "fdisk(", 6) == 0)
if (_strnicmp(p, "fdisk(", 6) == 0)
{
/*
* floppy disk path:
@ -43,7 +43,7 @@ BOOL DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* Boot
p++;
*BootPartition = 0xff;
}
else if (strnicmp(p, "cdrom(", 6) == 0)
else if (_strnicmp(p, "cdrom(", 6) == 0)
{
/*
* cdrom path:
@ -57,7 +57,7 @@ BOOL DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* Boot
p++;
*BootPartition = 0xff;
}
else if (strnicmp(p, "rdisk(", 6) == 0)
else if (_strnicmp(p, "rdisk(", 6) == 0)
{
/*
* hard disk path:
@ -66,7 +66,7 @@ BOOL DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* Boot
p = p + 6;
*BootDrive = atoi(p) + 0x80;
p = strchr(p, ')');
if ((p == NULL) || (strnicmp(p, ")partition(", 11) != 0))
if ((p == NULL) || (_strnicmp(p, ")partition(", 11) != 0))
return FALSE;
p = p + 11;
*BootPartition = atoi(p);
@ -126,11 +126,11 @@ ULONG ConvertArcNameToBiosDriveNumber(PCHAR ArcPath)
char * p;
ULONG DriveNumber = 0;
if (strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0)
if (_strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0)
return 0;
p = ArcPath + 15;
if (strnicmp(p, "fdisk(", 6) == 0)
if (_strnicmp(p, "fdisk(", 6) == 0)
{
/*
* floppy disk path:
@ -139,7 +139,7 @@ ULONG ConvertArcNameToBiosDriveNumber(PCHAR ArcPath)
p = p + 6;
DriveNumber = atoi(p);
}
else if (strnicmp(p, "rdisk(", 6) == 0)
else if (_strnicmp(p, "rdisk(", 6) == 0)
{
/*
* hard disk path:

View file

@ -243,7 +243,7 @@ FrLdrGetKernelBase(VOID)
while ((p = strchr(p, '/')) != NULL) {
/* Find "/3GB" */
if (!strnicmp(p + 1, "3GB", 3)) {
if (!_strnicmp(p + 1, "3GB", 3)) {
/* Make sure there's nothing following it */
if (p[4] == ' ' || p[4] == 0) {
@ -303,7 +303,7 @@ FrLdrGetPaeMode(VOID)
p++;
/* Find "PAE" */
if (!strnicmp(p, "PAE", 3)) {
if (!_strnicmp(p, "PAE", 3)) {
/* Make sure there's nothing following it */
if (p[3] == ' ' || p[3] == 0) {

View file

@ -453,7 +453,7 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
/* Make sure it should be started */
if ((StartValue == 0) &&
(TagValue == OrderList[TagIndex]) &&
(stricmp(DriverGroup, GroupName) == 0)) {
(_stricmp(DriverGroup, GroupName) == 0)) {
/* Get the Driver's Location */
ValueSize = 256;
@ -529,7 +529,7 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
if ((StartValue == 0) &&
(TagIndex > OrderList[0]) &&
(stricmp(DriverGroup, GroupName) == 0)) {
(_stricmp(DriverGroup, GroupName) == 0)) {
ValueSize = 256;
rc = RegQueryValue(hDriverKey, "ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize);
@ -660,7 +660,7 @@ LoadAndBootReactOS(PCSTR OperatingSystemName)
/*
* Special case for Live CD.
*/
if (!stricmp(SystemPath, "LiveCD"))
if (!_stricmp(SystemPath, "LiveCD"))
{
/* Normalize */
MachDiskGetBootPath(SystemPath, sizeof(SystemPath));

View file

@ -267,7 +267,7 @@ RegCreateKey(FRLDRHKEY ParentKey,
KeyList);
DbgPrint((DPRINT_REGISTRY, "SearchKey 0x%x\n", SearchKey));
DbgPrint((DPRINT_REGISTRY, "Searching '%s'\n", SearchKey->Name));
if (strnicmp(SearchKey->Name, name, subkeyLength) == 0)
if (_strnicmp(SearchKey->Name, name, subkeyLength) == 0)
break;
Ptr = Ptr->Flink;
@ -448,7 +448,7 @@ RegOpenKey(FRLDRHKEY ParentKey,
DbgPrint((DPRINT_REGISTRY, "SearchKey 0x%x\n", SearchKey));
DbgPrint((DPRINT_REGISTRY, "Searching '%s'\n", SearchKey->Name));
if (strnicmp(SearchKey->Name, name, subkeyLength) == 0)
if (_strnicmp(SearchKey->Name, name, subkeyLength) == 0)
break;
Ptr = Ptr->Flink;
@ -526,7 +526,7 @@ RegSetValue(FRLDRHKEY Key,
DbgPrint((DPRINT_REGISTRY, "Value->Name '%s'\n", Value->Name));
if (stricmp(Value->Name, ValueName) == 0)
if (_stricmp(Value->Name, ValueName) == 0)
break;
Ptr = Ptr->Flink;
@ -631,7 +631,7 @@ RegQueryValue(FRLDRHKEY Key,
DbgPrint((DPRINT_REGISTRY, "Searching for '%s'. Value name '%s'\n", ValueName, Value->Name));
if (stricmp(Value->Name, ValueName) == 0)
if (_stricmp(Value->Name, ValueName) == 0)
break;
Ptr = Ptr->Flink;
@ -692,7 +692,7 @@ RegDeleteValue(FRLDRHKEY Key,
Value = CONTAINING_RECORD(Ptr,
VALUE,
ValueList);
if (stricmp(Value->Name, ValueName) == 0)
if (_stricmp(Value->Name, ValueName) == 0)
break;
Ptr = Ptr->Flink;

View file

@ -173,3 +173,4 @@ VOID RtlListMoveEntryNext(PLIST_ITEM ListEntry)
RtlListRemoveEntry(ListEntry);
RtlListInsertEntry(ListNext, ListEntry);
}

View file

@ -1,37 +0,0 @@
/*
* 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>
int memcmp(const void *buf1, const void *buf2, size_t count)
{
unsigned int i;
const char* buffer1 = buf1;
const char* buffer2 = buf2;
for (i=0; i<count; i++)
{
if(buffer1[i] == buffer2[i])
continue;
else
return (buffer1[i] - buffer2[i]);
}
return 0;
}

View file

@ -1,50 +0,0 @@
/*
* 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>
#ifdef __i386__
void *memcpy(void *to, const void *from, size_t count)
{
__asm__( \
"or %%ecx,%%ecx\n\t"\
"jz .L1\n\t" \
"cld\n\t" \
"rep\n\t" \
"movsb\n\t" \
".L1:\n\t"
:
: "D" (to), "S" (from), "c" (count));
return to;
}
#else
void *memcpy(void *to, const void *from, size_t count)
{
unsigned int i;
char* buf1 = to;
const char* buf2 = from;
for (i=0; i<count; i++)
{
buf1[i] = buf2[i];
}
return to;
}
#endif

View file

@ -1,54 +0,0 @@
/*
* 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 *memmove(void *dest, const void *src, size_t count)
{
char *char_dest = (char *)dest;
char *char_src = (char *)src;
if ((char_dest <= char_src) || (char_dest >= (char_src+count)))
{
/* non-overlapping buffers */
while(count > 0)
{
*char_dest = *char_src;
char_dest++;
char_src++;
count--;
}
}
else
{
/* overlaping buffers */
char_dest = (char *)dest + count - 1;
char_src = (char *)src + count - 1;
while(count > 0)
{
*char_dest = *char_src;
char_dest--;
char_src--;
count--;
}
}
return dest;
}

View file

@ -1,49 +0,0 @@
/*
* 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>
#ifdef __i386__
void *memset(void *src, int val, size_t count)
{
__asm__( \
"or %%ecx,%%ecx\n\t"\
"jz .L1\n\t" \
"cld\t\n" \
"rep\t\n" \
"stosb\t\n" \
".L1:\n\t"
:
: "D" (src), "c" (count), "a" (val));
return src;
}
#else
void *memset(void *src, int val, size_t count)
{
unsigned int i;
unsigned char* buf1 = src;
for (i=0; i<count; i++)
{
buf1[i] = val;
}
return src;
}
#endif

View file

@ -1,182 +0,0 @@
/*
* 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>
/*
* print() - prints unformatted text to stdout
*/
void print(char *str)
{
size_t i;
for (i = 0; i < strlen(str); i++)
MachConsPutChar(str[i]);
}
/*
* printf() - prints formatted text to stdout
* originally from GRUB
*/
int printf(const char *format, ... )
{
va_list ap;
va_start(ap,format);
char c, *ptr, str[16];
int ll;
while ((c = *(format++)))
{
if (c != '%')
{
MachConsPutChar(c);
}
else
{
if (*format == 'I' && *(format+1) == '6' && *(format+2) == '4')
{
ll = 1;
format += 3;
}
else
{
ll = 0;
}
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
if (ll)
{
*convert_i64_to_ascii(str, c, va_arg(ap, unsigned long long)) = 0;
}
else
{
*convert_to_ascii(str, c, va_arg(ap, unsigned long)) = 0;
}
ptr = str;
while (*ptr)
{
MachConsPutChar(*(ptr++));
}
break;
case 'c': MachConsPutChar((va_arg(ap,int))&0xff); break;
case 's':
ptr = va_arg(ap,char *);
while ((c = *(ptr++)))
{
MachConsPutChar(c);
}
break;
case '%':
MachConsPutChar(c);
break;
default:
printf("\nprintf() invalid format specifier - %%%c\n", c);
break;
}
}
}
va_end(ap);
return 0;
}
int sprintf(char *buffer, const char *format, ... )
{
va_list ap;
char c, *ptr, str[16];
char *p = buffer;
int ll;
va_start(ap,format);
while ((c = *(format++)))
{
if (c != '%')
{
*p = c;
p++;
}
else
{
if (*format == 'I' && *(format+1) == '6' && *(format+2) == '4')
{
ll = 1;
format += 3;
}
else
{
ll = 0;
}
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
if (ll)
{
*convert_i64_to_ascii(str, c, va_arg(ap, unsigned long long)) = 0;
}
else
{
*convert_to_ascii(str, c, va_arg(ap, unsigned long)) = 0;
}
ptr = str;
while (*ptr)
{
*p = *(ptr++);
p++;
}
break;
case 'c':
*p = va_arg(ap,int)&0xff;
p++;
break;
case 's':
ptr = va_arg(ap,char *);
while ((c = *(ptr++)))
{
*p = c;
p++;
}
break;
case '%':
*p = c;
p++;
break;
default:
printf("\nsprintf() invalid format specifier - %%%c\n", c);
break;
}
}
}
va_end(ap);
*p=0;
return 0;
}

View file

@ -1,192 +0,0 @@
/*
* 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>
/*
* convert_to_ascii() - converts a number to it's ascii equivalent
* from:
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
*/
char *convert_to_ascii(char *buf, int c, int num)
{
unsigned long mult = 10;
char *ptr = buf;
if (c == 'x')
mult = 16;
if ((num & 0x80000000uL) && c == 'd')
{
num = (~num)+1;
*(ptr++) = '-';
buf++;
}
do
{
int dig = num % mult;
*(ptr++) = ( (dig > 9) ? dig + 'a' - 10 : '0' + dig );
}
while (num /= mult);
/* reorder to correct direction!! */
{
char *ptr1 = ptr-1;
char *ptr2 = buf;
while (ptr1 > ptr2)
{
int c = *ptr1;
*ptr1 = *ptr2;
*ptr2 = c;
ptr1--;
ptr2++;
}
}
return ptr;
}
char *convert_i64_to_ascii(char *buf, int c, unsigned long long num)
{
int mult = 10;
char *ptr = buf;
if (c == 'x')
mult = 16;
if ((num & 0x8000000000000000uLL) && c == 'd')
{
num = (~num)+1;
*(ptr++) = '-';
buf++;
}
do
{
int dig = num % mult;
*(ptr++) = ( (dig > 9) ? dig + 'a' - 10 : '0' + dig );
}
while (num /= mult);
/* reorder to correct direction!! */
{
char *ptr1 = ptr-1;
char *ptr2 = buf;
while (ptr1 > ptr2)
{
int c = *ptr1;
*ptr1 = *ptr2;
*ptr2 = c;
ptr1--;
ptr2++;
}
}
return ptr;
}
char *itoa(int value, char *string, int radix)
{
if(radix == 16)
*convert_to_ascii(string, 'x', value) = 0;
else
*convert_to_ascii(string, 'd', value) = 0;
return string;
}
int toupper(int c)
{
if((c >= 'a') && (c <= 'z'))
c -= 32;
return c;
}
int tolower(int c)
{
if((c >= 'A') && (c <= 'Z'))
c += 32;
return c;
}
int atoi(const char *string)
{
int base;
int result = 0;
const char *str;
if((string[0] == '0') && (string[1] == 'x'))
{
base = 16;
str = string + 2;
}
else
{
base = 10;
str = string;
}
while(1)
{
if(base == 16)
{
if(((*str < '0') || (*str > '9')) && ((*str < 'a') || (*str > 'f')) && ((*str < 'A') || (*str > 'F')))
break;
result *= base;
if((*str >= '0') && (*str <= '9'))
result += (*str - '0');
if((*str >= 'a') && (*str <= 'f'))
result += (*str - 'a') + 10;
if((*str >= 'A') && (*str <= 'F'))
result += (*str - 'A') + 10;
str++;
}
else //if(base == 10)
{
if((*str < '0') || (*str > '9'))
break;
result *= base;
result += (*str - '0');
str++;
}
}
return result;
}
int isspace(int c)
{
return(c == ' ' || (c >= 0x09 && c <= 0x0D));
}
int isdigit(int c)
{
return(c >= '0' && c <= '9');
}
int isxdigit(int c)
{
return((c >= '0' && c <= '9')||(c >= 'a' && c <= 'f')||(c >= 'A' && c <= 'F'));
}

View file

@ -1,176 +0,0 @@
/*
* 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>
size_t strlen(const char *str)
{
int len;
for(len=0; str[len] != '\0'; len++);
return len;
}
char *strcpy(char *dest, const char *src)
{
char *ret = dest;
while(*src)
*dest++ = *src++;
*dest = 0;
return ret;
}
char *strncpy(char *dest, const char *src, size_t count)
{
char *ret = dest;
while((*src) && (count--))
*dest++ = *src++;
if (count)
*dest = 0;
return ret;
}
char *strcat(char *dest, const char *src)
{
char *ret = dest;
while(*dest)
dest++;
while(*src)
*dest++ = *src++;
*dest = 0;
return ret;
}
char *strncat(char *dst, const char *src, size_t n)
{
if (n != 0)
{
char *d = dst;
const char *s = src;
while (*d != 0)
d++;
do
{
if ((*d = *s++) == 0)
break;
d++;
}
while (--n != 0);
*d = 0;
}
return dst;
}
char *strchr(const char *s, int c)
{
char cc = c;
while (*s)
{
if (*s == cc)
return (char *)s;
s++;
}
if (cc == 0)
return (char *)s;
return 0;
}
char *strrchr(const char *s, int c)
{
char cc = c;
const char *sp=(char *)0;
while (*s)
{
if (*s == cc)
sp = s;
s++;
}
if (cc == 0)
sp = s;
return (char *)sp;
}
int strcmp(const char *string1, const char *string2)
{
while(*string1 == *string2)
{
if(*string1 == 0)
return 0;
string1++;
string2++;
}
return *(unsigned const char *)string1 - *(unsigned const char *)(string2);
}
int stricmp(const char *string1, const char *string2)
{
while(tolower(*string1) == tolower(*string2))
{
if(*string1 == 0)
return 0;
string1++;
string2++;
}
return (int)tolower(*string1) - (int)tolower(*string2);
}
int strnicmp(const char *string1, const char *string2, size_t length)
{
if (length == 0)
return 0;
do
{
if (toupper(*string1) != toupper(*string2++))
return toupper(*(unsigned const char *)string1) - toupper(*(unsigned const char *)--string2);
if (*string1++ == 0)
break;
}
while (--length != 0);
return 0;
}
int strncmp(const char *string1, const char *string2, size_t length)
{
if (length == 0)
return 0;
do
{
if (*string1 != *string2++)
return *(unsigned const char *)string1 - *(unsigned const char *)--string2;
if (*string1++ == 0)
break;
}
while (--length != 0);
return 0;
}

View file

@ -21,6 +21,62 @@
PVOID TextVideoBuffer = NULL;
/*
* printf() - prints formatted text to stdout
* originally from GRUB
*/
int printf(const char *format, ... )
{
va_list ap;
va_start(ap,format);
char c, *ptr, str[16];
while ((c = *(format++)))
{
if (c != '%')
{
MachConsPutChar(c);
}
else
{
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
*_itoa(va_arg(ap, unsigned long), str, 10) = 0;
ptr = str;
while (*ptr)
{
MachConsPutChar(*(ptr++));
}
break;
case 'c': MachConsPutChar((va_arg(ap,int))&0xff); break;
case 's':
ptr = va_arg(ap,char *);
while ((c = *(ptr++)))
{
MachConsPutChar(c);
}
break;
case '%':
MachConsPutChar(c);
break;
default:
printf("\nprintf() invalid format specifier - %%%c\n", c);
break;
}
}
}
va_end(ap);
return 0;
}
BOOL TuiInitialize(VOID)
{
MachVideoClearScreen(ATTR(COLOR_WHITE, COLOR_BLACK));
@ -401,7 +457,7 @@ VOID TuiUpdateDateTime(VOID)
// Get the month name
strcpy(DateString, UiMonthNames[Month - 1]);
// Get the day
itoa(Day, TempString, 10);
_itoa(Day, TempString, 10);
// Get the day postfix
if (1 == Day || 21 == Day || 31 == Day)
{
@ -425,7 +481,7 @@ VOID TuiUpdateDateTime(VOID)
strcat(DateString, " ");
// Get the year and add it to the date
itoa(Year, TempString, 10);
_itoa(Year, TempString, 10);
strcat(DateString, TempString);
// Draw the date
@ -441,18 +497,18 @@ VOID TuiUpdateDateTime(VOID)
{
Hour = 12;
}
itoa(Hour, TempString, 10);
_itoa(Hour, TempString, 10);
strcpy(TimeString, " ");
strcat(TimeString, TempString);
strcat(TimeString, ":");
itoa(Minute, TempString, 10);
_itoa(Minute, TempString, 10);
if (Minute < 10)
{
strcat(TimeString, "0");
}
strcat(TimeString, TempString);
strcat(TimeString, ":");
itoa(Second, TempString, 10);
_itoa(Second, TempString, 10);
if (Second < 10)
{
strcat(TimeString, "0");
@ -653,37 +709,37 @@ VOID TuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG
UCHAR TuiTextToColor(PCSTR ColorText)
{
if (stricmp(ColorText, "Black") == 0)
if (_stricmp(ColorText, "Black") == 0)
return COLOR_BLACK;
else if (stricmp(ColorText, "Blue") == 0)
else if (_stricmp(ColorText, "Blue") == 0)
return COLOR_BLUE;
else if (stricmp(ColorText, "Green") == 0)
else if (_stricmp(ColorText, "Green") == 0)
return COLOR_GREEN;
else if (stricmp(ColorText, "Cyan") == 0)
else if (_stricmp(ColorText, "Cyan") == 0)
return COLOR_CYAN;
else if (stricmp(ColorText, "Red") == 0)
else if (_stricmp(ColorText, "Red") == 0)
return COLOR_RED;
else if (stricmp(ColorText, "Magenta") == 0)
else if (_stricmp(ColorText, "Magenta") == 0)
return COLOR_MAGENTA;
else if (stricmp(ColorText, "Brown") == 0)
else if (_stricmp(ColorText, "Brown") == 0)
return COLOR_BROWN;
else if (stricmp(ColorText, "Gray") == 0)
else if (_stricmp(ColorText, "Gray") == 0)
return COLOR_GRAY;
else if (stricmp(ColorText, "DarkGray") == 0)
else if (_stricmp(ColorText, "DarkGray") == 0)
return COLOR_DARKGRAY;
else if (stricmp(ColorText, "LightBlue") == 0)
else if (_stricmp(ColorText, "LightBlue") == 0)
return COLOR_LIGHTBLUE;
else if (stricmp(ColorText, "LightGreen") == 0)
else if (_stricmp(ColorText, "LightGreen") == 0)
return COLOR_LIGHTGREEN;
else if (stricmp(ColorText, "LightCyan") == 0)
else if (_stricmp(ColorText, "LightCyan") == 0)
return COLOR_LIGHTCYAN;
else if (stricmp(ColorText, "LightRed") == 0)
else if (_stricmp(ColorText, "LightRed") == 0)
return COLOR_LIGHTRED;
else if (stricmp(ColorText, "LightMagenta") == 0)
else if (_stricmp(ColorText, "LightMagenta") == 0)
return COLOR_LIGHTMAGENTA;
else if (stricmp(ColorText, "Yellow") == 0)
else if (_stricmp(ColorText, "Yellow") == 0)
return COLOR_YELLOW;
else if (stricmp(ColorText, "White") == 0)
else if (_stricmp(ColorText, "White") == 0)
return COLOR_WHITE;
return COLOR_BLACK;
@ -691,15 +747,15 @@ UCHAR TuiTextToColor(PCSTR ColorText)
UCHAR TuiTextToFillStyle(PCSTR FillStyleText)
{
if (stricmp(FillStyleText, "Light") == 0)
if (_stricmp(FillStyleText, "Light") == 0)
{
return LIGHT_FILL;
}
else if (stricmp(FillStyleText, "Medium") == 0)
else if (_stricmp(FillStyleText, "Medium") == 0)
{
return MEDIUM_FILL;
}
else if (stricmp(FillStyleText, "Dark") == 0)
else if (_stricmp(FillStyleText, "Dark") == 0)
{
return DARK_FILL;
}

View file

@ -230,7 +230,7 @@ VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo)
if (MenuInfo->MenuTimeRemaining >= 0)
{
strcpy(MenuLineText, "[ Time Remaining: ");
itoa(MenuInfo->MenuTimeRemaining, TempString, 10);
_itoa(MenuInfo->MenuTimeRemaining, TempString, 10);
strcat(MenuLineText, TempString);
strcat(MenuLineText, " ]");
@ -245,7 +245,7 @@ VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo)
//
for (Idx=0; Idx<MenuInfo->MenuItemCount; Idx++)
{
if (stricmp(MenuInfo->MenuItemList[Idx], "SEPARATOR") == 0)
if (_stricmp(MenuInfo->MenuItemList[Idx], "SEPARATOR") == 0)
{
UiDrawText(MenuInfo->Left, MenuInfo->Top + Idx + 1, "\xC7", ATTR(UiMenuFgColor, UiMenuBgColor));
UiDrawText(MenuInfo->Right, MenuInfo->Top + Idx + 1, "\xB6", ATTR(UiMenuFgColor, UiMenuBgColor));
@ -295,7 +295,7 @@ VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, ULONG MenuItemNumber)
//
// If it is a separator then adjust the text accordingly
//
if (stricmp(MenuInfo->MenuItemList[MenuItemNumber], "SEPARATOR") == 0)
if (_stricmp(MenuInfo->MenuItemList[MenuItemNumber], "SEPARATOR") == 0)
{
memset(MenuLineText, 0, 80);
memset(MenuLineText, 0xC4, (MenuInfo->Right - MenuInfo->Left - 1));
@ -387,7 +387,7 @@ ULONG TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterC
TuiDrawMenuItem(MenuInfo, MenuInfo->SelectedMenuItem + 1); // Deselect previous item
// Skip past any separators
if (MenuInfo->SelectedMenuItem > 0 && stricmp(MenuInfo->MenuItemList[MenuInfo->SelectedMenuItem], "SEPARATOR") == 0)
if (MenuInfo->SelectedMenuItem > 0 && _stricmp(MenuInfo->MenuItemList[MenuInfo->SelectedMenuItem], "SEPARATOR") == 0)
{
MenuInfo->SelectedMenuItem--;
}
@ -409,7 +409,7 @@ ULONG TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterC
TuiDrawMenuItem(MenuInfo, MenuInfo->SelectedMenuItem - 1); // Deselect previous item
// Skip past any separators
if (MenuInfo->SelectedMenuItem < (MenuInfo->MenuItemCount - 1) && stricmp(MenuInfo->MenuItemList[MenuInfo->SelectedMenuItem], "SEPARATOR") == 0)
if (MenuInfo->SelectedMenuItem < (MenuInfo->MenuItemCount - 1) && _stricmp(MenuInfo->MenuItemList[MenuInfo->SelectedMenuItem], "SEPARATOR") == 0)
{
MenuInfo->SelectedMenuItem++;
}

View file

@ -153,7 +153,7 @@ BOOL UiInitialize(BOOLEAN ShowGui)
}
if (IniReadSettingByName(SectionId, "SpecialEffects", SettingText, 260))
{
if (stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3)
if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3)
{
UiUseSpecialEffects = TRUE;
}
@ -544,7 +544,7 @@ VOID UiShowMessageBoxesInSection(PCSTR SectionName)
{
IniReadSettingByNumber(SectionId, Idx, SettingName, 79, SettingValue, 79);
if (stricmp(SettingName, "MessageBox") == 0)
if (_stricmp(SettingName, "MessageBox") == 0)
{
// Get the real length of the MessageBox text
MessageBoxTextSize = IniGetSectionSettingValueSize(SectionId, Idx);