From abfaf391015e3036af3d56859511bb7daaa6fe23 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 25 Sep 2001 07:35:37 +0000 Subject: [PATCH] New Z39.50 OID utilities. --- zutil/z3950oid.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 zutil/z3950oid.c diff --git a/zutil/z3950oid.c b/zutil/z3950oid.c new file mode 100644 index 0000000..f8eb6ab --- /dev/null +++ b/zutil/z3950oid.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 1995-2001, Index Data + * See the file LICENSE for details. + * + * $Id: z3950oid.c,v 1.1 2001-09-25 07:35:37 adam Exp $ + */ + +#if HAVE_CONFIG_H +#include +#endif + +#include + +Odr_oid *yaz_oidval_to_z3950oid (ODR o, int oid_class, int oid_value) +{ + oident ident; + int oid[OID_SIZE]; + + ident.proto = PROTO_Z3950; + ident.oclass = oid_class; + ident.value = oid_value; + + if (ident.value == VAL_NONE) + return 0; + + return odr_oiddup(o, oid_ent_to_oid(&ident, oid)); +} + +Odr_oid *yaz_str_to_z3950oid (ODR o, int oid_class, const char *str) +{ + struct oident ident; + int oid[OID_SIZE]; + + ident.proto = PROTO_Z3950; + ident.oclass = oid_class; + ident.value = oid_getvalbyname(str); + + if (ident.value == VAL_NONE) + return 0; + + return odr_oiddup(o, oid_ent_to_oid(&ident, oid)); +} + +const char *yaz_z3950oid_to_str (Odr_oid *oid, int *oid_class) +{ + struct oident *ident = oid_getentbyoid(oid); + + if (!ident || ident->value == VAL_NONE) + return 0; + *oid_class = ident->oclass; + return ident->desc; +} -- 1.7.10.4