/* This file is part of the Zebra server.
- Copyright (C) 1994-2009 Index Data
+ Copyright (C) 2004-2013 Index Data
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
p->buf = 0;
p->owner_of_buffer = 1;
p->encode_handle = iscz1_start();
- p->decode_handle = iscz1_start();
+ p->decode_handle = iscz1_start();
p->custom_record_id = 0;
p->nmem = nmem_create();
}
p->owner_of_buffer = copy_buf;
}
-
+
void zebra_rec_keys_get_buf(zebra_rec_keys_t p, char **buf, size_t *sz)
{
*buf = p->buf;
{
if (!p)
return;
-
+
if (p->owner_of_buffer)
xfree(p->buf);
if (p->encode_handle)
xfree(p);
}
-int zebra_rec_keys_add_hash(zebra_rec_keys_t keys,
+int zebra_rec_keys_add_hash(zebra_rec_keys_t keys,
const char *str, size_t slen,
const struct it_key *key)
{
return 1;
}
-void zebra_rec_keys_write(zebra_rec_keys_t keys,
+void zebra_rec_keys_write(zebra_rec_keys_t keys,
const char *str, size_t slen,
const struct it_key *key)
{
char *dst;
const char *src = (char*) key;
-
+
assert(keys->owner_of_buffer);
if (key->mem[1]) /* record_id custom */
{
assert(keys);
keys->buf_used = 0;
-
+
iscz1_reset(keys->encode_handle);
init_hash(keys);
{
const char *src = keys->buf + keys->fetch_offset;
char *dst = (char*) key;
-
+
assert (keys->fetch_offset < keys->buf_used);
/* store the destination key */
iscz1_decode(keys->decode_handle, &dst, &src);
-
+
/* store pointer to string and length of it */
*str = src;
*slen = strlen(src);
src += *slen + 1;
-
+
keys->fetch_offset = src - keys->buf;
}
return 1;