From c7dfadc3347abda902e15f79bfd513e1d48cfbba Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 24 Sep 2001 21:51:55 +0000 Subject: [PATCH] New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid and yaz_z3950oid_to_str. --- asn/prt-proto.h | 8 +++++++- include/yaz/odr.h | 7 ++++--- include/yaz/yaz-version.h | 9 +++++++-- include/yaz/z-proto.h | 11 ++++++++++- odr/odr_util.c | 13 +++++++++---- server/seshigh.c | 36 ++++++++++++------------------------ util/oid.c | 37 +++++++++++++++++++++---------------- util/xmalloc.c | 10 +++++++--- win/makefile | 11 ++++++++--- zutil/Makefile.am | 4 ++-- zutil/otherinfo.c | 8 ++++++-- zutil/pquery.c | 41 ++++++++++++----------------------------- zutil/prt-ext.c | 18 +++++++++--------- zutil/sortspec.c | 10 +++------- zutil/yaz-ccl.c | 25 ++++++++----------------- 15 files changed, 125 insertions(+), 123 deletions(-) diff --git a/asn/prt-proto.h b/asn/prt-proto.h index 9e59e16..2d5efb6 100644 --- a/asn/prt-proto.h +++ b/asn/prt-proto.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: prt-proto.h,v 1.2 2001-02-21 13:46:53 adam Exp $ + * $Id: prt-proto.h,v 1.3 2001-09-24 21:51:55 adam Exp $ */ #ifndef PRT_PROTO_H @@ -1145,6 +1145,12 @@ YAZ_EXPORT int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt, YAZ_EXPORT Z_APDU *zget_APDU(ODR o, int which); YAZ_EXPORT int z_Query(ODR o, Z_Query **p, int opt, const char *name); +YAZ_EXPORT Odr_oid *yaz_oidval_to_z3950oid (ODR o, int oid_class, + int oid_value); +YAZ_EXPORT Odr_oid *yaz_str_to_z3950oid (ODR o, int oid_class, + const char *str); +YAZ_EXPORT const char *yaz_z3950oid_to_str (Odr_oid *oid, int *oid_class); + YAZ_END_CDECL #include diff --git a/include/yaz/odr.h b/include/yaz/odr.h index ccff72e..abd1d73 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: odr.h,v 1.4 2001-03-25 21:55:12 adam Exp $ + * $Id: odr.h,v 1.5 2001-09-24 21:51:55 adam Exp $ */ #ifndef ODR_H @@ -339,8 +339,9 @@ YAZ_EXPORT void odr_choice_bias(ODR o, int what); YAZ_EXPORT void odr_choice_enable_bias(ODR o, int mode); YAZ_EXPORT int odr_total(ODR o); YAZ_EXPORT char *odr_errmsg(int n); -YAZ_EXPORT Odr_oid *odr_getoidbystr(ODR o, char *str); -YAZ_EXPORT Odr_oid *odr_getoidbystr_nmem(NMEM o, char *str); +YAZ_EXPORT Odr_oid *odr_getoidbystr(ODR o, const char *str); +YAZ_EXPORT Odr_oid *odr_getoidbystr_nmem(NMEM o, const char *str); + YAZ_EXPORT int odr_initmember(ODR o, void *p, int size); YAZ_EXPORT int odr_peektag(ODR o, int *zclass, int *tag, int *cons); YAZ_EXPORT void odr_setlenlen(ODR o, int len); diff --git a/include/yaz/yaz-version.h b/include/yaz/yaz-version.h index f6378b6..43121ef 100644 --- a/include/yaz/yaz-version.h +++ b/include/yaz/yaz-version.h @@ -2,7 +2,11 @@ * Current software version. * * $Log: yaz-version.h,v $ - * Revision 1.5 2001-05-18 11:42:03 adam + * Revision 1.6 2001-09-24 21:51:55 adam + * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid + * and yaz_z3950oid_to_str. + * + * Revision 1.5 2001/05/18 11:42:03 adam * YAZ Build date for WIN32. * * Revision 1.4 2001/05/16 07:37:39 adam @@ -108,4 +112,5 @@ #endif #endif -#endif \ No newline at end of file +#endif + diff --git a/include/yaz/z-proto.h b/include/yaz/z-proto.h index 0c255c7..9d84c00 100644 --- a/include/yaz/z-proto.h +++ b/include/yaz/z-proto.h @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: z-proto.h,v $ - * Revision 1.6 2001-09-19 10:19:07 adam + * Revision 1.7 2001-09-24 21:51:55 adam + * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid + * and yaz_z3950oid_to_str. + * + * Revision 1.6 2001/09/19 10:19:07 adam * Z_SortCase_caseInsensitive was set to wrong value. * * Revision 1.5 2001/05/17 14:16:15 adam @@ -126,6 +130,11 @@ typedef struct Z_IOItemOrder Z_ItemOrder; YAZ_EXPORT Z_APDU *zget_APDU(ODR o, int which); YAZ_EXPORT Z_Close *zget_Close (ODR o); +YAZ_EXPORT Odr_oid *yaz_oidval_to_z3950oid (ODR o, int oid_class, + int oid_value); +YAZ_EXPORT Odr_oid *yaz_str_to_z3950oid (ODR o, int oid_class, + const char *str); +YAZ_EXPORT const char *yaz_z3950oid_to_str (Odr_oid *oid, int *oid_class); YAZ_END_CDECL diff --git a/odr/odr_util.c b/odr/odr_util.c index 1d35925..71273f5 100644 --- a/odr/odr_util.c +++ b/odr/odr_util.c @@ -3,7 +3,11 @@ * See the file LICENSE for details. * * $Log: odr_util.c,v $ - * Revision 1.19 2000-02-29 13:44:55 adam + * Revision 1.20 2001-09-24 21:51:55 adam + * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid + * and yaz_z3950oid_to_str. + * + * Revision 1.19 2000/02/29 13:44:55 adam * Check for config.h (currently not generated). * * Revision 1.18 2000/01/31 13:15:21 adam @@ -86,10 +90,10 @@ Odr_oid *odr_oiddup(ODR odr, Odr_oid *o) return odr_oiddup_nmem (odr->mem, o); } -Odr_oid *odr_getoidbystr_nmem(NMEM nmem, char *str) +Odr_oid *odr_getoidbystr_nmem(NMEM nmem, const char *str) { int num = 1, i = 0; - char *p = str; + const char *p = str; Odr_oid *ret; if (!isdigit(*str)) @@ -105,8 +109,9 @@ Odr_oid *odr_getoidbystr_nmem(NMEM nmem, char *str) return ret; } -Odr_oid *odr_getoidbystr(ODR o, char *str) +Odr_oid *odr_getoidbystr(ODR o, const char *str) { return odr_getoidbystr_nmem (o->mem, str); } + diff --git a/server/seshigh.c b/server/seshigh.c index 62c3eb3..a2f4c35 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -3,7 +3,11 @@ * See the file LICENSE for details. * * $Log: seshigh.c,v $ - * Revision 1.118 2001-07-19 19:51:41 adam + * Revision 1.119 2001-09-24 21:51:55 adam + * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid + * and yaz_z3950oid_to_str. + * + * Revision 1.118 2001/07/19 19:51:41 adam * Added typecasts to make C++ happy. * * Revision 1.117 2001/06/13 20:47:40 adam @@ -1126,20 +1130,14 @@ static void set_addinfo (Z_DefaultDiagFormat *dr, char *addinfo, ODR odr) */ static Z_Records *diagrec(association *assoc, int error, char *addinfo) { - int oid[OID_SIZE]; Z_Records *rec = (Z_Records *) odr_malloc (assoc->encode, sizeof(*rec)); - oident bib1; int *err = odr_intdup(assoc->encode, error); Z_DiagRec *drec = (Z_DiagRec *) odr_malloc (assoc->encode, sizeof(*drec)); Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) odr_malloc (assoc->encode, sizeof(*dr)); - bib1.proto = assoc->proto; - bib1.oclass = CLASS_DIAGSET; - bib1.value = VAL_BIB1; - yaz_log(LOG_DEBUG, "Diagnostic: %d -- %s", error, addinfo ? addinfo : "NULL"); rec->which = Z_Records_NSD; @@ -1151,7 +1149,7 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo) drec->u.defaultFormat = dr; #endif dr->diagnosticSetId = - odr_oiddup (assoc->encode, oid_ent_to_oid(&bib1, oid)); + yaz_oidval_to_z3950oid (assoc->encode, CLASS_DIAGSET, VAL_BIB1); dr->condition = err; set_addinfo (dr, addinfo, assoc->encode); return rec; @@ -1163,27 +1161,21 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo) static Z_NamePlusRecord *surrogatediagrec(association *assoc, char *dbname, int error, char *addinfo) { - int oid[OID_SIZE]; Z_NamePlusRecord *rec = (Z_NamePlusRecord *) odr_malloc (assoc->encode, sizeof(*rec)); int *err = odr_intdup(assoc->encode, error); - oident bib1; Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (assoc->encode, sizeof(*drec)); Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) odr_malloc (assoc->encode, sizeof(*dr)); - bib1.proto = assoc->proto; - bib1.oclass = CLASS_DIAGSET; - bib1.value = VAL_BIB1; - yaz_log(LOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo); rec->databaseName = dbname; rec->which = Z_NamePlusRecord_surrogateDiagnostic; rec->u.surrogateDiagnostic = drec; drec->which = Z_DiagRec_defaultFormat; drec->u.defaultFormat = dr; - dr->diagnosticSetId = odr_oiddup (assoc->encode, - oid_ent_to_oid(&bib1, oid)); + dr->diagnosticSetId = + yaz_oidval_to_z3950oid (assoc->encode, CLASS_DIAGSET, VAL_BIB1); dr->condition = err; set_addinfo (dr, addinfo, assoc->encode); @@ -1195,18 +1187,14 @@ static Z_NamePlusRecord *surrogatediagrec(association *assoc, char *dbname, */ static Z_DiagRecs *diagrecs(association *assoc, int error, char *addinfo) { - int oid[OID_SIZE]; Z_DiagRecs *recs = (Z_DiagRecs *)odr_malloc (assoc->encode, sizeof(*recs)); int *err = odr_intdup(assoc->encode, error); - oident bib1; Z_DiagRec **recp = (Z_DiagRec **)odr_malloc (assoc->encode, sizeof(*recp)); Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (assoc->encode, sizeof(*drec)); - Z_DefaultDiagFormat *rec = (Z_DefaultDiagFormat *)odr_malloc (assoc->encode, sizeof(*rec)); + Z_DefaultDiagFormat *rec = (Z_DefaultDiagFormat *) + odr_malloc (assoc->encode, sizeof(*rec)); yaz_log(LOG_DEBUG, "DiagRecs: %d -- %s", error, addinfo ? addinfo : ""); - bib1.proto = assoc->proto; - bib1.oclass = CLASS_DIAGSET; - bib1.value = VAL_BIB1; recs->num_diagRecs = 1; recs->diagRecs = recp; @@ -1214,8 +1202,8 @@ static Z_DiagRecs *diagrecs(association *assoc, int error, char *addinfo) drec->which = Z_DiagRec_defaultFormat; drec->u.defaultFormat = rec; - rec->diagnosticSetId = odr_oiddup (assoc->encode, - oid_ent_to_oid(&bib1, oid)); + rec->diagnosticSetId = + yaz_oidval_to_z3950oid (assoc->encode, CLASS_DIAGSET, VAL_BIB1); rec->condition = err; #ifdef ASN_COMPILED diff --git a/util/oid.c b/util/oid.c index 50b2ef2..47fc423 100644 --- a/util/oid.c +++ b/util/oid.c @@ -3,7 +3,11 @@ * See the file LICENSE for details. * * $Log: oid.c,v $ - * Revision 1.46 2001-06-26 14:11:27 adam + * Revision 1.47 2001-09-24 21:51:55 adam + * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid + * and yaz_z3950oid_to_str. + * + * Revision 1.46 2001/06/26 14:11:27 adam * Added MUTEX functions for NMEM module (used by OID utility). * * Revision 1.45 2001/05/16 07:25:59 adam @@ -589,28 +593,29 @@ void oid_transfer (struct oident *oident) void oid_init (void) { - if (oid_init_flag) - return; - /* oid_transfer is thread safe, so there's nothing wrong in having - two threads calling it simultaniously. On the other hand - no thread may exit oid_init before all OID's bave been - transferred - which is why checked is set after oid_transfer... - */ - nmem_mutex_create (&oid_mutex); - nmem_mutex_enter (oid_mutex); - if (!oid_nmem) - oid_nmem = nmem_create (); - nmem_mutex_leave (oid_mutex); - oid_transfer (standard_oids); - oid_init_flag = 1; + if (oid_init_flag == 0) + { + /* oid_transfer is thread safe, so there's nothing wrong in having + two threads calling it simultaniously. On the other hand + no thread may exit oid_init before all OID's bave been + transferred - which is why checked is set after oid_transfer... + */ + nmem_mutex_create (&oid_mutex); + nmem_mutex_enter (oid_mutex); + if (!oid_nmem) + oid_nmem = nmem_create (); + nmem_mutex_leave (oid_mutex); + oid_transfer (standard_oids); + oid_init_flag = 1; + } } void oid_exit (void) { oid_init_flag = 0; - oid_nmem = 0; nmem_mutex_destroy (&oid_mutex); nmem_destroy (oid_nmem); + oid_nmem = 0; } static struct oident *oid_getentbyoid_x(int *o) diff --git a/util/xmalloc.c b/util/xmalloc.c index 390dc6d..16469d7 100644 --- a/util/xmalloc.c +++ b/util/xmalloc.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: xmalloc.c,v $ - * Revision 1.11 2000-02-29 13:44:55 adam + * Revision 1.12 2001-09-24 21:51:56 adam + * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid + * and yaz_z3950oid_to_str. + * + * Revision 1.11 2000/02/29 13:44:55 adam * Check for config.h (currently not generated). * * Revision 1.10 1999/11/30 13:47:12 adam @@ -70,7 +74,7 @@ #include #include -#define TRACE_XMALLOC 1 +#define TRACE_XMALLOC 2 #if TRACE_XMALLOC > 1 @@ -239,7 +243,7 @@ void xmalloc_trav_d(const char *file, int line) while (dinfo) { yaz_log (LOG_LOG, " %20s:%d p=%p size=%d", dinfo->file, dinfo->line, - dinfo+sizeof(*dinfo)+4*sizeof(char), dinfo->len); + ((char*) dinfo)+sizeof(*dinfo)+4*sizeof(char), dinfo->len); size += dinfo->len; dinfo = dinfo->next; } diff --git a/win/makefile b/win/makefile index 9dea6dd..7aca592 100644 --- a/win/makefile +++ b/win/makefile @@ -1,5 +1,5 @@ # makefile.mak - makefile for MS NMAKE -# $Id: makefile,v 1.24 2001-08-14 12:05:58 adam Exp $ +# $Id: makefile,v 1.25 2001-09-24 21:51:56 adam Exp $ # # Programmed by # HL: Heikki Levanto, Index Data @@ -280,7 +280,8 @@ YAZ_ZUTIL_OBJS= \ $(OBJDIR)\pquery.obj \ $(OBJDIR)\yaz-ccl.obj \ $(OBJDIR)\otherinfo.obj \ - $(OBJDIR)\sortspec.obj + $(OBJDIR)\sortspec.obj \ + $(OBJDIR)\z3950oid.obj YAZ_RET_OBJS= \ @@ -708,7 +709,11 @@ $(PROTOH): $(GENERATED_C_FILES) $(GENERATED_H_FILES) ########################################################### # # $Log: makefile,v $ -# Revision 1.24 2001-08-14 12:05:58 adam +# Revision 1.25 2001-09-24 21:51:56 adam +# New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid +# and yaz_z3950oid_to_str. +# +# Revision 1.24 2001/08/14 12:05:58 adam # Added sortspec. # # Revision 1.23 2001/05/18 11:42:03 adam diff --git a/zutil/Makefile.am b/zutil/Makefile.am index 6f65e69..e1d7fc1 100644 --- a/zutil/Makefile.am +++ b/zutil/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.6 2001-08-08 19:35:06 adam Exp $ +## $Id: Makefile.am,v 1.7 2001-09-24 21:51:56 adam Exp $ noinst_LTLIBRARIES = libzutil.la INCLUDES=-I$(top_srcdir)/include @@ -6,4 +6,4 @@ INCLUDES=-I$(top_srcdir)/include LIBS = libzutil_la_SOURCES = zget.c prt-ext.c yaz-ccl.c diagbib1.c logrpn.c \ - otherinfo.c pquery.c sortspec.c + otherinfo.c pquery.c sortspec.c z3950oid.c diff --git a/zutil/otherinfo.c b/zutil/otherinfo.c index e9fda01..db8e0a1 100644 --- a/zutil/otherinfo.c +++ b/zutil/otherinfo.c @@ -1,10 +1,14 @@ /* - * Copyright (c) 1999, Index Data + * Copyright (c) 1999-2001, Index Data * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: otherinfo.c,v $ - * Revision 1.4 1999-11-30 13:47:12 adam + * Revision 1.5 2001-09-24 21:51:56 adam + * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid + * and yaz_z3950oid_to_str. + * + * Revision 1.4 1999/11/30 13:47:12 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.3 1999/11/10 09:06:40 adam diff --git a/zutil/pquery.c b/zutil/pquery.c index 5003fd7..65bcb5d 100644 --- a/zutil/pquery.c +++ b/zutil/pquery.c @@ -3,7 +3,11 @@ * See the file LICENSE for details. * * $Log: pquery.c,v $ - * Revision 1.8 2001-07-19 19:14:53 adam + * Revision 1.9 2001-09-24 21:51:56 adam + * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid + * and yaz_z3950oid_to_str. + * + * Revision 1.8 2001/07/19 19:14:53 adam * C++ compile. * * Revision 1.7 2001/05/09 23:31:35 adam @@ -348,20 +352,8 @@ static Z_AttributesPlusTerm *rpn_term (struct lex_info *li, ODR o, elements[k] = (Z_AttributeElement*)odr_malloc (o,sizeof(**elements)); elements[k]->attributeType = &attr_tmp[2*i]; - if (attr_set[i] == VAL_NONE) - elements[k]->attributeSet = 0; - else - { - oident attrid; - int oid[OID_SIZE]; - - attrid.proto = PROTO_Z3950; - attrid.oclass = CLASS_ATTSET; - attrid.value = attr_set[i]; - - elements[k]->attributeSet = - odr_oiddup (o, oid_ent_to_oid (&attrid, oid)); - } + elements[k]->attributeSet = + yaz_oidval_to_z3950oid(o, attr_set[i], CLASS_ATTSET); if (attr_clist[i]) { elements[k]->which = Z_AttributeValue_complex; @@ -621,8 +613,6 @@ Z_RPNQuery *p_query_rpn_mk (ODR o, struct lex_info *li, oid_proto proto, char *attr_clist[512]; oid_value attr_set[512]; oid_value topSet = VAL_NONE; - oident oset; - int oid[OID_SIZE]; zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq)); lex (li); @@ -639,13 +629,11 @@ Z_RPNQuery *p_query_rpn_mk (ODR o, struct lex_info *li, oid_proto proto, topSet = p_query_dfset; if (topSet == VAL_NONE) topSet = VAL_BIB1; - oset.proto = proto; - oset.oclass = CLASS_ATTSET; - oset.value = topSet; - if (!oid_ent_to_oid (&oset, oid)) - return NULL; - zq->attributeSetId = odr_oiddup (o, oid); + zq->attributeSetId = yaz_oidval_to_z3950oid(o, CLASS_ATTSET, topSet); + + if (!zq->attributeSetId) + return 0; if (!(zq->RPNStructure = rpn_structure (li, o, proto, 0, 512, attr_array, attr_clist, attr_set))) @@ -678,8 +666,6 @@ Z_AttributesPlusTerm *p_query_scan_mk (struct lex_info *li, int num_attr = 0; int max_attr = 512; oid_value topSet = VAL_NONE; - oident oset; - int oid[OID_SIZE]; lex (li); if (li->query_look == 'r') @@ -693,11 +679,8 @@ Z_AttributesPlusTerm *p_query_scan_mk (struct lex_info *li, topSet = p_query_dfset; if (topSet == VAL_NONE) topSet = VAL_BIB1; - oset.proto = proto; - oset.oclass = CLASS_ATTSET; - oset.value = topSet; - *attributeSetP = odr_oiddup (o, oid_ent_to_oid (&oset, oid)); + *attributeSetP = yaz_oidval_to_z3950oid (o, CLASS_ATTSET, topSet); while (li->query_look == 'l') { diff --git a/zutil/prt-ext.c b/zutil/prt-ext.c index 099155a..a2a4f91 100644 --- a/zutil/prt-ext.c +++ b/zutil/prt-ext.c @@ -3,7 +3,11 @@ * See the file LICENSE for details. * * $Log: prt-ext.c,v $ - * Revision 1.6 2001-05-17 14:16:15 adam + * Revision 1.7 2001-09-24 21:51:56 adam + * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid + * and yaz_z3950oid_to_str. + * + * Revision 1.6 2001/05/17 14:16:15 adam * Added EXTERNAL handling for item update0 (1.0). * * Revision 1.5 2001/03/25 21:55:13 adam @@ -228,20 +232,16 @@ int z_External(ODR o, Z_External **p, int opt, const char *name) Z_External *z_ext_record(ODR o, int format, const char *buf, int len) { Z_External *thisext; - oident recform; - int oid[OID_SIZE]; thisext = (Z_External *) odr_malloc(o, sizeof(*thisext)); thisext->descriptor = 0; thisext->indirect_reference = 0; - recform.proto = PROTO_Z3950; - recform.oclass = CLASS_RECSYN; - recform.value = (enum oid_value) format; - if (!oid_ent_to_oid(&recform, oid)) + thisext->direct_reference = + yaz_oidval_to_z3950oid (o, CLASS_RECSYN, format); + if (!thisext->direct_reference) return 0; - thisext->direct_reference = odr_oiddup(o, oid); - + if (len < 0) /* Structured data */ { switch (format) diff --git a/zutil/sortspec.c b/zutil/sortspec.c index caf5603..3be2674 100644 --- a/zutil/sortspec.c +++ b/zutil/sortspec.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2001, Index Data. * See the file LICENSE for details. * - * $Id: sortspec.c,v 1.2 2001-08-10 12:50:40 adam Exp $ + * $Id: sortspec.c,v 1.3 2001-09-24 21:51:56 adam Exp $ */ #include @@ -15,8 +15,6 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg) { - int oid[OID_SIZE]; - oident bib1; char sort_string_buf[32], sort_flags[32]; Z_SortKeySpecList *sksl = (Z_SortKeySpecList *) odr_malloc (out, sizeof(*sksl)); @@ -25,9 +23,6 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg) sksl->num_specs = 0; sksl->specs = (Z_SortKeySpec **)odr_malloc (out, sizeof(sksl->specs) * 20); - bib1.proto = PROTO_Z3950; - bib1.oclass = CLASS_ATTSET; - bib1.value = VAL_BIB1; while ((sscanf (arg, "%31s %31s%n", sort_string_buf, sort_flags, &off)) == 2 && off > 1) { @@ -50,7 +45,8 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg) sk->which = Z_SortKey_sortAttributes; sk->u.sortAttributes = (Z_SortAttributes *) odr_malloc (out, sizeof(*sk->u.sortAttributes)); - sk->u.sortAttributes->id = oid_ent_to_oid(&bib1, oid); + sk->u.sortAttributes->id = + yaz_oidval_to_z3950oid(out, CLASS_ATTSET, VAL_BIB1); sk->u.sortAttributes->list = (Z_AttributeList *) odr_malloc (out, sizeof(*sk->u.sortAttributes->list)); sk->u.sortAttributes->list->attributes = (Z_AttributeElement **) diff --git a/zutil/yaz-ccl.c b/zutil/yaz-ccl.c index d1ab287..4c86dfe 100644 --- a/zutil/yaz-ccl.c +++ b/zutil/yaz-ccl.c @@ -3,7 +3,11 @@ * See the file LICENSE for details. * * $Log: yaz-ccl.c,v $ - * Revision 1.13 2001-05-09 23:31:35 adam + * Revision 1.14 2001-09-24 21:51:56 adam + * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid + * and yaz_z3950oid_to_str. + * + * Revision 1.13 2001/05/09 23:31:35 adam * String attribute values for PQF. Proper C-backslash escaping for PQF. * * Revision 1.12 2001/03/07 13:24:40 adam @@ -112,14 +116,8 @@ static Z_AttributesPlusTerm *ccl_rpn_term (ODR o, struct ccl_rpn_node *p) if (value != VAL_NONE) { - int oid[OID_SIZE]; - struct oident ident; - - ident.oclass = CLASS_ATTSET; - ident.proto = PROTO_Z3950; - ident.value = (oid_value) value; elements[i]->attributeSet = - odr_oiddup (o, oid_ent_to_oid (&ident, oid)); + yaz_oidval_to_z3950oid(o, CLASS_ATTSET, value); } } elements[i]->which = Z_AttributeValue_numeric; @@ -256,15 +254,8 @@ static Z_RPNStructure *ccl_rpn_structure (ODR o, struct ccl_rpn_node *p) Z_RPNQuery *ccl_rpn_query (ODR o, struct ccl_rpn_node *p) { - Z_RPNQuery *zq; - oident bib1; - int oid[OID_SIZE]; - bib1.proto = PROTO_Z3950; - bib1.oclass = CLASS_ATTSET; - bib1.value = VAL_BIB1; - - zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq)); - zq->attributeSetId = odr_oiddup (o, oid_ent_to_oid (&bib1, oid)); + Z_RPNQuery *zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq)); + zq->attributeSetId = yaz_oidval_to_z3950oid (o, CLASS_ATTSET, VAL_BIB1); zq->RPNStructure = ccl_rpn_structure (o, p); return zq; } -- 1.7.10.4