Implement RtlUnicodeStringToInteger (NTDLL)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This patch implements RtlUnicodeStringToInteger which is used by several unicode system libraries (eg SDBAPIU.DLL).

Changelog:
- Implement RtlUnicodeStringToInteger

? wine/dlls/msvcrt/tests
Index: wine/dlls/ntdll/ntdll.spec
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/ntdll.spec,v
retrieving revision 1.79
diff -u -r1.79 ntdll.spec
--- wine/dlls/ntdll/ntdll.spec	10 Oct 2002 17:55:48 -0000	1.79
+++ wine/dlls/ntdll/ntdll.spec	4 Nov 2002 18:32:14 -0000
@@ -528,7 +528,7 @@
 @ stdcall RtlUnicodeStringToAnsiSize(ptr) RtlUnicodeStringToAnsiSize
 @ stdcall RtlUnicodeStringToAnsiString(ptr ptr long) RtlUnicodeStringToAnsiString
 @ stub RtlUnicodeStringToCountedOemString
-@ stub RtlUnicodeStringToInteger
+@ stdcall RtlUnicodeStringToInteger(ptr long ptr) RtlUnicodeStringToInteger
 @ stdcall RtlUnicodeStringToOemSize(ptr) RtlUnicodeStringToOemSize
 @ stdcall RtlUnicodeStringToOemString(ptr ptr long) RtlUnicodeStringToOemString
 @ stub RtlUnicodeToCustomCPN
Index: wine/dlls/ntdll/rtlstr.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/rtlstr.c,v
retrieving revision 1.24
diff -u -r1.24 rtlstr.c
--- wine/dlls/ntdll/rtlstr.c	12 Sep 2002 22:07:03 -0000	1.24
+++ wine/dlls/ntdll/rtlstr.c	4 Nov 2002 18:32:16 -0000
@@ -835,3 +835,65 @@
 		*pf = out_flags;
 	return len;
 }
+
+/**************************************************************************
+ *	RtlUnicodeStringToInteger (NTDLL.@)
+ *
+ *	Convert a text buffer into its integer form
+ *      FIXME: handle hexadecimal notation as well
+ */
+NTSTATUS WINAPI RtlUnicodeStringToInteger(
+	const UNICODE_STRING *str,
+	int terminator, /* FIXME: guess. don't know what this actually is: this doesn't seem to do much in Windows*/
+	int * pdest)
+{
+	LPWSTR lpwstr = str->Buffer;
+	int CharsParsed = 0;
+	int RunningTotal = 0;
+	char bMinus = 0;
+
+	// no checking done on UNICODE_STRING and int* in native DLL either
+	TRACE("(%p, %d, %p)", str, terminator, pdest);
+
+	switch (terminator)
+	{
+		case 0:
+		case 2:
+		case 8:
+		case 10:
+		case 16:
+			break;
+		default:
+			return STATUS_INVALID_PARAMETER;
+	}
+
+	*pdest = 0;
+	for (; (CharsParsed < str->Length) && (*lpwstr <= ' '); lpwstr++)
+		CharsParsed++;
+
+	if (*lpwstr == '+')
+		lpwstr++;
+	else if (*lpwstr == '-')
+		bMinus = 1;
+
+	for (; (CharsParsed < str->Length) && (*lpwstr != '\0'); lpwstr++)
+	{
+		CharsParsed++;
+		if (*lpwstr > '9' || *lpwstr < '0')
+		{
+			if (*lpwstr <= ' ')
+			{
+				// if <= ' ' then it is a control char and so we stop parsing
+				*pdest = bMinus ? 0x80000000 : 0 | RunningTotal;
+				// otherwise it is an error and we return the caller a 0 as their integer
+			}
+			return STATUS_SUCCESS;
+		}
+		// increase significance of previous digits each time
+		// we find another valid one and add on this valid one
+		RunningTotal = *lpwstr - '0' + RunningTotal * 10;
+	}
+
+	*pdest = bMinus ? 0x80000000 : 0 | RunningTotal;
+	return STATUS_SUCCESS;
+}

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux