xref: /freebsd/share/examples/sunrpc/sort/rsort.c (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1 /* @(#)rsort.c	2.1 88/08/11 4.0 RPCSRC */
2 /*
3  * rsort.c
4  * Client side application which sorts argc, argv.
5  */
6 #include <stdio.h>
7 #include <rpc/rpc.h>
8 #include "sort.h"
9 
10 main(argc, argv)
11 	int argc;
12 	char **argv;
13 {
14 	char *machinename;
15 	struct sortstrings args, res;
16 	int i;
17 
18 	if (argc < 3) {
19 		fprintf(stderr, "usage: %s machinename [s1 ...]\n", argv[0]);
20 		exit(1);
21 	}
22 	machinename = argv[1];
23 	args.ss.ss_len = argc - 2;     /* substract off progname, machinename */
24 	args.ss.ss_val = &argv[2];
25 	res.ss.ss_val = (char **)NULL;
26 
27 	if ((i = callrpc(machinename, SORTPROG, SORTVERS, SORT,
28 	    xdr_sortstrings, &args, xdr_sortstrings, &res)))
29 	{
30 	    fprintf(stderr, "%s: call to sort service failed. ", argv[0]);
31 	    clnt_perrno(i);
32 	    fprintf(stderr, "\n");
33 	    exit(1);
34 	}
35 
36 	for (i = 0; i < res.ss.ss_len; i++) {
37 		printf("%s\n", res.ss.ss_val[i]);
38 	}
39 
40 	/* should free res here */
41 	exit(0);
42 }
43 
44