mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 08:03:01 +00:00
[RTL]
- Formatting only (no code changes) svn path=/trunk/; revision=72557
This commit is contained in:
parent
6d4d06afbb
commit
76de8ee7ce
1 changed files with 248 additions and 224 deletions
|
@ -46,6 +46,7 @@ RtlpGetCheckSum(PUNICODE_STRING Name)
|
||||||
|
|
||||||
CurChar = Name->Buffer;
|
CurChar = Name->Buffer;
|
||||||
Hash = (*CurChar << 8) + *(CurChar + 1);
|
Hash = (*CurChar << 8) + *(CurChar + 1);
|
||||||
|
|
||||||
if (Name->Length == 2 * sizeof(WCHAR))
|
if (Name->Length == 2 * sizeof(WCHAR))
|
||||||
{
|
{
|
||||||
return Hash;
|
return Hash;
|
||||||
|
@ -53,15 +54,18 @@ RtlpGetCheckSum(PUNICODE_STRING Name)
|
||||||
|
|
||||||
Saved = Hash;
|
Saved = Hash;
|
||||||
Len = 2;
|
Len = 2;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CurChar = CurChar + 2;
|
CurChar = CurChar + 2;
|
||||||
Hash = (Hash << 7) + *CurChar;
|
Hash = (Hash << 7) + *CurChar;
|
||||||
Hash = (Saved >> 1) + (Hash << 8);
|
Hash = (Saved >> 1) + (Hash << 8);
|
||||||
|
|
||||||
if (Len + 1 < Name->Length / sizeof(WCHAR))
|
if (Len + 1 < Name->Length / sizeof(WCHAR))
|
||||||
{
|
{
|
||||||
Hash += *(CurChar + 1);
|
Hash += *(CurChar + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Saved = Hash;
|
Saved = Hash;
|
||||||
Len += 2;
|
Len += 2;
|
||||||
} while (Len < Name->Length / sizeof(WCHAR));
|
} while (Len < Name->Length / sizeof(WCHAR));
|
||||||
|
@ -73,11 +77,13 @@ static ULONG
|
||||||
RtlpGetIndexLength(ULONG Index)
|
RtlpGetIndexLength(ULONG Index)
|
||||||
{
|
{
|
||||||
ULONG Length = 0;
|
ULONG Length = 0;
|
||||||
|
|
||||||
while (Index)
|
while (Index)
|
||||||
{
|
{
|
||||||
Index /= 10;
|
Index /= 10;
|
||||||
Length++;
|
Length++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Length ? Length : 1;
|
return Length ? Length : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +91,8 @@ RtlpGetIndexLength(ULONG Index)
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
VOID NTAPI
|
VOID
|
||||||
|
NTAPI
|
||||||
RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
||||||
IN BOOLEAN AllowExtendedCharacters,
|
IN BOOLEAN AllowExtendedCharacters,
|
||||||
IN OUT PGENERATE_NAME_CONTEXT Context,
|
IN OUT PGENERATE_NAME_CONTEXT Context,
|
||||||
|
@ -106,6 +113,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
||||||
WCHAR c;
|
WCHAR c;
|
||||||
|
|
||||||
StrLength = Name->Length / sizeof(WCHAR);
|
StrLength = Name->Length / sizeof(WCHAR);
|
||||||
|
|
||||||
DPRINT("StrLength: %lu\n", StrLength);
|
DPRINT("StrLength: %lu\n", StrLength);
|
||||||
|
|
||||||
/* Find last dot in Name */
|
/* Find last dot in Name */
|
||||||
|
@ -156,6 +164,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
||||||
for (i = DotPos, ExtLength = 0; ExtLength < 4 && i < StrLength; i++)
|
for (i = DotPos, ExtLength = 0; ExtLength < 4 && i < StrLength; i++)
|
||||||
{
|
{
|
||||||
c = UNICODE_NULL;
|
c = UNICODE_NULL;
|
||||||
|
|
||||||
if (AllowExtendedCharacters)
|
if (AllowExtendedCharacters)
|
||||||
{
|
{
|
||||||
c = RtlUpcaseUnicodeChar(Name->Buffer[i]);
|
c = RtlUpcaseUnicodeChar(Name->Buffer[i]);
|
||||||
|
@ -183,6 +192,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
||||||
{
|
{
|
||||||
ExtLength = 0;
|
ExtLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("ExtBuffer: '%.04S'\n", ExtBuffer);
|
DPRINT("ExtBuffer: '%.04S'\n", ExtBuffer);
|
||||||
DPRINT("ExtLength: %lu\n", ExtLength);
|
DPRINT("ExtLength: %lu\n", ExtLength);
|
||||||
|
|
||||||
|
@ -209,6 +219,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
||||||
(Context->LastIndexValue < 999))
|
(Context->LastIndexValue < 999))
|
||||||
{
|
{
|
||||||
Context->LastIndexValue++;
|
Context->LastIndexValue++;
|
||||||
|
|
||||||
if (Context->CheckSumInserted == FALSE &&
|
if (Context->CheckSumInserted == FALSE &&
|
||||||
Context->LastIndexValue > 9)
|
Context->LastIndexValue > 9)
|
||||||
{
|
{
|
||||||
|
@ -220,6 +231,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Context->LastIndexValue = 1;
|
Context->LastIndexValue = 1;
|
||||||
|
|
||||||
if (NameLength == 0)
|
if (NameLength == 0)
|
||||||
{
|
{
|
||||||
Context->CheckSumInserted = TRUE;
|
Context->CheckSumInserted = TRUE;
|
||||||
|
@ -246,25 +258,32 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
||||||
|
|
||||||
/* Build the short name */
|
/* Build the short name */
|
||||||
memcpy(Name8dot3->Buffer, NameBuffer, CopyLength * sizeof(WCHAR));
|
memcpy(Name8dot3->Buffer, NameBuffer, CopyLength * sizeof(WCHAR));
|
||||||
|
|
||||||
j = CopyLength;
|
j = CopyLength;
|
||||||
|
|
||||||
if (Context->CheckSumInserted)
|
if (Context->CheckSumInserted)
|
||||||
{
|
{
|
||||||
Checksum = Context->Checksum;
|
Checksum = Context->Checksum;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
Name8dot3->Buffer[j++] = (Checksum & 0xF) > 9 ? (Checksum & 0xF) + L'A' - 10 : (Checksum & 0xF) + L'0';
|
Name8dot3->Buffer[j++] = (Checksum & 0xF) > 9 ? (Checksum & 0xF) + L'A' - 10 : (Checksum & 0xF) + L'0';
|
||||||
Checksum >>= 4;
|
Checksum >>= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
j = CopyLength + 4;
|
j = CopyLength + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
Name8dot3->Buffer[j++] = L'~';
|
Name8dot3->Buffer[j++] = L'~';
|
||||||
j += IndexLength - 1;
|
j += IndexLength - 1;
|
||||||
CurrentIndex = Context->LastIndexValue;
|
CurrentIndex = Context->LastIndexValue;
|
||||||
|
|
||||||
for (i = 0; i < IndexLength; i++)
|
for (i = 0; i < IndexLength; i++)
|
||||||
{
|
{
|
||||||
Name8dot3->Buffer[j--] = (CurrentIndex % 10) + L'0';
|
Name8dot3->Buffer[j--] = (CurrentIndex % 10) + L'0';
|
||||||
CurrentIndex /= 10;
|
CurrentIndex /= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
j += IndexLength + 1;
|
j += IndexLength + 1;
|
||||||
|
|
||||||
memcpy(Name8dot3->Buffer + j, ExtBuffer, ExtLength * sizeof(WCHAR));
|
memcpy(Name8dot3->Buffer + j, ExtBuffer, ExtLength * sizeof(WCHAR));
|
||||||
|
@ -275,6 +294,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
||||||
/* Update context */
|
/* Update context */
|
||||||
Context->NameLength = (UCHAR)CopyLength;
|
Context->NameLength = (UCHAR)CopyLength;
|
||||||
Context->ExtensionLength = ExtLength;
|
Context->ExtensionLength = ExtLength;
|
||||||
|
|
||||||
memcpy(Context->NameBuffer, NameBuffer, CopyLength * sizeof(WCHAR));
|
memcpy(Context->NameBuffer, NameBuffer, CopyLength * sizeof(WCHAR));
|
||||||
memcpy(Context->ExtensionBuffer, ExtBuffer, ExtLength * sizeof(WCHAR));
|
memcpy(Context->ExtensionBuffer, ExtBuffer, ExtLength * sizeof(WCHAR));
|
||||||
}
|
}
|
||||||
|
@ -290,10 +310,9 @@ _Must_inspect_result_
|
||||||
NTSYSAPI
|
NTSYSAPI
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlIsNameLegalDOS8Dot3 (
|
RtlIsNameLegalDOS8Dot3(IN PCUNICODE_STRING Name,
|
||||||
_In_ PCUNICODE_STRING Name,
|
IN OUT POEM_STRING OemName,
|
||||||
_Inout_opt_ POEM_STRING OemName,
|
OUT PBOOLEAN NameContainsSpaces OPTIONAL)
|
||||||
_Out_opt_ PBOOLEAN NameContainsSpaces)
|
|
||||||
{
|
{
|
||||||
static const char Illegal[] = "*?<>|\"+=,;[]:/\\\345";
|
static const char Illegal[] = "*?<>|\"+=,;[]:/\\\345";
|
||||||
int Dot = -1;
|
int Dot = -1;
|
||||||
|
@ -322,6 +341,7 @@ RtlIsNameLegalDOS8Dot3 (
|
||||||
{
|
{
|
||||||
if (OemName->Length != 1 && (OemName->Length != 2 || OemName->Buffer[1] != '.')) return FALSE;
|
if (OemName->Length != 1 && (OemName->Length != 2 || OemName->Buffer[1] != '.')) return FALSE;
|
||||||
if (NameContainsSpaces) *NameContainsSpaces = FALSE;
|
if (NameContainsSpaces) *NameContainsSpaces = FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,10 +354,12 @@ RtlIsNameLegalDOS8Dot3 (
|
||||||
if (!i || i == OemName->Length-1 || OemName->Buffer[i+1] == '.') return FALSE;
|
if (!i || i == OemName->Length-1 || OemName->Buffer[i+1] == '.') return FALSE;
|
||||||
GotSpace = TRUE;
|
GotSpace = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '.':
|
case '.':
|
||||||
if (Dot != -1) return FALSE;
|
if (Dot != -1) return FALSE;
|
||||||
Dot = i;
|
Dot = i;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (strchr(Illegal, OemName->Buffer[i])) return FALSE;
|
if (strchr(Illegal, OemName->Buffer[i])) return FALSE;
|
||||||
break;
|
break;
|
||||||
|
@ -354,7 +376,9 @@ RtlIsNameLegalDOS8Dot3 (
|
||||||
{
|
{
|
||||||
if (Dot > 8 || (OemName->Length - Dot > 4) || Dot == OemName->Length - 1) return FALSE;
|
if (Dot > 8 || (OemName->Length - Dot > 4) || Dot == OemName->Length - 1) return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NameContainsSpaces) *NameContainsSpaces = GotSpace;
|
if (NameContainsSpaces) *NameContainsSpaces = GotSpace;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue