-/* $Id: dicttest.c,v 1.34 2005-04-15 10:47:48 adam Exp $
+/* $Id: dicttest.c,v 1.35 2005-09-13 11:51:05 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
yaz_log (YLOG_FATAL, "no config and/or dictionary specified");
exit (1);
}
- my_resource = res_open (config, 0, 0);
+ my_resource = res_open(0, 0);
if (!my_resource)
{
yaz_log (YLOG_FATAL, "cannot open resource `%s'", config);
exit (1);
}
+ res_read_file(my_resource, config);
+
bfs = bfs_create (res_get(my_resource, "register"), 0);
if (!bfs)
{
-/* $Id: api.h,v 1.29 2005-08-09 10:01:03 adam Exp $
+/* $Id: api.h,v 1.30 2005-09-13 11:51:05 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
one handle is sufficient
*/
YAZ_EXPORT
-ZebraHandle zebra_open(ZebraService zs);
+ZebraHandle zebra_open(ZebraService zs, Res res);
/**
\brief Destroys Zebra session handle.
-/* $Id: res.h,v 1.6 2005-08-17 21:28:07 adam Exp $
+/* $Id: res.h,v 1.7 2005-09-13 11:51:06 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
typedef struct res_struct *Res;
YAZ_EXPORT
-Res res_open (const char *name, Res res_def, Res over_res);
+Res res_open(Res res_def, Res over_res);
YAZ_EXPORT
-void res_close (Res r);
+void res_close(Res r);
YAZ_EXPORT
-void res_clear (Res r);
+ZEBRA_RES res_read_file(Res r, const char *fname);
YAZ_EXPORT
-const char *res_get (Res r, const char *name);
+ZEBRA_RES res_write_file(Res r, const char *fname);
YAZ_EXPORT
-const char *res_get_def (Res r, const char *name, const char *def);
+void res_clear(Res r);
YAZ_EXPORT
-int res_get_match (Res r, const char *name, const char *value, const char *s);
+const char *res_get(Res r, const char *name);
YAZ_EXPORT
-void res_set (Res r, const char *name, const char *value);
+const char *res_get_def(Res r, const char *name, const char *def);
YAZ_EXPORT
-int res_trav (Res r, const char *prefix, void *p,
- void (*f)(void *p, const char *name, const char *value));
+int res_get_match(Res r, const char *name, const char *value, const char *s);
+
+YAZ_EXPORT
+void res_set(Res r, const char *name, const char *value);
YAZ_EXPORT
-int res_write (Res r);
+int res_trav(Res r, const char *prefix, void *p,
+ void (*f)(void *p, const char *name, const char *value));
YAZ_EXPORT
-const char *res_get_prefix (Res r, const char *name, const char *prefix,
- const char *def);
+const char *res_get_prefix(Res r, const char *name, const char *prefix,
+ const char *def);
YAZ_EXPORT
ZEBRA_RES res_get_int(Res r, const char *name, int *val);
-/* $Id: apitest.c,v 1.22 2005-03-09 12:14:42 adam Exp $
+/* $Id: apitest.c,v 1.23 2005-09-13 11:51:06 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
exit (1);
}
/* open Zebra */
- zh = zebra_open (zs);
+ zh = zebra_open (zs, 0);
if (!zh)
{
printf ("zebras_open failed\n");
-/* $Id: index.h,v 1.149 2005-08-19 11:04:23 adam Exp $
+/* $Id: index.h,v 1.150 2005-09-13 11:51:06 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int destroyed;
ZebraSet sets;
Res res;
+ Res session_res;
char *user_perm;
int errCode;
zint hits;
-/* $Id: main.c,v 1.126 2005-08-26 10:11:49 adam Exp $
+/* $Id: main.c,v 1.127 2005-09-13 11:51:06 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int nsections = 0;
int enable_commit = 1;
char *database = 0;
- Res res = res_open(0, 0, 0);
+ Res res = res_open(0, 0);
int trans_started=0;
#if HAVE_SYS_TIMES_H
yaz_log (YLOG_FATAL, "Cannot read config %s", config);
exit (1);
}
- zh = zebra_open (zs);
+ zh = zebra_open (zs, 0);
zebra_shadow_enable (zh, enable_commit);
}
-/* $Id: zebraapi.c,v 1.184 2005-08-22 09:04:18 adam Exp $
+/* $Id: zebraapi.c,v 1.185 2005-09-13 11:51:06 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
static int log_level = 0;
static int log_level_initialized = 0;
-static Res zebra_open_res (ZebraHandle zh);
-static void zebra_close_res (ZebraHandle zh);
+static void zebra_open_res(ZebraHandle zh);
+static void zebra_close_res(ZebraHandle zh);
static void zebra_chdir (ZebraService zs)
{
zebra_index_merge (zh );
}
-static struct zebra_register *zebra_register_open (ZebraService zs,
- const char *name,
- int rw, int useshadow,
- Res res,
- const char *reg_path);
+static struct zebra_register *zebra_register_open(ZebraService zs,
+ const char *name,
+ int rw, int useshadow,
+ Res res,
+ const char *reg_path);
static void zebra_register_close (ZebraService zs, struct zebra_register *reg);
-ZebraHandle zebra_open (ZebraService zs)
+ZebraHandle zebra_open(ZebraService zs, Res res)
{
ZebraHandle zh;
const char *default_encoding;
zh->errCode = 0;
zh->errString = 0;
zh->res = 0;
+ zh->session_res = res_open(zs->global_res, res);
zh->user_perm = 0;
zh->reg_name = xstrdup ("");
zh->shadow_enable = 1;
zh->m_staticrank = 0;
- default_encoding = res_get_def(zs->global_res, "encoding", "ISO-8859-1");
+ default_encoding = res_get_def(zh->session_res, "encoding", "ISO-8859-1");
zh->iconv_to_utf8 =
yaz_iconv_open ("UTF-8", default_encoding);
yaz_log(YLOG_LOG, "zebra_start %s %s", ZEBRAVER,
configName ? configName : "");
- if ((res = res_open (configName, def_res, over_res)))
+ if ((res = res_open(def_res, over_res)))
{
const char *passwd_plain = 0;
const char *passwd_encrypt = 0;
ZebraService zh = xmalloc(sizeof(*zh));
+ if (configName)
+ res_read_file(res, configName);
+
zh->global_res = res;
zh->sessions = 0;
}
static
-struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
- int rw, int useshadow, Res res,
- const char *reg_path)
+struct zebra_register *zebra_register_open(ZebraService zs, const char *name,
+ int rw, int useshadow, Res res,
+ const char *reg_path)
{
struct zebra_register *reg;
int record_compression = REC_COMPRESS_NONE;
if (zh->reg)
zebra_register_close (zh->service, zh->reg);
zebra_close_res (zh);
+ res_close(zh->session_res);
xfree(zh->record_encoding);
int new_num_max;
};
-static Res zebra_open_res (ZebraHandle zh)
+static void zebra_open_res(ZebraHandle zh)
{
- Res res = 0;
char fname[512];
ASSERTZH;
zh->errCode = 0;
if (zh->path_reg)
{
- sprintf (fname, "%.200s/zebra.cfg", zh->path_reg);
- res = res_open (fname, zh->service->global_res, 0);
- if (!res)
- res = zh->service->global_res;
+ sprintf(fname, "%.200s/zebra.cfg", zh->path_reg);
+ zh->res = res_open(zh->session_res, 0);
+ res_read_file(zh->res, fname);
}
else if (*zh->reg_name == 0)
{
- res = zh->service->global_res;
+ zh->res = res_open(zh->session_res, 0);
}
else
{
yaz_log (YLOG_WARN, "no register root specified");
- return 0; /* no path for register - fail! */
+ zh->res = 0; /* no path for register - fail! */
}
- return res;
}
static void zebra_close_res (ZebraHandle zh)
{
ASSERTZH;
zh->errCode = 0;
- if (zh->res != zh->service->global_res)
- res_close (zh->res);
+ res_close (zh->res);
zh->res = 0;
}
strcat (zh->path_reg, zh->reg_name);
}
}
- zh->res = zebra_open_res (zh);
+ zebra_open_res(zh);
if (zh->lock_normal)
zebra_lock_destroy (zh->lock_normal);
if (zh->res)
{
char fname[512];
- const char *lock_area =res_get (zh->res, "lockDir");
+ const char *lock_area = res_get (zh->res, "lockDir");
if (!lock_area && zh->path_reg)
res_set (zh->res, "lockDir", zh->path_reg);
/* no database has been selected - so we select based on
resource setting (including group)
*/
- const char *group = res_get(zh->service->global_res, "group");
- const char *v = res_get_prefix(zh->service->global_res,
+ const char *group = res_get(zh->session_res, "group");
+ const char *v = res_get_prefix(zh->session_res,
"database", group, "Default");
return zebra_select_database(zh, v);
}
odr_malloc (stream, sizeof(*info.new_basenames) * info.new_num_max);
info.mem = stream->mem;
- res_trav (zh->service->global_res, "mapdb", &info, map_basenames_func);
+ res_trav (zh->session_res, "mapdb", &info, map_basenames_func);
for (i = 0; i<p->num_bases; i++)
if (p->basenames[i] && p->new_num_bases < p->new_num_max)
}
zebra_set_state (zh, 'd', seqno);
- zh->reg = zebra_register_open (zh->service, zh->reg_name,
- 1, rval ? 1 : 0, zh->res,
- zh->path_reg);
+ zh->reg = zebra_register_open(zh->service, zh->reg_name,
+ 1, rval ? 1 : 0, zh->res,
+ zh->path_reg);
if (zh->reg)
zh->reg->seqno = seqno;
else
resultSetInvalidate (zh);
zebra_register_close (zh->service, zh->reg);
}
- zh->reg = zebra_register_open (zh->service, zh->reg_name,
- 0, val == 'c' ? 1 : 0,
- zh->res, zh->path_reg);
+ zh->reg = zebra_register_open(zh->service, zh->reg_name,
+ 0, val == 'c' ? 1 : 0,
+ zh->res, zh->path_reg);
if (!zh->reg)
{
zebra_unlock (zh->lock_normal);
-/* $Id: zebrash.c,v 1.34 2005-06-14 20:28:54 adam Exp $
+/* $Id: zebrash.c,v 1.35 2005-09-13 11:51:06 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
if (!zs)
wrbuf_puts(outbuff,"zebra seems not to have been started, "
"trying anyway\n");
- zh=zebra_open(zs);
+ zh = zebra_open(zs, 0);
return 0; /* ok */
}
-/* $Id: zserver.c,v 1.139 2005-08-22 09:04:18 adam Exp $
+/* $Id: zserver.c,v 1.140 2005-09-13 11:51:06 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
yaz_log (YLOG_DEBUG, "bend_init");
sob = statserv_getcontrol ();
- if (!(zh = zebra_open (sob->handle)))
+ if (!(zh = zebra_open (sob->handle, 0)))
{
yaz_log (YLOG_WARN, "Failed to read config `%s'", sob->configname);
r->errcode = YAZ_BIB1_PERMANENT_SYSTEM_ERROR;
-/* $Id: safari1.c,v 1.5 2005-05-03 09:11:37 adam Exp $
+/* $Id: safari1.c,v 1.6 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
zint limits[3];
ZebraService zs = start_up("safari.cfg", argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, myrec);
do_query(__LINE__, zh, "@attr 1=any the", 3);
-/* $Id: t1.c,v 1.12 2005-01-15 19:38:35 adam Exp $
+/* $Id: t1.c,v 1.13 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
return close_down(zh, zs, 0);
}
-/* $Id: t10.c,v 1.8 2005-05-24 11:35:43 adam Exp $
+/* $Id: t10.c,v 1.9 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
{
int i;
ZebraService zs = start_up("zebrazv.cfg", argc, argv);
- ZebraHandle zh = zebra_open (zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, recs);
zebra_close(zh);
for (i = 0; tests[i].schema; i++)
{
- zh = zebra_open (zs);
+ zh = zebra_open(zs, 0);
zebra_select_database(zh, "Default");
zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema);
yaz_log(YLOG_LOG,"============%d: %s ===========", i, tests[i].schema);
-/* $Id: t11.c,v 1.2 2005-05-02 09:25:12 adam Exp $
+/* $Id: t11.c,v 1.3 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, myrec);
-/* $Id: t12.c,v 1.1 2005-05-09 13:22:44 adam Exp $
+/* $Id: t12.c,v 1.2 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int i;
int no_db = 140;
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
zebra_select_database(zh, "Default");
zebra_init(zh);
zebra_close(zh);
- zh = zebra_open (zs);
+ zh = zebra_open(zs, 0);
zebra_begin_trans (zh, 1);
for (i = 0; i<no_db; i++)
}
zebra_end_trans(zh);
zebra_close(zh);
- zh = zebra_open(zs);
+ zh = zebra_open(zs, 0);
for (i = 0; i<=no_db; i++)
{
char dbstr[20];
-/* $Id: t13.c,v 1.1 2005-08-17 21:30:31 adam Exp $
+/* $Id: t13.c,v 1.2 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
if (!zs)
exit(2);
- zh = zebra_open(zs);
+ zh = zebra_open(zs, 0);
zebra_select_database(zh, "Default");
-/* $Id: t2.c,v 1.16 2005-01-15 19:38:35 adam Exp $
+/* $Id: t2.c,v 1.17 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, myrec);
do_query(__LINE__,zh, "@attr 1=4 my", 1);
-/* $Id: t3.c,v 1.17 2005-04-15 10:47:49 adam Exp $
+/* $Id: t3.c,v 1.18 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
{
int i;
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, myrec);
-/* $Id: t4.c,v 1.17 2005-05-11 12:39:37 adam Exp $
+/* $Id: t4.c,v 1.18 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int number_to_fetch = 5;
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, myrec);
zebra_stop(zs);
zs = start_service("");
- zh = zebra_open(zs);
+ zh = zebra_open(zs, 0);
zebra_select_database(zh, "Default");
zebra_set_resource(zh, "sortmax", "3"); /* make small sort boundary */
-/* $Id: t5.c,v 1.13 2005-06-23 06:45:47 adam Exp $
+/* $Id: t5.c,v 1.14 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, myrec);
-/* $Id: t6.c,v 1.10 2005-08-05 10:40:13 adam Exp $
+/* $Id: t6.c,v 1.11 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
{
int i;
ZebraService zs = start_up("zebra6.cfg", argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
srand(17);
{
int l;
- zh = zebra_open (zs);
+ zh = zebra_open (zs, 0);
zebra_select_database(zh, "Default");
zebra_begin_trans (zh, 1);
zebra_end_trans(zh);
zebra_close(zh);
}
- zh = zebra_open(zs);
+ zh = zebra_open(zs, 0);
zebra_select_database(zh, "Default");
-/* $Id: t7.c,v 1.9 2005-05-11 12:39:38 adam Exp $
+/* $Id: t7.c,v 1.10 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int status;
ZEBRA_RES ret;
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open (zs);
+ ZebraHandle zh = zebra_open (zs, 0);
ODR odr_input = odr_createmem (ODR_DECODE);
ODR odr_output = odr_createmem (ODR_ENCODE);
YAZ_PQF_Parser parser = yaz_pqf_create();
-/* $Id: t8.c,v 1.7 2005-01-15 19:38:35 adam Exp $
+/* $Id: t8.c,v 1.8 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up("zebra8.cfg", argc, argv);
- ZebraHandle zh = zebra_open (zs);
+ ZebraHandle zh = zebra_open (zs, 0);
init_data(zh, recs);
-/* $Id: t9.c,v 1.6 2005-05-24 11:35:43 adam Exp $
+/* $Id: t9.c,v 1.7 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, recs);
-/* $Id: testlib.c,v 1.26 2005-08-18 12:50:18 adam Exp $
+/* $Id: testlib.c,v 1.27 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
}
/** start_service - do a zebra_start with a decent config name */
-ZebraService start_service(char *cfgname)
+ZebraService start_service(const char *cfgname)
{
char cfg[256];
const char *srcdir = get_srcdir();
cfgname="zebra.cfg";
sprintf(cfg, "%.200s/%.50s", srcdir, cfgname);
- zs=zebra_start(cfg);
+ zs = zebra_start(cfg);
if (!zs)
{
printf("zebra_start failed, probably because missing config file \n"
-/* $Id: testlib.h,v 1.15 2005-08-09 12:30:47 adam Exp $
+/* $Id: testlib.h,v 1.16 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
* and uses that if need be.
* The name defaults to zebra.cfg, if null or emtpy
*/
-ZebraService start_service(char *cfgname);
+ZebraService start_service(const char *cfgname);
/**
-/* $Id: charmap1.c,v 1.7 2005-06-14 12:42:19 adam Exp $
+/* $Id: charmap1.c,v 1.8 2005-09-13 11:51:07 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
char path[256];
check_filter(zs, "grs.xml");
-/* $Id: t1.c,v 1.4 2005-01-15 19:38:35 adam Exp $
+/* $Id: t1.c,v 1.5 2005-09-13 11:51:08 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
char path[256];
int i, errs = 0;
-/* $Id: grs.marc.c,v 1.1 2005-06-14 20:03:02 adam Exp $
+/* $Id: grs.marc.c,v 1.2 2005-09-13 11:51:08 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
char path[256];
check_filter(zs, "grs.marc");
-/* $Id: grs.xml.c,v 1.1 2005-06-14 20:03:02 adam Exp $
+/* $Id: grs.xml.c,v 1.2 2005-09-13 11:51:08 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
char path[256];
check_filter(zs, "grs.xml");
-/* $Id: text.c,v 1.1 2005-06-14 20:03:02 adam Exp $
+/* $Id: text.c,v 1.2 2005-09-13 11:51:08 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
char path[256];
check_filter(zs, "text");
-/* $Id: t1.c,v 1.5 2005-04-28 08:20:41 adam Exp $
+/* $Id: t1.c,v 1.6 2005-09-13 11:51:08 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
char path[256];
check_filter(zs, "grs.xml");
-/* $Id: t2.c,v 1.4 2005-04-28 08:20:41 adam Exp $
+/* $Id: t2.c,v 1.5 2005-09-13 11:51:08 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
char path[256];
zebra_select_database(zh, "Default");
-/* $Id: mbox1.c,v 1.1 2005-04-28 09:18:20 adam Exp $
+/* $Id: mbox1.c,v 1.2 2005-09-13 11:51:08 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
char path[256];
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
check_filter(zs, "grs.regx");
zebra_select_database(zh, "Default");
-/* $Id: t1.c,v 1.3 2005-01-15 19:38:39 adam Exp $
+/* $Id: t1.c,v 1.4 2005-09-13 11:51:09 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
char path[256];
check_koi8r();
-/* $Id: sort1.c,v 1.5 2005-08-09 12:30:47 adam Exp $
+/* $Id: sort1.c,v 1.6 2005-09-13 11:51:09 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
zint ids[5];
char path[256];
int i;
-/* $Id: t1.c,v 1.3 2005-08-09 12:30:48 adam Exp $
+/* $Id: t1.c,v 1.4 2005-09-13 11:51:10 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
char path[256];
int i;
zint ids[5];
-/* $Id: xpath1.c,v 1.3 2005-01-15 19:38:40 adam Exp $
+/* $Id: xpath1.c,v 1.4 2005-09-13 11:51:10 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
0};
zs = start_up(0, argc, argv);
- zh = zebra_open(zs);
+ zh = zebra_open(zs, 0);
init_data(zh, myrec);
do_query(__LINE__,zh, "@attr 1=/sgml/tag before", 0);
-/* $Id: xpath2.c,v 1.3 2005-01-15 19:38:40 adam Exp $
+/* $Id: xpath2.c,v 1.4 2005-09-13 11:51:11 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open (zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, myrec);
do_query(__LINE__,zh, "@attr 1=/Zthes/termName Sauropoda", 1);
-/* $Id: xpath3.c,v 1.4 2005-01-15 19:38:40 adam Exp $
+/* $Id: xpath3.c,v 1.5 2005-09-13 11:51:11 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, myrec);
#define q(qry,hits) do_query(__LINE__,zh,qry,hits)
-/* $Id: xpath4.c,v 1.3 2005-01-15 19:38:40 adam Exp $
+/* $Id: xpath4.c,v 1.4 2005-09-13 11:51:11 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
#if 0
yaz_log_init_level( yaz_log_mask_str_x("xpath4,rsbetween", LOG_DEFAULT_LEVEL));
-/* $Id: xpath5.c,v 1.3 2005-01-15 19:38:40 adam Exp $
+/* $Id: xpath5.c,v 1.4 2005-09-13 11:51:11 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int main(int argc, char **argv)
{
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
init_data(zh, recs);
// yaz_log_init_level(LOG_ALL);
-/* $Id: xpath6.c,v 1.4 2005-06-29 16:52:27 adam Exp $
+/* $Id: xpath6.c,v 1.5 2005-09-13 11:51:11 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
{
int i;
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
char path[256];
zebra_select_database(zh, "Default");
-/* $Id: xslt1.c,v 1.4 2005-08-18 12:50:20 adam Exp $
+/* $Id: xslt1.c,v 1.5 2005-09-13 11:51:11 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
char path[256];
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
check_filter(zs, "xslt");
-/* $Id: xslt2.c,v 1.4 2005-08-18 12:50:20 adam Exp $
+/* $Id: xslt2.c,v 1.5 2005-09-13 11:51:11 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
size_t r;
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
check_filter(zs, "xslt");
-/* $Id: xslt3.c,v 1.3 2005-08-18 12:50:20 adam Exp $
+/* $Id: xslt3.c,v 1.4 2005-09-13 11:51:11 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
size_t r;
ZebraService zs = start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
check_filter(zs, "xslt");
-/* $Id: xslt4.c,v 1.1 2005-08-18 12:50:20 adam Exp $
+/* $Id: xslt4.c,v 1.2 2005-09-13 11:51:11 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
char path[256];
ZebraService zs = start_up("zebrastaticrank.cfg", argc, argv);
- ZebraHandle zh = zebra_open(zs);
+ ZebraHandle zh = zebra_open(zs, 0);
check_filter(zs, "xslt");
-/* $Id: res.c,v 1.44 2005-08-17 21:28:07 adam Exp $
+/* $Id: res.c,v 1.45 2005-09-13 11:51:11 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
struct res_struct {
struct res_entry *first, *last;
- char *name;
- int init;
Res def_res;
Res over_res;
};
-static struct res_entry *add_entry (Res r)
+static struct res_entry *add_entry(Res r)
{
struct res_entry *resp;
if (!r->first)
resp = r->last = r->first =
- (struct res_entry *) xmalloc (sizeof(*resp));
+ (struct res_entry *) xmalloc(sizeof(*resp));
else
{
- resp = (struct res_entry *) xmalloc (sizeof(*resp));
+ resp = (struct res_entry *) xmalloc(sizeof(*resp));
r->last->next = resp;
r->last = resp;
}
return dst;
}
-static void reread (Res r)
+ZEBRA_RES res_read_file(Res r, const char *fname)
{
struct res_entry *resp;
char *line;
char fr_buf[1024];
FILE *fr;
- assert (r);
- r->init = 1;
-
- if (!r->name)
- return;
+ assert(r);
- fr = fopen (r->name, "r");
+ fr = fopen(fname, "r");
if (!fr)
{
- yaz_log (YLOG_WARN|YLOG_ERRNO, "Cannot open `%s'", r->name);
- return ;
+ yaz_log(YLOG_WARN|YLOG_ERRNO, "Cannot open `%s'", fname);
+ return ZEBRA_FAIL;
}
- val_buf = (char*) xmalloc (val_max);
+ val_buf = (char*) xmalloc(val_max);
while (1)
{
- line = fgets (fr_buf, sizeof(fr_buf)-1, fr);
+ line = fgets(fr_buf, sizeof(fr_buf)-1, fr);
if (!line)
break;
- if (*line == '#')
- {
- int no = 0;
-
- while (fr_buf[no] && fr_buf[no] != '\n')
- no++;
- fr_buf[no] = '\0';
-
- resp = add_entry (r);
- resp->name = (char*) xmalloc (no+1);
- resp->value = NULL;
- strcpy (resp->name, fr_buf);
- }
- else
+ if (*line != '#')
{
int no = 0;
while (1)
no = 0;
break;
}
- if (strchr (": \t", fr_buf[no]))
+ if (strchr(": \t", fr_buf[no]))
break;
no++;
}
if (!no)
continue;
fr_buf[no++] = '\0';
- resp = add_entry (r);
- resp->name = (char*) xmalloc (no);
- strcpy (resp->name, fr_buf);
+ resp = add_entry(r);
+ resp->name = (char*) xmalloc(no);
+ strcpy(resp->name, fr_buf);
- while (strchr (" \t", fr_buf[no]))
+ while (strchr(" \t", fr_buf[no]))
no++;
val_size = 0;
while (1)
val_size--;
val_buf[val_size] = '\0';
resp->value = xstrdup_env(val_buf);
- yaz_log (YLOG_DEBUG, "(name=%s,value=%s)",
+ yaz_log(YLOG_DEBUG, "(name=%s,value=%s)",
resp->name, resp->value);
break;
}
- else if (fr_buf[no] == '\\' && strchr ("\n\r\f", fr_buf[no+1]))
+ else if (fr_buf[no] == '\\' && strchr("\n\r\f", fr_buf[no+1]))
{
- line = fgets (fr_buf, sizeof(fr_buf)-1, fr);
+ line = fgets(fr_buf, sizeof(fr_buf)-1, fr);
if (!line)
{
val_buf[val_size] = '\0';
{
char *nb;
- nb = (char*) xmalloc (val_max+=1024);
- memcpy (nb, val_buf, val_size);
- xfree (val_buf);
+ nb = (char*) xmalloc(val_max+=1024);
+ memcpy(nb, val_buf, val_size);
+ xfree(val_buf);
val_buf = nb;
}
}
}
}
}
- xfree (val_buf);
- fclose (fr);
+ xfree(val_buf);
+ fclose(fr);
+ return ZEBRA_OK;
}
-Res res_open (const char *name, Res def_res, Res over_res)
+Res res_open(Res def_res, Res over_res)
{
Res r;
- if (name)
- {
-#ifdef WIN32
- if (access (name, 4))
-#else
- if (access (name, R_OK))
-#endif
- {
- yaz_log (YLOG_WARN|YLOG_ERRNO, "Cannot open `%s'", name);
- return 0;
- }
- }
- r = (Res) xmalloc (sizeof(*r));
- r->init = 0;
+ r = (Res) xmalloc(sizeof(*r));
r->first = r->last = NULL;
- if (name)
- r->name = xstrdup (name);
- else
- r->name=0;
r->def_res = def_res;
r->over_res = over_res;
return r;
}
-void res_clear (Res r)
+void res_clear(Res r)
{
- if (r->init)
+ struct res_entry *re, *re1;
+ for (re = r->first; re; re=re1)
{
- struct res_entry *re, *re1;
- for (re = r->first; re; re=re1)
- {
- if (re->name)
- xfree (re->name);
- if (re->value)
- xfree (re->value);
- re1 = re->next;
- xfree (re);
- }
+ if (re->name)
+ xfree(re->name);
+ if (re->value)
+ xfree(re->value);
+ re1 = re->next;
+ xfree(re);
}
- r->init = 0;
r->first = r->last = NULL;
}
-void res_close (Res r)
+void res_close(Res r)
{
if (!r)
return;
res_clear(r);
- xfree (r->name);
- xfree (r);
+ xfree(r);
}
-const char *res_get_prefix (Res r, const char *name, const char *prefix,
+const char *res_get_prefix(Res r, const char *name, const char *prefix,
const char *def)
{
const char *v = 0;;
return v;
}
-const char *res_get (Res r, const char *name)
+const char *res_get(Res r, const char *name)
{
struct res_entry *re;
const char *v;
if (v)
return v;
- if (!r->init)
- reread (r);
for (re = r->first; re; re=re->next)
- if (re->value && !yaz_matchstr (re->name, name))
+ if (re->value && !yaz_matchstr(re->name, name))
return re->value;
- return res_get (r->def_res, name);
+ return res_get(r->def_res, name);
}
-const char *res_get_def (Res r, const char *name, const char *def)
+const char *res_get_def(Res r, const char *name, const char *def)
{
const char *t;
- if (!(t = res_get (r, name)))
+ if (!(t = res_get(r, name)))
{
- yaz_log (YLOG_DEBUG, "CAUTION: Using default resource %s:%s", name, def);
+ yaz_log(YLOG_DEBUG, "CAUTION: Using default resource %s:%s", name, def);
return def;
}
else
return t;
}
-int res_get_match (Res r, const char *name, const char *value, const char *s)
+int res_get_match(Res r, const char *name, const char *value, const char *s)
{
- const char *cn = res_get (r, name);
+ const char *cn = res_get(r, name);
if (!cn)
cn = s;
- if (cn && !yaz_matchstr (cn, value))
+ if (cn && !yaz_matchstr(cn, value))
return 1;
return 0;
}
-void res_set (Res r, const char *name, const char *value)
+void res_set(Res r, const char *name, const char *value)
{
struct res_entry *re;
- assert (r);
- if (!r->init)
- reread (r);
+ assert(r);
for (re = r->first; re; re=re->next)
- if (re->value && !yaz_matchstr (re->name, name))
+ if (re->value && !yaz_matchstr(re->name, name))
{
- xfree (re->value);
- re->value = xstrdup_env (value);
+ xfree(re->value);
+ re->value = xstrdup_env(value);
return;
}
- re = add_entry (r);
- re->name = xstrdup (name);
- re->value = xstrdup_env (value);
+ re = add_entry(r);
+ re->name = xstrdup(name);
+ re->value = xstrdup_env(value);
}
-int res_trav (Res r, const char *prefix, void *p,
+int res_trav(Res r, const char *prefix, void *p,
void (*f)(void *p, const char *name, const char *value))
{
struct res_entry *re;
if (!r)
return 0;
+ no = res_trav(r->over_res, prefix, p, f);
+ if (no)
+ return no;
if (prefix)
l = strlen(prefix);
- if (!r->init)
- reread (r);
for (re = r->first; re; re=re->next)
if (re->value)
- if (l==0 || !memcmp (re->name, prefix, l))
+ if (l==0 || !memcmp(re->name, prefix, l))
{
(*f)(p, re->name, re->value);
no++;
}
if (!no)
- return res_trav (r->def_res, prefix, p, f);
+ return res_trav(r->def_res, prefix, p, f);
return no;
}
-int res_write (Res r)
+ZEBRA_RES res_write_file(Res r, const char *fname)
{
struct res_entry *re;
FILE *fr;
- assert (r);
- if (!r->init)
- reread (r);
- if (!r->name)
- return 0; /* ok, this was not from a file */
- fr = fopen (r->name, "w");
+ assert(r);
+ fr = fopen(fname, "w");
if (!fr)
{
- yaz_log (YLOG_FATAL|YLOG_ERRNO, "Cannot create `%s'", r->name);
- exit (1);
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "Cannot create `%s'", fname);
+ exit(1);
}
for (re = r->first; re; re=re->next)
int lefts = strlen(re->name)+2;
if (!re->value)
- fprintf (fr, "%s\n", re->name);
+ fprintf(fr, "%s\n", re->name);
else
{
- fprintf (fr, "%s: ", re->name);
+ fprintf(fr, "%s: ", re->name);
while (lefts + strlen(re->value+no) > 78)
{
int i = 20;
if (i<0)
ind = no + 78 - lefts;
for (i = no; i != ind; i++)
- putc (re->value[i], fr);
- fprintf (fr, "\\\n");
+ putc(re->value[i], fr);
+ fprintf(fr, "\\\n");
no=ind;
lefts = 0;
}
- fprintf (fr, "%s\n", re->value+no);
+ fprintf(fr, "%s\n", re->value+no);
}
}
- fclose (fr);
- return 0;
+ fclose(fr);
+ return ZEBRA_OK;
}
ZEBRA_RES res_get_int(Res r, const char *name, int *val)