2 * pmap_set - set portmapper table from data produced by pmap_dump
4 * Author: Wietse Venema (wietse@wzv.win.tue.nl), dept. of Mathematics and
5 * Computing Science, Eindhoven University of Technology, The Netherlands.
11 #include <netinet/in.h>
14 #include <rpc/pmap_clnt.h>
17 parse_line(char *buf
, u_long
*prog
, u_long
*vers
,
18 int *prot
, unsigned *port
);
21 main(int argc
, char **argv
)
29 while (fgets(buf
, sizeof(buf
), stdin
)) {
30 if (parse_line(buf
, &prog
, &vers
, &prot
, &port
) == 0) {
31 fprintf(stderr
, "%s: malformed line: %s", argv
[0], buf
);
34 if (pmap_set(prog
, vers
, prot
, (unsigned short) port
) == 0)
35 fprintf(stderr
, "not registered: %s", buf
);
40 /* parse_line - convert line to numbers */
43 parse_line(char *buf
, u_long
*prog
, u_long
*vers
,
44 int *prot
, unsigned *port
)
48 if (sscanf(buf
, "%lu %lu %255s %u", prog
, vers
, proto_name
, port
) != 4) {
51 if (strcmp(proto_name
, "tcp") == 0) {
55 if (strcmp(proto_name
, "udp") == 0) {
59 if (sscanf(proto_name
, "%d", prot
) == 1) {