-/* $Id: extract.c,v 1.124 2002-10-16 09:30:57 heikki Exp $
+/* $Id: extract.c,v 1.125 2002-10-22 09:37:55 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
if (!zh->reg->key_buf)
{
- int mem = 8*1024*1024;
+ int mem= 1024*1024* atoi( res_get_def( zh->res, "memmax", "8"));
+ if (mem <= 0)
+ {
+ logf(LOG_WARN, "Invalid memory setting, using default 8 MB");
+ mem= 1024*1024*8;
+ }
+ /* FIXME: That "8" should be in a default settings include */
+ /* not hard-coded here! -H */
zh->reg->key_buf = (char**) xmalloc (mem);
zh->reg->ptr_top = mem/sizeof(char*);
zh->reg->ptr_i = 0;
-/* $Id: main.c,v 1.98 2002-10-04 18:15:09 adam Exp $
+/* $Id: main.c,v 1.99 2002-10-22 09:37:55 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
char *configName = 0;
int nsections = 0;
int disableCommit = 0;
- size_t mem_max = 0;
+ char *mem_max = 0;
+
int trans_started=0;
#if HAVE_SYS_TIMES_H
struct tms tms1, tms2;
if (disableCommit)
zebra_shadow_enable (zh, 0);
}
+
if (rGroupDef.databaseName)
{
if (zebra_select_database (zh, rGroupDef.databaseName))
+ {
+ logf(LOG_FATAL, "Could not select database %s errCode=%d",
+ rGroupDef.databaseName, zebra_errCode(zh) );
exit (1);
+ }
}
else
{
if (zebra_select_database (zh, "Default"))
+ {
+ logf(LOG_FATAL, "Could not select database Default errCode=%d",
+ zebra_errCode(zh) );
exit (1);
+ }
}
+ if (mem_max)
+ zebra_set_resource(zh, "memmax",mem_max);
if (!strcmp (arg, "update"))
cmd = 'u';
else if (ret == 'l')
yaz_log_init_file (arg);
else if (ret == 'm')
- mem_max = 1024*1024*atoi(arg);
+ mem_max = arg;
else if (ret == 'd')
rGroupDef.databaseName = arg;
else if (ret == 's')
-/* $Id: zebraapi.c,v 1.73 2002-09-17 12:27:12 adam Exp $
+/* $Id: zebraapi.c,v 1.74 2002-10-22 09:37:56 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
zh->destroyed = 0;
zh->errCode = 0;
zh->errString = 0;
- zh->res = 0;
+ zh->res = 0;
zh->reg_name = xstrdup ("");
zh->path_reg = 0;
zh->record_encoding = xstrdup (encoding);
return 0;
}
+
+void zebra_set_resource(ZebraHandle zh, const char *name, const char *value)
+{
+ res_put(zh->res, name, value);
+}
+
+const char *zebra_get_resource(ZebraHandle zh,
+ const char *name, const char *defaultvalue)
+{
+ return res_get_def( zh->res, name, (char *)defaultvalue);
+}
-/* $Id: zebraapi.h,v 1.21 2002-09-17 12:27:12 adam Exp $
+/* $Id: zebraapi.h,v 1.22 2002-10-22 09:37:56 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
YAZ_EXPORT
int zebra_record_encoding (ZebraHandle zh, const char *encoding);
+/* Resources */
+YAZ_EXPORT
+void zebra_set_resource(ZebraHandle zh, const char *name, const char *value);
+YAZ_EXPORT
+const char *zebra_get_resource(ZebraHandle zh,
+ const char *name, const char *defaultvalue);
+
+
YAZ_END_CDECL
#endif
-/* $Id: res.c,v 1.32 2002-09-09 09:35:48 adam Exp $
+/* $Id: res.c,v 1.33 2002-10-22 09:37:56 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
val_buf = (char*) xmalloc (val_max);
+ if (!r->name)
+ return;
+
fr = fopen (r->name, "r");
if (!fr)
{
Res res_open (const char *name, Res def_res)
{
Res r;
+
+ if (name)
+ {
#ifdef WIN32
- if (access (name, 4))
+ if (access (name, 4))
#else
- if (access (name, R_OK))
+ if (access (name, R_OK))
#endif
- {
- logf (LOG_WARN|LOG_ERRNO, "Cannot open `%s'", name);
- return 0;
+ {
+ logf (LOG_WARN|LOG_ERRNO, "Cannot open `%s'", name);
+ return 0;
+ }
}
r = (Res) xmalloc (sizeof(*r));
r->init = 0;
r->first = r->last = NULL;
- r->name = xstrdup (name);
+ if (name)
+ r->name = xstrdup (name);
+ else
+ r->name=0;
r->def_res = def_res;
return r;
}
assert (r);
if (!r->init)
reread (r);
+ if (!r->name)
+ return 0; /* ok, this was not from a file */
fr = fopen (r->name, "w");
if (!fr)
{