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