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