[NET] Improve displaying status message (#4096)

- Simplify conditions
- Add application error translation function

[NET][MC] Add missing Russian (ru-RU) translation
This commit is contained in:
Marat Nagayev 2022-01-13 15:10:55 +00:00 committed by GitHub
parent cde6339155
commit 073607c237
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 13 deletions

View file

@ -1218,13 +1218,13 @@ cmdUser(
if (lpUserName == NULL && lpPassword == NULL)
{
Status = EnumerateUsers();
ConPrintf(StdOut, L"Status: %lu\n", Status);
PrintMessageString(TranslateAppMessage(Status));
return 0;
}
else if (lpUserName != NULL && lpPassword == NULL && argc == 3)
{
Status = DisplayUser(lpUserName);
ConPrintf(StdOut, L"Status: %lu\n", Status);
PrintMessageString(TranslateAppMessage(Status));
return 0;
}
@ -1250,12 +1250,12 @@ cmdUser(
(LPBYTE*)&pUserInfo);
if (Status != NERR_Success)
{
ConPrintf(StdOut, L"Status: %lu\n", Status);
PrintMessageString(TranslateAppMessage(Status));
result = 1;
goto done;
}
}
else if (bAdd && !bDelete)
else if (bAdd)
{
/* Add the user */
ZeroMemory(&UserInfo, sizeof(USER_INFO_4));
@ -1410,7 +1410,7 @@ cmdUser(
}
else
{
ConPrintf(StdOut, L"Status %lu\n\n", Status);
PrintMessageString(TranslateAppMessage(Status));
result = 1;
goto done;
}
@ -1426,25 +1426,24 @@ cmdUser(
4,
(LPBYTE)pUserInfo,
NULL);
ConPrintf(StdOut, L"Status: %lu\n", Status);
}
else if (bAdd && !bDelete)
else if (bAdd)
{
/* Add the user */
Status = NetUserAdd(NULL,
4,
(LPBYTE)pUserInfo,
NULL);
ConPrintf(StdOut, L"Status: %lu\n", Status);
}
else if (!bAdd && bDelete)
else if (bDelete)
{
/* Delete the user */
Status = NetUserDel(NULL,
lpUserName);
ConPrintf(StdOut, L"Status: %lu\n", Status);
}
PrintMessageString(TranslateAppMessage(Status));
if (Status == NERR_Success &&
lpPassword != NULL &&
bRandomPassword == TRUE)

View file

@ -75,6 +75,20 @@ PrintPadding(
}
DWORD
TranslateAppMessage(
DWORD dwMessage)
{
switch (dwMessage)
{
case NERR_Success:
return 3500; // APPERR_3500
case ERROR_MORE_DATA:
return 3513; // APPERR_3513
}
return dwMessage;
}
VOID
PrintMessageStringV(
DWORD dwMessage,

View file

@ -38,6 +38,10 @@ PrintPadding(
WCHAR chr,
INT nPaddedLength);
DWORD
TranslateAppMessage(
DWORD dwMessage);
VOID
PrintMessageString(
DWORD dwMessage);

View file

@ -2409,7 +2409,7 @@ Language=Romanian
The user name could not be found.
.
Language=Russian
The user name could not be found.
Не найдено имя пользователя.
.
Language=Spanish
The user name could not be found.
@ -2467,7 +2467,7 @@ Language=Romanian
The group already exists.
.
Language=Russian
The group already exists.
Указанная группа уже существует.
.
Language=Spanish
The group already exists.
@ -2496,7 +2496,7 @@ Language=Romanian
The account already exists.
.
Language=Russian
The account already exists.
Учётная запись уже существует.
.
Language=Spanish
The account already exists.