diff --git a/base/applications/network/route/CMakeLists.txt b/base/applications/network/route/CMakeLists.txt index bbb89e43739..fa6c1e9f8d0 100644 --- a/base/applications/network/route/CMakeLists.txt +++ b/base/applications/network/route/CMakeLists.txt @@ -1,5 +1,8 @@ +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) + add_executable(route route.c route.rc) set_module_type(route win32cui UNICODE) +target_link_libraries(route conutils ${PSEH_LIB}) add_importlibs(route ws2_32 iphlpapi msvcrt kernel32) add_cd_file(TARGET route DESTINATION reactos/system32 FOR all) diff --git a/base/applications/network/route/lang/en-US.rc b/base/applications/network/route/lang/en-US.rc new file mode 100644 index 00000000000..3629d3947e2 --- /dev/null +++ b/base/applications/network/route/lang/en-US.rc @@ -0,0 +1,49 @@ +/* + * FILE: base/applications/network/route/lang/en-US.rc + * PURPOSE: English translations for ReactOS Route Command + * TRANSLATORS: + */ + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +STRINGTABLE +BEGIN + IDS_USAGE "\n\ +route usage:\n\ +route print\n\ + prints the route table\n\ +route add [mask ] [metric ]\n\ + adds a route\n\ +route delete \n\ + deletes a route\n" + + IDS_ROUTE_ADD_HELP "\n\ +route add usage:\n\ +route add [mask ] [metric ]\n\ + Adds a route to the IP route table.\n\ + is the network or host to add a route to.\n\ + is the netmask to use (autodetected if unspecified)\n\ + is the gateway to use to access the network\n\ + is the metric to use (lower is preferred)\n" + + IDS_ROUTE_DEL_HELP "\n\ +route delete usage:\n\ +route delete \n\ + Removes a route from the IP route table.\n\ + is the network or host to add a route to.\n\ + is the gateway to remove the route from.\n" + + IDS_ROUTE_ADD_ERROR "Route addition failed\n" + IDS_ROUTE_DEL_ERROR "Route deletion failed\n" + IDS_ROUTE_ENUM_ERROR "Route enumeration failed\n" + IDS_SEPARATOR "===========================================================================\n" + IDS_INTERFACE_LIST "Interface List\n" + IDS_INTERFACE_ENTRY "0x%lu ........................... %hs\n" + IDS_IPV4_ROUTE_TABLE "\nIPv4 Route Table\n" + IDS_ACTIVE_ROUTES "Active Routes:\n" + IDS_ROUTES_ENTRY "%17s%17s%17s%16ld%9ld\n" + IDS_PERSISTENT_ROUTES "Persistent Routes:\n" + IDS_DEFAULT_GATEWAY "Default Gateway:%18s\n" + IDS_ROUTES_HEADER "Network Destination Netmask Gateway Interface Metric\n" + IDS_NONE " None\n" +END diff --git a/base/applications/network/route/resource.h b/base/applications/network/route/resource.h new file mode 100644 index 00000000000..646264a7467 --- /dev/null +++ b/base/applications/network/route/resource.h @@ -0,0 +1,18 @@ +#pragma once + +#define IDS_USAGE 100 +#define IDS_ROUTE_ADD_HELP 101 +#define IDS_ROUTE_DEL_HELP 102 +#define IDS_ROUTE_ADD_ERROR 103 +#define IDS_ROUTE_DEL_ERROR 104 +#define IDS_ROUTE_ENUM_ERROR 105 +#define IDS_SEPARATOR 106 +#define IDS_INTERFACE_LIST 107 +#define IDS_INTERFACE_ENTRY 108 +#define IDS_IPV4_ROUTE_TABLE 109 +#define IDS_ACTIVE_ROUTES 110 +#define IDS_PERSISTENT_ROUTES 111 +#define IDS_ROUTES_ENTRY 112 +#define IDS_DEFAULT_GATEWAY 113 +#define IDS_ROUTES_HEADER 114 +#define IDS_NONE 120 diff --git a/base/applications/network/route/route.c b/base/applications/network/route/route.c index b1212bde33a..56541527752 100644 --- a/base/applications/network/route/route.c +++ b/base/applications/network/route/route.c @@ -21,20 +21,16 @@ #include #include #include +#include + +#include "resource.h" #define IPBUF 17 #define IN_ADDR_OF(x) *((struct in_addr *)&(x)) static int Usage() { - _ftprintf( stderr, - _T("route usage:\n") - _T("route print\n") - _T(" prints the route table\n") - _T("route add [mask ] [metric ]\n") - _T(" adds a route\n") - _T("route delete \n") - _T(" deletes a route\n") ); + ConResPrintf(StdErr, IDS_USAGE); return 1; } @@ -45,7 +41,7 @@ static int PrintRoutes() ULONG Size = 0; DWORD Error = 0; ULONG adaptOutBufLen = sizeof(IP_ADAPTER_INFO); - TCHAR DefGate[16]; + WCHAR DefGate[16]; TCHAR Destination[IPBUF], Gateway[IPBUF], Netmask[IPBUF]; unsigned int i; @@ -86,29 +82,20 @@ static int PrintRoutes() _T("%s"), #endif pAdapterInfo->GatewayList.IpAddress.String); - _tprintf(_T("===========================================================================\n")); - _tprintf(_T("Interface List\n")); + ConResPrintf(StdOut, IDS_SEPARATOR); + ConResPrintf(StdOut, IDS_INTERFACE_LIST); /* FIXME - sort by the index! */ while (pAdapterInfo) { -#ifdef UNICODE - _tprintf(_T("0x%lu ........................... %hs\n"), -#else - _tprintf(_T("0x%lu ........................... %s\n"), -#endif - pAdapterInfo->Index, pAdapterInfo->Description); + ConResPrintf(StdOut, IDS_INTERFACE_ENTRY, pAdapterInfo->Index, pAdapterInfo->Description); pAdapterInfo = pAdapterInfo->Next; } - _tprintf(_T("===========================================================================\n")); + ConResPrintf(StdOut, IDS_SEPARATOR); - _tprintf(_T("===========================================================================\n")); - _tprintf(_T("Active Routes:\n")); - _tprintf( _T("%-27s%-17s%-14s%-11s%-10s\n"), - _T("Network Destination"), - _T("Netmask"), - _T("Gateway"), - _T("Interface"), - _T("Metric") ); + ConResPrintf(StdOut, IDS_IPV4_ROUTE_TABLE); + ConResPrintf(StdOut, IDS_SEPARATOR); + ConResPrintf(StdOut, IDS_ACTIVE_ROUTES); + ConResPrintf(StdOut, IDS_ROUTES_HEADER); for( i = 0; i < IpForwardTable->dwNumEntries; i++ ) { _stprintf( Destination, @@ -133,16 +120,18 @@ static int PrintRoutes() #endif inet_ntoa( IN_ADDR_OF(IpForwardTable->table[i].dwForwardNextHop) ) ); - _tprintf( _T("%17s%17s%17s%16ld%9ld\n"), - Destination, - Netmask, - Gateway, - IpForwardTable->table[i].dwForwardIfIndex, - IpForwardTable->table[i].dwForwardMetric1 ); + ConResPrintf(StdOut, IDS_ROUTES_ENTRY, + Destination, + Netmask, + Gateway, + IpForwardTable->table[i].dwForwardIfIndex, + IpForwardTable->table[i].dwForwardMetric1); } - _tprintf(_T("Default Gateway:%18s\n"), DefGate); - _tprintf(_T("===========================================================================\n")); - _tprintf(_T("Persistent Routes:\n")); + ConResPrintf(StdOut, IDS_DEFAULT_GATEWAY, DefGate); + ConResPrintf(StdOut, IDS_SEPARATOR); + + ConResPrintf(StdOut, IDS_PERSISTENT_ROUTES); + ConResPrintf(StdOut, IDS_NONE); free(IpForwardTable); free(pAdapterInfo); @@ -154,7 +143,7 @@ static int PrintRoutes() Error: if (pAdapterInfo) free(pAdapterInfo); if (IpForwardTable) free(IpForwardTable); - _ftprintf( stderr, _T("Route enumerate failed\n") ); + ConResPrintf(StdErr, IDS_ROUTE_ENUM_ERROR); return Error; } } @@ -216,21 +205,14 @@ static int add_route( int argc, TCHAR **argv ) { if( argc < 2 || !convert_add_cmd_line( &RowToAdd, argc, argv ) ) { - _ftprintf( stderr, - _T("route add usage:\n") - _T("route add [mask ] [metric ]\n") - _T(" Adds a route to the IP route table.\n") - _T(" is the network or host to add a route to.\n") - _T(" is the netmask to use (autodetected if unspecified)\n") - _T(" is the gateway to use to access the network\n") - _T(" is the metric to use (lower is preferred)\n") ); + ConResPrintf(StdErr, IDS_ROUTE_ADD_HELP); return 1; } if( (Error = CreateIpForwardEntry( &RowToAdd )) == ERROR_SUCCESS ) return 0; - _ftprintf( stderr, _T("Route addition failed\n") ); + ConResPrintf(StdErr, IDS_ROUTE_ADD_ERROR); return Error; } @@ -241,24 +223,22 @@ static int del_route( int argc, TCHAR **argv ) if( argc < 2 || !convert_add_cmd_line( &RowToDel, argc, argv ) ) { - _ftprintf( stderr, - _T("route delete usage:\n") - _T("route delete \n") - _T(" Removes a route from the IP route table.\n") - _T(" is the network or host to add a route to.\n") - _T(" is the gateway to remove the route from.\n") ); + ConResPrintf(StdErr, IDS_ROUTE_ADD_HELP); return 1; } if( (Error = DeleteIpForwardEntry( &RowToDel )) == ERROR_SUCCESS ) return 0; - _ftprintf( stderr, _T("Route addition failed\n") ); + ConResPrintf(StdErr, IDS_ROUTE_DEL_ERROR); return Error; } int _tmain( int argc, TCHAR **argv ) { + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + if( argc < 2 ) return Usage(); else if ( !_tcscmp( argv[1], _T("print") ) ) diff --git a/base/applications/network/route/route.rc b/base/applications/network/route/route.rc index ee77b881b4f..d4a5aeca965 100644 --- a/base/applications/network/route/route.rc +++ b/base/applications/network/route/route.rc @@ -1,5 +1,16 @@ +#include + +#include "resource.h" + #define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 Route" #define REACTOS_STR_INTERNAL_NAME "route" #define REACTOS_STR_ORIGINAL_FILENAME "route.exe" #define REACTOS_STR_ORIGINAL_COPYRIGHT "Art Yerkes (arty@users.sourceforge.net)" #include + +/* UTF-8 */ +#pragma code_page(65001) + +#ifdef LANGUAGE_EN_US + #include "lang/en-US.rc" +#endif