update for HEAD-2003091401
[reactos.git] / drivers / net / ndis / ndis / string.c
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS NDIS library
4  * FILE:        ndis/string.c
5  * PURPOSE:     String management routines
6  * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7  * REVISIONS:
8  *   CSH 01/08-2000 Created
9  */
10 #include <ndissys.h>
11
12
13 /*
14  * @implemented
15  */
16 NDIS_STATUS
17 EXPORT
18 NdisAnsiStringToUnicodeString(
19     IN OUT  PNDIS_STRING        DestinationString,
20     IN      PANSI_STRING   SourceString)
21 /*
22  * FUNCTION: Converts an ANSI string to an NDIS (unicode) string
23  * ARGUMENTS:
24  *     DestinationString = Address of buffer to place converted string in
25  *     SourceString      = Pointer to ANSI string to be converted
26  */
27 {
28         return (NDIS_STATUS)RtlAnsiStringToUnicodeString(
29         (PUNICODE_STRING)DestinationString,
30         (PANSI_STRING)SourceString, FALSE);
31 }
32
33
34 /*
35  * @implemented
36  */
37 BOOLEAN
38 EXPORT
39 NdisEqualString(
40     IN  PNDIS_STRING    String1,
41     IN  PNDIS_STRING    String2,
42     IN  BOOLEAN         CaseInsensitive)
43 /*
44  * FUNCTION: Tests two strings for equality
45  * ARGUMENTS:
46  *     String1         = Pointer to first string
47  *     String2         = Pointer to second string
48  *     CaseInsensitive = TRUE if the compare should be case insensitive
49  */
50 {
51     return RtlEqualUnicodeString(
52         (PUNICODE_STRING)String1,
53         (PUNICODE_STRING)String2,
54         CaseInsensitive);
55 }
56
57
58 /*
59  * @implemented
60  */
61 VOID
62 EXPORT
63 NdisInitAnsiString(
64     IN OUT  PANSI_STRING   DestinationString,
65     IN      PCSTR               SourceString)
66 /*
67  * FUNCTION: Initializes an ANSI string
68  * ARGUMENTS:
69  *     DestinationString = Address of buffer to place string in
70  *     SourceString      = Pointer to null terminated ANSI string
71  */
72 {
73     RtlInitString(
74         (PANSI_STRING)DestinationString,
75         (PCSZ)SourceString);
76 }
77
78
79 /*
80  * @implemented
81  */
82 VOID
83 EXPORT
84 NdisInitializeString(
85     IN OUT  PNDIS_STRING    DestinationString,
86     IN      PUCHAR          SourceString)
87 /*
88  * FUNCTION: Initializes an NDIS (unicode) string
89  * ARGUMENTS:
90  *     DestinationString = Address of buffer to place string in
91  *     SourceString      = Pointer to null terminated ANSI string
92  */
93 {
94     ANSI_STRING AnsiString;
95
96     RtlInitAnsiString(
97         &AnsiString,
98         (PCSZ)SourceString);
99
100     RtlAnsiStringToUnicodeString(
101         (PUNICODE_STRING)DestinationString,
102         &AnsiString,
103         TRUE);
104 }
105
106
107 /*
108  * @implemented
109  */
110 VOID
111 EXPORT
112 NdisInitUnicodeString(
113     IN OUT  PNDIS_STRING    DestinationString,
114     IN      PCWSTR          SourceString)
115 /*
116  * FUNCTION: Initializes an unicode string
117  * ARGUMENTS:
118  *     DestinationString = Address of buffer to place string in
119  *     SourceString      = Pointer to null terminated unicode string
120  */
121 {
122     RtlInitUnicodeString(
123         (PUNICODE_STRING)DestinationString,
124         SourceString);
125 }
126
127
128 /*
129  * @implemented
130  */
131 NDIS_STATUS
132 EXPORT
133 NdisUnicodeStringToAnsiString(
134     IN OUT  PANSI_STRING   DestinationString,
135     IN      PNDIS_STRING        SourceString)
136 /*
137  * FUNCTION: Converts an NDIS (unicode) string to an ANSI string
138  * ARGUMENTS:
139  *     DestinationString = Address of buffer to place converted string in
140  *     SourceString      = Pointer to unicode string to be converted
141  */
142 {
143         return (NDIS_STATUS)RtlUnicodeStringToAnsiString(
144         (PANSI_STRING)DestinationString,
145         (PUNICODE_STRING)SourceString,
146         FALSE);
147 }
148
149
150 /*
151  * @implemented
152  */
153 NTSTATUS
154 EXPORT
155 NdisUpcaseUnicodeString(
156     OUT PUNICODE_STRING DestinationString,  
157     IN  PUNICODE_STRING SourceString)
158 /*
159  * FUNCTION:
160  * ARGUMENTS:
161  * NOTES:
162  *    NDIS 5.0
163  */
164 {
165   ASSERT_IRQL(PASSIVE_LEVEL);
166   // FIXME - not sure if 3rd param should be TRUE or FALSE
167   return RtlUpcaseUnicodeString ( DestinationString, SourceString, FALSE );
168 }
169
170 /* EOF */