version 1.7, 1997/06/23 22:21:48 |
version 1.8, 1997/12/19 09:03:33 |
|
|
struct servent *sp = 0; |
struct servent *sp = 0; |
char line[80], *cp; |
char line[80], *cp; |
|
|
sprintf(line, "%.*s.", 16, inetname(*in)); |
snprintf(line, sizeof line, "%.*s.", 16, inetname(*in)); |
cp = strchr(line, '\0'); |
cp = strchr(line, '\0'); |
if (!nflag && port) |
if (!nflag && port) |
sp = getservbyport(port, proto); |
sp = getservbyport(port, proto); |
if (sp || port == 0) |
if (sp || port == 0) |
sprintf(cp, "%.8s", sp ? sp->s_name : "*"); |
snprintf(cp, sizeof line - strlen(cp), "%.8s", |
|
sp ? sp->s_name : "*"); |
else |
else |
sprintf(cp, "%d", ntohs((u_short)port)); |
snprintf(cp, sizeof line - strlen(cp), "%d", |
|
ntohs((u_short)port)); |
/* pad to full column to clear any garbage */ |
/* pad to full column to clear any garbage */ |
cp = strchr(line, '\0'); |
cp = strchr(line, '\0'); |
while (cp - line < 22) |
while (cp - line < 22) |
|
|
else { |
else { |
in.s_addr = ntohl(in.s_addr); |
in.s_addr = ntohl(in.s_addr); |
#define C(x) ((x) & 0xff) |
#define C(x) ((x) & 0xff) |
sprintf(line, "%u.%u.%u.%u", C(in.s_addr >> 24), |
snprintf(line, sizeof line, "%u.%u.%u.%u", C(in.s_addr >> 24), |
C(in.s_addr >> 16), C(in.s_addr >> 8), C(in.s_addr)); |
C(in.s_addr >> 16), C(in.s_addr >> 8), C(in.s_addr)); |
} |
} |
return (line); |
return (line); |