mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
- Implement RtlFindCharInUnicodeString
- Implement RtlInitializeSListHead, RtlFirstEntrySList, RtlQueryDepthSList Based on Wine implementation svn path=/trunk/; revision=36931
This commit is contained in:
parent
7661ad3e1c
commit
df2aabc6ab
2 changed files with 187 additions and 96 deletions
|
@ -19,21 +19,33 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlInitializeSListHead(IN PSLIST_HEADER ListHead)
|
RtlInitializeSListHead(IN PSLIST_HEADER ListHead)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN64
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
|
#else
|
||||||
|
ListHead->Alignment = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PSLIST_ENTRY
|
PSLIST_ENTRY
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlFirstEntrySList(IN const SLIST_HEADER *ListHead)
|
RtlFirstEntrySList(IN const SLIST_HEADER *ListHead)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN64
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
#else
|
||||||
|
return ListHead->Next.Next;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
WORD
|
WORD
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlQueryDepthSList(IN PSLIST_HEADER ListHead)
|
RtlQueryDepthSList(IN PSLIST_HEADER ListHead)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN64
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
return ListHead->Depth;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,56 +229,56 @@ RtlCharToInteger(
|
||||||
char bMinus = 0;
|
char bMinus = 0;
|
||||||
|
|
||||||
while (*str != '\0' && *str <= ' ') {
|
while (*str != '\0' && *str <= ' ') {
|
||||||
str++;
|
str++;
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
if (*str == '+') {
|
if (*str == '+') {
|
||||||
str++;
|
str++;
|
||||||
} else if (*str == '-') {
|
} else if (*str == '-') {
|
||||||
bMinus = 1;
|
bMinus = 1;
|
||||||
str++;
|
str++;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
if (base == 0) {
|
if (base == 0) {
|
||||||
base = 10;
|
base = 10;
|
||||||
if (str[0] == '0') {
|
if (str[0] == '0') {
|
||||||
if (str[1] == 'b') {
|
if (str[1] == 'b') {
|
||||||
str += 2;
|
str += 2;
|
||||||
base = 2;
|
base = 2;
|
||||||
} else if (str[1] == 'o') {
|
} else if (str[1] == 'o') {
|
||||||
str += 2;
|
str += 2;
|
||||||
base = 8;
|
base = 8;
|
||||||
} else if (str[1] == 'x') {
|
} else if (str[1] == 'x') {
|
||||||
str += 2;
|
str += 2;
|
||||||
base = 16;
|
base = 16;
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* if */
|
} /* if */
|
||||||
} else if (base != 2 && base != 8 && base != 10 && base != 16) {
|
} else if (base != 2 && base != 8 && base != 10 && base != 16) {
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
return STATUS_ACCESS_VIOLATION;
|
return STATUS_ACCESS_VIOLATION;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
while (*str != '\0') {
|
while (*str != '\0') {
|
||||||
chCurrent = *str;
|
chCurrent = *str;
|
||||||
if (chCurrent >= '0' && chCurrent <= '9') {
|
if (chCurrent >= '0' && chCurrent <= '9') {
|
||||||
digit = chCurrent - '0';
|
digit = chCurrent - '0';
|
||||||
} else if (chCurrent >= 'A' && chCurrent <= 'Z') {
|
} else if (chCurrent >= 'A' && chCurrent <= 'Z') {
|
||||||
digit = chCurrent - 'A' + 10;
|
digit = chCurrent - 'A' + 10;
|
||||||
} else if (chCurrent >= 'a' && chCurrent <= 'z') {
|
} else if (chCurrent >= 'a' && chCurrent <= 'z') {
|
||||||
digit = chCurrent - 'a' + 10;
|
digit = chCurrent - 'a' + 10;
|
||||||
} else {
|
} else {
|
||||||
digit = -1;
|
digit = -1;
|
||||||
} /* if */
|
} /* if */
|
||||||
if (digit < 0 || digit >= (int)base) {
|
if (digit < 0 || digit >= (int)base) {
|
||||||
*value = bMinus ? -RunningTotal : RunningTotal;
|
*value = bMinus ? -RunningTotal : RunningTotal;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
RunningTotal = RunningTotal * base + digit;
|
RunningTotal = RunningTotal * base + digit;
|
||||||
str++;
|
str++;
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
*value = bMinus ? -RunningTotal : RunningTotal;
|
*value = bMinus ? -RunningTotal : RunningTotal;
|
||||||
|
@ -546,34 +546,34 @@ NTSTATUS NTAPI RtlIntegerToChar(
|
||||||
ULONG len;
|
ULONG len;
|
||||||
|
|
||||||
if (base == 0) {
|
if (base == 0) {
|
||||||
base = 10;
|
base = 10;
|
||||||
} else if (base != 2 && base != 8 && base != 10 && base != 16) {
|
} else if (base != 2 && base != 8 && base != 10 && base != 16) {
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
pos = &buffer[32];
|
pos = &buffer[32];
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
|
|
||||||
do {
|
do {
|
||||||
pos--;
|
pos--;
|
||||||
digit = value % base;
|
digit = value % base;
|
||||||
value = value / base;
|
value = value / base;
|
||||||
if (digit < 10) {
|
if (digit < 10) {
|
||||||
*pos = '0' + digit;
|
*pos = '0' + digit;
|
||||||
} else {
|
} else {
|
||||||
*pos = 'A' + digit - 10;
|
*pos = 'A' + digit - 10;
|
||||||
} /* if */
|
} /* if */
|
||||||
} while (value != 0L);
|
} while (value != 0L);
|
||||||
|
|
||||||
len = &buffer[32] - pos;
|
len = &buffer[32] - pos;
|
||||||
if (len > length) {
|
if (len > length) {
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_OVERFLOW;
|
||||||
} else if (str == NULL) {
|
} else if (str == NULL) {
|
||||||
return STATUS_ACCESS_VIOLATION;
|
return STATUS_ACCESS_VIOLATION;
|
||||||
} else if (len == length) {
|
} else if (len == length) {
|
||||||
memcpy(str, pos, len);
|
memcpy(str, pos, len);
|
||||||
} else {
|
} else {
|
||||||
memcpy(str, pos, len + 1);
|
memcpy(str, pos, len + 1);
|
||||||
} /* if */
|
} /* if */
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -800,65 +800,65 @@ RtlUnicodeStringToInteger(const UNICODE_STRING *str, /* [I] Unicode string to be
|
||||||
char bMinus = 0;
|
char bMinus = 0;
|
||||||
|
|
||||||
while (CharsRemaining >= 1 && *lpwstr <= ' ') {
|
while (CharsRemaining >= 1 && *lpwstr <= ' ') {
|
||||||
lpwstr++;
|
lpwstr++;
|
||||||
CharsRemaining--;
|
CharsRemaining--;
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
if (CharsRemaining >= 1) {
|
if (CharsRemaining >= 1) {
|
||||||
if (*lpwstr == '+') {
|
if (*lpwstr == '+') {
|
||||||
lpwstr++;
|
lpwstr++;
|
||||||
CharsRemaining--;
|
CharsRemaining--;
|
||||||
} else if (*lpwstr == '-') {
|
} else if (*lpwstr == '-') {
|
||||||
bMinus = 1;
|
bMinus = 1;
|
||||||
lpwstr++;
|
lpwstr++;
|
||||||
CharsRemaining--;
|
CharsRemaining--;
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
if (base == 0) {
|
if (base == 0) {
|
||||||
base = 10;
|
base = 10;
|
||||||
if (CharsRemaining >= 2 && lpwstr[0] == '0') {
|
if (CharsRemaining >= 2 && lpwstr[0] == '0') {
|
||||||
if (lpwstr[1] == 'b') {
|
if (lpwstr[1] == 'b') {
|
||||||
lpwstr += 2;
|
lpwstr += 2;
|
||||||
CharsRemaining -= 2;
|
CharsRemaining -= 2;
|
||||||
base = 2;
|
base = 2;
|
||||||
} else if (lpwstr[1] == 'o') {
|
} else if (lpwstr[1] == 'o') {
|
||||||
lpwstr += 2;
|
lpwstr += 2;
|
||||||
CharsRemaining -= 2;
|
CharsRemaining -= 2;
|
||||||
base = 8;
|
base = 8;
|
||||||
} else if (lpwstr[1] == 'x') {
|
} else if (lpwstr[1] == 'x') {
|
||||||
lpwstr += 2;
|
lpwstr += 2;
|
||||||
CharsRemaining -= 2;
|
CharsRemaining -= 2;
|
||||||
base = 16;
|
base = 16;
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* if */
|
} /* if */
|
||||||
} else if (base != 2 && base != 8 && base != 10 && base != 16) {
|
} else if (base != 2 && base != 8 && base != 10 && base != 16) {
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
return STATUS_ACCESS_VIOLATION;
|
return STATUS_ACCESS_VIOLATION;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
while (CharsRemaining >= 1) {
|
while (CharsRemaining >= 1) {
|
||||||
wchCurrent = *lpwstr;
|
wchCurrent = *lpwstr;
|
||||||
if (wchCurrent >= '0' && wchCurrent <= '9') {
|
if (wchCurrent >= '0' && wchCurrent <= '9') {
|
||||||
digit = wchCurrent - '0';
|
digit = wchCurrent - '0';
|
||||||
} else if (wchCurrent >= 'A' && wchCurrent <= 'Z') {
|
} else if (wchCurrent >= 'A' && wchCurrent <= 'Z') {
|
||||||
digit = wchCurrent - 'A' + 10;
|
digit = wchCurrent - 'A' + 10;
|
||||||
} else if (wchCurrent >= 'a' && wchCurrent <= 'z') {
|
} else if (wchCurrent >= 'a' && wchCurrent <= 'z') {
|
||||||
digit = wchCurrent - 'a' + 10;
|
digit = wchCurrent - 'a' + 10;
|
||||||
} else {
|
} else {
|
||||||
digit = -1;
|
digit = -1;
|
||||||
} /* if */
|
} /* if */
|
||||||
if (digit < 0 || digit >= base) {
|
if (digit < 0 || digit >= base) {
|
||||||
*value = bMinus ? -RunningTotal : RunningTotal;
|
*value = bMinus ? -RunningTotal : RunningTotal;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
RunningTotal = RunningTotal * base + digit;
|
RunningTotal = RunningTotal * base + digit;
|
||||||
lpwstr++;
|
lpwstr++;
|
||||||
CharsRemaining--;
|
CharsRemaining--;
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
*value = bMinus ? -RunningTotal : RunningTotal;
|
*value = bMinus ? -RunningTotal : RunningTotal;
|
||||||
|
@ -2240,6 +2240,85 @@ RtlFindCharInUnicodeString(IN ULONG Flags,
|
||||||
IN PCUNICODE_STRING MatchString,
|
IN PCUNICODE_STRING MatchString,
|
||||||
OUT PUSHORT Position)
|
OUT PUSHORT Position)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
int main_idx;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
unsigned int search_idx;
|
||||||
|
|
||||||
|
switch (Flags)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
for (main_idx = 0; main_idx < SearchString->Length / sizeof(WCHAR); main_idx++)
|
||||||
|
{
|
||||||
|
for (search_idx = 0; search_idx < MatchString->Length / sizeof(WCHAR); search_idx++)
|
||||||
|
{
|
||||||
|
if (SearchString->Buffer[main_idx] == MatchString->Buffer[search_idx])
|
||||||
|
{
|
||||||
|
*Position = (main_idx + 1) * sizeof(WCHAR);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*Position = 0;
|
||||||
|
return STATUS_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
for (main_idx = SearchString->Length / sizeof(WCHAR) - 1; main_idx >= 0; main_idx--)
|
||||||
|
{
|
||||||
|
for (search_idx = 0; search_idx < MatchString->Length / sizeof(WCHAR); search_idx++)
|
||||||
|
{
|
||||||
|
if (SearchString->Buffer[main_idx] == MatchString->Buffer[search_idx])
|
||||||
|
{
|
||||||
|
*Position = main_idx * sizeof(WCHAR);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*Position = 0;
|
||||||
|
return STATUS_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
for (main_idx = 0; main_idx < SearchString->Length / sizeof(WCHAR); main_idx++)
|
||||||
|
{
|
||||||
|
search_idx = 0;
|
||||||
|
while (search_idx < MatchString->Length / sizeof(WCHAR) &&
|
||||||
|
SearchString->Buffer[main_idx] != MatchString->Buffer[search_idx])
|
||||||
|
{
|
||||||
|
search_idx++;
|
||||||
|
}
|
||||||
|
if (search_idx >= MatchString->Length / sizeof(WCHAR))
|
||||||
|
{
|
||||||
|
*Position = (main_idx + 1) * sizeof(WCHAR);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*Position = 0;
|
||||||
|
return STATUS_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
for (main_idx = SearchString->Length / sizeof(WCHAR) - 1; main_idx >= 0; main_idx--)
|
||||||
|
{
|
||||||
|
search_idx = 0;
|
||||||
|
while (search_idx < MatchString->Length / sizeof(WCHAR) &&
|
||||||
|
SearchString->Buffer[main_idx] != MatchString->Buffer[search_idx])
|
||||||
|
{
|
||||||
|
search_idx++;
|
||||||
|
}
|
||||||
|
if (search_idx >= MatchString->Length / sizeof(WCHAR))
|
||||||
|
{
|
||||||
|
*Position = main_idx * sizeof(WCHAR);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*Position = 0;
|
||||||
|
return STATUS_NOT_FOUND;
|
||||||
|
}
|
||||||
|
} /* switch */
|
||||||
|
|
||||||
|
return STATUS_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue