/*
- * Copyright (c) 1995-1998, Index Data.
+ * Copyright (c) 1995-1999, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_tagset.c,v $
- * Revision 1.9 1998-10-13 16:09:53 adam
+ * Revision 1.15 2002-04-04 20:49:46 adam
+ * New functions yaz_is_abspath, yaz_path_fopen_base
+ *
+ * Revision 1.14 1999/11/30 13:47:12 adam
+ * Improved installation. Moved header files to include/yaz.
+ *
+ * Revision 1.13 1999/10/21 12:06:29 adam
+ * Retrieval module no longer uses ctype.h - functions.
+ *
+ * Revision 1.12 1999/08/27 09:40:32 adam
+ * Renamed logf function to yaz_log. Removed VC++ project files.
+ *
+ * Revision 1.11 1998/10/19 14:16:36 adam
+ * Fixed data1_gettagbyname. Bug introduced by previous revision.
+ *
+ * Revision 1.10 1998/10/15 08:29:17 adam
+ * Tag set type may be specified in reference to it using "tagset"
+ * directive in .abs-files and "include" directive in .tag-files.
+ *
+ * Revision 1.9 1998/10/13 16:09:53 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.
#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
#include <string.h>
-#include <log.h>
-#include <data1.h>
+#include <yaz/log.h>
+#include <yaz/data1.h>
/*
* We'll probably want to add some sort of hashed index to these lookup-
for (i = 0; types[i].tname; i++)
if (!data1_matchstr(types[i].tname, t))
return types[i].type;
- return 0;
+ return DATA1K_unknown;
}
data1_tag *data1_gettagbynum (data1_handle dh, data1_tagset *s,
int type, int value)
{
data1_tag *r;
-
+
for (; s; s = s->next)
{
/* scan local set */
if (r->which == DATA1T_numeric && r->value.numeric == value)
return r;
/* scan included sets */
- if (s->children && (r = data1_gettagbynum (dh, s->children,
- type, value)))
+ if (s->children &&
+ (r = data1_gettagbynum (dh, s->children, type, value)))
return r;
}
return 0;
}
-data1_tag *data1_gettagbyname (data1_handle dh, data1_tagset *s, char *name)
+data1_tag *data1_gettagbyname (data1_handle dh, data1_tagset *s,
+ const char *name)
{
data1_tag *r;
(data1_tagset *) nmem_malloc(data1_nmem_get (dh), sizeof(*res));
res->name = 0;
res->reference = VAL_NONE;
- res->type = 0;
res->tags = 0;
+ res->type = 0;
res->children = 0;
res->next = 0;
return res;
}
-data1_tagset *data1_read_tagset (data1_handle dh, char *file)
+data1_tagset *data1_read_tagset (data1_handle dh, const char *file, int type)
{
NMEM mem = data1_nmem_get (dh);
- data1_tagset *res = 0, **childp;
+ data1_tagset *res = 0;
+ data1_tagset **childp;
data1_tag **tagp;
FILE *f;
int lineno = 0;
int argc;
char *argv[50], line[512];
- if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r")))
+ if (!(f = data1_path_fopen(dh, file, "r")))
{
- logf(LOG_WARN|LOG_ERRNO, "%s", file);
+ yaz_log(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
}
res = data1_empty_tagset (dh);
+ res->type = type;
childp = &res->children;
tagp = &res->tags;
if (argc != 4)
{
- logf(LOG_WARN, "%s:%d: Bad # args to tag", file, lineno);
+ yaz_log(LOG_WARN, "%s:%d: Bad # args to tag", file, lineno);
continue;
}
value = atoi(argv[1]);
if (!(rr->kind = data1_maptype(dh, type)))
{
- logf(LOG_WARN, "%s:%d: Unknown datatype %s",
+ yaz_log(LOG_WARN, "%s:%d: Unknown datatype %s",
file, lineno, type);
fclose(f);
return 0;
{
if (argc != 2)
{
- logf(LOG_WARN, "%s:%d: Bad # args to name", file, lineno);
+ yaz_log(LOG_WARN, "%s:%d: Bad # args to name", file, lineno);
continue;
}
res->name = nmem_strdup(mem, argv[1]);
if (argc != 2)
{
- logf(LOG_WARN, "%s:%d: Bad # args to reference", file, lineno);
+ yaz_log(LOG_WARN, "%s:%d: Bad # args to reference",
+ file, lineno);
continue;
}
name = argv[1];
if ((res->reference = oid_getvalbyname(name)) == VAL_NONE)
{
- logf(LOG_WARN, "%s:%d: Unknown tagset ref '%s'",
- file, lineno, name);
+ yaz_log(LOG_WARN, "%s:%d: Unknown tagset ref '%s'",
+ file, lineno, name);
continue;
}
}
{
if (argc != 2)
{
- logf(LOG_WARN, "%s:%d: Bad # args to type", file, lineno);
+ yaz_log (LOG_WARN, "%s:%d: Bad # args to type", file, lineno);
continue;
}
- res->type = atoi(argv[1]);
+ if (!res->type)
+ res->type = atoi(argv[1]);
}
else if (!strcmp(cmd, "include"))
{
char *name;
+ int type = 0;
- if (argc != 2)
+ if (argc < 2)
{
- logf(LOG_WARN, "%s:%d: Bad # args to include",
- file, lineno);
+ yaz_log(LOG_WARN, "%s:%d: Bad # args to include",
+ file, lineno);
continue;
}
name = argv[1];
- if (!(*childp = data1_read_tagset (dh, name)))
+ if (argc == 3)
+ type = atoi(argv[2]);
+ *childp = data1_read_tagset (dh, name, type);
+ if (!(*childp))
{
- logf(LOG_WARN, "%s:%d: Inclusion failed for tagset %s",
- file, lineno, name);
+ yaz_log(LOG_WARN, "%s:%d: Inclusion failed for tagset %s",
+ file, lineno, name);
continue;
}
childp = &(*childp)->next;
}
else
{
- logf(LOG_WARN, "%s:%d: Unknown directive '%s'",
- file, lineno, cmd);
+ yaz_log(LOG_WARN, "%s:%d: Unknown directive '%s'",
+ file, lineno, cmd);
}
}
fclose(f);