Author: tfaber
Date: Sat Feb 7 10:07:24 2015
New Revision: 66187
URL:
http://svn.reactos.org/svn/reactos?rev=66187&view=rev
Log:
[RTL]
- Implement RtlIpv4StringToAddressA and RtlIpv4StringToAddressExA using their -W
counterparts
CORE-6490
Modified:
trunk/reactos/lib/rtl/network.c
Modified: trunk/reactos/lib/rtl/network.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/network.c?rev=6618…
==============================================================================
--- trunk/reactos/lib/rtl/network.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/network.c [iso-8859-1] Sat Feb 7 10:07:24 2015
@@ -131,31 +131,70 @@
}
/*
- * @unimplemented
- */
-NTSTATUS
-NTAPI
-RtlIpv4StringToAddressA(IN PCSTR String,
- IN BOOLEAN Strict,
- OUT PCSTR *Terminator,
- OUT struct in_addr *Addr)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
-
-/*
-* @unimplemented
-*/
-NTSTATUS
-NTAPI
-RtlIpv4StringToAddressExA(IN PCSTR AddressString,
- IN BOOLEAN Strict,
- OUT struct in_addr *Address,
- OUT PUSHORT Port)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+RtlIpv4StringToAddressA(
+ _In_ PCSTR String,
+ _In_ BOOLEAN Strict,
+ _Out_ PCSTR *Terminator,
+ _Out_ struct in_addr *Addr)
+{
+ NTSTATUS Status;
+ ANSI_STRING AddressA;
+ UNICODE_STRING AddressW;
+ PCWSTR TerminatorW = NULL;
+
+ Status = RtlInitAnsiStringEx(&AddressA, String);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ Status = RtlAnsiStringToUnicodeString(&AddressW, &AddressA, TRUE);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ Status = RtlIpv4StringToAddressW(AddressW.Buffer,
+ Strict,
+ &TerminatorW,
+ Addr);
+
+ ASSERT(TerminatorW >= AddressW.Buffer);
+ *Terminator = String + (TerminatorW - AddressW.Buffer);
+
+ RtlFreeUnicodeString(&AddressW);
+
+ return Status;
+}
+
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+RtlIpv4StringToAddressExA(
+ _In_ PCSTR AddressString,
+ _In_ BOOLEAN Strict,
+ _Out_ struct in_addr *Address,
+ _Out_ PUSHORT Port)
+{
+ NTSTATUS Status;
+ ANSI_STRING AddressA;
+ UNICODE_STRING AddressW;
+
+ Status = RtlInitAnsiStringEx(&AddressA, AddressString);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ Status = RtlAnsiStringToUnicodeString(&AddressW, &AddressA, TRUE);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ Status = RtlIpv4StringToAddressExW(AddressW.Buffer, Strict, Address, Port);
+
+ RtlFreeUnicodeString(&AddressW);
+
+ return Status;
}
/*