version 1.22, 1997/11/09 16:33:09 |
version 1.23, 1998/02/27 12:07:33 |
|
|
static int first; |
static int first; |
static struct rpcnams *rpcn; |
static struct rpcnams *rpcn; |
struct rpcnams *n; |
struct rpcnams *n; |
char num[10]; |
char num[20]; |
|
|
if (first == 0) { |
if (first == 0) { |
first = 1; |
first = 1; |
|
|
if (rpc) |
if (rpc) |
n->rpcname = strdup(rpc->r_name); |
n->rpcname = strdup(rpc->r_name); |
else { |
else { |
sprintf(num, "%ld", head->pml_map.pm_prog); |
snprintf(num, sizeof num, "%ld", |
|
head->pml_map.pm_prog); |
n->rpcname = strdup(num); |
n->rpcname = strdup(num); |
} |
} |
} |
} |
|
|
int proton; |
int proton; |
int width; |
int width; |
|
|
sprintf(line, "%.*s.", (Aflag && !nflag) ? 12 : 16, inetname(in)); |
snprintf(line, sizeof line, "%.*s.", (Aflag && !nflag) ? 12 : 16, |
|
inetname(in)); |
cp = strchr(line, '\0'); |
cp = strchr(line, '\0'); |
if (!nflag && port) |
if (!nflag && port) |
sp = getservbyport((int)port, proto); |
sp = getservbyport((int)port, proto); |
if (sp || port == 0) |
if (sp || port == 0) |
sprintf(cp, "%.8s", sp ? sp->s_name : "*"); |
snprintf(cp, line + sizeof line - cp, "%.8s", |
|
sp ? sp->s_name : "*"); |
else if (local && !nflag && (nam = getrpcportnam(ntohs(port), |
else if (local && !nflag && (nam = getrpcportnam(ntohs(port), |
(strcmp(proto, "tcp") == 0 ? IPPROTO_TCP : IPPROTO_UDP)))) |
(strcmp(proto, "tcp") == 0 ? IPPROTO_TCP : IPPROTO_UDP)))) |
sprintf(cp, "%d[%.8s]", ntohs(port), nam); |
snprintf(cp, line + sizeof line - cp, "%d[%.8s]", |
|
ntohs(port), nam); |
else |
else |
sprintf(cp, "%d", ntohs(port)); |
snprintf(cp, line + sizeof line - cp, "%d", ntohs(port)); |
width = Aflag ? 18 : 22; |
width = Aflag ? 18 : 22; |
printf(" %-*.*s", width, width, line); |
printf(" %-*.*s", width, width, line); |
} |
} |
|
|
} |
} |
} |
} |
if (inp->s_addr == INADDR_ANY) |
if (inp->s_addr == INADDR_ANY) |
strcpy(line, "*"); |
snprintf(line, sizeof line, "*"); |
else if (cp) |
else if (cp) |
strcpy(line, cp); |
snprintf(line, sizeof line, "%s", cp); |
else { |
else { |
inp->s_addr = ntohl(inp->s_addr); |
inp->s_addr = ntohl(inp->s_addr); |
#define C(x) ((x) & 0xff) |
#define C(x) ((x) & 0xff) |
sprintf(line, "%u.%u.%u.%u", C(inp->s_addr >> 24), |
snprintf(line, sizeof line, "%u.%u.%u.%u", |
C(inp->s_addr >> 16), C(inp->s_addr >> 8), C(inp->s_addr)); |
C(inp->s_addr >> 24), C(inp->s_addr >> 16), |
|
C(inp->s_addr >> 8), C(inp->s_addr)); |
} |
} |
return (line); |
return (line); |
} |
} |