diff --git a/base/applications/network/tracert/CMakeLists.txt b/base/applications/network/tracert/CMakeLists.txt index 132f7fc..d06d7d5 100644 --- a/base/applications/network/tracert/CMakeLists.txt +++ b/base/applications/network/tracert/CMakeLists.txt @@ -1,5 +1,8 @@ +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) + add_executable(tracert tracert.cpp tracert.rc) set_module_type(tracert win32cui UNICODE) -add_importlibs(tracert ws2_32 iphlpapi user32 msvcrt kernel32 ntdll) +target_link_libraries(tracert conutils ${PSEH_LIB}) +add_importlibs(tracert ws2_32 iphlpapi msvcrt kernel32 ntdll) add_cd_file(TARGET tracert DESTINATION reactos/system32 FOR all) diff --git a/base/applications/network/tracert/lang/de-DE.rc b/base/applications/network/tracert/lang/de-DE.rc index dae8fce..d8285d7 100644 --- a/base/applications/network/tracert/lang/de-DE.rc +++ b/base/applications/network/tracert/lang/de-DE.rc @@ -1,37 +1,42 @@ +/* + * FILE: base/applications/network/ping/tracert/de-DE.rc + * PURPOSE: German translations for ReactOS Tracert Command + * TRANSLATORS: reactosfanboy + */ LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL STRINGTABLE BEGIN IDS_USAGE "\r\n\ -Usage: tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name \r\n\r\n\ -Options:\r\n\ - -d Do not resolve addresses to hostnames.\r\n\ - -h maximum_hops Maximum number of hops to search for target.\r\n\ - -j host-list Loose source route along host-list.\r\n\ - -w timeout Wait timeout milliseconds for each reply.\r\n\ - -4 Force using IPv4.\r\n\ - -6 Force using IPv6.\r\n\ +Syntax: tracert [-d] [-h maximum_hops] [-j Hostliste] [-w Zeitlimit] Zielname \r\n\r\n\ +Optionen:\r\n\ + -d Adressen nicht in Hostnamen auflösen.\r\n\ + -h maximum_hops Maximale Sprunganzahl bei Zielsuche.\r\n\ + -j Hostliste 'Loose Source Route' gemäß Hostliste.\r\n\ + -w Zeitlimit Zeitlimit in Millisekunden für eine Antwort.\r\n\ + -4 erzwingt IPv4.\r\n\ + -6 erzwingt IPv6.\r\n\ \r\n" - IDS_INVALID_OPTION "%1 is not a valid command option.\r\n" - IDS_TRACE_INFO "\r\nTracing route to %1 [%2]\r\nover a maximum of %3!u! hops:\r\n\r\n" - IDS_TRACE_COMPLETE "\r\nTrace complete.\r\n" - IDS_UNABLE_RESOLVE "Unable to resolve target system name %1.\r\n" + IDS_INVALID_OPTION "%s ist keine gültige Befehlsoption.\r\n" + IDS_TRACE_INFO "\r\nRoutenverfolgung zu %s [%s]\r\nüber maximal %3u Hops:\r\n\r\n" + IDS_TRACE_COMPLETE "\r\nRoutenverfolgung beendet.\r\n" + IDS_UNABLE_RESOLVE "Der Zielname %s konnte nicht aufgelöst werden.\r\n" - IDS_GEN_FAILURE "General failure.\r\n" - IDS_TRANSMIT_FAILED "Transmit failed. (Error %1!u!)\r\n" + IDS_GEN_FAILURE "Allgemeiner Fehler.\r\n" + IDS_TRANSMIT_FAILED "Übertragungsfehler. (Fehler %1u)\r\n" - IDS_HOP_COUNT "%1!3lu! %0\r\n" - IDS_HOP_TIME "%1!4lu! ms %0\r\n" - IDS_HOP_ZERO, " <1 ms %0\r\n" - IDS_TIMEOUT " * %0\r\n" - IDS_HOP_RES_INFO "%1 [%2]" - IDS_HOP_IP_INFO "%1" + IDS_HOP_COUNT "%3u " + IDS_HOP_TIME "%4u ms " + IDS_HOP_ZERO, " <1 ms " + IDS_TIMEOUT " * " + IDS_HOP_RES_INFO "%s [%s]" + IDS_HOP_IP_INFO "%s" IDS_LINEBREAK "\r\n" - IDS_REQ_TIMED_OUT "Request timed out.\r\n" - IDS_HOP_RESPONSE " reports: " - IDS_DEST_HOST_UNREACHABLE "Destination host unreachable.\r\n" - IDS_DEST_NET_UNREACHABLE "Destination network unreachable.\r\n" + IDS_REQ_TIMED_OUT "Zeitüberschreitung der Anforderung.\r\n" + IDS_HOP_RESPONSE " Antwort: " + IDS_DEST_HOST_UNREACHABLE "Zielhost nicht erreichbar.\r\n" + IDS_DEST_NET_UNREACHABLE "Zielnetz nicht erreichbar.\r\n" END diff --git a/base/applications/network/tracert/tracert.cpp b/base/applications/network/tracert/tracert.cpp index 1b52d56..081b441 100644 --- a/base/applications/network/tracert/tracert.cpp +++ b/base/applications/network/tracert/tracert.cpp @@ -14,9 +14,9 @@ #include #include #define _INC_WINDOWS -#include #include #include +#include #else #include #include @@ -48,110 +48,11 @@ struct TraceInfo } Info = { 0 }; - -#ifndef USE_CONUTILS -static -INT -LengthOfStrResource( - _In_ HINSTANCE hInst, - _In_ UINT uID -) -{ - HRSRC hrSrc; - HGLOBAL hRes; - LPWSTR lpName, lpStr; - - if (hInst == NULL) return -1; - - lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1); - - if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) && - (hRes = LoadResource(hInst, hrSrc)) && - (lpStr = (WCHAR*)LockResource(hRes))) - { - UINT x; - uID &= 0xF; - for (x = 0; x < uID; x++) - { - lpStr += (*lpStr) + 1; - } - return (int)(*lpStr); - } - return -1; -} - -static -INT -AllocAndLoadString( - _In_ UINT uID, - _Out_ LPWSTR *lpTarget -) -{ - HMODULE hInst; - INT Length; - - hInst = GetModuleHandleW(NULL); - Length = LengthOfStrResource(hInst, uID); - if (Length++ > 0) - { - (*lpTarget) = (LPWSTR)LocalAlloc(LMEM_FIXED, - Length * sizeof(WCHAR)); - if ((*lpTarget) != NULL) - { - INT Ret; - if (!(Ret = LoadStringW(hInst, uID, *lpTarget, Length))) - { - LocalFree((HLOCAL)(*lpTarget)); - } - return Ret; - } - } - return 0; -} - -static -INT -OutputText( - _In_ UINT uID, - ...) -{ - LPWSTR Format; - DWORD Ret = 0; - va_list lArgs; - - if (AllocAndLoadString(uID, &Format) > 0) - { - va_start(lArgs, uID); - - LPWSTR Buffer; - Ret = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING, - Format, - 0, - 0, - (LPWSTR)&Buffer, - 0, - &lArgs); - va_end(lArgs); - - if (Ret) - { - wprintf(Buffer); - LocalFree(Buffer); - } - LocalFree((HLOCAL)Format); - } - - return Ret; -} -#else -#define OutputText(Id, ...) ConResPrintf(StdOut, Id, __VA_ARGS__) -#endif //USE_CONUTILS - static VOID Usage() { - OutputText(IDS_USAGE); + ConResPrintf(StdOut, IDS_USAGE); } static ULONG @@ -263,11 +164,11 @@ PrintHopInfo(_In_ PVOID Buffer) { if (Resolved) { - OutputText(IDS_HOP_RES_INFO, HostName, IpAddress); + ConResPrintf(StdOut, IDS_HOP_RES_INFO, HostName, IpAddress); } else { - OutputText(IDS_HOP_IP_INFO, IpAddress); + ConResPrintf(StdOut, IDS_HOP_IP_INFO, IpAddress); } } @@ -308,11 +209,11 @@ DecodeResponse( case IP_TTL_EXPIRED_TRANSIT: if (RoundTripTime) { - OutputText(IDS_HOP_TIME, RoundTripTime); + ConResPrintf(StdOut, IDS_HOP_TIME, RoundTripTime); } else { - OutputText(IDS_HOP_ZERO); + ConResPrintf(StdOut, IDS_HOP_ZERO); } break; @@ -320,27 +221,27 @@ DecodeResponse( case IP_DEST_NET_UNREACHABLE: FoundTarget = true; PrintHopInfo(AddressInfo); - OutputText(IDS_HOP_RESPONSE); + ConResPrintf(StdOut, IDS_HOP_RESPONSE); if (Status == IP_DEST_HOST_UNREACHABLE) { - OutputText(IDS_DEST_HOST_UNREACHABLE); + ConResPrintf(StdOut, IDS_DEST_HOST_UNREACHABLE); } else if (Status == IP_DEST_NET_UNREACHABLE) { - OutputText(IDS_DEST_NET_UNREACHABLE); + ConResPrintf(StdOut, IDS_DEST_NET_UNREACHABLE); } return true; case IP_REQ_TIMED_OUT: - OutputText(IDS_TIMEOUT); + ConResPrintf(StdOut, IDS_TIMEOUT); break; case IP_GENERAL_FAILURE: - OutputText(IDS_GEN_FAILURE); + ConResPrintf(StdOut, IDS_GEN_FAILURE); return false; default: - OutputText(IDS_TRANSMIT_FAILED, Status); + ConResPrintf(StdOut, IDS_TRANSMIT_FAILED, Status); return false; } @@ -353,11 +254,11 @@ DecodeResponse( if (Status == IP_TTL_EXPIRED_TRANSIT || Status == IP_SUCCESS) { PrintHopInfo(AddressInfo); - OutputText(IDS_LINEBREAK); + ConResPrintf(StdOut, IDS_LINEBREAK); } else if (Status == IP_REQ_TIMED_OUT) { - OutputText(IDS_REQ_TIMED_OUT); + ConResPrintf(StdOut, IDS_REQ_TIMED_OUT); } } @@ -371,7 +272,7 @@ RunTraceRoute() Success = ResolveTarget(); if (!Success) { - OutputText(IDS_UNABLE_RESOLVE, Info.HostName); + ConResPrintf(StdOut, IDS_UNABLE_RESOLVE, Info.HostName); return false; } @@ -415,7 +316,7 @@ RunTraceRoute() return false; } - OutputText(IDS_TRACE_INFO, Info.HostName, Info.TargetIP, Info.MaxHops); + ConResPrintf(StdOut, IDS_TRACE_INFO, Info.HostName, Info.TargetIP, Info.MaxHops); IP_OPTION_INFORMATION IpOptionInfo; ZeroMemory(&IpOptionInfo, sizeof(IpOptionInfo)); @@ -425,7 +326,7 @@ RunTraceRoute() bool FoundTarget = false; while ((HopCount <= Info.MaxHops) && (FoundTarget == false) && (Quit == false)) { - OutputText(IDS_HOP_COUNT, HopCount); + ConResPrintf(StdOut, IDS_HOP_COUNT, HopCount); for (int Ping = 1; Ping <= NUM_OF_PINGS; Ping++) { @@ -483,7 +384,7 @@ RunTraceRoute() Sleep(100); } - OutputText(IDS_TRACE_COMPLETE); + ConResPrintf(StdOut, IDS_TRACE_COMPLETE); FreeAddrInfoW(Info.Target); if (Info.hIcmpFile) @@ -535,7 +436,7 @@ ParseCmdline(int argc, wchar_t *argv[]) default: { - OutputText(IDS_INVALID_OPTION, argv[i]); + ConResPrintf(StdOut, IDS_INVALID_OPTION, argv[i]); Usage(); return false; } @@ -554,6 +455,9 @@ ParseCmdline(int argc, wchar_t *argv[]) EXTERN_C int wmain(int argc, wchar_t *argv[]) { + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + Info.ResolveAddresses = true; Info.MaxHops = 30; Info.Timeout = 4000;