/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2009 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
#include <yaz/yaz-util.h>
#include <yaz/odr.h>
};
struct yaz_oid_db standard_db_l = {
- yaz_oid_standard_entries, 0, 0
+ 0, 0, 0
};
yaz_oid_db_t standard_db = &standard_db_l;
return standard_db;
}
+#define get_entries(db) (db->xmalloced==0 ? yaz_oid_standard_entries : db->entries)
+
const Odr_oid *yaz_string_to_oid(yaz_oid_db_t oid_db,
oid_class oclass, const char *name)
{
struct yaz_oid_entry *e;
if (oclass != CLASS_GENERAL)
{
- for (e = oid_db->entries; e->name; e++)
+ for (e = get_entries(oid_db); e->name; e++)
{
if (!yaz_matchstr(e->name, name) && oclass == e->oclass)
return e->oid;
}
}
- for (e = oid_db->entries; e->name; e++)
+ for (e = get_entries(oid_db); e->name; e++)
{
if (!yaz_matchstr(e->name, name))
return e->oid;
return 0;
for (; oid_db; oid_db = oid_db->next)
{
- struct yaz_oid_entry *e = oid_db->entries;
+ struct yaz_oid_entry *e = get_entries(oid_db);
for (; e->name; e++)
{
if (!oid_oidcmp(e->oid, oid))
const char *yaz_oid_to_string_buf(const Odr_oid *oid, oid_class *oclass, char *buf)
{
- const char *p = yaz_oid_to_string(standard_db, oid, oclass);
+ const char *p = yaz_oid_to_string(yaz_oid_std(), oid, oclass);
if (p)
return p;
if (oclass)
int yaz_oid_is_iso2709(const Odr_oid *oid)
{
if (oid_oidlen(oid) == 6 && oid[0] == 1 && oid[1] == 2
- && oid[2] == 840 && oid[3] == 10003 && oid[4] == 5
+ && oid[2] == 840 && oid[3] == 10003 && oid[4] == 5
&& oid[5] <= 29 && oid[5] != 16)
return 1;
return 0;
{
for (; oid_db; oid_db = oid_db->next)
{
- struct yaz_oid_entry *e = oid_db->entries;
-
+ struct yaz_oid_entry *e = get_entries(oid_db);
+
for (; e->name; e++)
func(e->oid, e->oclass, e->name, client_data);
}
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab