-/*
- * Copyright (C) 1995-2007, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2013 Index Data
* See the file LICENSE for details.
- *
- * $Id: zoom-opt.c,v 1.8 2007-05-05 11:53:26 adam Exp $
*/
/**
* \file zoom-opt.c
* \brief Implements ZOOM options handling
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <assert.h>
#include "zoom-p.h"
#include <yaz/xmalloc.h>
+struct ZOOM_options_entry {
+ char *name;
+ char *value;
+ int len; /* of `value', which may contain NULs */
+ struct ZOOM_options_entry *next;
+};
+
+struct ZOOM_options_p {
+ int refcount;
+ void *callback_handle;
+ ZOOM_options_callback callback_func;
+ struct ZOOM_options_entry *entries;
+ ZOOM_options parent1;
+ ZOOM_options parent2;
+};
+
static void set_value(struct ZOOM_options_entry **e,
const char *value, int len)
{
ZOOM_options dst = ZOOM_options_create();
struct ZOOM_options_entry *src_e = src->entries;
struct ZOOM_options_entry **dst_e = &dst->entries;
-
+
while(src_e)
{
append_entry(dst_e, src_e->name, src_e->value, src_e->len);
void *callback_handle)
{
ZOOM_options_callback callback_old;
-
+
assert(opt);
callback_old = opt->callback_func;
opt->callback_func = callback_func;
if (opt->refcount == 0)
{
struct ZOOM_options_entry *e;
-
+
ZOOM_options_destroy(opt->parent1);
ZOOM_options_destroy(opt->parent2);
e = opt->entries;
if (!opt)
return 0;
if (opt->callback_func)
+ {
v = (*opt->callback_func)(opt->callback_handle, name);
+ if (v)
+ *lenp = strlen(v);
+ }
if (!v)
{
struct ZOOM_options_entry *e;
ZOOM_options_get_bool(ZOOM_options opt, const char *name, int defa)
{
const char *v = ZOOM_options_get(opt, name);
-
+
if (!v)
return defa;
if (!strcmp(v, "1") || !strcmp(v, "T"))
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab