ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2005
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
22 participants
582 discussions
Start a n
N
ew thread
[gvg] 17741: Correct notepad location
by gvg@svn.reactos.com
Correct notepad location Modified: trunk/reactos/bootdata/hivecls.inf _____ Modified: trunk/reactos/bootdata/hivecls.inf --- trunk/reactos/bootdata/hivecls.inf 2005-09-08 13:27:17 UTC (rev 17740) +++ trunk/reactos/bootdata/hivecls.inf 2005-09-08 14:01:53 UTC (rev 17741) @@ -45,7 +45,7 @@ ; install notepad as handler for .txt files HKCR,".txt","",0x00000000,"txtfile" HKCR,".txt","Content Type",0x00000000,"text/plain" -HKCR,"txtfile\shell\open\command","",0x00020000,"%SystemRoot%\bin\notep ad.exe %1" +HKCR,"txtfile\shell\open\command","",0x00020000,"%SystemRoot%\System32\ notepad.exe %1" HKCR,"CLSID",,0x00000012
19 years, 3 months
1
0
0
0
[gvg] 17740: saveliyt@mail.ru:
by gvg@svn.reactos.com
saveliyt(a)mail.ru: Start SCM on livecd too Modified: trunk/reactos/subsys/system/winlogon/winlogon.c _____ Modified: trunk/reactos/subsys/system/winlogon/winlogon.c --- trunk/reactos/subsys/system/winlogon/winlogon.c 2005-09-08 13:08:21 UTC (rev 17739) +++ trunk/reactos/subsys/system/winlogon/winlogon.c 2005-09-08 13:27:17 UTC (rev 17740) @@ -593,6 +593,8 @@ DbgPrint("WL: Cannot switch to Winlogon desktop (0x%X)\n", GetLastError()); } + InitServices(); + /* Check for pending setup */ if (GetSetupType () != 0) { @@ -616,8 +618,6 @@ return 2; } - InitServices(); - #if 0 /* real winlogon uses "Winlogon" */ RtlInitUnicodeString((PUNICODE_STRING)&ProcessName, L"Winlogon");
19 years, 3 months
1
0
0
0
[gvg] 17739: Reserve space for The Terminator
by gvg@svn.reactos.com
Reserve space for The Terminator Modified: trunk/reactos/boot/freeldr/freeldr/inifile/inifile.c _____ Modified: trunk/reactos/boot/freeldr/freeldr/inifile/inifile.c --- trunk/reactos/boot/freeldr/freeldr/inifile/inifile.c 2005-09-08 08:38:16 UTC (rev 17738) +++ trunk/reactos/boot/freeldr/freeldr/inifile/inifile.c 2005-09-08 13:08:21 UTC (rev 17739) @@ -218,7 +218,7 @@ RtlZeroMemory(SectionItem, sizeof(INI_SECTION_ITEM)); // Allocate the setting name buffer - SectionItem->ItemName = MmAllocateMemory(strlen(SettingName)); + SectionItem->ItemName = MmAllocateMemory(strlen(SettingName) + 1); if (!SectionItem->ItemName) { MmFreeMemory(SectionItem); @@ -226,7 +226,7 @@ } // Allocate the setting value buffer - SectionItem->ItemValue = MmAllocateMemory(strlen(SettingValue)); + SectionItem->ItemValue = MmAllocateMemory(strlen(SettingValue) + 1); if (!SectionItem->ItemValue) { MmFreeMemory(SectionItem->ItemName);
19 years, 3 months
1
0
0
0
[ion] 17738: Well heck I'm getting tired of ? <local stuff in my tree> too
by ion@svn.reactos.com
Well heck I'm getting tired of ? <local stuff in my tree> too Property changes on: trunk/reactos ___________________________________________________________________ Name: svn:ignore - *.sys *.exe *.dll *.cpl *.a *.o *.d *.coff *.dsp *.dsw *.aps *.ncb *.opt *.sym *.plg *.bak *.zip *.iso *.cab *.bat *.log makefile.auto config.xml obj-* output-* doxy-doc cd reactos ros + *.sys *.exe *.dll *.cpl *.a *.o *.d *.coff *.dsp *.dsw *.aps *.ncb *.opt *.sym *.plg *.bak *.zip *.iso *.img *.cab *.bat *.log *.patch *.diff makefile.auto config.xml obj-* output-* doxy-doc cd reactos ros
19 years, 3 months
1
0
0
0
[gvg] 17737: Getting tired of seeing "? ros"
by gvg@svn.reactos.com
Getting tired of seeing "? ros" Property changes on: trunk/reactos ___________________________________________________________________ Name: svn:ignore - *.sys *.exe *.dll *.cpl *.a *.o *.d *.coff *.dsp *.dsw *.aps *.ncb *.opt *.sym *.plg *.bak *.zip *.iso *.cab *.bat *.log makefile.auto config.xml obj-* output-* doxy-doc cd reactos + *.sys *.exe *.dll *.cpl *.a *.o *.d *.coff *.dsp *.dsw *.aps *.ncb *.opt *.sym *.plg *.bak *.zip *.iso *.cab *.bat *.log makefile.auto config.xml obj-* output-* doxy-doc cd reactos ros
19 years, 3 months
1
0
0
0
[gvg] 17736: Translate partition 0 to active partition. Fixes bug 181.
by gvg@svn.reactos.com
Translate partition 0 to active partition. Fixes bug 181. Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/i386.h Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c Modified: trunk/reactos/boot/freeldr/freeldr/disk/partition.c Modified: trunk/reactos/boot/freeldr/freeldr/include/disk.h Modified: trunk/reactos/boot/freeldr/freeldr/include/machine.h Modified: trunk/reactos/boot/freeldr/freeldr/linuxboot.c Modified: trunk/reactos/boot/freeldr/freeldr/machine.c Modified: trunk/reactos/boot/freeldr/freeldr/miscboot.c Modified: trunk/reactos/boot/freeldr/freeldr/reactos/arcname.c Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c _____ Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/i386.h --- trunk/reactos/boot/freeldr/freeldr/arch/i386/i386.h 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/i386.h 2005-09-08 08:29:01 UTC (rev 17736) @@ -34,6 +34,7 @@ extern BOOL i386DiskGetBootPath(char *BootPath, unsigned Size); extern VOID i386DiskGetBootDevice(PULONG BootDevice); extern BOOL i386DiskBootingFromFloppy(VOID); +extern BOOL i386DiskNormalizeSystemPath(char *SystemPath, unsigned Size); #endif /* __I386_I386_H_ */ _____ Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c --- trunk/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c 2005-09-08 08:29:01 UTC (rev 17736) @@ -165,6 +165,7 @@ memcpy(Buffer, Ptr, BufferSize); +#ifdef DEBUG DbgPrint((DPRINT_DISK, "size of buffer: %x\n", Ptr[0])); DbgPrint((DPRINT_DISK, "information flags: %x\n", Ptr[1])); DbgPrint((DPRINT_DISK, "number of physical cylinders on drive: %u\n", *(PULONG)&Ptr[2])); @@ -194,6 +195,7 @@ { DbgPrint((DPRINT_HB, "signature: %x\n", Ptr[15])); } +#endif return TRUE; } @@ -202,6 +204,7 @@ { PARTITION_TABLE_ENTRY PartitionTableEntry; UCHAR VolumeType; + ULONG ActivePartition; DbgPrint((DPRINT_FILESYSTEM, "FsOpenVolume() DriveNumber: 0x%x PartitionNumber: 0x%x\n", i386BootDrive, i386BootPartition)); @@ -234,7 +237,7 @@ if (i386BootPartition == 0) { // Partition requested was zero which means the boot partition - if (! DiskGetActivePartitionEntry(i386BootDrive, &PartitionTableEntry)) + if (! DiskGetActivePartitionEntry(i386BootDrive, &PartitionTableEntry, &ActivePartition)) { /* Try partition-less disk */ *StartSector = 0; @@ -460,6 +463,46 @@ return TRUE; } +BOOL +i386DiskNormalizeSystemPath(char *SystemPath, unsigned Size) +{ + CHAR BootPath[256]; + ULONG PartitionNumber; + ULONG DriveNumber; + PARTITION_TABLE_ENTRY PartEntry; + char *p; + + if (!DissectArcPath(SystemPath, BootPath, &DriveNumber, &PartitionNumber)) + { + return FALSE; + } + + if (0 != PartitionNumber) + { + return TRUE; + } + + if (! DiskGetActivePartitionEntry(DriveNumber, + &PartEntry, + &PartitionNumber) || + PartitionNumber < 1 || 9 < PartitionNumber) + { + return FALSE; + } + + p = SystemPath; + while ('\0' != *p && 0 != strnicmp(p, "partition(", 10)) { + p++; + } + p = strchr(p, ')'); + if (NULL == p || '0' != *(p - 1)) { + return FALSE; + } + *(p - 1) = '0' + PartitionNumber; + + return TRUE; +} + #endif /* defined __i386__ */ /* EOF */ _____ Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c --- trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c 2005-09-08 08:29:01 UTC (rev 17736) @@ -54,6 +54,7 @@ MachVtbl.DiskGetBootPath = i386DiskGetBootPath; MachVtbl.DiskGetBootDevice = i386DiskGetBootDevice; MachVtbl.DiskBootingFromFloppy = i386DiskBootingFromFloppy; + MachVtbl.DiskNormalizeSystemPath = i386DiskNormalizeSystemPath; MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors; MachVtbl.DiskGetPartitionEntry = PcDiskGetPartitionEntry; MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry; _____ Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c --- trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c 2005-09-08 08:29:01 UTC (rev 17736) @@ -52,6 +52,7 @@ MachVtbl.DiskGetBootPath = i386DiskGetBootPath; MachVtbl.DiskGetBootDevice = i386DiskGetBootDevice; MachVtbl.DiskBootingFromFloppy = i386DiskBootingFromFloppy; + MachVtbl.DiskNormalizeSystemPath = i386DiskNormalizeSystemPath; MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors; MachVtbl.DiskGetPartitionEntry = XboxDiskGetPartitionEntry; MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry; _____ Modified: trunk/reactos/boot/freeldr/freeldr/disk/partition.c --- trunk/reactos/boot/freeldr/freeldr/disk/partition.c 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/disk/partition.c 2005-09-08 08:29:01 UTC (rev 17736) @@ -26,12 +26,14 @@ #include <machine.h> -BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry) +BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, + PPARTITION_TABLE_ENTRY PartitionTableEntry, + ULONG *ActivePartition) { ULONG BootablePartitionCount = 0; - ULONG ActivePartition = 0; MASTER_BOOT_RECORD MasterBootRecord; + *ActivePartition = 0; // Read master boot record if (!DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord)) { @@ -42,22 +44,22 @@ if (MasterBootRecord.PartitionTable[0].BootIndicator == 0x80) { BootablePartitionCount++; - ActivePartition = 0; + *ActivePartition = 1; } if (MasterBootRecord.PartitionTable[1].BootIndicator == 0x80) { BootablePartitionCount++; - ActivePartition = 1; + *ActivePartition = 2; } if (MasterBootRecord.PartitionTable[2].BootIndicator == 0x80) { BootablePartitionCount++; - ActivePartition = 2; + *ActivePartition = 3; } if (MasterBootRecord.PartitionTable[3].BootIndicator == 0x80) { BootablePartitionCount++; - ActivePartition = 3; + *ActivePartition = 4; } // Make sure there was only one bootable partition @@ -73,7 +75,9 @@ } // Copy the partition table entry - RtlCopyMemory(PartitionTableEntry, &MasterBootRecord.PartitionTable[ActivePartition], sizeof(PARTITION_TABLE_ENTRY)); + RtlCopyMemory(PartitionTableEntry, + &MasterBootRecord.PartitionTable[*ActivePartition - 1], + sizeof(PARTITION_TABLE_ENTRY)); return TRUE; } _____ Modified: trunk/reactos/boot/freeldr/freeldr/include/disk.h --- trunk/reactos/boot/freeldr/freeldr/include/disk.h 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/include/disk.h 2005-09-08 08:29:01 UTC (rev 17736) @@ -130,7 +130,7 @@ // Fixed Disk Partition Management Functions // //////////////////////////////////////////////////////////////////////// /////////////// -BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry); +BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry, ULONG *ActivePartition); BOOL DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry); BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry); BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry); _____ Modified: trunk/reactos/boot/freeldr/freeldr/include/machine.h --- trunk/reactos/boot/freeldr/freeldr/include/machine.h 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/include/machine.h 2005-09-08 08:29:01 UTC (rev 17736) @@ -61,6 +61,7 @@ BOOL (*DiskGetBootPath)(char *BootPath, unsigned Size); VOID (*DiskGetBootDevice)(PULONG BootDevice); BOOL (*DiskBootingFromFloppy)(VOID); + BOOL (*DiskNormalizeSystemPath)(char *SystemPath, unsigned Size); BOOL (*DiskReadLogicalSectors)(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); BOOL (*DiskGetPartitionEntry)(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry); BOOL (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry); @@ -97,6 +98,7 @@ #define MachDiskGetBootPath(Path, Size) MachVtbl.DiskGetBootPath((Path), (Size)) #define MachDiskGetBootDevice(BootDevice) MachVtbl.DiskGetBootDevice(BootDevice) #define MachDiskBootingFromFloppy() MachVtbl.DiskBootingFromFloppy() +#define MachDiskNormalizeSystemPath(Path, Size) MachVtbl.DiskNormalizeSystemPath((Path), (Size)) #define MachDiskReadLogicalSectors(Drive, Start, Count, Buf) MachVtbl.DiskReadLogicalSectors((Drive), (Start), (Count), (Buf)) #define MachDiskGetPartitionEntry(Drive, Part, Entry) MachVtbl.DiskGetPartitionEntry((Drive), (Part), (Entry)) #define MachDiskGetDriveGeometry(Drive, Geom) MachVtbl.DiskGetDriveGeometry((Drive), (Geom)) _____ Modified: trunk/reactos/boot/freeldr/freeldr/linuxboot.c --- trunk/reactos/boot/freeldr/freeldr/linuxboot.c 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/linuxboot.c 2005-09-08 08:29:01 UTC (rev 17736) @@ -81,6 +81,11 @@ } // Open the boot volume + if (!MachDiskNormalizeSystemPath(LinuxBootPath, sizeof(LinuxBootPath))) + { + UiMessageBox("Invalid boot path"); + goto LinuxBootFailed; + } if (!FsOpenSystemVolume(LinuxBootPath, NULL, NULL)) { UiMessageBox("Failed to open boot drive."); _____ Modified: trunk/reactos/boot/freeldr/freeldr/machine.c --- trunk/reactos/boot/freeldr/freeldr/machine.c 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/machine.c 2005-09-08 08:29:01 UTC (rev 17736) @@ -42,6 +42,7 @@ #undef MachDiskGetBootPath #undef MachDiskGetBootDevice #undef MachDiskBootingFromFloppy +#undef MachDiskNormalizeSystemPath #undef MachDiskReadLogicalSectors #undef MachDiskGetPartitionEntry #undef MachDiskGetDriveGeometry @@ -192,6 +193,12 @@ } BOOL +MachDiskNormalizeSystemPath(char *SystemPath, unsigned Size) +{ + return MachVtbl.DiskNormalizeSystemPath(SystemPath, Size); +} + +BOOL MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer) { return MachVtbl.DiskReadLogicalSectors(DriveNumber, SectorNumber, SectorCount, Buffer); _____ Modified: trunk/reactos/boot/freeldr/freeldr/miscboot.c --- trunk/reactos/boot/freeldr/freeldr/miscboot.c 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/miscboot.c 2005-09-08 08:29:01 UTC (rev 17736) @@ -54,6 +54,12 @@ return; } + if (!MachDiskNormalizeSystemPath(FileName, sizeof(FileName))) + { + UiMessageBox("Invalid path to boot sector file"); + return; + } + if (!FsOpenSystemVolume(FileName, FileName, NULL)) { UiMessageBox("Failed to open boot drive."); _____ Modified: trunk/reactos/boot/freeldr/freeldr/reactos/arcname.c --- trunk/reactos/boot/freeldr/freeldr/reactos/arcname.c 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/reactos/arcname.c 2005-09-08 08:29:01 UTC (rev 17736) @@ -73,7 +73,7 @@ p = p + 11; *BootPartition = atoi(p); p = strchr(p, ')'); - if ((p == NULL) || (*BootPartition == 0)) + if (p == NULL) return FALSE; p++; } _____ Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c --- trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c 2005-09-08 06:52:01 UTC (rev 17735) +++ trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c 2005-09-08 08:29:01 UTC (rev 17736) @@ -671,6 +671,12 @@ } else { + if (! MachDiskNormalizeSystemPath(SystemPath, + sizeof(SystemPath))) + { + UiMessageBox("Invalid system path"); + return; + } /* copy system path into kernel command line */ strcpy(reactos_kernel_cmdline, SystemPath); }
19 years, 3 months
1
0
0
0
[ion] 17735: - Move s(w)printf to rtl (cannot be shared in string because of differences with the CRT implementation). - Fix build errors due to previous commits (sorry).
by ion@svn.reactos.com
- Move s(w)printf to rtl (cannot be shared in string because of differences with the CRT implementation). - Fix build errors due to previous commits (sorry). Modified: trunk/reactos/include/ndk/rtlfuncs.h Modified: trunk/reactos/include/ndk/zwfuncs.h Modified: trunk/reactos/lib/crt/crt.xml Deleted: trunk/reactos/lib/crt/ctype/ Modified: trunk/reactos/lib/ntdll/ntdll.xml Deleted: trunk/reactos/lib/ntdll/stdio/ Modified: trunk/reactos/lib/rtl/rtl.xml Added: trunk/reactos/lib/rtl/sprintf.c Added: trunk/reactos/lib/rtl/swprintf.c Modified: trunk/reactos/lib/string/ctype.c Added: trunk/reactos/lib/string/scanf.h Added: trunk/reactos/lib/string/sscanf.c Modified: trunk/reactos/lib/string/string.xml Modified: trunk/reactos/ntoskrnl/ntoskrnl.xml Deleted: trunk/reactos/ntoskrnl/rtl/ctype.c Deleted: trunk/reactos/ntoskrnl/rtl/sprintf.c Deleted: trunk/reactos/ntoskrnl/rtl/stdlib.c Deleted: trunk/reactos/ntoskrnl/rtl/swprintf.c _____ Modified: trunk/reactos/include/ndk/rtlfuncs.h --- trunk/reactos/include/ndk/rtlfuncs.h 2005-09-08 05:03:34 UTC (rev 17734) +++ trunk/reactos/include/ndk/rtlfuncs.h 2005-09-08 06:52:01 UTC (rev 17735) @@ -2013,4 +2013,29 @@ NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation); + +static __inline struct _PEB* NtCurrentPeb (void) +{ + struct _PEB * pPeb; + +#if defined(__GNUC__) + + __asm__ __volatile__ + ( + "movl %%fs:0x30, %0\n" /* fs:30h == Teb->Peb */ + : "=r" (pPeb) /* can't have two memory operands */ + : /* no inputs */ + ); + +#elif defined(_MSC_VER) + + __asm mov eax, fs:0x30; + __asm mov pPeb, eax + +#else +#error Unknown compiler for inline assembler #endif + + return pPeb; +} +#endif _____ Modified: trunk/reactos/include/ndk/zwfuncs.h --- trunk/reactos/include/ndk/zwfuncs.h 2005-09-08 05:03:34 UTC (rev 17734) +++ trunk/reactos/include/ndk/zwfuncs.h 2005-09-08 06:52:01 UTC (rev 17735) @@ -4350,29 +4350,4 @@ VOID ); - -static __inline struct _PEB* NtCurrentPeb (void) -{ - struct _PEB * pPeb; - -#if defined(__GNUC__) - - __asm__ __volatile__ - ( - "movl %%fs:0x30, %0\n" /* fs:30h == Teb->Peb */ - : "=r" (pPeb) /* can't have two memory operands */ - : /* no inputs */ - ); - -#elif defined(_MSC_VER) - - __asm mov eax, fs:0x30; - __asm mov pPeb, eax - -#else -#error Unknown compiler for inline assembler #endif - - return pPeb; -} -#endif _____ Modified: trunk/reactos/lib/crt/crt.xml --- trunk/reactos/lib/crt/crt.xml 2005-09-08 05:03:34 UTC (rev 17734) +++ trunk/reactos/lib/crt/crt.xml 2005-09-08 06:52:01 UTC (rev 17735) @@ -22,17 +22,6 @@ <file>putch.c</file> <file>ungetch.c</file> </directory> - <directory name="ctype"> - <file>ctype.c</file> - <file>isalnum.c</file> - <file>isascii.c</file> - <file>iscntrl.c</file> - <file>isgraph.c</file> - <file>isprint.c</file> - <file>ispunct.c</file> - <file>isupper.c</file> - <file>isctype.c</file> - </directory> <directory name="direct"> <file>chdir.c</file> <file>chdrive.c</file> _____ Modified: trunk/reactos/lib/ntdll/ntdll.xml --- trunk/reactos/lib/ntdll/ntdll.xml 2005-09-08 05:03:34 UTC (rev 17734) +++ trunk/reactos/lib/ntdll/ntdll.xml 2005-09-08 06:52:01 UTC (rev 17735) @@ -37,11 +37,6 @@ <file>libsupp.c</file> <file>version.c</file> </directory> - <directory name="stdio"> - <file>sprintf.c</file> - <file>sscanf.c</file> - <file>swprintf.c</file> - </directory> <directory name="def"> <file>ntdll.rc</file> </directory> _____ Modified: trunk/reactos/lib/rtl/rtl.xml --- trunk/reactos/lib/rtl/rtl.xml 2005-09-08 05:03:34 UTC (rev 17734) +++ trunk/reactos/lib/rtl/rtl.xml 2005-09-08 06:52:01 UTC (rev 17735) @@ -51,6 +51,8 @@ <file>sd.c</file> <file>security.c</file> <file>sid.c</file> + <file>sprintf.c</file> + <file>swprintf.c</file> <file>splaytree.c</file> <file>thread.c</file> <file>time.c</file> _____ Added: trunk/reactos/lib/rtl/sprintf.c --- trunk/reactos/lib/rtl/sprintf.c 2005-09-08 05:03:34 UTC (rev 17734) +++ trunk/reactos/lib/rtl/sprintf.c 2005-09-08 06:52:01 UTC (rev 17735) @@ -0,0 +1,545 @@ +/* + * PROGRAMMERS: David Welch + * Eric Kohl + * + */ + +/* + * linux/lib/vsprintf.c + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ +/* + * Wirzenius wrote this portably, Torvalds fucked it up :-) + */ +#include <rtl.h> + +#define ZEROPAD 1 /* pad with zero */ +#define SIGN 2 /* unsigned/signed long */ +#define PLUS 4 /* show plus */ +#define SPACE 8 /* space if plus */ +#define LEFT 16 /* left justified */ +#define SPECIAL 32 /* 0x */ +#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ + + +static +__inline +int +do_div(long long *n, int base) +{ + int a; + a = ((unsigned long long) *n) % (unsigned) base; + *n = ((unsigned long long) *n) / (unsigned) base; + return a; +} + + +static int skip_atoi(const char **s) +{ + int i=0; + + while (isdigit(**s)) + i = i*10 + *((*s)++) - '0'; + return i; +} + + +static char * +number(char * buf, char * end, long long num, int base, int size, int precision, int type) +{ + char c,sign,tmp[66]; + const char *digits; + const char *small_digits = "0123456789abcdefghijklmnopqrstuvwxyz"; + const char *large_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + int i; + + digits = (type & LARGE) ? large_digits : small_digits; + if (type & LEFT) + type &= ~ZEROPAD; + if (base < 2 || base > 36) + return 0; + c = (type & ZEROPAD) ? '0' : ' '; + sign = 0; + if (type & SIGN) { + if (num < 0) { + sign = '-'; + num = -num; + size--; + } else if (type & PLUS) { + sign = '+'; + size--; + } else if (type & SPACE) { + sign = ' '; + size--; + } + } + if (type & SPECIAL) { + if (base == 16) + size -= 2; + else if (base == 8) + size--; + } + i = 0; + if (num == 0) + tmp[i++]='0'; + else while (num != 0) + tmp[i++] = digits[do_div(&num,base)]; + if (i > precision) + precision = i; + size -= precision; + if (!(type&(ZEROPAD+LEFT))) { + while(size-->0) { + if (buf <= end) + *buf = ' '; + ++buf; + } + } + if (sign) { + if (buf <= end) + *buf = sign; + ++buf; + } + if (type & SPECIAL) { + if (base==8) { + if (buf <= end) + *buf = '0'; + ++buf; + } else if (base==16) { + if (buf <= end) + *buf = '0'; + ++buf; + if (buf <= end) + *buf = digits[33]; + ++buf; + } + } + if (!(type & LEFT)) { + while (size-- > 0) { + if (buf <= end) + *buf = c; + ++buf; + } + } + while (i < precision--) { + if (buf <= end) + *buf = '0'; + ++buf; + } + while (i-- > 0) { + if (buf <= end) + *buf = tmp[i]; + ++buf; + } + while (size-- > 0) { + if (buf <= end) + *buf = ' '; + ++buf; + } + return buf; +} + +static char* +string(char* buf, char* end, const char* s, int len, int field_width, int precision, int flags) +{ + int i; + if (s == NULL) + { + s = "<NULL>"; + len = 6; + } + else + { + if (len == -1) + { + len = 0; + while ((unsigned int)len < (unsigned int)precision && s[len]) + len++; + } + else + { + if ((unsigned int)len > (unsigned int)precision) + len = precision; + } + } + if (!(flags & LEFT)) + while (len < field_width--) + { + if (buf <= end) + *buf = ' '; + ++buf; + } + for (i = 0; i < len; ++i) + { + if (buf <= end) + *buf = *s++; + ++buf; + } + while (len < field_width--) + { + if (buf <= end) + *buf = ' '; + ++buf; + } + return buf; +} + +static char* +stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int precision, int flags) +{ + int i; + if (sw == NULL) + { + sw = L"<NULL>"; + len = 6; + } + else + { + if (len == -1) + { + len = 0; + while ((unsigned int)len < (unsigned int)precision && sw[len]) + len++; + } + else + { + if ((unsigned int)len > (unsigned int)precision) + len = precision; + } + } + if (!(flags & LEFT)) + while (len < field_width--) + { + if (buf <= end) + *buf = ' '; + ++buf; + } + for (i = 0; i < len; ++i) + { + if (buf <= end) + *buf = (unsigned char)(*sw++); + ++buf; + } + while (len < field_width--) + { + if (buf <= end) + *buf = ' '; + ++buf; + } + return buf; +} + +/* + * @implemented + */ +int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args) +{ + int len; + unsigned long long num; + int base; + char *str, *end; + const char *s; + const wchar_t *sw; + + int flags; /* flags to number() */ + + int field_width; /* width of output field */ + int precision; /* min. # of digits for integers; max + number of chars for from string */ + int qualifier; /* 'h', 'l', 'L', 'I' or 'w' for integer fields */ + + str = buf; + end = buf + cnt - 1; + if (end < buf - 1) { + end = ((void *) -1); + cnt = end - buf + 1; + } + + for ( ; *fmt ; ++fmt) { + if (*fmt != '%') { + if (str <= end) + *str = *fmt; + ++str; + continue; + } + + /* process flags */ + flags = 0; + repeat: + ++fmt; /* this also skips first '%' */ + switch (*fmt) { + case '-': flags |= LEFT; goto repeat; + case '+': flags |= PLUS; goto repeat; + case ' ': flags |= SPACE; goto repeat; + case '#': flags |= SPECIAL; goto repeat; + case '0': flags |= ZEROPAD; goto repeat; + } + + /* get field width */ + field_width = -1; + if (isdigit(*fmt)) + field_width = skip_atoi(&fmt); + else if (*fmt == '*') { + ++fmt; + /* it's the next argument */ + field_width = va_arg(args, int); + if (field_width < 0) { + field_width = -field_width; + flags |= LEFT; + } + } + + /* get the precision */ + precision = -1; + if (*fmt == '.') { + ++fmt; + if (isdigit(*fmt)) + precision = skip_atoi(&fmt); + else if (*fmt == '*') { + ++fmt; + /* it's the next argument */ + precision = va_arg(args, int); + } + if (precision < 0) + precision = 0; + } + + /* get the conversion qualifier */ + qualifier = -1; + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') { + qualifier = *fmt; + ++fmt; + } else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') { + qualifier = *fmt; + fmt += 3; + } + + /* default base */ + base = 10; + + switch (*fmt) { + case 'c': /* finished */ + if (!(flags & LEFT)) + while (--field_width > 0) { + if (str <= end) + *str = ' '; + ++str; + } + if (qualifier == 'l' || qualifier == 'w') { + if (str <= end) + *str = (unsigned char)(wchar_t) va_arg(args, int); + ++str; + } else { + if (str <= end) + *str = (unsigned char) va_arg(args, int); + ++str; + } + while (--field_width > 0) { + if (str <= end) + *str = ' '; + ++str; + } + continue; + + case 'C': /* finished */ + if (!(flags & LEFT)) + while (--field_width > 0) { + if (str <= end) + *str = ' '; + ++str; + } + if (qualifier == 'h') { + if (str <= end) + *str = (unsigned char) va_arg(args, int); + ++str; + } else { + if (str <= end) + *str = (unsigned char)(wchar_t) va_arg(args, int); + ++str; + } + while (--field_width > 0) { + if (str <= end) + *str = ' '; + ++str; + } + continue; + + case 's': /* finished */ + if (qualifier == 'l' || qualifier == 'w') { + /* print unicode string */ + sw = va_arg(args, wchar_t *); + str = stringw(str, end, sw, -1, field_width, precision, flags); + } else { + /* print ascii string */ + s = va_arg(args, char *); + str = string(str, end, s, -1, field_width, precision, flags); + } + continue; + + case 'S': + if (qualifier == 'h') { + /* print ascii string */ + s = va_arg(args, char *); + str = string(str, end, s, -1, field_width, precision, flags); + } else { + /* print unicode string */ + sw = va_arg(args, wchar_t *); + str = stringw(str, end, sw, -1, field_width, precision, flags); + } + continue; + + case 'Z': + if (qualifier == 'w') { + /* print counted unicode string */ + PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING); + if ((pus == NULL) || (pus->Buffer == NULL)) { + sw = NULL; + len = -1; + } else { + sw = pus->Buffer; + len = pus->Length / sizeof(WCHAR); + } + str = stringw(str, end, sw, len, field_width, precision, flags); + } else { + /* print counted ascii string */ + PANSI_STRING pus = va_arg(args, PANSI_STRING); + if ((pus == NULL) || (pus->Buffer == NULL)) { + s = NULL; + len = -1; + } else { + s = pus->Buffer; + len = pus->Length; + } + str = string(str, end, s, len, field_width, precision, flags); + } + continue; + + case 'p': + if (field_width == -1) { + field_width = 2 * sizeof(void *); + flags |= ZEROPAD; + } + str = number(str, end, + (unsigned long) va_arg(args, void *), 16, + field_width, precision, flags); + continue; + + case 'n': + /* FIXME: What does C99 say about the overflow case here? */ + if (qualifier == 'l') { + long * ip = va_arg(args, long *); + *ip = (str - buf); + } else { + int * ip = va_arg(args, int *); + *ip = (str - buf); + } + continue; + + /* integer number formats - set up the flags and "break" */ + case 'o': + base = 8; + break; + + case 'b': + base = 2; + break; + + case 'X': + flags |= LARGE; + case 'x': + base = 16; + break; + + case 'd': + case 'i': + flags |= SIGN; + case 'u': + break; + + default: + if (*fmt != '%') { + if (str <= end) + *str = '%'; + ++str; + } + if (*fmt) { + if (str <= end) + *str = *fmt; + ++str; + } else + --fmt; + continue; + } + + if (qualifier == 'I') + num = va_arg(args, unsigned long long); + else if (qualifier == 'l') { + if (flags & SIGN) + num = va_arg(args, long); + else + num = va_arg(args, unsigned long); + } + else if (qualifier == 'h') { + if (flags & SIGN) + num = va_arg(args, int); + else + num = va_arg(args, unsigned int); + } + else { + if (flags & SIGN) + num = va_arg(args, int); + else + num = va_arg(args, unsigned int); + } + str = number(str, end, num, base, field_width, precision, flags); + } + if (str <= end) + *str = '\0'; + else if (cnt > 0) + /* don't write out a null byte if the buf size is zero */ + *end = '\0'; + return str-buf; +} + + +/* + * @implemented + */ +int sprintf(char * buf, const char *fmt, ...) +{ + va_list args; + int i; + + va_start(args, fmt); + i=_vsnprintf(buf,MAXLONG,fmt,args); + va_end(args); + return i; +} + + +/* + * @implemented + */ +int _snprintf(char * buf, size_t cnt, const char *fmt, ...) +{ + va_list args; + int i; + + va_start(args, fmt); + i=_vsnprintf(buf,cnt,fmt,args); + va_end(args); + return i; +} + + +/* + * @implemented + */ +int vsprintf(char *buf, const char *fmt, va_list args) +{ + return _vsnprintf(buf,MAXLONG,fmt,args); +} + +/* EOF */ _____ Added: trunk/reactos/lib/rtl/swprintf.c --- trunk/reactos/lib/rtl/swprintf.c 2005-09-08 05:03:34 UTC (rev 17734) +++ trunk/reactos/lib/rtl/swprintf.c 2005-09-08 06:52:01 UTC (rev 17735) @@ -0,0 +1,545 @@ +/* + * PROGRAMMERS: David Welch + * Eric Kohl + * + * TODO: + * - Verify the implementation of '%Z'. + */ + +/* + * linux/lib/vsprintf.c + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ +/* + * Wirzenius wrote this portably, Torvalds fucked it up :-) + */ + +#include <rtl.h> + +#define ZEROPAD 1 /* pad with zero */ +#define SIGN 2 /* unsigned/signed long */ +#define PLUS 4 /* show plus */ +#define SPACE 8 /* space if plus */ +#define LEFT 16 /* left justified */ +#define SPECIAL 32 /* 0x */ +#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ + + +static +__inline +int +do_div(long long *n, int base) +{ + int a; + a = ((unsigned long long) *n) % (unsigned) base; + *n = ((unsigned long long) *n) / (unsigned) base; + return a; +} + + +static int skip_atoi(const wchar_t **s) +{ + int i=0; + + while (iswdigit(**s)) + i = i*10 + *((*s)++) - L'0'; + return i; +} + + +static wchar_t * +number(wchar_t * buf, wchar_t * end, long long num, int base, int size, int precision, int type) +{ + wchar_t c, sign, tmp[66]; + const wchar_t *digits; + const wchar_t *small_digits = L"0123456789abcdefghijklmnopqrstuvwxyz"; + const wchar_t *large_digits = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + int i; + + digits = (type & LARGE) ? large_digits : small_digits; + if (type & LEFT) + type &= ~ZEROPAD; + if (base < 2 || base > 36) + return 0; + c = (type & ZEROPAD) ? L'0' : L' '; + sign = 0; + if (type & SIGN) { + if (num < 0) { + sign = L'-'; + num = -num; + size--; + } else if (type & PLUS) { + sign = L'+'; + size--; + } else if (type & SPACE) { + sign = ' '; + size--; + } + } + if (type & SPECIAL) { + if (base == 16) + size -= 2; + else if (base == 8) + size--; + } + i = 0; + if (num == 0) + tmp[i++] = L'0'; + else while (num != 0) + tmp[i++] = digits[do_div(&num,base)]; + if (i > precision) + precision = i; + size -= precision; + if (!(type&(ZEROPAD+LEFT))) { + while(size-->0) { + if (buf <= end) + *buf = L' '; + ++buf; + } + } + if (sign) { + if (buf <= end) + *buf = sign; + ++buf; + } + if (type & SPECIAL) { + if (base==8) { + if (buf <= end) + *buf = L'0'; + ++buf; + } else if (base==16) { + if (buf <= end) + *buf = L'0'; + ++buf; + if (buf <= end) + *buf = digits[33]; + ++buf; + } + } + if (!(type & LEFT)) { + while (size-- > 0) { + if (buf <= end) + *buf = c; + ++buf; + } + } + while (i < precision--) { + if (buf <= end) + *buf = L'0'; + ++buf; + } + while (i-- > 0) { + if (buf <= end) + *buf = tmp[i]; + ++buf; + } + while (size-- > 0) { + if (buf <= end) + *buf = L' '; + ++buf; + } + return buf; +} + +static wchar_t* +string(wchar_t* buf, wchar_t* end, const char* s, int len, int field_width, int precision, int flags) +{ + int i; + if (s == NULL) + { + s = "<NULL>"; + len = 6; + } + else + { + if (len == -1) + { + len = 0; + while ((unsigned int)len < (unsigned int)precision && s[len]) + len++; + } + else + { + if ((unsigned int)len > (unsigned int)precision) + len = precision; + } + } + if (!(flags & LEFT)) + while (len < field_width--) + { + if (buf <= end) + *buf = L' '; + ++buf; + } + for (i = 0; i < len; ++i) + { + if (buf <= end) + *buf = *s++; + ++buf; + } + while (len < field_width--) + { + if (buf <= end) + *buf = L' '; + ++buf; + } + return buf; +} + +static wchar_t* +stringw(wchar_t* buf, wchar_t* end, const wchar_t* sw, int len, int field_width, int precision, int flags) +{ + int i; + if (sw == NULL) + { + sw = L"<NULL>"; + len = 6; + } + else + { + if (len == -1) + { + len = 0; + while ((unsigned int)len < (unsigned int)precision && sw[len]) + len++; + } + else + { + if ((unsigned int)len > (unsigned int)precision) + len = precision; + } + } + if (!(flags & LEFT)) + while (len < field_width--) + { + if (buf <= end) + *buf = L' '; + buf++; + } + for (i = 0; i < len; ++i) + { + if (buf <= end) + *buf = *sw++; + buf++; + } + while (len < field_width--) + { + if (buf <= end) + *buf = L' '; + buf++; + } + return buf; +} + +/* + * @implemented + */ +int _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args) +{ + int len; + unsigned long long num; + int base; + wchar_t * str, * end; + const char *s; + const wchar_t *sw; + + int flags; /* flags to number() */ + + int field_width; /* width of output field */ + int precision; /* min. # of digits for integers; max + number of chars for from string */ + int qualifier; /* 'h', 'l', 'L', 'w' or 'I' for integer fields */ + + str = buf; + end = buf + cnt - 1; + if (end < buf - 1) { + end = ((void *) -1); + cnt = end - buf + 1; + } + + for ( ; *fmt ; ++fmt) { + if (*fmt != L'%') { + if (str <= end) + *str = *fmt; + ++str; + continue; + } + + /* process flags */ + flags = 0; + repeat: + ++fmt; /* this also skips first '%' */ + switch (*fmt) { + case L'-': flags |= LEFT; goto repeat; + case L'+': flags |= PLUS; goto repeat; + case L' ': flags |= SPACE; goto repeat; + case L'#': flags |= SPECIAL; goto repeat; + case L'0': flags |= ZEROPAD; goto repeat; + } + + /* get field width */ + field_width = -1; + if (iswdigit(*fmt)) + field_width = skip_atoi(&fmt); + else if (*fmt == L'*') { + ++fmt; + /* it's the next argument */ + field_width = va_arg(args, int); + if (field_width < 0) { + field_width = -field_width; + flags |= LEFT; + } + } + + /* get the precision */ + precision = -1; + if (*fmt == L'.') { + ++fmt; + if (iswdigit(*fmt)) + precision = skip_atoi(&fmt); + else if (*fmt == L'*') { + ++fmt; + /* it's the next argument */ + precision = va_arg(args, int); + } + if (precision < 0) + precision = 0; + } + + /* get the conversion qualifier */ + qualifier = -1; + if (*fmt == L'h' || *fmt == L'l' || *fmt == L'L' || *fmt == L'w') { + qualifier = *fmt; + ++fmt; + } else if (*fmt == L'I' && *(fmt+1) == L'6' && *(fmt+2) == L'4') { + qualifier = *fmt; + fmt += 3; + } + + /* default base */ + base = 10; + + switch (*fmt) { + case L'c': [truncated at 1000 lines; 2962 more skipped]
19 years, 3 months
1
0
0
0
[ion] 17734: Share more duplicated functions
by ion@svn.reactos.com
Share more duplicated functions Modified: trunk/reactos/include/ndk/rtlfuncs.h Modified: trunk/reactos/lib/ntdll/ntdll.xml Deleted: trunk/reactos/lib/ntdll/stdlib/ Added: trunk/reactos/lib/string/abs.c Added: trunk/reactos/lib/string/atoi.c Added: trunk/reactos/lib/string/atoi64.c Added: trunk/reactos/lib/string/atol.c Added: trunk/reactos/lib/string/bsearch.c Added: trunk/reactos/lib/string/itoa.c Added: trunk/reactos/lib/string/itow.c Added: trunk/reactos/lib/string/labs.c Added: trunk/reactos/lib/string/lfind.c Added: trunk/reactos/lib/string/mbstowcs.c Added: trunk/reactos/lib/string/rand.c Added: trunk/reactos/lib/string/splitp.c Modified: trunk/reactos/lib/string/string.xml Added: trunk/reactos/lib/string/strtol.c Added: trunk/reactos/lib/string/strtoul.c Added: trunk/reactos/lib/string/wcstol.c Added: trunk/reactos/lib/string/wcstombs.c Added: trunk/reactos/lib/string/wcstoul.c Added: trunk/reactos/lib/string/wtoi.c Added: trunk/reactos/lib/string/wtoi64.c Added: trunk/reactos/lib/string/wtol.c Modified: trunk/reactos/ntoskrnl/ntoskrnl.xml _____ Modified: trunk/reactos/include/ndk/rtlfuncs.h --- trunk/reactos/include/ndk/rtlfuncs.h 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/include/ndk/rtlfuncs.h 2005-09-08 05:03:34 UTC (rev 17734) @@ -11,6 +11,8 @@ /* DEPENDENCIES **************************************************************/ #include <ntnls.h> +#include "extypes.h" +#include "rtltypes.h" /* PROTOTYPES ****************************************************************/ _____ Modified: trunk/reactos/lib/ntdll/ntdll.xml --- trunk/reactos/lib/ntdll/ntdll.xml 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/ntdll/ntdll.xml 2005-09-08 05:03:34 UTC (rev 17734) @@ -42,27 +42,6 @@ <file>sscanf.c</file> <file>swprintf.c</file> </directory> - <directory name="stdlib"> - <file>abs.c</file> - <file>atoi64.c</file> - <file>atoi.c</file> - <file>atol.c</file> - <file>bsearch.c</file> - <file>itoa.c</file> - <file>itow.c</file> - <file>labs.c</file> - <file>lfind.c</file> - <file>mbstowcs.c</file> - <file>splitp.c</file> - <file>strtol.c</file> - <file>strtoul.c</file> - <file>wcstol.c</file> - <file>wcstombs.c</file> - <file>wcstoul.c</file> - <file>wtoi64.c</file> - <file>wtoi.c</file> - <file>wtol.c</file> - </directory> <directory name="def"> <file>ntdll.rc</file> </directory> _____ Added: trunk/reactos/lib/string/abs.c --- trunk/reactos/lib/string/abs.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/abs.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,10 @@ +#include <string.h> + +/* + * @implemented + */ +int +abs(int j) +{ + return j<0 ? -j : j; +} _____ Added: trunk/reactos/lib/string/atoi.c --- trunk/reactos/lib/string/atoi.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/atoi.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,11 @@ +#include <string.h> +#include <stdlib.h> + +/* + * @implemented + */ +int +atoi(const char *str) +{ + return (int)strtol(str, 0, 10); +} _____ Added: trunk/reactos/lib/string/atoi64.c --- trunk/reactos/lib/string/atoi64.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/atoi64.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,36 @@ +#include <string.h> +#include <ctype.h> + +/* + * @implemented + */ +__int64 +_atoi64 (const char *nptr) +{ + int c; + __int64 value; + int sign; + + while (isspace((int)*nptr)) + ++nptr; + + c = (int)*nptr++; + sign = c; + if (c == '-' || c == '+') + c = (int)*nptr++; + + value = 0; + + while (isdigit(c)) + { + value = 10 * value + (c - '0'); + c = (int)*nptr++; + } + + if (sign == '-') + return -value; + else + return value; +} + +/* EOF */ _____ Added: trunk/reactos/lib/string/atol.c --- trunk/reactos/lib/string/atol.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/atol.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,11 @@ +#include <string.h> +#include <stdlib.h> + +/* + * @implemented + */ +long +atol(const char *str) +{ + return strtol(str, 0, 10); +} _____ Added: trunk/reactos/lib/string/bsearch.c --- trunk/reactos/lib/string/bsearch.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/bsearch.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,27 @@ +#include <string.h> + +/* + * @implemented + */ +void * +bsearch(const void *key, const void *base0, size_t nelem, + size_t size, int (*cmp)(const void *ck, const void *ce)) +{ + char *base = (char *)base0; + int lim, cmpval; + void *p; + + for (lim = nelem; lim != 0; lim >>= 1) + { + p = base + (lim >> 1) * size; + cmpval = (*cmp)(key, p); + if (cmpval == 0) + return p; + if (cmpval > 0) + { /* key > p: move right */ + base = (char *)p + size; + lim--; + } /* else move left */ + } + return 0; +} _____ Added: trunk/reactos/lib/string/itoa.c --- trunk/reactos/lib/string/itoa.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/itoa.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,167 @@ +#include <string.h> +#include <stdlib.h> + +/* + * @implemented + */ +char * +_i64toa(__int64 value, char *string, int radix) +{ + char tmp[65]; + char *tp = tmp; + __int64 i; + unsigned __int64 v; + __int64 sign; + char *sp; + + if (radix > 36 || radix <= 1) + { + return 0; + } + + sign = (radix == 10 && value < 0); + if (sign) + v = -value; + else + v = (unsigned __int64)value; + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+'0'; + else + *tp++ = i + 'a' - 10; + } + + sp = string; + if (sign) + *sp++ = '-'; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + return string; +} + + +/* + * @implemented + */ +char * +_ui64toa(unsigned __int64 value, char *string, int radix) +{ + char tmp[65]; + char *tp = tmp; + __int64 i; + unsigned __int64 v; + char *sp; + + if (radix > 36 || radix <= 1) + { + return 0; + } + + v = (unsigned __int64)value; + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+'0'; + else + *tp++ = i + 'a' - 10; + } + + sp = string; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + return string; +} + + +/* + * @implemented + */ +char * +_itoa(int value, char *string, int radix) +{ + return _ltoa(value, string, radix); +} + + +/* + * @implemented + */ +char * +_ltoa(long value, char *string, int radix) +{ + unsigned long val; + int negative; + char buffer[33]; + char *pos; + int digit; + + if (value < 0 && radix == 10) { + negative = 1; + val = -value; + } else { + negative = 0; + val = value; + } /* if */ + + pos = &buffer[32]; + *pos = '\0'; + + do { + digit = val % radix; + val = val / radix; + if (digit < 10) { + *--pos = '0' + digit; + } else { + *--pos = 'a' + digit - 10; + } /* if */ + } while (val != 0L); + + if (negative) { + *--pos = '-'; + } /* if */ + + memcpy(string, pos, &buffer[32] - pos + 1); + return string; +} + + +/* + * @implemented + */ +char * +_ultoa(unsigned long value, char *string, int radix) +{ + char tmp[33]; + char *tp = tmp; + long i; + unsigned long v = value; + char *sp; + + if (radix > 36 || radix <= 1) + { + return 0; + } + + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+'0'; + else + *tp++ = i + 'a' - 10; + } + + sp = string; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + return string; +} _____ Added: trunk/reactos/lib/string/itow.c --- trunk/reactos/lib/string/itow.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/itow.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,200 @@ +#include <string.h> + +/* + * @implemented + */ +wchar_t * +_i64tow(__int64 value, wchar_t *string, int radix) +{ + wchar_t tmp[65]; + wchar_t *tp = tmp; + __int64 i; + unsigned __int64 v; + __int64 sign; + wchar_t *sp; + + if (radix > 36 || radix <= 1) + { + return 0; + } + + sign = (radix == 10 && value < 0); + if (sign) + v = -value; + else + v = (unsigned __int64)value; + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+L'0'; + else + *tp++ = i + L'a' - 10; + } + + sp = string; + if (sign) + *sp++ = L'-'; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + return string; +} + + +/* + * @implemented + */ +wchar_t * +_ui64tow(unsigned __int64 value, wchar_t *string, int radix) +{ + wchar_t tmp[65]; + wchar_t *tp = tmp; + __int64 i; + unsigned __int64 v; + wchar_t *sp; + + if (radix > 36 || radix <= 1) + { + return 0; + } + + v = (unsigned __int64)value; + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+L'0'; + else + *tp++ = i + L'a' - 10; + } + + sp = string; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + return string; +} + + +/* + * @implemented + */ +wchar_t * +_itow(int value, wchar_t *string, int radix) +{ + wchar_t tmp[33]; + wchar_t *tp = tmp; + int i; + unsigned v; + int sign; + wchar_t *sp; + + if (radix > 36 || radix <= 1) + { + return 0; + } + + sign = (radix == 10 && value < 0); + if (sign) + v = -value; + else + v = (unsigned)value; + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+L'0'; + else + *tp++ = i + L'a' - 10; + } + + sp = string; + if (sign) + *sp++ = L'-'; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + return string; +} + + +/* + * @implemented + */ +wchar_t * +_ltow(long value, wchar_t *string, int radix) +{ + wchar_t tmp[33]; + wchar_t *tp = tmp; + long i; + unsigned long v; + int sign; + wchar_t *sp; + + if (radix > 36 || radix <= 1) + { + return 0; + } + + sign = (radix == 10 && value < 0); + if (sign) + v = -value; + else + v = (unsigned long)value; + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+L'0'; + else + *tp++ = i + L'a' - 10; + } + + sp = string; + if (sign) + *sp++ = L'-'; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + return string; +} + + +/* + * @implemented + */ +wchar_t * +_ultow(unsigned long value, wchar_t *string, int radix) +{ + wchar_t tmp[33]; + wchar_t *tp = tmp; + long i; + unsigned long v = value; + wchar_t *sp; + + if (radix > 36 || radix <= 1) + { + return 0; + } + + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+L'0'; + else + *tp++ = i + L'a' - 10; + } + + sp = string; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + return string; +} _____ Added: trunk/reactos/lib/string/labs.c --- trunk/reactos/lib/string/labs.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/labs.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,9 @@ +#include <string.h> +/* + * @implemented + */ +long +labs(long j) +{ + return j<0 ? -j : j; +} _____ Added: trunk/reactos/lib/string/lfind.c --- trunk/reactos/lib/string/lfind.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/lfind.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,20 @@ +#include <string.h> +/* + * @implemented + */ +void *_lfind(const void *key, const void *base, size_t *nelp, + size_t width, int (*compar)(const void *, const void *)) +{ + char* char_base = (char*)base; + size_t i; + + for (i = 0; i < *nelp; i++) + { + if (compar(key, char_base) == 0) + return char_base; + + char_base += width; + } + + return NULL; +} _____ Added: trunk/reactos/lib/string/mbstowcs.c --- trunk/reactos/lib/string/mbstowcs.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/mbstowcs.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,61 @@ +#include <windows.h> +#define NTOS_MODE_USER +#define _NTSYSTEM_ +#include <ndk/umtypes.h> +#include <ndk/rtlfuncs.h> +#include <string.h> + +/* + * @implemented + */ +int mbtowc (wchar_t *wchar, const char *mbchar, size_t count) +{ + NTSTATUS Status; + ULONG Size; + + if (wchar == NULL) + return 0; + + Status = RtlMultiByteToUnicodeN (wchar, + sizeof(WCHAR), + &Size, + (char *)mbchar, + count); + if (!NT_SUCCESS(Status)) + return -1; + + return (int)Size; +} + +/* + * @implemented + */ +size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count) +{ + NTSTATUS Status; + ULONG Size; + ULONG Length; + + Length = strlen (mbstr); + + if (wcstr == NULL) + { + RtlMultiByteToUnicodeSize (&Size, + (char *)mbstr, + Length); + + return (size_t)Size; + } + + Status = RtlMultiByteToUnicodeN (wcstr, + count, + &Size, + (char *)mbstr, + Length); + if (!NT_SUCCESS(Status)) + return -1; + + return (size_t)Size; +} + +/* EOF */ _____ Added: trunk/reactos/lib/string/rand.c --- trunk/reactos/lib/string/rand.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/rand.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,29 @@ +#include <stdlib.h> + +#if defined(__GNUC__) +static unsigned long long next = 0; +#else +static unsigned __int64 next = 0; +#endif + +/* + * @implemented + */ +int rand(void) +{ +#if defined(__GNUC__) + next = next * 0x5deece66dLL + 11; +#else + next = next * 0x5deece66di64 + 11; +#endif + return (int)((next >> 16) & RAND_MAX); +} + + +/* + * @implemented + */ +void srand(unsigned seed) +{ + next = seed; +} _____ Added: trunk/reactos/lib/string/splitp.c --- trunk/reactos/lib/string/splitp.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/splitp.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,50 @@ +#include <string.h> +/* + * @implemented + */ +void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext) +{ + char* tmp_drive; + char* tmp_dir; + char* tmp_ext; + + tmp_drive = (char*)strchr(path,':'); + if (drive) { + if (tmp_drive) { + strncpy(drive,tmp_drive-1,2); + *(drive+2) = 0; + } else { + *drive = 0; + } + } + if (!tmp_drive) { + tmp_drive = (char*)path - 1; + } + + tmp_dir = (char*)strrchr(path,'\\'); + if (dir) { + if (tmp_dir) { + strncpy(dir,tmp_drive+1,tmp_dir-tmp_drive); + *(dir+(tmp_dir-tmp_drive)) = 0; + } else { + *dir =0; + } + } + + tmp_ext = (char*)strrchr(path,'.'); + if (!tmp_ext) { + tmp_ext = (char*)path+strlen(path); + } + if (ext) { + strcpy(ext,tmp_ext); + } + + if (tmp_dir) { + strncpy(fname,tmp_dir+1,tmp_ext-tmp_dir-1); + *(fname+(tmp_ext-tmp_dir-1)) = 0; + } else { + strncpy(fname,tmp_drive+1,tmp_ext-tmp_drive-1); + *(fname+(tmp_ext-path))=0; + } +} + _____ Modified: trunk/reactos/lib/string/string.xml --- trunk/reactos/lib/string/string.xml 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/string.xml 2005-09-08 05:03:34 UTC (rev 17734) @@ -76,4 +76,24 @@ <file>wstring.c</file> <file>wcsrev.c</file> <file>wcsnset.c</file> + <file>abs.c</file> + <file>atoi64.c</file> + <file>atoi.c</file> + <file>atol.c</file> + <file>bsearch.c</file> + <file>itoa.c</file> + <file>itow.c</file> + <file>labs.c</file> + <file>lfind.c</file> + <file>mbstowcs.c</file> + <file>splitp.c</file> + <file>strtol.c</file> + <file>strtoul.c</file> + <file>wcstol.c</file> + <file>wcstombs.c</file> + <file>wcstoul.c</file> + <file>wtoi64.c</file> + <file>wtoi.c</file> + <file>wtol.c</file> + <file>rand.c</file> </module> _____ Added: trunk/reactos/lib/string/strtol.c --- trunk/reactos/lib/string/strtol.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/strtol.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,90 @@ +#include <string.h> +#include <limits.h> +#include <ctype.h> + +/* + * @implemented + */ +long +strtol(const char *nptr, char **endptr, int base) +{ + const char *s = nptr; + unsigned long acc; + int c; + unsigned long cutoff; + int neg = 0, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') + { + neg = 1; + c = *s++; + } + else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) + { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; + cutlim = cutoff % (unsigned long)base; + cutoff /= (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) + { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else + { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) + { + acc = neg ? LONG_MIN : LONG_MAX; + } + else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = any ? (char *)s - 1 : (char *)nptr; + return acc; +} _____ Added: trunk/reactos/lib/string/strtoul.c --- trunk/reactos/lib/string/strtoul.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/strtoul.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,73 @@ +#include <string.h> +#include <limits.h> +#include <ctype.h> + +/* + * Convert a string to an unsigned long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + * + * @implemented + */ +unsigned long +strtoul(const char *nptr, char **endptr, int base) +{ + const char *s = nptr; + unsigned long acc; + int c; + unsigned long cutoff; + int neg = 0, any, cutlim; + + /* + * See strtol for comments as to the logic used. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') + { + neg = 1; + c = *s++; + } + else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) + { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; + cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) + { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) + { + acc = ULONG_MAX; + } + else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = any ? (char *)s - 1 : (char *)nptr; + return acc; +} _____ Added: trunk/reactos/lib/string/wcstol.c --- trunk/reactos/lib/string/wcstol.c 2005-09-08 04:27:02 UTC (rev 17733) +++ trunk/reactos/lib/string/wcstol.c 2005-09-08 05:03:34 UTC (rev 17734) @@ -0,0 +1,90 @@ +#include <string.h> +#include <ctype.h> +#include <limits.h> + +/* + * @implemented + */ +long +wcstol(const wchar_t *nptr, wchar_t **endptr, int base) +{ + const wchar_t *s = nptr; + unsigned long acc; + int c; + unsigned long cutoff; + int neg = 0, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + do { + c = *s++; + } while (iswctype(c, _SPACE)); + if (c == '-') + { + neg = 1; + c = *s++; + } + else if (c == L'+') + c = *s++; + if ((base == 0 || base == 16) && + c == L'0' && (*s == L'x' || *s == L'X')) + { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == L'0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. [truncated at 1000 lines; 263 more skipped]
19 years, 3 months
1
0
0
0
[ion] 17733: Don't duplicate string and ctype functions 2 (or even 3) times... we have stringlib for that
by ion@svn.reactos.com
Don't duplicate string and ctype functions 2 (or even 3) times... we have stringlib for that Modified: trunk/reactos/lib/kjs/ksrc/compat.c Modified: trunk/reactos/lib/ntdll/ntdll.xml Deleted: trunk/reactos/lib/ntdll/string/ Added: trunk/reactos/lib/string/ctype.c Added: trunk/reactos/lib/string/memicmp.c Added: trunk/reactos/lib/string/stricmp.c Modified: trunk/reactos/lib/string/string.xml Added: trunk/reactos/lib/string/strlwr.c Added: trunk/reactos/lib/string/strnicmp.c Added: trunk/reactos/lib/string/strrev.c Added: trunk/reactos/lib/string/strset.c Added: trunk/reactos/lib/string/strstr.c Added: trunk/reactos/lib/string/strupr.c Added: trunk/reactos/lib/string/wcsnset.c Added: trunk/reactos/lib/string/wcsrev.c Added: trunk/reactos/lib/string/wstring.c Modified: trunk/reactos/ntoskrnl/ntoskrnl.xml Deleted: trunk/reactos/ntoskrnl/rtl/string.c Deleted: trunk/reactos/ntoskrnl/rtl/wstring.c _____ Modified: trunk/reactos/lib/kjs/ksrc/compat.c --- trunk/reactos/lib/kjs/ksrc/compat.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/kjs/ksrc/compat.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -12,10 +12,6 @@ __kernel_abort(); } -int isalnum( int x ) { return isalpha(x) || isdigit(x); } -int iscntrl( int x ) { return 32 > x; } -int ispunct( int x ) { return !isspace(x) && !isalnum(x) && !iscntrl(x) && !isspace(x); } - static int belongs_to_base( int x, int base ) { if( x >= '0' && '9' >= x ) { if( base > x - '0' ) return x - '0'; _____ Modified: trunk/reactos/lib/ntdll/ntdll.xml --- trunk/reactos/lib/ntdll/ntdll.xml 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/ntdll/ntdll.xml 2005-09-08 04:27:02 UTC (rev 17733) @@ -12,6 +12,7 @@ <library>intrlck</library> <library>string</library> <linkerflag>-lgcc</linkerflag> + <linkerflag>-nostdlib</linkerflag> <linkerflag>-nostartfiles</linkerflag> <directory name="csr"> <file>api.c</file> @@ -62,16 +63,6 @@ <file>wtoi.c</file> <file>wtol.c</file> </directory> - <directory name="string"> - <file>ctype.c</file> - <file>memicmp.c</file> - <file>stricmp.c</file> - <file>strlwr.c</file> - <file>strnicmp.c</file> - <file>strstr.c</file> - <file>strupr.c</file> - <file>wstring.c</file> - </directory> <directory name="def"> <file>ntdll.rc</file> </directory> _____ Copied: trunk/reactos/lib/string/ctype.c (from rev 17732, trunk/reactos/lib/ntdll/string/ctype.c) --- trunk/reactos/lib/ntdll/string/ctype.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/ctype.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,507 @@ +#include <string.h> +#include <ctype.h> + +#undef _pctype + +#define upalpha ('A' - 'a') + + +unsigned short _ctype[] = { + 0, /* <EOF>, 0xFFFF */ + _CONTROL, /* CTRL+@, 0x00 */ + _CONTROL, /* CTRL+A, 0x01 */ + _CONTROL, /* CTRL+B, 0x02 */ + _CONTROL, /* CTRL+C, 0x03 */ + _CONTROL, /* CTRL+D, 0x04 */ + _CONTROL, /* CTRL+E, 0x05 */ + _CONTROL, /* CTRL+F, 0x06 */ + _CONTROL, /* CTRL+G, 0x07 */ + _CONTROL, /* CTRL+H, 0x08 */ + _CONTROL | _SPACE, /* CTRL+I, 0x09 */ + _CONTROL | _SPACE, /* CTRL+J, 0x0a */ + _CONTROL | _SPACE, /* CTRL+K, 0x0b */ + _CONTROL | _SPACE, /* CTRL+L, 0x0c */ + _CONTROL | _SPACE, /* CTRL+M, 0x0d */ + _CONTROL, /* CTRL+N, 0x0e */ + _CONTROL, /* CTRL+O, 0x0f */ + _CONTROL, /* CTRL+P, 0x10 */ + _CONTROL, /* CTRL+Q, 0x11 */ + _CONTROL, /* CTRL+R, 0x12 */ + _CONTROL, /* CTRL+S, 0x13 */ + _CONTROL, /* CTRL+T, 0x14 */ + _CONTROL, /* CTRL+U, 0x15 */ + _CONTROL, /* CTRL+V, 0x16 */ + _CONTROL, /* CTRL+W, 0x17 */ + _CONTROL, /* CTRL+X, 0x18 */ + _CONTROL, /* CTRL+Y, 0x19 */ + _CONTROL, /* CTRL+Z, 0x1a */ + _CONTROL, /* CTRL+[, 0x1b */ + _CONTROL, /* CTRL+\, 0x1c */ + _CONTROL, /* CTRL+], 0x1d */ + _CONTROL, /* CTRL+^, 0x1e */ + _CONTROL, /* CTRL+_, 0x1f */ + _SPACE | _BLANK, /* ` ', 0x20 */ + _PUNCT, /* `!', 0x21 */ + _PUNCT, /* 0x22 */ + _PUNCT, /* `#', 0x23 */ + _PUNCT, /* `$', 0x24 */ + _PUNCT, /* `%', 0x25 */ + _PUNCT, /* `&', 0x26 */ + _PUNCT, /* 0x27 */ + _PUNCT, /* `(', 0x28 */ + _PUNCT, /* `)', 0x29 */ + _PUNCT, /* `*', 0x2a */ + _PUNCT, /* `+', 0x2b */ + _PUNCT, /* `,', 0x2c */ + _PUNCT, /* `-', 0x2d */ + _PUNCT, /* `.', 0x2e */ + _PUNCT, /* `/', 0x2f */ + _DIGIT | _HEX, /* `0', 0x30 */ + _DIGIT | _HEX, /* `1', 0x31 */ + _DIGIT | _HEX, /* `2', 0x32 */ + _DIGIT | _HEX, /* `3', 0x33 */ + _DIGIT | _HEX, /* `4', 0x34 */ + _DIGIT | _HEX, /* `5', 0x35 */ + _DIGIT | _HEX, /* `6', 0x36 */ + _DIGIT | _HEX, /* `7', 0x37 */ + _DIGIT | _HEX, /* `8', 0x38 */ + _DIGIT | _HEX, /* `9', 0x39 */ + _PUNCT, /* `:', 0x3a */ + _PUNCT, /* `;', 0x3b */ + _PUNCT, /* `<', 0x3c */ + _PUNCT, /* `=', 0x3d */ + _PUNCT, /* `>', 0x3e */ + _PUNCT, /* `?', 0x3f */ + _PUNCT, /* `@', 0x40 */ + _UPPER | _HEX, /* `A', 0x41 */ + _UPPER | _HEX, /* `B', 0x42 */ + _UPPER | _HEX, /* `C', 0x43 */ + _UPPER | _HEX, /* `D', 0x44 */ + _UPPER | _HEX, /* `E', 0x45 */ + _UPPER | _HEX, /* `F', 0x46 */ + _UPPER, /* `G', 0x47 */ + _UPPER, /* `H', 0x48 */ + _UPPER, /* `I', 0x49 */ + _UPPER, /* `J', 0x4a */ + _UPPER, /* `K', 0x4b */ + _UPPER, /* `L', 0x4c */ + _UPPER, /* `M', 0x4d */ + _UPPER, /* `N', 0x4e */ + _UPPER, /* `O', 0x4f */ + _UPPER, /* `P', 0x50 */ + _UPPER, /* `Q', 0x51 */ + _UPPER, /* `R', 0x52 */ + _UPPER, /* `S', 0x53 */ + _UPPER, /* `T', 0x54 */ + _UPPER, /* `U', 0x55 */ + _UPPER, /* `V', 0x56 */ + _UPPER, /* `W', 0x57 */ + _UPPER, /* `X', 0x58 */ + _UPPER, /* `Y', 0x59 */ + _UPPER, /* `Z', 0x5a */ + _PUNCT, /* `[', 0x5b */ + _PUNCT, /* 0x5c */ + _PUNCT, /* `]', 0x5d */ + _PUNCT, /* `^', 0x5e */ + _PUNCT, /* `_', 0x5f */ + _PUNCT, /* 0x60 */ + _LOWER | _HEX, /* `a', 0x61 */ + _LOWER | _HEX, /* `b', 0x62 */ + _LOWER | _HEX, /* `c', 0x63 */ + _LOWER | _HEX, /* `d', 0x64 */ + _LOWER | _HEX, /* `e', 0x65 */ + _LOWER | _HEX, /* `f', 0x66 */ + _LOWER, /* `g', 0x67 */ + _LOWER, /* `h', 0x68 */ + _LOWER, /* `i', 0x69 */ + _LOWER, /* `j', 0x6a */ + _LOWER, /* `k', 0x6b */ + _LOWER, /* `l', 0x6c */ + _LOWER, /* `m', 0x6d */ + _LOWER, /* `n', 0x6e */ + _LOWER, /* `o', 0x6f */ + _LOWER, /* `p', 0x70 */ + _LOWER, /* `q', 0x71 */ + _LOWER, /* `r', 0x72 */ + _LOWER, /* `s', 0x73 */ + _LOWER, /* `t', 0x74 */ + _LOWER, /* `u', 0x75 */ + _LOWER, /* `v', 0x76 */ + _LOWER, /* `w', 0x77 */ + _LOWER, /* `x', 0x78 */ + _LOWER, /* `y', 0x79 */ + _LOWER, /* `z', 0x7a */ + _PUNCT, /* `{', 0x7b */ + _PUNCT, /* `|', 0x7c */ + _PUNCT, /* `}', 0x7d */ + _PUNCT, /* `~', 0x7e */ + _CONTROL, /* 0x7f */ + 0, /* 0x80 */ + 0, /* 0x81 */ + 0, /* 0x82 */ + 0, /* 0x83 */ + 0, /* 0x84 */ + 0, /* 0x85 */ + 0, /* 0x86 */ + 0, /* 0x87 */ + 0, /* 0x88 */ + 0, /* 0x89 */ + 0, /* 0x8a */ + 0, /* 0x8b */ + 0, /* 0x8c */ + 0, /* 0x8d */ + 0, /* 0x8e */ + 0, /* 0x8f */ + 0, /* 0x90 */ + 0, /* 0x91 */ + 0, /* 0x92 */ + 0, /* 0x93 */ + 0, /* 0x94 */ + 0, /* 0x95 */ + 0, /* 0x96 */ + 0, /* 0x97 */ + 0, /* 0x98 */ + 0, /* 0x99 */ + 0, /* 0x9a */ + 0, /* 0x9b */ + 0, /* 0x9c */ + 0, /* 0x9d */ + 0, /* 0x9e */ + 0, /* 0x9f */ + 0, /* 0xa0 */ + 0, /* 0xa1 */ + 0, /* 0xa2 */ + 0, /* 0xa3 */ + 0, /* 0xa4 */ + 0, /* 0xa5 */ + 0, /* 0xa6 */ + 0, /* 0xa7 */ + 0, /* 0xa8 */ + 0, /* 0xa9 */ + 0, /* 0xaa */ + 0, /* 0xab */ + 0, /* 0xac */ + 0, /* 0xad */ + 0, /* 0xae */ + 0, /* 0xaf */ + 0, /* 0xb0 */ + 0, /* 0xb1 */ + 0, /* 0xb2 */ + 0, /* 0xb3 */ + 0, /* 0xb4 */ + 0, /* 0xb5 */ + 0, /* 0xb6 */ + 0, /* 0xb7 */ + 0, /* 0xb8 */ + 0, /* 0xb9 */ + 0, /* 0xba */ + 0, /* 0xbb */ + 0, /* 0xbc */ + 0, /* 0xbd */ + 0, /* 0xbe */ + 0, /* 0xbf */ + 0, /* 0xc0 */ + 0, /* 0xc1 */ + 0, /* 0xc2 */ + 0, /* 0xc3 */ + 0, /* 0xc4 */ + 0, /* 0xc5 */ + 0, /* 0xc6 */ + 0, /* 0xc7 */ + 0, /* 0xc8 */ + 0, /* 0xc9 */ + 0, /* 0xca */ + 0, /* 0xcb */ + 0, /* 0xcc */ + 0, /* 0xcd */ + 0, /* 0xce */ + 0, /* 0xcf */ + 0, /* 0xd0 */ + 0, /* 0xd1 */ + 0, /* 0xd2 */ + 0, /* 0xd3 */ + 0, /* 0xd4 */ + 0, /* 0xd5 */ + 0, /* 0xd6 */ + 0, /* 0xd7 */ + 0, /* 0xd8 */ + 0, /* 0xd9 */ + 0, /* 0xda */ + 0, /* 0xdb */ + 0, /* 0xdc */ + 0, /* 0xdd */ + 0, /* 0xde */ + 0, /* 0xdf */ + 0, /* 0xe0 */ + 0, /* 0xe1 */ + 0, /* 0xe2 */ + 0, /* 0xe3 */ + 0, /* 0xe4 */ + 0, /* 0xe5 */ + 0, /* 0xe6 */ + 0, /* 0xe7 */ + 0, /* 0xe8 */ + 0, /* 0xe9 */ + 0, /* 0xea */ + 0, /* 0xeb */ + 0, /* 0xec */ + 0, /* 0xed */ + 0, /* 0xee */ + 0, /* 0xef */ + 0, /* 0xf0 */ + 0, /* 0xf1 */ + 0, /* 0xf2 */ + 0, /* 0xf3 */ + 0, /* 0xf4 */ + 0, /* 0xf5 */ + 0, /* 0xf6 */ + 0, /* 0xf7 */ + 0, /* 0xf8 */ + 0, /* 0xf9 */ + 0, /* 0xfa */ + 0, /* 0xfb */ + 0, /* 0xfc */ + 0, /* 0xfd */ + 0, /* 0xfe */ + 0 /* 0xff */ +}; + +unsigned short *_pctype = _ctype + 1; +unsigned short *_pwctype = _ctype + 1; + +int _isctype (int c, int ctypeFlags) +{ + return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags); +} + +/* + * @implemented + */ +int iswctype(wint_t wc, wctype_t wctypeFlags) +{ + return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags); +} + +/* + * @implemented + */ +int isalpha(int c) +{ + return(_isctype(c, _ALPHA)); +} + +/* + * @implemented + */ +int isalnum(int c) +{ + return(_isctype(c, _ALPHA | _DIGIT)); +} + +/* + * @implemented + */ +int __isascii(int c) +{ + return ((unsigned char)c <= 0x7f); +} + +/* + * @implemented + */ +int iscntrl(int c) +{ + return(_isctype(c, _CONTROL)); +} + +/* + * @implemented + */ +int __iscsym(int c) +{ + return(isalnum(c)||(c == '_')); +} + +/* + * @implemented + */ +int __iscsymf(int c) +{ + return(isalpha(c)||(c == '_')); +} + +/* + * @implemented + */ +int isdigit(int c) +{ + return(_isctype(c, _DIGIT)); +} + +/* + * @implemented + */ +int isgraph(int c) +{ + return (_isctype (c, _PUNCT | _ALPHA | _DIGIT)); +} + +/* + * @implemented + */ +int islower(int c) +{ + return (_isctype (c, _LOWER)); +} + +/* + * @implemented + */ +int isprint(int c) +{ + return (_isctype (c, _BLANK | _PUNCT | _ALPHA | _DIGIT)); +} + +/* + * @implemented + */ +int ispunct(int c) +{ + return (_isctype (c, _PUNCT)); +} + +/* + * @implemented + */ +int isspace(int c) +{ + return (_isctype (c, _SPACE)); +} + +/* + * @implemented + */ +int isupper(int c) +{ + return (_isctype (c, _UPPER)); +} + +/* + * @implemented + */ +int isxdigit(int c) +{ + return (_isctype (c, _HEX)); +} + + +/* + * @implemented + */ +int iswalpha(wint_t c) +{ + return (iswctype (c, _ALPHA)); +} + +/* + * @implemented + */ +int iswdigit(wint_t c) +{ + return (iswctype (c, _DIGIT)); +} + +/* + * @implemented + */ +int iswlower(wint_t c) +{ + return (iswctype (c, _LOWER)); +} + +/* + * @implemented + */ +int iswspace(wint_t c) +{ + return (iswctype (c, _SPACE)); +} + +/* + * @implemented + */ +int iswxdigit(wint_t c) +{ + return (iswctype (c, _HEX)); +} + + +/* + * @implemented + */ +int __toascii(int c) +{ + return((unsigned)(c) & 0x7f); +} + +/* + * @implemented + */ +int _tolower(int c) +{ + if (_isctype (c, _UPPER)) + return (c - upalpha); + return(c); +} + +/* + * @implemented + */ +int _toupper(int c) +{ + if (_isctype (c, _LOWER)) + return (c + upalpha); + return(c); +} + +/* + * @implemented + */ +int tolower(int c) +{ + if (_isctype (c, _UPPER)) + return (c - upalpha); + return(c); +} + +/* + * @implemented + */ +int toupper(int c) +{ + if (_isctype (c, _LOWER)) + return (c + upalpha); + return(c); +} + +/* + * @implemented + */ +wchar_t towlower(wchar_t c) +{ + if (iswctype (c, _UPPER)) + return (c - upalpha); + return(c); +} + +/* + * @implemented + */ +wchar_t towupper(wchar_t c) +{ + if (iswctype (c, _LOWER)) + return (c + upalpha); + return(c); +} + +/* EOF */ _____ Copied: trunk/reactos/lib/string/memicmp.c (from rev 17732, trunk/reactos/lib/ntdll/string/memicmp.c) --- trunk/reactos/lib/ntdll/string/memicmp.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/memicmp.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,22 @@ +#include <string.h> +#include <ctype.h> + +/* + * @implemented + */ +int +_memicmp(const void *s1, const void *s2, size_t n) +{ + if (n != 0) + { + const unsigned char *p1 = s1, *p2 = s2; + + do { + if (toupper(*p1) != toupper(*p2)) + return (*p1 - *p2); + p1++; + p2++; + } while (--n != 0); + } + return 0; +} _____ Copied: trunk/reactos/lib/string/stricmp.c (from rev 17732, trunk/reactos/lib/ntdll/string/stricmp.c) --- trunk/reactos/lib/ntdll/string/stricmp.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/stricmp.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,27 @@ +#include <string.h> +#include <ctype.h> + +/* + * @implemented + */ +int +_stricmp(const char *s1, const char *s2) +{ + while (toupper(*s1) == toupper(*s2)) + { + if (*s1 == 0) + return 0; + s1++; + s2++; + } + return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2)); +} + +/* + * @implemented + */ +int +_strcmpi(const char *s1, const char *s2) +{ + return _stricmp(s1,s2); +} _____ Modified: trunk/reactos/lib/string/string.xml --- trunk/reactos/lib/string/string.xml 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/string.xml 2005-09-08 04:27:02 UTC (rev 17733) @@ -59,9 +59,21 @@ The current implemention of rbuild generates a dependency rule for each occurence of a file. --> + <file>ctype.c</file> <file>memccpy.c</file> <file>memcmp.c</file> + <file>memicmp.c</file> <file>strcspn.c</file> + <file>stricmp.c</file> + <file>strnicmp.c</file> + <file>strlwr.c</file> + <file>strrev.c</file> + <file>strset.c</file> + <file>strstr.c</file> + <file>strupr.c</file> <file>strpbrk.c</file> <file>strspn.c</file> + <file>wstring.c</file> + <file>wcsrev.c</file> + <file>wcsnset.c</file> </module> _____ Copied: trunk/reactos/lib/string/strlwr.c (from rev 17732, trunk/reactos/lib/ntdll/string/strlwr.c) --- trunk/reactos/lib/ntdll/string/strlwr.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/strlwr.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,17 @@ +#include <string.h> +#include <ctype.h> + + +/* + * @implemented + */ +char * _strlwr(char *x) +{ + char *y=x; + + while (*y) { + *y=tolower(*y); + y++; + } + return x; +} _____ Copied: trunk/reactos/lib/string/strnicmp.c (from rev 17732, trunk/reactos/lib/ntdll/string/strnicmp.c) --- trunk/reactos/lib/ntdll/string/strnicmp.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/strnicmp.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,20 @@ +#include <string.h> +#include <ctype.h> + +/* + + * @implemented + */ +int _strnicmp(const char *s1, const char *s2, size_t n) +{ + + if (n == 0) + return 0; + do { + if (toupper(*s1) != toupper(*s2++)) + return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)--s2); + if (*s1++ == 0) + break; + } while (--n != 0); + return 0; +} _____ Added: trunk/reactos/lib/string/strrev.c --- trunk/reactos/lib/string/strrev.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/strrev.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,24 @@ +#include <string.h> + +/* + * @implemented + */ +char * _strrev(char *s) +{ + char *e; + char a; + + e = s; + while (*e) + e++; + + while (s<e) + { + a = *s; + *s = *e; + *e = a; + s++; + e--; + } + return s; +} _____ Added: trunk/reactos/lib/string/strset.c --- trunk/reactos/lib/string/strset.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/strset.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,33 @@ +#include <string.h> + +/* + * @implemented + */ +char* _strnset(char* szToFill, int szFill, size_t sizeMaxFill) +{ + char *t = szToFill; + int i = 0; + while (*szToFill != 0 && i < (int) sizeMaxFill) + { + *szToFill = szFill; + szToFill++; + i++; + + } + return t; +} + +/* + * @implemented + */ +char* _strset(char* szToFill, int szFill) +{ + char *t = szToFill; + while (*szToFill != 0) + { + *szToFill = szFill; + szToFill++; + + } + return t; +} _____ Copied: trunk/reactos/lib/string/strstr.c (from rev 17732, trunk/reactos/lib/ntdll/string/strstr.c) --- trunk/reactos/lib/ntdll/string/strstr.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/strstr.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,24 @@ +#include <string.h> + +/* + * @implemented + */ +char * +strstr(const char *s, const char *find) +{ + char c, sc; + size_t len; + + if ((c = *find++) != 0) + { + len = strlen(find); + do { + do { + if ((sc = *s++) == 0) + return 0; + } while (sc != c); + } while (strncmp(s, find, len) != 0); + s--; + } + return (char *)s; +} _____ Copied: trunk/reactos/lib/string/strupr.c (from rev 17732, trunk/reactos/lib/ntdll/string/strupr.c) --- trunk/reactos/lib/ntdll/string/strupr.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/strupr.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,17 @@ +#include <string.h> +#include <ctype.h> + + +/* + * @implemented + */ +char *_strupr(char *x) +{ + char *y=x; + + while (*y) { + *y=toupper(*y); + y++; + } + return x; +} _____ Added: trunk/reactos/lib/string/wcsnset.c --- trunk/reactos/lib/string/wcsnset.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/wcsnset.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,17 @@ +#include <string.h> + +/* + * @implemented + */ +wchar_t *_wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill) +{ + wchar_t *t = wsToFill; + int i = 0; + while( *wsToFill != 0 && i < (int) sizeMaxFill) + { + *wsToFill = wcFill; + wsToFill++; + i++; + } + return t; +} _____ Added: trunk/reactos/lib/string/wcsrev.c --- trunk/reactos/lib/string/wcsrev.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/wcsrev.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,22 @@ +#include <string.h> + +/* + * @implemented + */ +wchar_t *_wcsrev(wchar_t *s) +{ + wchar_t *e; + wchar_t a; + e=s; + while (*e) + e++; + while (s<e) + { + a=*s; + *s=*e; + *e=a; + s++; + e--; + } + return s; +} _____ Copied: trunk/reactos/lib/string/wstring.c (from rev 17732, trunk/reactos/lib/ntdll/string/wstring.c) --- trunk/reactos/lib/ntdll/string/wstring.c 2005-09-08 02:29:30 UTC (rev 17732) +++ trunk/reactos/lib/string/wstring.c 2005-09-08 04:27:02 UTC (rev 17733) @@ -0,0 +1,154 @@ +#include <string.h> +#include <ctype.h> + +/* FUNCTIONS *****************************************************************/ + +int _wcsicmp (const wchar_t* cs, const wchar_t * ct) +{ + while (towlower(*cs) == towlower(*ct)) + { + if (*cs == 0) + return 0; + cs++; + ct++; + } + return towlower(*cs) - towlower(*ct); +} + + +/* + * @implemented + */ +wchar_t *_wcslwr (wchar_t *x) +{ + wchar_t *y=x; + + while (*y) { + *y=towlower(*y); + y++; + } + return x; +} + + +/* + * @implemented + */ +int _wcsnicmp (const wchar_t * cs, const wchar_t * ct, size_t count) +{ + if (count == 0) + return 0; + do { + if (towupper(*cs) != towupper(*ct++)) + return towupper(*cs) - towupper(*--ct); + if (*cs++ == 0) + break; + } while (--count != 0); + return 0; +} + + +/* + * @implemented + */ +wchar_t *_wcsupr(wchar_t *x) +{ + wchar_t *y=x; + + while (*y) { + *y=towupper(*y); + y++; + } + return x; +} + +/* + * @implemented + */ +size_t wcscspn(const wchar_t *str,const wchar_t *reject) +{ + wchar_t *s; + wchar_t *t; + s=(wchar_t *)str; + do { + t=(wchar_t *)reject; + while (*t) { + if (*t==*s) + break; + t++; + } + if (*t) + break; + s++; + } while (*s); + return s-str; /* nr of wchars */ +} + +/* + * @implemented + */ +wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2) +{ + const wchar_t *scanp; + int c, sc; + + while ((c = *s1++) != 0) + { + for (scanp = s2; (sc = *scanp++) != 0;) + if (sc == c) + { + return (wchar_t *)(--s1); + } + } + return 0; +} + +/* + * @implemented + */ +size_t wcsspn(const wchar_t *str,const wchar_t *accept) +{ + wchar_t *s; + wchar_t *t; + s=(wchar_t *)str; + do { + t=(wchar_t *)accept; + while (*t) { + if (*t==*s) + break; + t++; + } + if (!*t) + break; + s++; + } while (*s); + return s-str; /* nr of wchars */ +} + + +/* + * @implemented + */ +wchar_t *wcsstr(const wchar_t *s,const wchar_t *b) +{ + wchar_t *x; + wchar_t *y; + wchar_t *c; + x=(wchar_t *)s; + while (*x) { + if (*x==*b) { + y=x; [truncated at 1000 lines; 399 more skipped]
19 years, 3 months
1
0
0
0
[ion] 17732: - Move more stuff to /rtl
by ion@svn.reactos.com
- Move more stuff to /rtl - Bring back Ki* callbacks into ntdll. Modified: trunk/reactos/lib/ntdll/def/ntdll.def Modified: trunk/reactos/lib/ntdll/inc/ntdllp.h Modified: trunk/reactos/lib/ntdll/ldr/startup.c Added: trunk/reactos/lib/ntdll/main/dispatch.c Modified: trunk/reactos/lib/ntdll/ntdll.xml Deleted: trunk/reactos/lib/ntdll/rtl/critical.c Deleted: trunk/reactos/lib/ntdll/rtl/exception.c Modified: trunk/reactos/lib/ntdll/rtl/libsupp.c Deleted: trunk/reactos/lib/ntdll/rtl/path.c Deleted: trunk/reactos/lib/rtl/apc.c Deleted: trunk/reactos/lib/rtl/callback.c Added: trunk/reactos/lib/rtl/critical.c Modified: trunk/reactos/lib/rtl/heap.c Added: trunk/reactos/lib/rtl/path.c Modified: trunk/reactos/lib/rtl/rtl.h Modified: trunk/reactos/lib/rtl/rtl.xml Added: trunk/reactos/lib/rtl/vectoreh.c Modified: trunk/reactos/ntoskrnl/rtl/libsupp.c _____ Modified: trunk/reactos/lib/ntdll/def/ntdll.def --- trunk/reactos/lib/ntdll/def/ntdll.def 2005-09-08 00:09:32 UTC (rev 17731) +++ trunk/reactos/lib/ntdll/def/ntdll.def 2005-09-08 02:29:30 UTC (rev 17732) @@ -317,7 +317,6 @@ RtlAreBitsClear@12 RtlAreBitsSet@12 RtlAssert@16 -RtlBaseProcessStartRoutine DATA ;RtlCaptureStackBackTrace RtlCharToInteger@12 RtlCheckRegistryKey@8 _____ Modified: trunk/reactos/lib/ntdll/inc/ntdllp.h --- trunk/reactos/lib/ntdll/inc/ntdllp.h 2005-09-08 00:09:32 UTC (rev 17731) +++ trunk/reactos/lib/ntdll/inc/ntdllp.h 2005-09-08 02:29:30 UTC (rev 17732) @@ -27,50 +27,11 @@ (STDCALL *PDLLMAIN_FUNC)(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved); -VOID -STDCALL -RtlpInitDeferedCriticalSection( - VOID -); + #if defined(KDBG) || defined(DBG) VOID LdrpLoadUserModuleSymbols(PLDR_DATA_TABLE_ENTRY LdrModule); #endif extern HANDLE WindowsApiPort; -NTSTATUS -STDCALL -RtlpWaitForCriticalSection( - PRTL_CRITICAL_SECTION CriticalSection -); - -VOID -STDCALL -RtlpUnWaitCriticalSection( - PRTL_CRITICAL_SECTION CriticalSection -); - -VOID -STDCALL -RtlpCreateCriticalSectionSem( - PRTL_CRITICAL_SECTION CriticalSection -); - -VOID -STDCALL -RtlpInitDeferedCriticalSection( - VOID -); - -VOID -STDCALL -RtlpFreeDebugInfo( - PRTL_CRITICAL_SECTION_DEBUG DebugInfo -); - -PRTL_CRITICAL_SECTION_DEBUG -STDCALL -RtlpAllocateDebugInfo( - VOID -); /* EOF */ _____ Modified: trunk/reactos/lib/ntdll/ldr/startup.c --- trunk/reactos/lib/ntdll/ldr/startup.c 2005-09-08 00:09:32 UTC (rev 17731) +++ trunk/reactos/lib/ntdll/ldr/startup.c 2005-09-08 02:29:30 UTC (rev 17732) @@ -17,6 +17,7 @@ VOID RtlInitializeHeapManager (VOID); VOID LdrpInitLoader(VOID); +VOID STDCALL RtlpInitDeferedCriticalSection(VOID); /* GLOBALS *******************************************************************/ _____ Added: trunk/reactos/lib/ntdll/main/dispatch.c --- trunk/reactos/lib/ntdll/main/dispatch.c 2005-09-08 00:09:32 UTC (rev 17731) +++ trunk/reactos/lib/ntdll/main/dispatch.c 2005-09-08 02:29:30 UTC (rev 17732) @@ -0,0 +1,121 @@ +/* COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * PURPOSE: User-mode APC support + * FILE: lib/ntdll/main/dispatch.c + * PROGRAMER: David Welch <welch(a)cwcom.net> + */ + +/* INCLUDES *****************************************************************/ + +#include <ntdll.h> +#define NDEBUG +#include <debug.h> + +typedef NTSTATUS (STDCALL *KERNEL_CALLBACK_FUNCTION)(PVOID Argument, + ULONG ArgumentLength); + +EXCEPTION_DISPOSITION +RtlpExecuteVectoredExceptionHandlers(IN PEXCEPTION_RECORD ExceptionRecord, + IN PCONTEXT Context); + +ULONG +RtlpDispatchException(IN PEXCEPTION_RECORD ExceptionRecord, + IN PCONTEXT Context); +/* FUNCTIONS ****************************************************************/ + +/* + * @implemented + */ +VOID +STDCALL +KiUserApcDispatcher(PIO_APC_ROUTINE ApcRoutine, + PVOID ApcContext, + PIO_STATUS_BLOCK Iosb, + ULONG Reserved, + PCONTEXT Context) +{ + /* + * Call the APC + */ + //DPRINT1("ITS ME\n"); + ApcRoutine(ApcContext, + Iosb, + Reserved); + /* + * Switch back to the interrupted context + */ + //DPRINT1("switch back\n"); + NtContinue(Context, 1); +} + +/* + * @implemented + */ +VOID +STDCALL +KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord, + PCONTEXT Context) +{ + EXCEPTION_RECORD NestedExceptionRecord; + NTSTATUS Status; + + if(RtlpExecuteVectoredExceptionHandlers(ExceptionRecord, + Context) != ExceptionContinueExecution) + { + Status = NtContinue(Context, FALSE); + } + else + { + if(RtlpDispatchException(ExceptionRecord, Context) != ExceptionContinueExecution) + { + Status = NtContinue(Context, FALSE); + } + else + { + Status = NtRaiseException(ExceptionRecord, Context, FALSE); + } + } + + NestedExceptionRecord.ExceptionCode = Status; + NestedExceptionRecord.ExceptionFlags = EXCEPTION_NONCONTINUABLE; + NestedExceptionRecord.ExceptionRecord = ExceptionRecord; + NestedExceptionRecord.NumberParameters = Status; + + RtlRaiseException(&NestedExceptionRecord); +} + +/* + * @implemented + */ +VOID +STDCALL +KiRaiseUserExceptionDispatcher(VOID) +{ + EXCEPTION_RECORD ExceptionRecord; + + ExceptionRecord.ExceptionCode = ((PTEB)NtCurrentTeb())->ExceptionCode; + ExceptionRecord.ExceptionFlags = 0; + ExceptionRecord.ExceptionRecord = NULL; + ExceptionRecord.NumberParameters = 0; + + RtlRaiseException(&ExceptionRecord); +} + +/* + * @implemented + */ +VOID +STDCALL +KiUserCallbackDispatcher(ULONG RoutineIndex, + PVOID Argument, + ULONG ArgumentLength) +{ + PPEB Peb; + NTSTATUS Status; + KERNEL_CALLBACK_FUNCTION Callback; + + Peb = NtCurrentPeb(); + Callback = (KERNEL_CALLBACK_FUNCTION)Peb->KernelCallbackTable[RoutineIndex]; + Status = Callback(Argument, ArgumentLength); + ZwCallbackReturn(NULL, 0, Status); +} _____ Modified: trunk/reactos/lib/ntdll/ntdll.xml --- trunk/reactos/lib/ntdll/ntdll.xml 2005-09-08 00:09:32 UTC (rev 17731) +++ trunk/reactos/lib/ntdll/ntdll.xml 2005-09-08 02:29:30 UTC (rev 17732) @@ -29,13 +29,11 @@ <file>utils.c</file> </directory> <directory name="main"> + <file>dispatch.c</file> <file>dllmain.c</file> </directory> <directory name="rtl"> - <file>critical.c</file> - <file>exception.c</file> <file>libsupp.c</file> - <file>path.c</file> <file>version.c</file> </directory> <directory name="stdio"> _____ Deleted: trunk/reactos/lib/ntdll/rtl/critical.c --- trunk/reactos/lib/ntdll/rtl/critical.c 2005-09-08 00:09:32 UTC (rev 17731) +++ trunk/reactos/lib/ntdll/rtl/critical.c 2005-09-08 02:29:30 UTC (rev 17732) @@ -1,693 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/ntdll/rtl/critical.c - * PURPOSE: Critical sections - * UPDATE HISTORY: - * Created 30/09/98 - * Rewritten ROS version, based on WINE code plus - * some fixes useful only for ROS right now - 03/01/05 - */ - -/* INCLUDES ******************************************************************/ - -#include <ntdll.h> -#define NDEBUG -#include <debug.h> - -/* FUNCTIONS *****************************************************************/ - -#define MAX_STATIC_CS_DEBUG_OBJECTS 64 - -static RTL_CRITICAL_SECTION RtlCriticalSectionLock; -static LIST_ENTRY RtlCriticalSectionList; -static BOOLEAN RtlpCritSectInitialized = FALSE; -static RTL_CRITICAL_SECTION_DEBUG RtlpStaticDebugInfo[MAX_STATIC_CS_DEBUG_OBJECTS]; -static BOOLEAN RtlpDebugInfoFreeList[MAX_STATIC_CS_DEBUG_OBJECTS]; - -/*++ - * RtlDeleteCriticalSection - * @implemented NT4 - * - * Deletes a Critical Section - * - * Params: - * CriticalSection - Critical section to delete. - * - * Returns: - * STATUS_SUCCESS, or error value returned by NtClose. - * - * Remarks: - * The critical section members should not be read after this call. - * - *--*/ -NTSTATUS -STDCALL -RtlDeleteCriticalSection( - PRTL_CRITICAL_SECTION CriticalSection) -{ - NTSTATUS Status = STATUS_SUCCESS; - - DPRINT("Deleting Critical Section: %x\n", CriticalSection); - /* Close the Event Object Handle if it exists */ - if (CriticalSection->LockSemaphore) { - - /* In case NtClose fails, return the status */ - Status = NtClose(CriticalSection->LockSemaphore); - - } - - /* Protect List */ - RtlEnterCriticalSection(&RtlCriticalSectionLock); - - /* Remove it from the list */ - RemoveEntryList(&CriticalSection->DebugInfo->ProcessLocksList); - - /* Unprotect */ - RtlLeaveCriticalSection(&RtlCriticalSectionLock); - - /* Free it */ - RtlpFreeDebugInfo(CriticalSection->DebugInfo); - - /* Wipe it out */ - RtlZeroMemory(CriticalSection, sizeof(RTL_CRITICAL_SECTION)); - - /* Return */ - return Status; -} - -/*++ - * RtlSetCriticalSectionSpinCount - * @implemented NT4 - * - * Sets the spin count for a critical section. - * - * Params: - * CriticalSection - Critical section to set the spin count for. - * - * SpinCount - Spin count for the critical section. - * - * Returns: - * STATUS_SUCCESS. - * - * Remarks: - * SpinCount is ignored on single-processor systems. - * - *--*/ -DWORD -STDCALL -RtlSetCriticalSectionSpinCount( - PRTL_CRITICAL_SECTION CriticalSection, - ULONG SpinCount - ) -{ - ULONG OldCount = CriticalSection->SpinCount; - - /* Set to parameter if MP, or to 0 if this is Uniprocessor */ - CriticalSection->SpinCount = (NtCurrentPeb()->NumberOfProcessors > 1) ? SpinCount : 0; - return OldCount; -} - -/*++ - * RtlEnterCriticalSection - * @implemented NT4 - * - * Waits to gain ownership of the critical section. - * - * Params: - * CriticalSection - Critical section to wait for. - * - * Returns: - * STATUS_SUCCESS. - * - * Remarks: - * Uses a fast-path unless contention happens. - * - *--*/ -NTSTATUS -STDCALL -RtlEnterCriticalSection( - PRTL_CRITICAL_SECTION CriticalSection) -{ - HANDLE Thread = (HANDLE)NtCurrentTeb()->Cid.UniqueThread; - - /* Try to Lock it */ - if (InterlockedIncrement(&CriticalSection->LockCount) != 0) { - - /* - * We've failed to lock it! Does this thread - * actually own it? - */ - if (Thread == CriticalSection->OwningThread) { - - /* You own it, so you'll get it when you're done with it! No need to - use the interlocked functions as only the thread who already owns - the lock can modify this data. */ - CriticalSection->RecursionCount++; - return STATUS_SUCCESS; - } - - /* NOTE - CriticalSection->OwningThread can be NULL here because changing - this information is not serialized. This happens when thread a - acquires the lock (LockCount == 0) and thread b tries to - acquire it as well (LockCount == 1) but thread a hasn't had a - chance to set the OwningThread! So it's not an error when - OwningThread is NULL here! */ - - /* We don't own it, so we must wait for it */ - RtlpWaitForCriticalSection(CriticalSection); - } - - /* Lock successful. Changing this information has not to be serialized because - only one thread at a time can actually change it (the one who acquired - the lock)! */ - CriticalSection->OwningThread = Thread; - CriticalSection->RecursionCount = 1; - return STATUS_SUCCESS; -} - -/*++ - * RtlInitializeCriticalSection - * @implemented NT4 - * - * Initialises a new critical section. - * - * Params: - * CriticalSection - Critical section to initialise - * - * Returns: - * STATUS_SUCCESS. - * - * Remarks: - * Simply calls RtlInitializeCriticalSectionAndSpinCount - * - *--*/ -NTSTATUS -STDCALL -RtlInitializeCriticalSection( - PRTL_CRITICAL_SECTION CriticalSection) -{ - /* Call the Main Function */ - return RtlInitializeCriticalSectionAndSpinCount(CriticalSection, 0); -} - -/*++ - * RtlInitializeCriticalSectionAndSpinCount - * @implemented NT4 - * - * Initialises a new critical section. - * - * Params: - * CriticalSection - Critical section to initialise - * - * SpinCount - Spin count for the critical section. - * - * Returns: - * STATUS_SUCCESS. - * - * Remarks: - * SpinCount is ignored on single-processor systems. - * - *--*/ -NTSTATUS -STDCALL -RtlInitializeCriticalSectionAndSpinCount ( - PRTL_CRITICAL_SECTION CriticalSection, - ULONG SpinCount) -{ - PRTL_CRITICAL_SECTION_DEBUG CritcalSectionDebugData; - - /* First things first, set up the Object */ - DPRINT("Initializing Critical Section: %x\n", CriticalSection); - CriticalSection->LockCount = -1; - CriticalSection->RecursionCount = 0; - CriticalSection->OwningThread = 0; - CriticalSection->SpinCount = (NtCurrentPeb()->NumberOfProcessors > 1) ? SpinCount : 0; - CriticalSection->LockSemaphore = 0; - - /* Allocate the Debug Data */ - CritcalSectionDebugData = RtlpAllocateDebugInfo(); - DPRINT("Allocated Debug Data: %x inside Process: %x\n", - CritcalSectionDebugData, - NtCurrentTeb()->Cid.UniqueProcess); - - if (!CritcalSectionDebugData) { - - /* This is bad! */ - DPRINT1("Couldn't allocate Debug Data for: %x\n", CriticalSection); - return STATUS_NO_MEMORY; - } - - /* Set it up */ - CritcalSectionDebugData->Type = RTL_CRITSECT_TYPE; - CritcalSectionDebugData->ContentionCount = 0; - CritcalSectionDebugData->EntryCount = 0; - CritcalSectionDebugData->CriticalSection = CriticalSection; - CriticalSection->DebugInfo = CritcalSectionDebugData; - - /* - * Add it to the List of Critical Sections owned by the process. - * If we've initialized the Lock, then use it. If not, then probably - * this is the lock initialization itself, so insert it directly. - */ - if ((CriticalSection != &RtlCriticalSectionLock) && (RtlpCritSectInitialized)) { - - DPRINT("Securely Inserting into ProcessLocks: %x, %x, %x\n", - &CritcalSectionDebugData->ProcessLocksList, - CriticalSection, - &RtlCriticalSectionList); - - /* Protect List */ - RtlEnterCriticalSection(&RtlCriticalSectionLock); - - /* Add this one */ - InsertTailList(&RtlCriticalSectionList, &CritcalSectionDebugData->ProcessLocksList); - - /* Unprotect */ - RtlLeaveCriticalSection(&RtlCriticalSectionLock); - - } else { - - DPRINT("Inserting into ProcessLocks: %x, %x, %x\n", - &CritcalSectionDebugData->ProcessLocksList, - CriticalSection, - &RtlCriticalSectionList); - - /* Add it directly */ - InsertTailList(&RtlCriticalSectionList, &CritcalSectionDebugData->ProcessLocksList); - } - - return STATUS_SUCCESS; -} - -/*++ - * RtlLeaveCriticalSection - * @implemented NT4 - * - * Releases a critical section and makes if available for new owners. - * - * Params: - * CriticalSection - Critical section to release. - * - * Returns: - * STATUS_SUCCESS. - * - * Remarks: - * If another thread was waiting, the slow path is entered. - * - *--*/ -NTSTATUS -STDCALL -RtlLeaveCriticalSection( - PRTL_CRITICAL_SECTION CriticalSection) -{ -#ifndef NDEBUG - HANDLE Thread = (HANDLE)NtCurrentTeb()->Cid.UniqueThread; - - /* In win this case isn't checked. However it's a valid check so it should only - be performed in debug builds! */ - if (Thread != CriticalSection->OwningThread) - { - DPRINT1("Releasing critical section not owned!\n"); - return STATUS_INVALID_PARAMETER; - } -#endif - - /* Decrease the Recursion Count. No need to do this atomically because only - the thread who holds the lock can call this function (unless the program - is totally screwed... */ - if (--CriticalSection->RecursionCount) { - - /* Someone still owns us, but we are free. This needs to be done atomically. */ - InterlockedDecrement(&CriticalSection->LockCount); - - } else { - - /* Nobody owns us anymore. No need to do this atomically. See comment - above. */ - CriticalSection->OwningThread = 0; - - /* Was someone wanting us? This needs to be done atomically. */ - if (-1 != InterlockedDecrement(&CriticalSection->LockCount)) { - - /* Let him have us */ - RtlpUnWaitCriticalSection(CriticalSection); - } - } - - /* Sucessful! */ - return STATUS_SUCCESS; -} - -/*++ - * RtlTryEnterCriticalSection - * @implemented NT4 - * - * Attemps to gain ownership of the critical section without waiting. - * - * Params: - * CriticalSection - Critical section to attempt acquiring. - * - * Returns: - * TRUE if the critical section has been acquired, FALSE otherwise. - * - * Remarks: - * None - * - *--*/ -BOOLEAN -STDCALL -RtlTryEnterCriticalSection( - PRTL_CRITICAL_SECTION CriticalSection) -{ - /* Try to take control */ - if (InterlockedCompareExchange(&CriticalSection->LockCount, - 0, - -1) == -1) { - - /* It's ours */ - CriticalSection->OwningThread = NtCurrentTeb()->Cid.UniqueThread; - CriticalSection->RecursionCount = 1; - return TRUE; - - } else if (CriticalSection->OwningThread == NtCurrentTeb()->Cid.UniqueThread) { - - /* It's already ours */ - InterlockedIncrement(&CriticalSection->LockCount); - CriticalSection->RecursionCount++; - return TRUE; - } - - /* It's not ours */ - return FALSE; -} - -/*++ - * RtlpWaitForCriticalSection - * - * Slow path of RtlEnterCriticalSection. Waits on an Event Object. - * - * Params: - * CriticalSection - Critical section to acquire. - * - * Returns: - * STATUS_SUCCESS, or raises an exception if a deadlock is occuring. - * - * Remarks: - * None - * - *--*/ -NTSTATUS -STDCALL -RtlpWaitForCriticalSection( - PRTL_CRITICAL_SECTION CriticalSection) -{ - NTSTATUS Status; - EXCEPTION_RECORD ExceptionRecord; - BOOLEAN LastChance = FALSE; - LARGE_INTEGER Timeout; - - /* Wait 2.5 minutes */ - Timeout.QuadPart = 150000L * (ULONGLONG)10000; - Timeout.QuadPart = -Timeout.QuadPart; - /* ^^ HACK HACK HACK. Good way: - Timeout = &NtCurrentPeb()->CriticalSectionTimeout */ - - /* Do we have an Event yet? */ - if (!CriticalSection->LockSemaphore) { - RtlpCreateCriticalSectionSem(CriticalSection); - } - - /* Increase the Debug Entry count */ - DPRINT("Waiting on Critical Section Event: %x %x\n", - CriticalSection, - CriticalSection->LockSemaphore); - CriticalSection->DebugInfo->EntryCount++; - - for (;;) { - - /* Increase the number of times we've had contention */ - CriticalSection->DebugInfo->ContentionCount++; - - /* Wait on the Event */ - Status = NtWaitForSingleObject(CriticalSection->LockSemaphore, - FALSE, - &Timeout); - - /* We have Timed out */ - if (Status == STATUS_TIMEOUT) { - - /* Is this the 2nd time we've timed out? */ - if (LastChance) { - - DPRINT1("Deadlock: %x\n", CriticalSection); - - /* Yes it is, we are raising an exception */ - ExceptionRecord.ExceptionCode = STATUS_POSSIBLE_DEADLOCK; - ExceptionRecord.ExceptionFlags = 0; - ExceptionRecord.ExceptionRecord = NULL; - ExceptionRecord.ExceptionAddress = RtlRaiseException; - ExceptionRecord.NumberParameters = 1; - ExceptionRecord.ExceptionInformation[0] = (ULONG_PTR)CriticalSection; - RtlRaiseException(&ExceptionRecord); - - } - - /* One more try */ - LastChance = TRUE; - - } else { - - /* If we are here, everything went fine */ - return STATUS_SUCCESS; - } - } -} - -/*++ - * RtlpUnWaitCriticalSection - * - * Slow path of RtlLeaveCriticalSection. Fires an Event Object. - * - * Params: - * CriticalSection - Critical section to release. - * - * Returns: - * None. Raises an exception if the system call failed. - * - * Remarks: - * None - * - *--*/ -VOID -STDCALL -RtlpUnWaitCriticalSection( - PRTL_CRITICAL_SECTION CriticalSection) - -{ - NTSTATUS Status; - - /* Do we have an Event yet? */ - if (!CriticalSection->LockSemaphore) { - RtlpCreateCriticalSectionSem(CriticalSection); - } - - /* Signal the Event */ - DPRINT("Signaling Critical Section Event: %x, %x\n", - CriticalSection, - CriticalSection->LockSemaphore); - Status = NtSetEvent(CriticalSection->LockSemaphore, NULL); - - if (!NT_SUCCESS(Status)) { - - /* We've failed */ - DPRINT1("Signaling Failed for: %x, %x, %x\n", - CriticalSection, - CriticalSection->LockSemaphore, - Status); - RtlRaiseStatus(Status); - } -} - -/*++ - * RtlpCreateCriticalSectionSem - * - * Checks if an Event has been created for the critical section. - * - * Params: - * None - * - * Returns: - * None. Raises an exception if the system call failed. - * - * Remarks: - * None - * - *--*/ -VOID -STDCALL -RtlpCreateCriticalSectionSem( - PRTL_CRITICAL_SECTION CriticalSection) -{ - HANDLE hEvent = CriticalSection->LockSemaphore; - HANDLE hNewEvent; - NTSTATUS Status; - - /* Chevk if we have an event */ - if (!hEvent) { - - /* No, so create it */ - if (!NT_SUCCESS(Status = NtCreateEvent(&hNewEvent, - EVENT_ALL_ACCESS, - NULL, - SynchronizationEvent, - FALSE))) { - - /* We failed, this is bad... */ - DPRINT1("Failed to Create Event!\n"); - InterlockedDecrement(&CriticalSection->LockCount); - RtlRaiseStatus(Status); - return; - } - DPRINT("Created Event: %x \n", hNewEvent); - - if ((hEvent = InterlockedCompareExchangePointer((PVOID*)&CriticalSection->LockSemaphor e, - (PVOID)hNewEvent, - 0))) { - - /* Some just created an event */ - DPRINT("Closing already created event: %x\n", hNewEvent); - NtClose(hNewEvent); - } - } - - return; -} - -/*++ - * RtlpInitDeferedCriticalSection - * - * Initializes the Critical Section implementation. - * - * Params: - * None - * - * Returns: - * None. - * - * Remarks: - * After this call, the Process Critical Section list is protected. - * - *--*/ -VOID -STDCALL -RtlpInitDeferedCriticalSection( - VOID) -{ - - /* Initialize the Process Critical Section List */ - InitializeListHead(&RtlCriticalSectionList); - - /* Initialize the CS Protecting the List */ - RtlInitializeCriticalSection(&RtlCriticalSectionLock); - - /* It's now safe to enter it */ - RtlpCritSectInitialized = TRUE; -} - -/*++ - * RtlpAllocateDebugInfo - * - * Finds or allocates memory for a Critical Section Debug Object - * - * Params: - * None - * - * Returns: - * A pointer to an empty Critical Section Debug Object. - * - * Remarks: - * For optimization purposes, the first 64 entries can be cached. From - * then on, future Critical Sections will allocate memory from the heap. - * - *--*/ -PRTL_CRITICAL_SECTION_DEBUG -STDCALL -RtlpAllocateDebugInfo( - VOID) -{ - ULONG i; - - /* Try to allocate from our buffer first */ - for (i = 0; i < MAX_STATIC_CS_DEBUG_OBJECTS; i++) { - - /* Check if Entry is free */ - if (!RtlpDebugInfoFreeList[i]) { - - /* Mark entry in use */ - DPRINT("Using entry: %d. Buffer: %x\n", i, &RtlpStaticDebugInfo[i]); - RtlpDebugInfoFreeList[i] = TRUE; - - /* Use free entry found */ - return &RtlpStaticDebugInfo[i]; - } - - } - - /* We are out of static buffer, allocate dynamic */ - return RtlAllocateHeap(NtCurrentPeb()->ProcessHeap, - 0, - sizeof(RTL_CRITICAL_SECTION_DEBUG)); -} - -/*++ - * RtlpFreeDebugInfo - * - * Frees the memory for a Critical Section Debug Object - * - * Params: - * DebugInfo - Pointer to Critical Section Debug Object to free. - * - * Returns: - * None. - * - * Remarks: - * If the pointer is part of the static buffer, then the entry is made - * free again. If not, the object is de-allocated from the heap. - * - *--*/ -VOID -STDCALL -RtlpFreeDebugInfo( - PRTL_CRITICAL_SECTION_DEBUG DebugInfo) -{ - ULONG EntryId; - - /* Is it part of our cached entries? */ - if ((DebugInfo >= RtlpStaticDebugInfo) && - (DebugInfo <= &RtlpStaticDebugInfo[MAX_STATIC_CS_DEBUG_OBJECTS-1])) { - - /* Yes. zero it out */ - RtlZeroMemory(DebugInfo, sizeof(RTL_CRITICAL_SECTION_DEBUG)); - - /* Mark as free */ - EntryId = (DebugInfo - RtlpStaticDebugInfo); - DPRINT("Freeing from Buffer: %x. Entry: %d inside Process: %x\n", - DebugInfo, - EntryId, - NtCurrentTeb()->Cid.UniqueProcess); - RtlpDebugInfoFreeList[EntryId] = FALSE; - - } else { - - /* It's a dynamic one, so free from the heap */ - DPRINT("Freeing from Heap: %x inside Process: %x\n", - DebugInfo, - NtCurrentTeb()->Cid.UniqueProcess); - RtlFreeHeap(NtCurrentPeb()->ProcessHeap, 0, DebugInfo); - - } -} - -/* EOF */ _____ Deleted: trunk/reactos/lib/ntdll/rtl/exception.c --- trunk/reactos/lib/ntdll/rtl/exception.c 2005-09-08 00:09:32 UTC (rev 17731) +++ trunk/reactos/lib/ntdll/rtl/exception.c 2005-09-08 02:29:30 UTC (rev 17732) @@ -1,221 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * PURPOSE: User-mode exception support - * FILE: lib/ntdll/rtl/exception.c - * PROGRAMERS: David Welch <welch(a)cwcom.net> - * Skywing <skywing(a)valhallalegends.com> - * KJK::Hyperion <noog(a)libero.it> - * UPDATES: Skywing, 09/11/2003: Implemented RtlRaiseException and - * KiUserRaiseExceptionDispatcher. - * KJK::Hyperion, 22/06/2003: Moved common parts to rtl - */ - -/* INCLUDES *****************************************************************/ - -#include <ntdll.h> -#define NDEBUG -#include <debug.h> - -static RTL_CRITICAL_SECTION RtlpVectoredExceptionLock; -static LIST_ENTRY RtlpVectoredExceptionHead; - -typedef struct _RTL_VECTORED_EXCEPTION_HANDLER -{ - LIST_ENTRY ListEntry; - PVECTORED_EXCEPTION_HANDLER VectoredHandler; -} RTL_VECTORED_EXCEPTION_HANDLER, *PRTL_VECTORED_EXCEPTION_HANDLER; - -/* FIXME - stupid ld won't resolve RtlDecodePointer! Since their implementation - is the same just use RtlEncodePointer for now! */ -#define RtlDecodePointer RtlEncodePointer - -/* FUNCTIONS ***************************************************************/ - -VOID STDCALL -RtlBaseProcessStart(PTHREAD_START_ROUTINE StartAddress, - PVOID Parameter); - -__declspec(dllexport) -PRTL_BASE_PROCESS_START_ROUTINE RtlBaseProcessStartRoutine = RtlBaseProcessStart; - -ULONG -RtlpDispatchException(IN PEXCEPTION_RECORD ExceptionRecord, - IN PCONTEXT Context); - -EXCEPTION_DISPOSITION -RtlpExecuteVectoredExceptionHandlers(IN PEXCEPTION_RECORD ExceptionRecord, - IN PCONTEXT Context) -{ - PLIST_ENTRY CurrentEntry; - PRTL_VECTORED_EXCEPTION_HANDLER veh; - PVECTORED_EXCEPTION_HANDLER VectoredHandler; - EXCEPTION_POINTERS ExceptionInfo; - - ExceptionInfo.ExceptionRecord = ExceptionRecord; - ExceptionInfo.ContextRecord = Context; - - if(RtlpVectoredExceptionHead.Flink != &RtlpVectoredExceptionHead) - { - RtlEnterCriticalSection(&RtlpVectoredExceptionLock); - for(CurrentEntry = RtlpVectoredExceptionHead.Flink; - CurrentEntry != &RtlpVectoredExceptionHead; - CurrentEntry = CurrentEntry->Flink) - { - veh = CONTAINING_RECORD(CurrentEntry, - RTL_VECTORED_EXCEPTION_HANDLER, - ListEntry); - VectoredHandler = RtlDecodePointer(veh->VectoredHandler); - if(VectoredHandler(&ExceptionInfo) == EXCEPTION_CONTINUE_EXECUTION) - { - RtlLeaveCriticalSection(&RtlpVectoredExceptionLock); [truncated at 1000 lines; 3575 more skipped]
19 years, 3 months
1
0
0
0
← Newer
1
...
42
43
44
45
46
47
48
...
59
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Results per page:
10
25
50
100
200