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