Reactos

[ARP] Replace some hard-coded strings by message resources

+200 -47
+1
base/applications/network/arp/CMakeLists.txt
··· 1 1 2 2 add_executable(arp arp.c arp.rc) 3 3 set_module_type(arp win32cui) 4 + add_dependencies(arp arp_msg) 4 5 add_importlibs(arp iphlpapi ws2_32 shlwapi msvcrt kernel32) 5 6 add_cd_file(TARGET arp DESTINATION reactos/system32 FOR all)
+74 -47
base/applications/network/arp/arp.c
··· 60 60 */ 61 61 DWORD DoFormatMessage(VOID) 62 62 { 63 - LPVOID lpMsgBuf; 63 + LPTSTR lpMsgBuf; 64 64 DWORD RetVal; 65 65 66 66 DWORD ErrorCode = GetLastError(); ··· 79 79 80 80 if (RetVal != 0) 81 81 { 82 - _tprintf(_T("%s"), (LPTSTR)lpMsgBuf); 83 - 82 + _putts(lpMsgBuf); 84 83 LocalFree(lpMsgBuf); 85 84 /* return number of TCHAR's stored in output buffer 86 85 * excluding '\0' - as FormatMessage does*/ ··· 90 89 return 0; 91 90 } 92 91 92 + VOID 93 + PrintMessage( 94 + DWORD dwMessage) 95 + { 96 + LPTSTR lpMsgBuf; 97 + DWORD RetVal; 98 + 99 + RetVal = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 100 + FORMAT_MESSAGE_FROM_HMODULE | 101 + FORMAT_MESSAGE_IGNORE_INSERTS, 102 + GetModuleHandleW(NULL), 103 + dwMessage, 104 + LANG_USER_DEFAULT, 105 + (LPTSTR)&lpMsgBuf, 106 + 0, 107 + NULL); 108 + if (RetVal != 0) 109 + { 110 + _putts(lpMsgBuf); 111 + LocalFree(lpMsgBuf); 112 + } 113 + } 114 + 115 + VOID 116 + PrintMessageV( 117 + DWORD dwMessage, 118 + ...) 119 + { 120 + LPTSTR lpMsgBuf; 121 + va_list args = NULL; 122 + DWORD RetVal; 123 + 124 + va_start(args, dwMessage); 125 + 126 + RetVal = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE, 127 + GetModuleHandleW(NULL), 128 + dwMessage, 129 + LANG_USER_DEFAULT, 130 + (LPTSTR)&lpMsgBuf, 131 + 0, 132 + &args); 133 + va_end(args); 134 + 135 + if (RetVal != 0) 136 + { 137 + _putts(lpMsgBuf); 138 + LocalFree(lpMsgBuf); 139 + } 140 + } 141 + 93 142 /* 94 143 * 95 144 * Takes an ARP entry and prints the IP address, ··· 118 167 /* print cache type */ 119 168 switch (pIpAddRow->dwType) 120 169 { 121 - case MIB_IPNET_TYPE_DYNAMIC : _tprintf(_T("dynamic\n")); 122 - break; 123 - case MIB_IPNET_TYPE_STATIC : _tprintf(_T("static\n")); 124 - break; 125 - case MIB_IPNET_TYPE_INVALID : _tprintf(_T("invalid\n")); 126 - break; 127 - case MIB_IPNET_TYPE_OTHER : _tprintf(_T("other\n")); 128 - break; 170 + case MIB_IPNET_TYPE_DYNAMIC: 171 + PrintMessage(10007); 172 + break; 173 + 174 + case MIB_IPNET_TYPE_STATIC: 175 + PrintMessage(10008); 176 + break; 177 + 178 + case MIB_IPNET_TYPE_INVALID: 179 + PrintMessage(10006); 180 + break; 181 + 182 + case MIB_IPNET_TYPE_OTHER: 183 + PrintMessage(10005); 184 + break; 129 185 } 130 186 return EXIT_SUCCESS; 131 187 } ··· 173 229 /* check there are entries in the table */ 174 230 if (pIpNetTable->dwNumEntries == 0) 175 231 { 176 - _tprintf(_T("No ARP entires found\n")); 232 + PrintMessage(10018); 177 233 goto cleanup; 178 234 } 179 235 ··· 213 269 214 270 215 271 /* print header, including interface IP address and index number */ 216 - _tprintf(_T("\nInterface: %s --- 0x%lx \n"), szIntIpAddr, pIpNetTable->table[0].dwIndex); 217 - _tprintf(_T(" Internet Address Physical Address Type\n")); 272 + PrintMessageV(10003, szIntIpAddr, pIpNetTable->table[0].dwIndex); 218 273 219 274 /* go through all ARP entries */ 220 275 for (i=0; i < pIpNetTable->dwNumEntries; i++) ··· 269 324 { 270 325 if ((dwIpAddr = inet_addr(pszInetAddr)) == INADDR_NONE) 271 326 { 272 - _tprintf(_T("ARP: bad IP address: %s\n"), pszInetAddr); 327 + PrintMessageV(10001, pszInetAddr); 273 328 return EXIT_FAILURE; 274 329 } 275 330 } ··· 282 337 /* check MAC address */ 283 338 if (strlen(pszEthAddr) != 17) 284 339 { 285 - _tprintf(_T("ARP: bad argument: %s\n"), pszEthAddr); 340 + PrintMessageV(10002, pszEthAddr); 286 341 return EXIT_FAILURE; 287 342 } 288 343 for (i=0; i<17; i++) ··· 292 347 293 348 if (!isxdigit(pszEthAddr[i])) 294 349 { 295 - _tprintf(_T("ARP: bad argument: %s\n"), pszEthAddr); 350 + PrintMessageV(10002, pszEthAddr); 296 351 return EXIT_FAILURE; 297 352 } 298 353 } ··· 412 467 bFlushTable = TRUE; 413 468 else if ((dwIpAddr = inet_addr(pszInetAddr)) == INADDR_NONE) 414 469 { 415 - _tprintf(_T("ARP: bad IP address: %s\n"), pszInetAddr); 470 + PrintMessageV(10001, pszInetAddr); 416 471 exit(EXIT_FAILURE); 417 472 } 418 473 } ··· 508 563 */ 509 564 VOID Usage(VOID) 510 565 { 511 - _tprintf(_T("\nDisplays and modifies the IP-to-Physical address translation tables used by\n" 512 - "address resolution protocol (ARP).\n" 513 - "\n" 514 - "ARP -s inet_addr eth_addr [if_addr]\n" 515 - "ARP -d inet_addr [if_addr]\n" 516 - "ARP -a [inet_addr] [-N if_addr]\n" 517 - "\n" 518 - " -a Displays current ARP entries by interrogating the current\n" 519 - " protocol data. If inet_addr is specified, the IP and Physical\n" 520 - " addresses for only the specified computer are displayed. If\n" 521 - " more than one network interface uses ARP, entries for each ARP\n" 522 - " table are displayed.\n" 523 - " -g Same as -a.\n" 524 - " inet_addr Specifies an internet address.\n" 525 - " -N if_addr Displays the ARP entries for the network interface specified\n" 526 - " by if_addr.\n" 527 - " -d Deletes the host specified by inet_addr. inet_addr may be\n" 528 - " wildcarded with * to delete all hosts.\n" 529 - " -s Adds the host and associates the Internet address inet_addr\n" 530 - " with the Physical address eth_addr. The Physical address is\n" 531 - " given as 6 hexadecimal bytes separated by hyphens. The entry\n" 532 - " is permanent.\n" 533 - " eth_addr Specifies a physical address.\n" 534 - " if_addr If present, this specifies the Internet address of the\n" 535 - " interface whose address translation table should be modified.\n" 536 - " If not present, the first applicable interface will be used.\n" 537 - "Example:\n" 538 - " > arp -s 157.55.85.212 00-aa-00-62-c6-09 .... Adds a static entry.\n" 539 - " > arp -a .... Displays the arp table.\n\n")); 566 + PrintMessage(10000); 540 567 } 541 568 542 569 /*
+1
base/applications/network/arp/arp.rc
··· 3 3 #define REACTOS_STR_ORIGINAL_FILENAME "arp.exe" 4 4 #define REACTOS_STR_ORIGINAL_COPYRIGHT "Ged Murphy (gedmurphy@gmail.com)" 5 5 #include <reactos/version.rc> 6 + #include <arp_msg.rc>
+1
sdk/include/reactos/mc/CMakeLists.txt
··· 3 3 bugcodes.mc) 4 4 5 5 list(APPEND UNICODE_SOURCE 6 + arp_msg.mc 6 7 errcodes.mc 7 8 net_msg.mc 8 9 neteventmsg.mc
+123
sdk/include/reactos/mc/arp_msg.mc
··· 1 + MessageIdTypedef=DWORD 2 + 3 + SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS 4 + Informational=0x1:STATUS_SEVERITY_INFORMATIONAL 5 + Warning=0x2:STATUS_SEVERITY_WARNING 6 + Error=0x3:STATUS_SEVERITY_ERROR 7 + ) 8 + 9 + FacilityNames=(System=0x0:FACILITY_SYSTEM 10 + ) 11 + 12 + LanguageNames=(English=0x409:MSG00409 13 + ) 14 + 15 + MessageId=10000 16 + SymbolicName=MSG_ARP_SYNTAX 17 + Severity=Success 18 + Facility=System 19 + Language=English 20 + Displays and modifies the IP-to-Physical address translation tables used by 21 + address resolution protocol (ARP). 22 + 23 + ARP -s inet_addr eth_addr [if_addr] 24 + ARP -d inet_addr [if_addr] 25 + ARP -a [inet_addr] [-N if_addr] 26 + 27 + -a Displays current ARP entries by interrogating the current 28 + protocol data. If inet_addr is specified, the IP and Physical 29 + addresses for only the specified computer are displayed. If 30 + more than one network interface uses ARP, entries for each ARP 31 + table are displayed. 32 + -g Same as -a. 33 + inet_addr Specifies an internet address. 34 + -N if_addr Displays the ARP entries for the network interface specified 35 + by if_addr. 36 + -d Deletes the host specified by inet_addr. inet_addr may be 37 + wildcarded with * to delete all hosts. 38 + -s Adds the host and associates the Internet address inet_addr 39 + with the Physical address eth_addr. The Physical address is 40 + given as 6 hexadecimal bytes separated by hyphens. The entry 41 + is permanent. 42 + eth_addr Specifies a physical address. 43 + if_addr If present, this specifies the Internet address of the 44 + interface whose address translation table should be modified. 45 + If not present, the first applicable interface will be used. 46 + Example: 47 + > arp -s 157.55.85.212 00-aa-00-62-c6-09 .... Adds a static entry. 48 + > arp -a .... Displays the arp table. 49 + . 50 + 51 + MessageId=10001 52 + SymbolicName=MSG_ARP_BAD_IP_ADDRESS 53 + Severity=Success 54 + Facility=System 55 + Language=English 56 + ARP: bad IP address: %1 57 + . 58 + 59 + MessageId=10002 60 + SymbolicName=MSG_ARP_BAD_ARGUMENT 61 + Severity=Success 62 + Facility=System 63 + Language=English 64 + ARP: bad argument: %1 65 + . 66 + 67 + MessageId=10003 68 + SymbolicName=MSG_ARP_INTERFACE 69 + Severity=Success 70 + Facility=System 71 + Language=English 72 + 73 + Interface: %1!s! --- 0x%2!lx! 74 + Internet Address Physical Address Type 75 + . 76 + 77 + MessageId=10005 78 + SymbolicName=MSG_ARP_OTHER 79 + Severity=Success 80 + Facility=System 81 + Language=English 82 + other%0 83 + . 84 + 85 + MessageId=10006 86 + SymbolicName=MSG_ARP_INVALID 87 + Severity=Success 88 + Facility=System 89 + Language=English 90 + invalid%0 91 + . 92 + 93 + MessageId=10007 94 + SymbolicName=MSG_ARP_DYNAMIC 95 + Severity=Success 96 + Facility=System 97 + Language=English 98 + dynamic%0 99 + . 100 + 101 + MessageId=10008 102 + SymbolicName=MSG_ARP_STATIC 103 + Severity=Success 104 + Facility=System 105 + Language=English 106 + static%0 107 + . 108 + 109 + MessageId=10013 110 + SymbolicName=MSG_ARP_ENTRY_FORMAT 111 + Severity=Success 112 + Facility=System 113 + Language=English 114 + %1!-20s! %2!-20s! %3!-10s! 115 + . 116 + 117 + MessageId=10018 118 + SymbolicName=MSG_ARP_NO_ENTRIES 119 + Severity=Success 120 + Facility=System 121 + Language=English 122 + No ARP entires found 123 + .