summaryrefslogtreecommitdiffstats
path: root/lib/librpc/demo/sort/sort_proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/librpc/demo/sort/sort_proc.c')
-rw-r--r--lib/librpc/demo/sort/sort_proc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/librpc/demo/sort/sort_proc.c b/lib/librpc/demo/sort/sort_proc.c
new file mode 100644
index 0000000..5538faf
--- /dev/null
+++ b/lib/librpc/demo/sort/sort_proc.c
@@ -0,0 +1,27 @@
+/* @(#)sort_proc.c 2.1 88/08/11 4.0 RPCSRC */
+#include <rpc/rpc.h>
+#include "sort.h"
+
+static int
+comparestrings(sp1, sp2)
+ char **sp1, **sp2;
+{
+ return (strcmp(*sp1, *sp2));
+}
+
+struct sortstrings *
+sort_1(ssp)
+ struct sortstrings *ssp;
+{
+ static struct sortstrings ss_res;
+
+ if (ss_res.ss.ss_val != (str *)NULL)
+ free(ss_res.ss.ss_val);
+
+ qsort(ssp->ss.ss_val, ssp->ss.ss_len, sizeof (char *), comparestrings);
+ ss_res.ss.ss_len = ssp->ss.ss_len;
+ ss_res.ss.ss_val = (str *)malloc(ssp->ss.ss_len * sizeof(str *));
+ bcopy(ssp->ss.ss_val, ss_res.ss.ss_val,
+ ssp->ss.ss_len * sizeof(str *));
+ return(&ss_res);
+}
OpenPOWER on IntegriCloud