5 #include <netinet/in.h>
10 pserv(const struct servent
*svp
)
14 printf("name=%s, port=%d, proto=%s, aliases=",
15 svp
->s_name
, ntohs((uint16_t)svp
->s_port
), svp
->s_proto
);
16 for (pp
= svp
->s_aliases
; *pp
; pp
++)
24 (void)fprintf(stderr
, "Usage: %s\n"
25 "\t%s -p <port> [-P <proto>]\n"
26 "\t%s -n <name> [-P <proto>]\n", getprogname(), getprogname(),
32 main(int argc
, char *argv
[])
35 const char *port
= NULL
, *proto
= NULL
, *name
= NULL
;
38 while ((c
= getopt(argc
, argv
, "p:n:P:")) != -1) {
57 if ((svp
= getservbyport(htons(atoi(port
)), proto
)) != NULL
)
62 if ((svp
= getservbyname(name
, proto
)) != NULL
)
68 while ((svp
= getservent()) != NULL
)