Print symbolic names for appletalk ports. Also some very minor style 9 issues.

PR: bin/4157
Submitted by: Denny Gentry <denny1@home.com>
This commit is contained in:
Warner Losh 2001-06-15 20:47:01 +00:00
parent 7b748f0a21
commit 5d8eff0053

View File

@ -50,8 +50,9 @@ static const char rcsid[] =
#include <netatalk/at.h> #include <netatalk/at.h>
#include <netatalk/ddp_var.h> #include <netatalk/ddp_var.h>
#include <nlist.h>
#include <errno.h> #include <errno.h>
#include <nlist.h>
#include <netdb.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "netstat.h" #include "netstat.h"
@ -106,6 +107,7 @@ static char *
at_pr_port(struct sockaddr_at *sat) at_pr_port(struct sockaddr_at *sat)
{ {
static char mybuf[50]; static char mybuf[50];
struct servent *serv;
switch(sat->sat_port) { switch(sat->sat_port) {
case ATADDR_ANYPORT: case ATADDR_ANYPORT:
@ -113,7 +115,18 @@ static char mybuf[50];
case 0xff: case 0xff:
return "????"; return "????";
default: default:
sprintf(mybuf,"%d",(unsigned int)sat->sat_port); if (nflag) {
(void)snprintf(mybuf, sizeof(mybuf), "%d",
(unsigned int)sat->sat_port);
} else {
serv = getservbyport(sat->sat_port, "ddp");
if (serv == NULL)
(void)snprintf(mybuf, sizeof(mybuf), "%d",
(unsigned int) sat->sat_port);
else
(void) snprintf(mybuf, sizeof(mybuf), "%s",
serv->s_name);
}
} }
return mybuf; return mybuf;
} }