ig4 - Interrupt handling was mpsafe already, just set INTR_MPSAFE
[dragonfly.git] / share / examples / sunrpc / dir / rls.c
blobaa7f79f91b5760966e5ba68b8877a48065892fd2
1 /* @(#)rls.c 2.2 88/08/12 4.0 RPCSRC */
2 /*
3 * rls.c: Remote directory listing client
4 */
5 #include <stdio.h>
6 #include <rpc/rpc.h> /* always need this */
7 #include "dir.h" /* need this too: will be generated by rpcgen*/
9 extern int errno;
11 main(argc, argv)
12 int argc;
13 char *argv[];
15 CLIENT *cl;
16 char *server;
17 char *dir;
18 readdir_res *result;
19 namelist nl;
22 if (argc != 3) {
23 fprintf(stderr, "usage: %s host directory\n", argv[0]);
24 exit(1);
28 * Remember what our command line arguments refer to
30 server = argv[1];
31 dir = argv[2];
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");
39 if (cl == NULL) {
41 * Couldn't establish connection with server.
42 * Print error message and die.
44 clnt_pcreateerror(server);
45 exit(1);
49 * Call the remote procedure "readdir" on the server
51 result = readdir_1(&dir, cl);
52 if (result == NULL) {
54 * An error occurred while calling the server.
55 * Print error message and die.
57 clnt_perror(cl, server);
58 exit(1);
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;
70 perror(dir);
71 exit(1);
75 * Successfuly got a directory listing.
76 * Print it out.
78 for (nl = result->readdir_res_u.list; nl != NULL; nl = nl->next) {
79 printf("%s\n", nl->name);