1 /* Test for sorting routines */
5 #include "lib/fastbuf.h"
14 #define SORT_KEY struct key
15 #define SORT_PREFIX(x) s_##x
17 #define SORT_INPUT_FILE
18 #define SORT_OUTPUT_FILE
22 s_compare(struct key *a, struct key *b)
24 return strcmp(a->line, b->line);
28 s_fetch_key(struct fastbuf *f, struct key *a)
30 return !!bgets(f, a->line, sizeof(a->line));
34 s_copy_data(struct fastbuf *src UNUSED, struct fastbuf *dest, struct key *k)
36 bputsn(dest, k->line);
40 s_fetch_item(struct fastbuf *src UNUSED, struct key *k, byte *limit UNUSED)
42 byte *end = (byte *) k->line + strlen(k->line) + 1;
43 #if 0 /* Testing splits */
44 uns r = random_max(10000);
55 s_store_item(struct fastbuf *f, struct key *k)
57 s_copy_data(NULL, f, k);
62 s_merge_data(struct fastbuf *src1 UNUSED, struct fastbuf *src2 UNUSED, struct fastbuf *dest, struct key *k1, struct key *k2 UNUSED)
64 s_copy_data(NULL, dest, k1);
67 static inline struct key *
68 s_merge_items(struct key *a, struct key *b UNUSED)
74 #include "lib/sorter.h"
77 main(int argc, char **argv)
80 if (cf_getopt(argc, argv, CF_SHORT_OPTS, CF_NO_LONG_OPTS, NULL) >= 0 ||
83 fputs("This program supports only the following command-line arguments:\n" CF_USAGE, stderr);
87 s_sort(argv[optind], argv[optind+1]);