and yaz_z3950oid_to_str.
* 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
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 <yaz/prt-rsc.h>
* 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
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);
* 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
#endif
#endif
-#endif
\ No newline at end of file
+#endif
+
* 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
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
* 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
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))
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);
}
+
* 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
*/
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;
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;
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);
*/
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;
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
* 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
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)
* 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
#include <yaz/log.h>
#include <yaz/xmalloc.h>
-#define TRACE_XMALLOC 1
+#define TRACE_XMALLOC 2
#if TRACE_XMALLOC > 1
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;
}
# 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
$(OBJDIR)\pquery.obj \
$(OBJDIR)\yaz-ccl.obj \
$(OBJDIR)\otherinfo.obj \
- $(OBJDIR)\sortspec.obj
+ $(OBJDIR)\sortspec.obj \
+ $(OBJDIR)\z3950oid.obj
YAZ_RET_OBJS= \
###########################################################
#
# $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
-## $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
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
/*
- * 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
* 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
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;
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);
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)))
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')
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')
{
* 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
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)
* 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 <stdio.h>
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));
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)
{
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 **)
* 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
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;
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;
}