https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d5c74ae6fe841863b62722ff5424a1b023761e40
commit d5c74ae6fe841863b62722ff5424a1b023761e40 Author: Eric Kohl <eric.k...@reactos.org> AuthorDate: Sun Dec 23 14:16:53 2018 +0100 Commit: Eric Kohl <eric.k...@reactos.org> CommitDate: Sun Dec 23 14:18:51 2018 +0100 [NET] Load netmsg.dll right from the start and print some messages using netmsg.dll rather than local strings. @Translators: Please start translating messages from netmsgmsg.mc and errorcodes.mc (located in sdk\include\reactos\mc). They will be used instead of local strings. --- base/applications/network/net/cmdConfig.c | 2 +- base/applications/network/net/cmdGroup.c | 1 + base/applications/network/net/cmdHelpMsg.c | 17 +-------- base/applications/network/net/cmdLocalGroup.c | 1 + base/applications/network/net/cmdStatistics.c | 2 +- base/applications/network/net/cmdUse.c | 4 +-- base/applications/network/net/main.c | 51 +++++++++++++++------------ base/applications/network/net/net.h | 2 ++ 8 files changed, 38 insertions(+), 42 deletions(-) diff --git a/base/applications/network/net/cmdConfig.c b/base/applications/network/net/cmdConfig.c index 0211b9bfec..df7fce2c96 100644 --- a/base/applications/network/net/cmdConfig.c +++ b/base/applications/network/net/cmdConfig.c @@ -302,7 +302,7 @@ done: NetApiBufferFree(ServerInfo); if (result == 0) - ConResPuts(StdOut, IDS_ERROR_NO_ERROR); + PrintErrorMessage(ERROR_SUCCESS); return result; } \ No newline at end of file diff --git a/base/applications/network/net/cmdGroup.c b/base/applications/network/net/cmdGroup.c index ccb5c6cb04..4fc1e7e08d 100644 --- a/base/applications/network/net/cmdGroup.c +++ b/base/applications/network/net/cmdGroup.c @@ -255,6 +255,7 @@ cmdGroup( } else { + PrintErrorMessage(3506/*, argv[i]*/); result = 1; goto done; } diff --git a/base/applications/network/net/cmdHelpMsg.c b/base/applications/network/net/cmdHelpMsg.c index 801def5cce..faa54d2b6e 100644 --- a/base/applications/network/net/cmdHelpMsg.c +++ b/base/applications/network/net/cmdHelpMsg.c @@ -13,8 +13,6 @@ INT cmdHelpMsg(INT argc, WCHAR **argv) { - WCHAR szBuffer[MAX_PATH]; - HMODULE hMsgDll = NULL; INT i; LONG errNum; PWSTR endptr; @@ -52,20 +50,9 @@ INT cmdHelpMsg(INT argc, WCHAR **argv) if (errNum >= MIN_LANMAN_MESSAGE_ID && errNum <= MAX_LANMAN_MESSAGE_ID) { - /* Load netmsg.dll */ - GetSystemDirectoryW(szBuffer, ARRAYSIZE(szBuffer)); - wcscat(szBuffer, L"\\netmsg.dll"); - - hMsgDll = LoadLibrary(szBuffer); - if (hMsgDll == NULL) - { - ConPrintf(StdOut, L"Failed to load netmsg.dll\n"); - return 0; - } - FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY, - hMsgDll, + hModuleNetMsg, errNum, LANG_USER_DEFAULT, (LPWSTR)&pBuffer, @@ -80,8 +67,6 @@ INT cmdHelpMsg(INT argc, WCHAR **argv) { PrintErrorMessage(3871); } - - FreeLibrary(hMsgDll); } else { diff --git a/base/applications/network/net/cmdLocalGroup.c b/base/applications/network/net/cmdLocalGroup.c index 44489b377f..e6970926ee 100644 --- a/base/applications/network/net/cmdLocalGroup.c +++ b/base/applications/network/net/cmdLocalGroup.c @@ -275,6 +275,7 @@ cmdLocalGroup( } else { + PrintErrorMessage(3506/*, argv[i]*/); result = 1; goto done; } diff --git a/base/applications/network/net/cmdStatistics.c b/base/applications/network/net/cmdStatistics.c index 62bbca716c..652445ace4 100644 --- a/base/applications/network/net/cmdStatistics.c +++ b/base/applications/network/net/cmdStatistics.c @@ -294,7 +294,7 @@ cmdStatistics( } if (result == 0) - ConResPuts(StdOut, IDS_ERROR_NO_ERROR); + PrintErrorMessage(ERROR_SUCCESS); return result; } \ No newline at end of file diff --git a/base/applications/network/net/cmdUse.c b/base/applications/network/net/cmdUse.c index 59bc580a4d..1c1c479eff 100644 --- a/base/applications/network/net/cmdUse.c +++ b/base/applications/network/net/cmdUse.c @@ -109,7 +109,7 @@ cmdUse( { Status = EnumerateConnections(NULL); if (Status == NO_ERROR) - ConResPrintf(StdOut, IDS_ERROR_NO_ERROR); + PrintErrorMessage(ERROR_SUCCESS); else PrintError(Status); @@ -125,7 +125,7 @@ cmdUse( Status = EnumerateConnections(argv[2]); if (Status == NO_ERROR) - ConResPrintf(StdOut, IDS_ERROR_NO_ERROR); + PrintErrorMessage(ERROR_SUCCESS); else PrintError(Status); diff --git a/base/applications/network/net/main.c b/base/applications/network/net/main.c index 0c932a23f3..34637202c7 100644 --- a/base/applications/network/net/main.c +++ b/base/applications/network/net/main.c @@ -45,6 +45,7 @@ COMMAND cmds[] = {NULL, NULL} }; +HMODULE hModuleNetMsg = NULL; VOID @@ -80,28 +81,15 @@ VOID PrintErrorMessage( DWORD dwError) { - WCHAR szDllBuffer[MAX_PATH]; WCHAR szErrorBuffer[16]; - HMODULE hMsgDll = NULL; PWSTR pBuffer; PWSTR pErrorInserts[2] = {NULL, NULL}; - /* Load netmsg.dll */ - GetSystemDirectoryW(szDllBuffer, ARRAYSIZE(szDllBuffer)); - wcscat(szDllBuffer, L"\\netmsg.dll"); - - hMsgDll = LoadLibrary(szDllBuffer); - if (hMsgDll == NULL) - { - ConPrintf(StdErr, L"Failed to load netmsg.dll\n"); - return; - } - if (dwError >= MIN_LANMAN_MESSAGE_ID && dwError <= MAX_LANMAN_MESSAGE_ID) { FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, - hMsgDll, + hModuleNetMsg, dwError, LANG_USER_DEFAULT, (LPWSTR)&pBuffer, @@ -141,7 +129,7 @@ PrintErrorMessage( /* Format and print the 3514 message */ FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY, - hMsgDll, + hModuleNetMsg, 3514, LANG_USER_DEFAULT, (LPWSTR)&pBuffer, @@ -154,8 +142,6 @@ PrintErrorMessage( pBuffer = NULL; } } - - FreeLibrary(hMsgDll); } @@ -198,29 +184,50 @@ ReadFromConsole( int wmain(int argc, WCHAR **argv) { + WCHAR szDllBuffer[MAX_PATH]; PCOMMAND cmdptr; + int nResult = 0; + BOOL bRun = FALSE; /* Initialize the Console Standard Streams */ ConInitStdStreams(); - if (argc < 2) + /* Load netmsg.dll */ + GetSystemDirectoryW(szDllBuffer, ARRAYSIZE(szDllBuffer)); + wcscat(szDllBuffer, L"\\netmsg.dll"); + + hModuleNetMsg = LoadLibrary(szDllBuffer); + if (hModuleNetMsg == NULL) { - ConResPuts(StdOut, IDS_NET_SYNTAX); + ConPrintf(StdErr, L"Failed to load netmsg.dll\n"); return 1; } + if (argc < 2) + { + nResult = 1; + goto done; + } + /* Scan the command table */ for (cmdptr = cmds; cmdptr->name; cmdptr++) { if (_wcsicmp(argv[1], cmdptr->name) == 0) { - return cmdptr->func(argc, argv); + nResult = cmdptr->func(argc, argv); + bRun = TRUE; + break; } } - ConResPuts(StdOut, IDS_NET_SYNTAX); +done: + if (bRun == FALSE) + ConResPuts(StdOut, IDS_NET_SYNTAX); - return 1; + if (hModuleNetMsg != NULL) + FreeLibrary(hModuleNetMsg); + + return nResult; } INT unimplemented(INT argc, WCHAR **argv) diff --git a/base/applications/network/net/net.h b/base/applications/network/net/net.h index e075a55a6e..4e2f4a1518 100644 --- a/base/applications/network/net/net.h +++ b/base/applications/network/net/net.h @@ -26,6 +26,8 @@ #include "resource.h" +extern HMODULE hModuleNetMsg; + VOID PrintPaddedResourceString( UINT uID,