oksirc/dns.cpp
Darren VanBuren 851c2f79e3 Separate UI to new file, still not quite complete.
Also fixed code style in files, and settings used by CLion.
2017-07-09 15:17:24 -07:00

23 lines
No EOL
750 B
C++

#include "dns.h"
PRErrorCode LookupName(char *hostname, PRNetAddr *result) {
// Attempt to resolve a name.
PRAddrInfo *addrInfos = PR_GetAddrInfoByName(hostname, PR_AF_UNSPEC, PR_AI_ADDRCONFIG);
void *iter = nullptr;
// PRNetAddr firstAddr;
// PRNetAddr tempAddr;
// do {
iter = PR_EnumerateAddrInfo(iter, addrInfos, 0, result);
char ipString[80];
PRStatus status = PR_NetAddrToString(result, ipString, 75);
if (status == PR_FAILURE) {
const PRErrorCode err = PR_GetError();
fprintf(stderr, "Error: Converting PRNetAddr to string %d: %s\n",
err, PR_ErrorToName(err));
return err;
}
printf("Found IP Address: %s\n", ipString);
return 0;
// break;
// } while(iter);
}