e53e826502f0cb8a131a28bcae6ad382d8674973
[reactos.git] / reactos / ntoskrnl / fs / name.c
1 /* $Id: name.c,v 1.9 2004/08/15 16:39:02 chorns Exp $
2 *
3 * reactos/ntoskrnl/fs/name.c
4 *
5 */
6
7 #include <ntoskrnl.h>
8
9 /* DATA */
10
11 PUCHAR * FsRtlLegalAnsiCharacterArray = NULL;
12
13
14 /**********************************************************************
15 * NAME EXPORTED
16 * FsRtlAreNamesEqual@16
17 *
18 * DESCRIPTION
19 *
20 * ARGUMENTS
21 *
22 * RETURN VALUE
23 *
24 * NOTE
25 * From Bo Branten's ntifs.h v25.
26 *
27 * @unimplemented
28 */
29 BOOLEAN STDCALL
30 FsRtlAreNamesEqual (IN PUNICODE_STRING Name1,
31 IN PUNICODE_STRING Name2,
32 IN BOOLEAN IgnoreCase,
33 IN PWCHAR UpcaseTable OPTIONAL)
34 {
35 return FALSE;
36 }
37
38
39 /**********************************************************************
40 * NAME EXPORTED
41 * FsRtlDissectName@16
42 *
43 * DESCRIPTION
44 * Dissects a given path name into first and remaining part.
45 *
46 * ARGUMENTS
47 * Name
48 * Unicode string to dissect.
49 *
50 * FirstPart
51 * Pointer to user supplied UNICODE_STRING, that will
52 * later point to the first part of the original name.
53 *
54 * RemainingPart
55 * Pointer to user supplied UNICODE_STRING, that will
56 * later point to the remaining part of the original name.
57 *
58 * RETURN VALUE
59 * None
60 *
61 * EXAMPLE
62 * Name: \test1\test2\test3
63 * FirstPart: test1
64 * RemainingPart: test2\test3
65 *
66 * @implemented
67 */
68 VOID STDCALL
69 FsRtlDissectName (IN UNICODE_STRING Name,
70 OUT PUNICODE_STRING FirstPart,
71 OUT PUNICODE_STRING RemainingPart)
72 {
73 USHORT NameOffset = 0;
74 USHORT NameLength = 0;
75 USHORT Length;
76
77 FirstPart->Length = 0;
78 FirstPart->MaximumLength = 0;
79 FirstPart->Buffer = NULL;
80
81 RemainingPart->Length = 0;
82 RemainingPart->MaximumLength = 0;
83 RemainingPart->Buffer = NULL;
84
85 if (Name.Length == 0)
86 return;
87
88 /* Skip leading backslash */
89 if (Name.Buffer[0] == L'\\')
90 NameOffset++;
91
92 Length = Name.Length / sizeof(WCHAR);
93
94 /* Search for next backslash or end-of-string */
95 while ((NameOffset + NameLength <= Length) &&
96 (Name.Buffer[NameOffset + NameLength] != L'\\'))
97 {
98 NameLength++;
99 }
100
101 FirstPart->Length = NameLength * sizeof(WCHAR);
102 FirstPart->MaximumLength = NameLength * sizeof(WCHAR);
103 FirstPart->Buffer = &Name.Buffer[NameOffset];
104
105 NameOffset += (NameLength + 1);
106 if (NameOffset < Length)
107 {
108 RemainingPart->Length = (Length - NameOffset) * sizeof(WCHAR);
109 RemainingPart->MaximumLength = (Length - NameOffset) * sizeof(WCHAR);
110 RemainingPart->Buffer = &Name.Buffer[NameOffset];
111 }
112 }
113
114
115 /**********************************************************************
116 * NAME EXPORTED
117 * FsRtlDoesNameContainWildCards@4
118 *
119 * DESCRIPTION
120 *
121 * ARGUMENTS
122 *
123 * RETURN VALUE
124 *
125 * NOTE
126 * From Bo Branten's ntifs.h v12.
127 *
128 * @implemented
129 */
130 BOOLEAN STDCALL
131 FsRtlDoesNameContainWildCards (IN PUNICODE_STRING Name)
132 {
133 PWCHAR Ptr;
134
135 if (Name->Length == 0)
136 return FALSE;
137
138 /* Set pointer to last character of the string */
139 Ptr = (PWCHAR)((ULONG_PTR)Name->Buffer + Name->Length - sizeof(WCHAR));
140
141 while (Ptr > Name->Buffer)
142 {
143 /* Stop at backslash */
144 if (*Ptr == L'\\')
145 return FALSE;
146
147 /* Check for wildcards */
148 if ((*Ptr < L'@') &&
149 (*Ptr == L'\"' || *Ptr == L'*' || *Ptr == L'<' ||
150 *Ptr == L'>' || *Ptr == L'?'))
151 return TRUE;
152
153 /* Move to previous character */
154 Ptr--;
155 }
156
157 return FALSE;
158 }
159
160
161 /**********************************************************************
162 * NAME EXPORTED
163 * FsRtlIsNameInExpression@16
164 *
165 * DESCRIPTION
166 *
167 * ARGUMENTS
168 *
169 * RETURN VALUE
170 *
171 * NOTE
172 * From Bo Branten's ntifs.h v12.
173 *
174 * @unimplemented
175 */
176 BOOLEAN STDCALL
177 FsRtlIsNameInExpression (IN PUNICODE_STRING Expression,
178 IN PUNICODE_STRING Name,
179 IN BOOLEAN IgnoreCase,
180 IN PWCHAR UpcaseTable OPTIONAL)
181 {
182 return FALSE;
183 }
184
185 /* EOF */