[ARP] Move the message file

Move the message file because we do not need to generate a global message header file for the arp utility.
This commit is contained in:
Eric Kohl 2021-12-31 16:35:25 +01:00
parent d7722f39fb
commit 6623b8d155
4 changed files with 21 additions and 19 deletions

View file

@ -1,4 +1,5 @@
add_message_headers(UNICODE arp_msg.mc)
add_executable(arp arp.c arp.rc) add_executable(arp arp.c arp.rc)
set_module_type(arp win32cui) set_module_type(arp win32cui)
add_dependencies(arp arp_msg) add_dependencies(arp arp_msg)

View file

@ -39,6 +39,8 @@
#include <winsock2.h> #include <winsock2.h>
#include <iphlpapi.h> #include <iphlpapi.h>
#include <arp_msg.h>
/* /*
* Globals * Globals
*/ */
@ -168,19 +170,19 @@ DWORD PrintEntries(PMIB_IPNETROW pIpAddRow)
switch (pIpAddRow->dwType) switch (pIpAddRow->dwType)
{ {
case MIB_IPNET_TYPE_DYNAMIC: case MIB_IPNET_TYPE_DYNAMIC:
PrintMessage(10007); PrintMessage(MSG_ARP_DYNAMIC);
break; break;
case MIB_IPNET_TYPE_STATIC: case MIB_IPNET_TYPE_STATIC:
PrintMessage(10008); PrintMessage(MSG_ARP_STATIC);
break; break;
case MIB_IPNET_TYPE_INVALID: case MIB_IPNET_TYPE_INVALID:
PrintMessage(10006); PrintMessage(MSG_ARP_INVALID);
break; break;
case MIB_IPNET_TYPE_OTHER: case MIB_IPNET_TYPE_OTHER:
PrintMessage(10005); PrintMessage(MSG_ARP_OTHER);
break; break;
} }
_putts(_T("")); _putts(_T(""));
@ -217,7 +219,7 @@ DWORD DisplayArpEntries(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
pIpNetTable = (PMIB_IPNETTABLE)HeapAlloc(GetProcessHeap(), 0, Size); pIpNetTable = (PMIB_IPNETTABLE)HeapAlloc(GetProcessHeap(), 0, Size);
if (pIpNetTable == NULL) if (pIpNetTable == NULL)
{ {
PrintMessage(10004); PrintMessage(MSG_ARP_NO_MEMORY);
dwError = ERROR_NOT_ENOUGH_MEMORY; dwError = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup; goto cleanup;
} }
@ -235,7 +237,7 @@ DWORD DisplayArpEntries(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
/* check there are entries in the table */ /* check there are entries in the table */
if (pIpNetTable->dwNumEntries == 0) if (pIpNetTable->dwNumEntries == 0)
{ {
PrintMessage(10018); PrintMessage(MSG_ARP_NO_ENTRIES);
goto cleanup; goto cleanup;
} }
@ -249,7 +251,7 @@ DWORD DisplayArpEntries(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
pIpAddrTable = (PMIB_IPADDRTABLE)HeapAlloc(GetProcessHeap(), 0, Size); pIpAddrTable = (PMIB_IPADDRTABLE)HeapAlloc(GetProcessHeap(), 0, Size);
if (pIpAddrTable == NULL) if (pIpAddrTable == NULL)
{ {
PrintMessage(10004); PrintMessage(MSG_ARP_NO_MEMORY);
dwError = ERROR_NOT_ENOUGH_MEMORY; dwError = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup; goto cleanup;
} }
@ -300,12 +302,12 @@ DWORD DisplayArpEntries(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
/* Print message and leave if there are no relevant ARP entries */ /* Print message and leave if there are no relevant ARP entries */
if (dwCount == 0) if (dwCount == 0)
{ {
PrintMessage(10018); PrintMessage(MSG_ARP_NO_ENTRIES);
goto cleanup; goto cleanup;
} }
/* print header, including interface IP address and index number */ /* print header, including interface IP address and index number */
PrintMessageV(10003, szIntIpAddr, pIpNetTable->table[0].dwIndex); PrintMessageV(MSG_ARP_INTERFACE, szIntIpAddr, pIpNetTable->table[0].dwIndex);
/* go through all ARP entries */ /* go through all ARP entries */
for (i = 0; i < pIpNetTable->dwNumEntries; i++) for (i = 0; i < pIpNetTable->dwNumEntries; i++)
@ -365,14 +367,14 @@ DWORD Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
dwIpAddr = inet_addr(pszInetAddr); dwIpAddr = inet_addr(pszInetAddr);
if (dwIpAddr == INADDR_NONE) if (dwIpAddr == INADDR_NONE)
{ {
PrintMessageV(10001, pszInetAddr); PrintMessageV(MSG_ARP_BAD_IP_ADDRESS, pszInetAddr);
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
} }
/* check MAC address */ /* check MAC address */
if (strlen(pszEthAddr) != 17) if (strlen(pszEthAddr) != 17)
{ {
PrintMessageV(10002, pszEthAddr); PrintMessageV(MSG_ARP_BAD_ARGUMENT, pszEthAddr);
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
} }
@ -383,7 +385,7 @@ DWORD Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
if (!isxdigit(pszEthAddr[i])) if (!isxdigit(pszEthAddr[i]))
{ {
PrintMessageV(10002, pszEthAddr); PrintMessageV(MSG_ARP_BAD_ARGUMENT, pszEthAddr);
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
} }
} }
@ -396,7 +398,7 @@ DWORD Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
pIpNetTable = (PMIB_IPNETTABLE)HeapAlloc(GetProcessHeap(), 0, Size); pIpNetTable = (PMIB_IPNETTABLE)HeapAlloc(GetProcessHeap(), 0, Size);
if (pIpNetTable == NULL) if (pIpNetTable == NULL)
{ {
PrintMessage(10004); PrintMessage(MSG_ARP_NO_MEMORY);
dwError = ERROR_NOT_ENOUGH_MEMORY; dwError = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup; goto cleanup;
} }
@ -415,7 +417,7 @@ DWORD Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
pAddHost = (PMIB_IPNETROW)HeapAlloc(GetProcessHeap(), 0, sizeof(MIB_IPNETROW)); pAddHost = (PMIB_IPNETROW)HeapAlloc(GetProcessHeap(), 0, sizeof(MIB_IPNETROW));
if (pAddHost == NULL) if (pAddHost == NULL)
{ {
PrintMessage(10004); PrintMessage(MSG_ARP_NO_MEMORY);
dwError = ERROR_NOT_ENOUGH_MEMORY; dwError = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup; goto cleanup;
} }
@ -518,7 +520,7 @@ DWORD Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
dwIpAddr = inet_addr(pszInetAddr); dwIpAddr = inet_addr(pszInetAddr);
if (dwIpAddr == INADDR_NONE) if (dwIpAddr == INADDR_NONE)
{ {
PrintMessageV(10001, pszInetAddr); PrintMessageV(MSG_ARP_BAD_IP_ADDRESS, pszInetAddr);
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
} }
} }
@ -531,7 +533,7 @@ DWORD Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
pIpNetTable = (PMIB_IPNETTABLE) HeapAlloc(GetProcessHeap(), 0, Size); pIpNetTable = (PMIB_IPNETTABLE) HeapAlloc(GetProcessHeap(), 0, Size);
if (pIpNetTable == NULL) if (pIpNetTable == NULL)
{ {
PrintMessage(10004); PrintMessage(MSG_ARP_NO_MEMORY);
dwError = ERROR_NOT_ENOUGH_MEMORY; dwError = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup; goto cleanup;
} }
@ -550,7 +552,7 @@ DWORD Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
pDelHost = (MIB_IPNETROW *)HeapAlloc(GetProcessHeap(), 0, sizeof(MIB_IPNETROW)); pDelHost = (MIB_IPNETROW *)HeapAlloc(GetProcessHeap(), 0, sizeof(MIB_IPNETROW));
if (pDelHost == NULL) if (pDelHost == NULL)
{ {
PrintMessage(10004); PrintMessage(MSG_ARP_NO_MEMORY);
dwError = ERROR_NOT_ENOUGH_MEMORY; dwError = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup; goto cleanup;
} }
@ -613,7 +615,7 @@ cleanup:
*/ */
VOID Usage(VOID) VOID Usage(VOID)
{ {
PrintMessage(10000); PrintMessage(MSG_ARP_SYNTAX);
} }
/* /*

View file

@ -3,7 +3,6 @@ list(APPEND ANSI_SOURCE
bugcodes.mc) bugcodes.mc)
list(APPEND UNICODE_SOURCE list(APPEND UNICODE_SOURCE
arp_msg.mc
errcodes.mc errcodes.mc
net_msg.mc net_msg.mc
neteventmsg.mc neteventmsg.mc