[NET/USE]

On enumeration, don't print raw status

svn path=/trunk/; revision=73449
This commit is contained in:
Pierre Schweitzer
2016-12-11 10:23:02 +00:00
parent 332071647d
commit 0afae481fa
9 changed files with 34 additions and 14 deletions
+26 -14
View File
@@ -63,6 +63,21 @@ EnumerateConnections(LPCWSTR Local)
return 0;
}
static
VOID
PrintError(DWORD Status)
{
LPWSTR Buffer;
ConResPrintf(StdErr, IDS_ERROR_SYSTEM_ERROR, Status);
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, Status, 0, (LPWSTR)&Buffer, 0, NULL))
{
ConPrintf(StdErr, L"\n%s", Buffer);
LocalFree(Buffer);
}
}
INT
cmdUse(
INT argc,
@@ -73,7 +88,11 @@ cmdUse(
if (argc == 2)
{
Status = EnumerateConnections(NULL);
ConPrintf(StdOut, L"Status: %lu\n", Status);
if (Status == NO_ERROR)
ConResPrintf(StdOut, IDS_ERROR_NO_ERROR);
else
PrintError(Status);
return 0;
}
else if (argc == 3)
@@ -92,7 +111,11 @@ cmdUse(
}
Status = EnumerateConnections(argv[2]);
ConPrintf(StdOut, L"Status: %lu\n", Status);
if (Status == NO_ERROR)
ConResPrintf(StdOut, IDS_ERROR_NO_ERROR);
else
PrintError(Status);
return 0;
}
@@ -100,7 +123,6 @@ cmdUse(
if (Len != 1 && Len != 2)
{
ConResPrintf(StdErr, IDS_ERROR_INVALID_OPTION_VALUE, L"DeviceName");
ConPrintf(StdOut, L"Len: %lu\n", Len);
return 1;
}
@@ -192,17 +214,7 @@ cmdUse(
if (argv[2][0] == L'*' && Status == NO_ERROR && OutFlags == CONNECT_LOCALDRIVE)
ConResPrintf(StdOut, IDS_USE_NOW_CONNECTED, argv[3], Access);
else if (Status != NO_ERROR)
{
LPWSTR Buffer;
ConResPrintf(StdErr, IDS_ERROR_SYSTEM_ERROR, Status);
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, Status, 0, (LPWSTR)&Buffer, 0, NULL))
{
ConPrintf(StdErr, L"\n%s\n", Buffer);
LocalFree(Buffer);
}
}
PrintError(Status);
return Status;
}
@@ -123,4 +123,5 @@ BEGIN
IDS_ERROR_OPTION_NOT_SUPPORTED "The %s option is not supported yet.\n"
IDS_ERROR_INVALID_OPTION_VALUE "You entered an invalid value for the %s option.\n"
IDS_ERROR_SYSTEM_ERROR "The system error %d happened.\n"
IDS_ERROR_NO_ERROR "The command got executed successfully.\n"
END
@@ -126,4 +126,5 @@ BEGIN
IDS_ERROR_OPTION_NOT_SUPPORTED "La opción %s todavía no está disponible.\n"
IDS_ERROR_INVALID_OPTION_VALUE "El valor para la opción %s no es válido.\n"
IDS_ERROR_SYSTEM_ERROR "The system error %d happened.\n"
IDS_ERROR_NO_ERROR "The command got executed successfully.\n"
END
@@ -129,4 +129,5 @@ BEGIN
IDS_ERROR_OPTION_NOT_SUPPORTED "Opţiunea %s încă nu este admisă.\n"
IDS_ERROR_INVALID_OPTION_VALUE "Aţi introdus o valoare nevalidă pentru opţiunea %s.\n"
IDS_ERROR_SYSTEM_ERROR "The system error %d happened.\n"
IDS_ERROR_NO_ERROR "The command got executed successfully.\n"
END
@@ -125,4 +125,5 @@ BEGIN
IDS_ERROR_OPTION_NOT_SUPPORTED "Опция %s в данный момент не поддерживается.\n"
IDS_ERROR_INVALID_OPTION_VALUE "Вы ввели неверный данные для данной опции %s.\n"
IDS_ERROR_SYSTEM_ERROR "The system error %d happened.\n"
IDS_ERROR_NO_ERROR "The command got executed successfully.\n"
END
@@ -125,4 +125,5 @@ BEGIN
IDS_ERROR_OPTION_NOT_SUPPORTED "%s seçeneği daha desteklenmiyor.\n"
IDS_ERROR_INVALID_OPTION_VALUE "%s seçeneği için geçersiz bir değer girdiniz.\n"
IDS_ERROR_SYSTEM_ERROR "The system error %d happened.\n"
IDS_ERROR_NO_ERROR "The command got executed successfully.\n"
END
@@ -125,4 +125,5 @@ BEGIN
IDS_ERROR_OPTION_NOT_SUPPORTED "尚不支持 %s 选项。\n"
IDS_ERROR_INVALID_OPTION_VALUE "Y您输入了无效的值为 %s 选项。\n"
IDS_ERROR_SYSTEM_ERROR "The system error %d happened.\n"
IDS_ERROR_NO_ERROR "The command got executed successfully.\n"
END
@@ -125,4 +125,5 @@ BEGIN
IDS_ERROR_OPTION_NOT_SUPPORTED "尚不支援 %s 選項。\n"
IDS_ERROR_INVALID_OPTION_VALUE "您輸入了無效的值為 %s 選項。\n"
IDS_ERROR_SYSTEM_ERROR "The system error %d happened.\n"
IDS_ERROR_NO_ERROR "The command got executed successfully.\n"
END
@@ -103,3 +103,4 @@
#define IDS_ERROR_OPTION_NOT_SUPPORTED 700
#define IDS_ERROR_INVALID_OPTION_VALUE 701
#define IDS_ERROR_SYSTEM_ERROR 702
#define IDS_ERROR_NO_ERROR 703