projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update NEWS
[yaz-moved-to-github.git]
/
src
/
oid_db.c
diff --git
a/src/oid_db.c
b/src/oid_db.c
index
8318018
..
7d9f103
100644
(file)
--- a/
src/oid_db.c
+++ b/
src/oid_db.c
@@
-1,8
+1,6
@@
-/*
- * Copyright (C) 1995-2007, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2010 Index Data
* See the file LICENSE for details.
* See the file LICENSE for details.
- *
- * $Id: oid_db.c,v 1.8 2007-05-08 08:22:36 adam Exp $
*/
/**
*/
/**
@@
-29,7
+27,7
@@
struct yaz_oid_db {
};
struct yaz_oid_db standard_db_l = {
};
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;
};
yaz_oid_db_t standard_db = &standard_db_l;
@@
-38,6
+36,8
@@
yaz_oid_db_t yaz_oid_std(void)
return standard_db;
}
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)
{
const Odr_oid *yaz_string_to_oid(yaz_oid_db_t oid_db,
oid_class oclass, const char *name)
{
@@
-46,13
+46,13
@@
const Odr_oid *yaz_string_to_oid(yaz_oid_db_t oid_db,
struct yaz_oid_entry *e;
if (oclass != CLASS_GENERAL)
{
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;
}
}
{
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;
{
if (!yaz_matchstr(e->name, name))
return e->oid;
@@
-83,7
+83,7
@@
const char *yaz_oid_to_string(yaz_oid_db_t oid_db,
return 0;
for (; oid_db; oid_db = oid_db->next)
{
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))
for (; e->name; e++)
{
if (!oid_oidcmp(e->oid, oid))
@@
-99,7
+99,7
@@
const char *yaz_oid_to_string(yaz_oid_db_t oid_db,
const char *yaz_oid_to_string_buf(const Odr_oid *oid, oid_class *oclass, char *buf)
{
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)
if (p)
return p;
if (oclass)
@@
-107,6
+107,16
@@
const char *yaz_oid_to_string_buf(const Odr_oid *oid, oid_class *oclass, char *b
return oid_oid_to_dotstring(oid, buf);
}
return oid_oid_to_dotstring(oid, buf);
}
+
+char *oid_name_to_dotstring(oid_class oclass, const char *name, char *oid_buf)
+{
+ const Odr_oid *oid = yaz_string_to_oid(yaz_oid_std(), oclass, name);
+ if (oid)
+ return oid_oid_to_dotstring(oid, oid_buf);
+ return 0;
+}
+
+
int yaz_oid_is_iso2709(const Odr_oid *oid)
{
if (oid_oidlen(oid) == 6 && oid[0] == 1 && oid[1] == 2
int yaz_oid_is_iso2709(const Odr_oid *oid)
{
if (oid_oidlen(oid) == 6 && oid[0] == 1 && oid[1] == 2
@@
-116,7
+126,7
@@
int yaz_oid_is_iso2709(const Odr_oid *oid)
return 0;
}
return 0;
}
-int yaz_oid_add(yaz_oid_db_t oid_db, int oclass, const char *name,
+int yaz_oid_add(yaz_oid_db_t oid_db, oid_class oclass, const char *name,
const Odr_oid *new_oid)
{
const Odr_oid *oid = yaz_string_to_oid(oid_db, oclass, name);
const Odr_oid *new_oid)
{
const Odr_oid *oid = yaz_string_to_oid(oid_db, oclass, name);
@@
-184,7
+194,7
@@
void yaz_oid_trav(yaz_oid_db_t oid_db,
{
for (; oid_db; oid_db = oid_db->next)
{
{
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);
for (; e->name; e++)
func(e->oid, e->oclass, e->name, client_data);
@@
-194,6
+204,7
@@
void yaz_oid_trav(yaz_oid_db_t oid_db,
/*
* Local variables:
* c-basic-offset: 4
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab