1 /* $Id: name.c,v 1.10 2004/08/18 02:32:00 navaraf Exp $
3 * reactos/ntoskrnl/fs/name.c
11 PUCHAR
* FsRtlLegalAnsiCharacterArray
= NULL
;
13 /**********************************************************************
15 * FsRtlAreNamesEqual@16
24 * From Bo Branten's ntifs.h v25.
29 FsRtlAreNamesEqual (IN PUNICODE_STRING Name1
,
30 IN PUNICODE_STRING Name2
,
31 IN BOOLEAN IgnoreCase
,
32 IN PWCHAR UpcaseTable OPTIONAL
)
38 /**********************************************************************
43 * Dissects a given path name into first and remaining part.
47 * Unicode string to dissect.
50 * Pointer to user supplied UNICODE_STRING, that will
51 * later point to the first part of the original name.
54 * Pointer to user supplied UNICODE_STRING, that will
55 * later point to the remaining part of the original name.
61 * Name: \test1\test2\test3
63 * RemainingPart: test2\test3
68 FsRtlDissectName (IN UNICODE_STRING Name
,
69 OUT PUNICODE_STRING FirstPart
,
70 OUT PUNICODE_STRING RemainingPart
)
72 USHORT NameOffset
= 0;
73 USHORT NameLength
= 0;
76 FirstPart
->Length
= 0;
77 FirstPart
->MaximumLength
= 0;
78 FirstPart
->Buffer
= NULL
;
80 RemainingPart
->Length
= 0;
81 RemainingPart
->MaximumLength
= 0;
82 RemainingPart
->Buffer
= NULL
;
87 /* Skip leading backslash */
88 if (Name
.Buffer
[0] == L
'\\')
91 Length
= Name
.Length
/ sizeof(WCHAR
);
93 /* Search for next backslash or end-of-string */
94 while ((NameOffset
+ NameLength
< Length
) &&
95 (Name
.Buffer
[NameOffset
+ NameLength
] != L
'\\'))
101 FirstPart
->MaximumLength
= NameLength
* sizeof(WCHAR
);
102 FirstPart
->Buffer
= &Name
.Buffer
[NameOffset
];
104 NameOffset
+= NameLength
+ 1;
105 if (NameOffset
< Length
)
107 RemainingPart
->Length
= (Length
- NameOffset
) * sizeof(WCHAR
);
108 RemainingPart
->MaximumLength
= (Length
- NameOffset
) * sizeof(WCHAR
);
109 RemainingPart
->Buffer
= &Name
.Buffer
[NameOffset
];
114 /**********************************************************************
116 * FsRtlDoesNameContainWildCards@4
125 * From Bo Branten's ntifs.h v12.
130 FsRtlDoesNameContainWildCards (IN PUNICODE_STRING Name
)
134 if (Name
->Length
== 0)
137 /* Set pointer to last character of the string */
138 Ptr
= Name
->Buffer
+ (Name
->Length
/ sizeof(WCHAR
));
140 while (Ptr
>= Name
->Buffer
)
142 /* Stop at backslash */
146 /* Check for wildcards */
148 (*Ptr
== L
'\"' || *Ptr
== L
'*' || *Ptr
== L
'<' ||
149 *Ptr
== L
'>' || *Ptr
== L
'?'))
152 /* Move to previous character */
160 /**********************************************************************
162 * FsRtlIsNameInExpression@16
171 * From Bo Branten's ntifs.h v12.
176 FsRtlIsNameInExpression (IN PUNICODE_STRING Expression
,
177 IN PUNICODE_STRING Name
,
178 IN BOOLEAN IgnoreCase
,
179 IN PWCHAR UpcaseTable OPTIONAL
)
181 USHORT ExpressionPosition
, NamePosition
;
182 UNICODE_STRING TempExpression
, TempName
;
184 ExpressionPosition
= 0;
186 while (ExpressionPosition
< (Expression
->Length
/ sizeof(WCHAR
)) &&
187 NamePosition
< (Name
->Length
/ sizeof(WCHAR
)))
189 if (Expression
->Buffer
[ExpressionPosition
] == L
'*')
191 ExpressionPosition
++;
192 if (ExpressionPosition
== (Expression
->Length
/ sizeof(WCHAR
)))
196 while (NamePosition
< (Name
->Length
/ sizeof(WCHAR
)))
198 TempExpression
.Length
=
199 TempExpression
.MaximumLength
=
200 Expression
->Length
- (ExpressionPosition
* sizeof(WCHAR
));
201 TempExpression
.Buffer
= Expression
->Buffer
+ ExpressionPosition
;
203 TempName
.MaximumLength
=
204 Name
->Length
- (NamePosition
* sizeof(WCHAR
));
205 TempName
.Buffer
= Name
->Buffer
+ NamePosition
;
206 /* FIXME: Rewrite to get rid of recursion */
207 if (FsRtlIsNameInExpression(&TempExpression
, &TempName
,
208 IgnoreCase
, UpcaseTable
))
216 /* FIXME: Take UpcaseTable into account! */
217 if (Expression
->Buffer
[ExpressionPosition
] == L
'?' ||
219 RtlUpcaseUnicodeChar(Expression
->Buffer
[ExpressionPosition
]) ==
220 RtlUpcaseUnicodeChar(Name
->Buffer
[NamePosition
])) ||
222 Expression
->Buffer
[ExpressionPosition
] ==
223 Name
->Buffer
[NamePosition
]))
226 ExpressionPosition
++;
234 if (ExpressionPosition
== (Expression
->Length
/ sizeof(WCHAR
)) &&
235 NamePosition
== (Name
->Length
/ sizeof(WCHAR
)))