}
#endif
+int
+safe_integer(long i, char *buff, char **bp)
+{
+ char lbuf[128];
+ snprintf(lbuf, 128, "%ld", i);
+ return safe_str(lbuf, buff, bp);
+}
+
int
safe_str(const char *c, char *buff, char **bp)
{
if ((gairesult = getnameinfo(&remote.addr, rlen, host, sizeof host, NULL,
0, NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
safe_str("Error: getnameinfo(remote): ", buf, &bp);
- if (gairesult == EAI_SYSTEM)
+ if (gairesult == EAI_SYSTEM) {
+ safe_integer(errno, buf, &bp);
+ safe_chr('/', buf, &bp);
safe_str(strerror(errno), buf, &bp);
- else
+ } else {
+ safe_integer(gairesult, buf, &bp);
+ safe_chr('/', buf, &bp);
safe_str(gai_strerror(gairesult), buf, &bp);
+ }
} else {
safe_str(host, buf, &bp);
}
sizeof lport,
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
safe_str("Error: getnameinfo(local): ", buf, &bp);
- if (gairesult == EAI_SYSTEM)
+ if (gairesult == EAI_SYSTEM) {
+ safe_integer(errno, buf, &bp);
+ safe_chr('/', buf, &bp);
safe_str(strerror(errno), buf, &bp);
- else
+ } else {
+ safe_integer(gairesult, buf, &bp);
+ safe_chr('/', buf, &bp);
safe_str(gai_strerror(gairesult), buf, &bp);
+ }
} else {
safe_str(lport, buf, &bp);
}
if ((gairesult = getnameinfo(&remote.addr, rlen, host, sizeof host, NULL,
0, NI_NUMERICSERV) != 0)) {
safe_str("Error: getnameinfo(local/dns): ", buf, &bp);
- if (gairesult == EAI_SYSTEM)
+ if (gairesult == EAI_SYSTEM) {
+ safe_integer(errno, buf, &bp);
+ safe_chr('/', buf, &bp);
safe_str(strerror(errno), buf, &bp);
- else
+ } else {
+ safe_integer(gairesult, buf, &bp);
+ safe_chr('/', buf, &bp);
safe_str(gai_strerror(gairesult), buf, &bp);
+ }
} else {
safe_str(host, buf, &bp);
}