86602ebc29bb459cd821cad988fa74d8f32c641d
[reactos.git] / reactos / 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 * Vizzini (vizzini@plasmic.com)
8 * REVISIONS:
9 * CSH 01/08-2000 Created
10 * Vizzini 08-Oct-2003 Error checking, documentation, and formatting
11 */
12
13 #include "ndissys.h"
14
15 \f
16 /*
17 * @implemented
18 */
19 NDIS_STATUS
20 EXPORT
21 NdisAnsiStringToUnicodeString(
22 IN OUT PNDIS_STRING DestinationString,
23 IN PANSI_STRING SourceString)
24 /*
25 * FUNCTION: Converts an ANSI string to an NDIS (unicode) string
26 * ARGUMENTS:
27 * DestinationString = Address of buffer to place converted string in
28 * SourceString = Pointer to ANSI string to be converted
29 * NOTES:
30 * - caller must be running at IRQL = PASSIVE_LEVEL
31 */
32 {
33 PAGED_CODE();
34 ASSERT(DestinationString);
35 ASSERT(SourceString);
36
37 return (NDIS_STATUS)RtlAnsiStringToUnicodeString(
38 (PUNICODE_STRING)DestinationString,
39 (PANSI_STRING)SourceString, FALSE);
40 }
41
42 #undef NdisEqualString
43
44 \f
45 /*
46 * @implemented
47 */
48 BOOLEAN
49 EXPORT
50 NdisEqualString(
51 IN PNDIS_STRING String1,
52 IN PNDIS_STRING String2,
53 IN BOOLEAN CaseInsensitive)
54 /*
55 * FUNCTION: Tests two strings for equality
56 * ARGUMENTS:
57 * String1 = Pointer to first string
58 * String2 = Pointer to second string
59 * CaseInsensitive = TRUE if the compare should be case insensitive
60 * NOTES:
61 * - caller must be at IRQL = PASSIVE_LEVEL
62 */
63 {
64 PAGED_CODE();
65 ASSERT(String1);
66 ASSERT(String2);
67
68 return RtlEqualUnicodeString((PUNICODE_STRING)String1,
69 (PUNICODE_STRING)String2,
70 CaseInsensitive);
71 }
72
73 \f
74 /*
75 * @implemented
76 */
77 VOID
78 EXPORT
79 NdisInitAnsiString(
80 IN OUT PANSI_STRING DestinationString,
81 IN PCSTR SourceString)
82 /*
83 * FUNCTION: Initializes an ANSI string
84 * ARGUMENTS:
85 * DestinationString = Address of buffer to place string in
86 * SourceString = Pointer to null terminated ANSI string
87 * NOTES:
88 * - Caller must be at IRQL <= DISPATCH_LEVEL
89 */
90 {
91 ASSERT(DestinationString);
92 ASSERT(SourceString);
93
94 RtlInitString((PANSI_STRING)DestinationString, (PCSZ)SourceString);
95 }
96
97 \f
98 /*
99 * @implemented
100 */
101 VOID
102 EXPORT
103 NdisInitializeString(
104 IN OUT PNDIS_STRING DestinationString,
105 IN PUCHAR SourceString)
106 /*
107 * FUNCTION: Initializes an NDIS (unicode) string
108 * ARGUMENTS:
109 * DestinationString = Address of buffer to place string in
110 * SourceString = Pointer to null terminated ANSI string
111 * NOTES:
112 * - Must be called at IRQL = PASSIVE_LEVEL
113 */
114 {
115 ANSI_STRING AnsiString;
116
117 PAGED_CODE();
118 ASSERT(DestinationString);
119 ASSERT(SourceString);
120
121 RtlInitAnsiString(&AnsiString, (PCSZ)SourceString);
122
123 RtlAnsiStringToUnicodeString((PUNICODE_STRING)DestinationString, &AnsiString, TRUE);
124 }
125
126 \f
127 /*
128 * @implemented
129 */
130 VOID
131 EXPORT
132 NdisInitUnicodeString(
133 IN OUT PNDIS_STRING DestinationString,
134 IN PCWSTR SourceString)
135 /*
136 * FUNCTION: Initializes an unicode string
137 * ARGUMENTS:
138 * DestinationString = Address of buffer to place string in
139 * SourceString = Pointer to null terminated unicode string
140 * NOTES:
141 * - call with IRQL <= DISPATCH_LEVEL
142 */
143 {
144 ASSERT(DestinationString);
145 ASSERT(SourceString);
146
147 RtlInitUnicodeString((PUNICODE_STRING)DestinationString, SourceString);
148 }
149
150 \f
151 /*
152 * @implemented
153 */
154 NDIS_STATUS
155 EXPORT
156 NdisUnicodeStringToAnsiString(
157 IN OUT PANSI_STRING DestinationString,
158 IN PNDIS_STRING SourceString)
159 /*
160 * FUNCTION: Converts an NDIS (unicode) string to an ANSI string
161 * ARGUMENTS:
162 * DestinationString = Address of buffer to place converted string in
163 * SourceString = Pointer to unicode string to be converted
164 * NOTES:
165 * - must be called at IRQL = PASSIVE_LEVEL
166 */
167 {
168 PAGED_CODE();
169 ASSERT(DestinationString);
170 ASSERT(SourceString);
171
172 return (NDIS_STATUS)RtlUnicodeStringToAnsiString(
173 (PANSI_STRING)DestinationString,
174 (PUNICODE_STRING)SourceString,
175 FALSE);
176 }
177
178 \f
179 /*
180 * @implemented
181 */
182 NTSTATUS
183 EXPORT
184 NdisUpcaseUnicodeString(
185 OUT PUNICODE_STRING DestinationString,
186 IN PUNICODE_STRING SourceString)
187 /*
188 * FUNCTION: Uppercase a UNICODE string
189 * ARGUMENTS:
190 * DestinationString: caller-allocated space for the uppercased string
191 * SourceString: string to be uppercased
192 * NOTES:
193 * - Currently requires caller to allocate destination string - XXX is this right?
194 * - callers must be running at IRQL = PASSIVE_LEVEL
195 */
196 {
197 PAGED_CODE();
198 ASSERT(SourceString);
199 ASSERT(DestinationString);
200
201 return RtlUpcaseUnicodeString (DestinationString, SourceString, FALSE );
202 }
203
204 /* EOF */
205