+#endif
+
+#define ENCODE_BUFLEN 768
+struct encode_info {
+ void *encode_handle;
+ void *decode_handle;
+ char buf[ENCODE_BUFLEN];
+};
+
+static int log_level = 0;
+static int log_level_initialized = 1;
+
+static void zebra_init_log_level()
+{
+ if (!log_level_initialized)
+ {
+ log_level = yaz_log_module_level("extract");
+ log_level_initialized = 1;
+ }
+}
+
+static void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno,
+ int cmd, zebra_rec_keys_t reckeys,
+ zint staticrank);
+static void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno,
+ int cmd, zebra_rec_keys_t skp);
+static void extract_schema_add (struct recExtractCtrl *p, Odr_oid *oid);
+static void extract_token_add (RecWord *p);
+
+static void encode_key_init (struct encode_info *i);
+static void encode_key_write (char *k, struct encode_info *i, FILE *outf);
+static void encode_key_flush (struct encode_info *i, FILE *outf);
+
+#define USE_SHELLSORT 0
+
+#if USE_SHELLSORT
+static void shellsort(void *ar, int r, size_t s,
+ int (*cmp)(const void *a, const void *b))
+{
+ char *a = ar;
+ char v[100];
+ int h, i, j, k;
+ static const int incs[16] = { 1391376, 463792, 198768, 86961, 33936,
+ 13776, 4592, 1968, 861, 336,
+ 112, 48, 21, 7, 3, 1 };
+ for ( k = 0; k < 16; k++)
+ for (h = incs[k], i = h; i < r; i++)
+ {
+ memcpy (v, a+s*i, s);
+ j = i;
+ while (j > h && (*cmp)(a + s*(j-h), v) > 0)
+ {
+ memcpy (a + s*j, a + s*(j-h), s);
+ j -= h;
+ }
+ memcpy (a+s*j, v, s);
+ }
+}
+#endif