/* @(#)rls.c 2.2 88/08/12 4.0 RPCSRC */
* rls.c: Remote directory listing client
#include <rpc/rpc.h> /* always need this */
#include "dir.h" /* need this too: will be generated by rpcgen*/
fprintf(stderr
, "usage: %s host directory\n", argv
[0]);
* Remember what our command line arguments refer to
* Create client "handle" used for calling DIRPROG on the
* server designated on the command line. We tell the rpc package
* to use the "tcp" protocol when contacting the server.
cl
= clnt_create(server
, DIRPROG
, DIRVERS
, "tcp");
* Couldn't establish connection with server.
* Print error message and die.
clnt_pcreateerror(server
);
* Call the remote procedure "readdir" on the server
result
= readdir_1(&dir
, cl
);
* An error occurred while calling the server.
* Print error message and die.
* Okay, we successfully called the remote procedure.
if (result
->errno
!= 0) {
* A remote system error occurred.
* Print error message and die.
* Successfuly got a directory listing.
for (nl
= result
->readdir_res_u
.list
; nl
!= NULL
; nl
= nl
->next
) {
printf("%s\n", nl
->name
);