--- /hd3/rup/rup.1 Mon Apr 5 22:31:13 2004 +++ /hd3/rup/rup.1 Mon Apr 5 21:19:40 2004 @@ -42,6 +42,7 @@ .Sh SYNOPSIS .Nm .Op Ar host ... +.Op Ar -f .Sh DESCRIPTION The .Nm @@ -62,6 +63,11 @@ .Nm utility uses an RPC protocol defined in .Pa /usr/include/rpcsvc/rstat.x . +.Pp +.Bl -tag -width Op +.It Fl f Ar +This option specifies which file is read by rup to query the addresses/hostnames +defined within it. .Sh EXAMPLES .Bd -literal example% rup otherhost @@ -81,12 +87,12 @@ daemon has terminated on the remote host. .It rup: RPC: Port mapper failure - RPC: Timed out The remote host is not running the portmapper (see -.Xr portmap 8 ) , +.Xr rpcbind 8 ) , and cannot accommodate any RPC-based services. The host may be down. .El .Sh SEE ALSO -.Xr portmap 8 , -.Xr rpc.rstatd 8 +.Xr rpc.rstatd 8 , +.Xr rpcbind 8 .Sh HISTORY The .Nm --- /hd3/rup/rup.c Mon Apr 5 21:24:45 2004 +++ /hd3/rup/rup.c Mon Apr 5 22:26:20 2004 @@ -57,6 +57,7 @@ #include #define HOST_WIDTH 15 +#define MAXBUF 512 struct host_list { struct host_list *next; @@ -107,7 +108,7 @@ hp = gethostbyaddr((char *)&raddrp->sin_addr.s_addr, sizeof(struct in_addr), AF_INET); - if (hp) + if (hp == NULL) host = hp->h_name; else host = inet_ntoa(raddrp->sin_addr); @@ -220,21 +221,52 @@ int main(int argc, char *argv[]) { - int ch; - - while ((ch = getopt(argc, argv, "?")) != -1) - switch (ch) { - default: - usage(); - /*NOTREACHED*/ - } - - setlinebuf(stdout); - if (argc == optind) - allhosts(); - else { - for (; optind < argc; optind++) - (void) onehost(argv[optind]); - } - exit(0); + int ch, f_flag = 0, i = 0; + FILE *fd; + char file_buf[MAXBUF], *host; + + while ((ch = getopt(argc, argv, "f:")) != -1) + switch (ch) { + case 'f': + f_flag = 1; + break; + default: + usage(); + /* NOTREACHED */ + } + + if (!f_flag) { + setlinebuf(stdout); + if (argc == optind) { + allhosts(); + } else { + for (; optind < argc; optind++) + onehost(argv[optind]); + } + } else { + if ((fd = fopen(optarg, "r")) == NULL) + err(1, "%s", optarg); + + while (!feof(fd)) { + if (fgets(file_buf, sizeof(file_buf), fd) != NULL) { + if ((host = malloc(sizeof(file_buf))) == NULL) + err(1, NULL); + bzero(host, sizeof(file_buf)); + if (!ferror(fd)) { + for (i = 0; i < (int)sizeof(file_buf); i++) { + if (file_buf[i] == '#' || file_buf[i] == '\n' || file_buf[i] == ' ') + break; + + host[i] = file_buf[i]; + } + onehost(host); + } else { + err(1, NULL); + } + free(host); + } + } + fclose(fd); + } + return 0; }