Author: arty Date: Fri Nov 20 21:51:17 2009 New Revision: 44245
URL: http://svn.reactos.org/svn/reactos?rev=44245&view=rev Log: Take trunk definition of FsRtlIsNameInExpression.
Modified: branches/arty-newcc/ntoskrnl/fsrtl/name.c
Modified: branches/arty-newcc/ntoskrnl/fsrtl/name.c URL: http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/fsrtl/name.c... ============================================================================== --- branches/arty-newcc/ntoskrnl/fsrtl/name.c [iso-8859-1] (original) +++ branches/arty-newcc/ntoskrnl/fsrtl/name.c [iso-8859-1] Fri Nov 20 21:51:17 2009 @@ -31,7 +31,7 @@ { if ((Expression->Buffer[i] == (IgnoreCase ? UpcaseTable[Name->Buffer[k]] : Name->Buffer[k])) || (Expression->Buffer[i] == L'?') || (Expression->Buffer[i] == DOS_QM) || - (Expression->Buffer[i] == DOS_DOT && (Name->Buffer[k] == L'.' || Name->Buffer[k] == L'0'))) + (Expression->Buffer[i] == DOS_DOT && (Name->Buffer[k] == L'.' || Name->Buffer[k]== L'0'))) { k++; } @@ -304,31 +304,80 @@ IN BOOLEAN IgnoreCase, IN PWCHAR UpcaseTable OPTIONAL) { - BOOLEAN Result; - NTSTATUS Status; - UNICODE_STRING IntName; - - if (IgnoreCase && !UpcaseTable) - { - Status = RtlUpcaseUnicodeString(&IntName, Name, TRUE); - if (Status != STATUS_SUCCESS) - { - ExRaiseStatus(Status); - } - Name = &IntName; - IgnoreCase = FALSE; - } - else - { - IntName.Buffer = NULL; - } - - Result = FsRtlIsNameInExpressionPrivate(Expression, Name, IgnoreCase, UpcaseTable); - - if (IntName.Buffer != NULL) - { - RtlFreeUnicodeString(&IntName); - } - - return Result; -} + USHORT ExpressionPosition, NamePosition; + UNICODE_STRING TempExpression, TempName; + + ExpressionPosition = 0; + NamePosition = 0; + while (ExpressionPosition < (Expression->Length / sizeof(WCHAR)) && + NamePosition < (Name->Length / sizeof(WCHAR))) + { + if (Expression->Buffer[ExpressionPosition] == L'*') + { + ExpressionPosition++; + if (ExpressionPosition == (Expression->Length / sizeof(WCHAR))) + { + return TRUE; + } + while (NamePosition < (Name->Length / sizeof(WCHAR))) + { + TempExpression.Length = + TempExpression.MaximumLength = + Expression->Length - (ExpressionPosition * sizeof(WCHAR)); + TempExpression.Buffer = Expression->Buffer + ExpressionPosition; + TempName.Length = + TempName.MaximumLength = + Name->Length - (NamePosition * sizeof(WCHAR)); + TempName.Buffer = Name->Buffer + NamePosition; + /* FIXME: Rewrite to get rid of recursion */ + if (FsRtlIsNameInExpression(&TempExpression, &TempName, + IgnoreCase, UpcaseTable)) + { + return TRUE; + } + NamePosition++; + } + } + else + { + /* FIXME: Take UpcaseTable into account! */ + if (Expression->Buffer[ExpressionPosition] == L'?' || + (IgnoreCase && + RtlUpcaseUnicodeChar(Expression->Buffer[ExpressionPosition]) == + RtlUpcaseUnicodeChar(Name->Buffer[NamePosition])) || + (!IgnoreCase && + Expression->Buffer[ExpressionPosition] == + Name->Buffer[NamePosition])) + { + NamePosition++; + ExpressionPosition++; + } + else + { + return FALSE; + } + } + } + + /* Handle matching of "f0_*.*" expression to "f0_000" file name. */ + if (ExpressionPosition < (Expression->Length / sizeof(WCHAR)) && + Expression->Buffer[ExpressionPosition] == L'.') + { + while (ExpressionPosition < (Expression->Length / sizeof(WCHAR)) && + (Expression->Buffer[ExpressionPosition] == L'.' || + Expression->Buffer[ExpressionPosition] == L'*' || + Expression->Buffer[ExpressionPosition] == L'?')) + { + ExpressionPosition++; + } + } + + if (ExpressionPosition == (Expression->Length / sizeof(WCHAR)) && + NamePosition == (Name->Length / sizeof(WCHAR))) + { + return TRUE; + } + + return FALSE; +} +