PageRenderTime 12ms CodeModel.GetById 8ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/share/examples/sunrpc/sort/rsort.c

https://bitbucket.org/freebsd/freebsd-head/
C | 43 lines | 31 code | 6 blank | 6 comment | 3 complexity | d9ee43ca738e4ff7ed281395385d21d4 MD5 | raw file
 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
10main(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