/*
- * Copyright (c) 1995-1997, Index Data.
+ * Copyright (c) 1995-1999, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_map.c,v $
- * Revision 1.13 1998-02-11 11:53:35 adam
+ * Revision 1.17 1999-11-30 13:47:12 adam
+ * Improved installation. Moved header files to include/yaz.
+ *
+ * Revision 1.16 1999/10/21 12:06:29 adam
+ * Retrieval module no longer uses ctype.h - functions.
+ *
+ * Revision 1.15 1999/08/27 09:40:32 adam
+ * Renamed logf function to yaz_log. Removed VC++ project files.
+ *
+ * Revision 1.14 1998/10/13 16:09:50 adam
+ * Added support for arbitrary OID's for tagsets, schemas and attribute sets.
+ * Added support for multiple attribute set references and tagset references
+ * from an abstract syntax file.
+ * Fixed many bad logs-calls in routines that read the various
+ * specifications regarding data1 (*.abs,*.att,...) and made the messages
+ * consistent whenever possible.
+ * Added extra 'lineno' argument to function readconf_line.
+ *
+ * Revision 1.13 1998/02/11 11:53:35 adam
* Changed code so that it compiles as C++.
*
* Revision 1.12 1997/11/18 09:51:09 adam
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
-
-#include <oid.h>
-#include <log.h>
-#include <readconf.h>
-#include <tpath.h>
-#include <data1.h>
-#include <d1_map.h>
+#include <yaz/oid.h>
+#include <yaz/log.h>
+#include <yaz/readconf.h>
+#include <yaz/tpath.h>
+#include <yaz/data1.h>
+#include <yaz/d1_map.h>
data1_maptab *data1_read_maptab (data1_handle dh, const char *file)
{
NMEM mem = data1_nmem_get (dh);
data1_maptab *res = (data1_maptab *)nmem_malloc(mem, sizeof(*res));
FILE *f;
+ int lineno = 0;
int argc;
char *argv[50], line[512];
data1_mapunit **mapp;
if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r")))
{
- logf(LOG_WARN|LOG_ERRNO, "%s", file);
+ yaz_log(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
}
res->name = 0;
- res->target_absyn_ref = ODR_NONE;
+ res->target_absyn_ref = VAL_NONE;
res->map = 0;
mapp = &res->map;
res->next = 0;
- while ((argc = readconf_line(f, line, 512, argv, 50)))
+ while ((argc = readconf_line(f, &lineno, line, 512, argv, 50)))
if (!strcmp(argv[0], "targetref"))
{
if (argc != 2)
{
- logf(LOG_WARN, "%s: one argument required for targetref",
- file);
+ yaz_log(LOG_WARN, "%s:%d: Bad # args for targetref",
+ file, lineno);
continue;
}
- if ((res->target_absyn_ref = oid_getvalbyname(argv[1])) == ODR_NONE)
+ if ((res->target_absyn_ref = oid_getvalbyname(argv[1]))
+ == VAL_NONE)
{
- logf(LOG_WARN, "%s: Unknown reference '%s'", file, argv[1]);
+ yaz_log(LOG_WARN, "%s:%d: Unknown reference '%s'",
+ file, lineno, argv[1]);
continue;
}
}
{
if (argc != 2)
{
- logf(LOG_WARN, "%s: one argument required for targetref",
- file);
+ yaz_log(LOG_WARN, "%s:%d: Bad # args for targetname",
+ file, lineno);
continue;
}
- res->target_absyn_name = (char *)nmem_malloc(mem, strlen(argv[1])+1);
+ res->target_absyn_name =
+ (char *)nmem_malloc(mem, strlen(argv[1])+1);
strcpy(res->target_absyn_name, argv[1]);
}
else if (!yaz_matchstr(argv[0], "localnumeric"))
{
if (argc != 2)
{
- logf(LOG_WARN, "%s: one argument required for name",
- file);
+ yaz_log(LOG_WARN, "%s:%d: Bad # args for name", file, lineno);
continue;
}
res->name = (char *)nmem_malloc(mem, strlen(argv[1])+1);
if (argc < 3)
{
- logf(LOG_WARN, "%s: At least 2 arguments required for map",
- file);
+ yaz_log(LOG_WARN, "%s:%d: Bad # of args for map",
+ file, lineno);
continue;
}
*mapp = (data1_mapunit *)nmem_malloc(mem, sizeof(**mapp));
(*mapp)->no_data = 1;
else
(*mapp)->no_data = 0;
- (*mapp)->source_element_name = (char *)nmem_malloc(mem, strlen(argv[1])+1);
+ (*mapp)->source_element_name =
+ (char *)nmem_malloc(mem, strlen(argv[1])+1);
strcpy((*mapp)->source_element_name, argv[1]);
mtp = &(*mapp)->target_path;
if (*path == '/')
if ((np = sscanf(path, "(%d,%[^)]):%[^/]", &type, valstr,
parm)) < 2)
{
- logf(LOG_WARN, "%s: Syntax error in map directive: %s",
- file, argv[2]);
+ yaz_log(LOG_WARN, "%s:%d: Syntax error in map "
+ "directive: %s", file, lineno, argv[2]);
fclose(f);
return 0;
}
(*mtp)->new_field = 1;
else
(*mtp)->new_field = 0;
- if ((type != 3 || local_numeric) && isdigit(*valstr))
+ if ((type != 3 || local_numeric) && d1_isdigit(*valstr))
{
(*mtp)->which = D1_MAPTAG_numeric;
(*mtp)->value.numeric = atoi(valstr);
else
{
(*mtp)->which = D1_MAPTAG_string;
- (*mtp)->value.string = (char *)nmem_malloc(mem, strlen(valstr)+1);
+ (*mtp)->value.string =
+ (char *)nmem_malloc(mem, strlen(valstr)+1);
strcpy((*mtp)->value.string, valstr);
}
mtp = &(*mtp)->next;
mapp = &(*mapp)->next;
}
else
- logf(LOG_WARN, "%s: Unknown directive '%s'", argv[0]);
+ yaz_log(LOG_WARN, "%s:%d: Unknown directive '%s'",
+ file, lineno, argv[0]);
fclose(f);
return res;
res->u.root.type = map->target_absyn_name;
if (!(res->u.root.absyn = data1_get_absyn(dh, map->target_absyn_name)))
{
- logf(LOG_WARN, "%s: Failed to load target absyn '%s'",
- map->name, map->target_absyn_name);
+ yaz_log(LOG_WARN, "%s: Failed to load target absyn '%s'",
+ map->name, map->target_absyn_name);
}
res->parent = 0;
res->root = res;