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