1944fcc15SGarrett Wollman /*
2944fcc15SGarrett Wollman * rsort.c
3944fcc15SGarrett Wollman * Client side application which sorts argc, argv.
4944fcc15SGarrett Wollman */
5944fcc15SGarrett Wollman #include <stdio.h>
6944fcc15SGarrett Wollman #include <rpc/rpc.h>
7944fcc15SGarrett Wollman #include "sort.h"
8944fcc15SGarrett Wollman
main(argc,argv)9944fcc15SGarrett Wollman main(argc, argv)
10944fcc15SGarrett Wollman int argc;
11944fcc15SGarrett Wollman char **argv;
12944fcc15SGarrett Wollman {
13944fcc15SGarrett Wollman char *machinename;
14944fcc15SGarrett Wollman struct sortstrings args, res;
15944fcc15SGarrett Wollman int i;
16944fcc15SGarrett Wollman
17944fcc15SGarrett Wollman if (argc < 3) {
18944fcc15SGarrett Wollman fprintf(stderr, "usage: %s machinename [s1 ...]\n", argv[0]);
19944fcc15SGarrett Wollman exit(1);
20944fcc15SGarrett Wollman }
21944fcc15SGarrett Wollman machinename = argv[1];
22944fcc15SGarrett Wollman args.ss.ss_len = argc - 2; /* substract off progname, machinename */
23944fcc15SGarrett Wollman args.ss.ss_val = &argv[2];
24944fcc15SGarrett Wollman res.ss.ss_val = (char **)NULL;
25944fcc15SGarrett Wollman
26944fcc15SGarrett Wollman if ((i = callrpc(machinename, SORTPROG, SORTVERS, SORT,
27944fcc15SGarrett Wollman xdr_sortstrings, &args, xdr_sortstrings, &res)))
28944fcc15SGarrett Wollman {
29944fcc15SGarrett Wollman fprintf(stderr, "%s: call to sort service failed. ", argv[0]);
30944fcc15SGarrett Wollman clnt_perrno(i);
31944fcc15SGarrett Wollman fprintf(stderr, "\n");
32944fcc15SGarrett Wollman exit(1);
33944fcc15SGarrett Wollman }
34944fcc15SGarrett Wollman
35944fcc15SGarrett Wollman for (i = 0; i < res.ss.ss_len; i++) {
36944fcc15SGarrett Wollman printf("%s\n", res.ss.ss_val[i]);
37944fcc15SGarrett Wollman }
38944fcc15SGarrett Wollman
39944fcc15SGarrett Wollman /* should free res here */
40944fcc15SGarrett Wollman exit(0);
41944fcc15SGarrett Wollman }
42944fcc15SGarrett Wollman
43