From 79bf9f1b8b224b6b7323b280fca704591ac17324 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 29 Sep 1997 13:18:59 +0000 Subject: [PATCH 1/1] Added function, oid_ent_to_oid, to replace the function oid_getoidbyent, which is not thread safe. --- CHANGELOG | 5 ++++ client/client.c | 76 +++++++++++--------------------------------------- include/oid.h | 11 ++++++-- retrieval/d1_espec.c | 9 ++++-- server/seshigh.c | 18 ++++++++---- util/oid.c | 21 +++++++++++--- util/pquery.c | 15 +++++++--- 7 files changed, 77 insertions(+), 78 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 840de9d..8395d13 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,11 @@ Possible compatibility problems with earlier versions marked with '*'. --- XXXXX +Revised the CCL parser utility to be thread safe. + +Added function, oid_ent_to_oid, to replace the function +oid_getoidbyent, which is not thread safe. + * Added nmem_init and nmem_exit to initialize and release NMEM resources. Function nmem_init should be called once in the initial thread before NMEM/ODR is used. statserv.c and client.c diff --git a/client/client.c b/client/client.c index a627386..66dc48e 100644 --- a/client/client.c +++ b/client/client.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: client.c,v $ - * Revision 1.52 1997-09-29 07:20:31 adam + * Revision 1.53 1997-09-29 13:18:59 adam + * Added function, oid_ent_to_oid, to replace the function + * oid_getoidbyent, which is not thread safe. + * + * Revision 1.52 1997/09/29 07:20:31 adam * Client code uses nmem_init. * * Revision 1.51 1997/09/26 09:41:55 adam @@ -620,6 +624,7 @@ static int send_searchRequest(char *arg) Z_APDU *apdu = zget_APDU(out, Z_APDU_searchRequest); Z_SearchRequest *req = apdu->u.searchRequest; Z_Query query; + int oid[OID_SIZE]; #if CCL2RPN struct ccl_rpn_node *rpn; int error, pos; @@ -665,12 +670,13 @@ static int send_searchRequest(char *arg) mediumSetPresentNumber > 0)) { oident prefsyn; + int oid[OID_SIZE]; prefsyn.proto = protocol; prefsyn.oclass = CLASS_RECSYN; prefsyn.value = recordsyntax; req->preferredRecordSyntax = - odr_oiddup(out, oid_getoidbyent(&prefsyn)); + odr_oiddup(out, oid_ent_to_oid(&prefsyn, oid)); req->smallSetElementSetNames = req->mediumSetElementSetNames = elementSetNames; } @@ -704,7 +710,7 @@ static int send_searchRequest(char *arg) bib1.proto = protocol; bib1.oclass = CLASS_ATTSET; bib1.value = VAL_BIB1; - RPNquery->attributeSetId = oid_getoidbyent(&bib1); + RPNquery->attributeSetId = oid_ent_to_oid(&bib1, oid); query.u.type_1 = RPNquery; ccl_rpn_delete (rpn); break; @@ -834,6 +840,7 @@ static int send_presentRequest(char *arg) Z_RecordComposition compo; oident prefsyn; int nos = 1; + int oid[OID_SIZE]; char *p; char setstring[100]; @@ -864,7 +871,8 @@ static int send_presentRequest(char *arg) prefsyn.proto = protocol; prefsyn.oclass = CLASS_RECSYN; prefsyn.value = recordsyntax; - req->preferredRecordSyntax = oid_getoidbyent(&prefsyn); + req->preferredRecordSyntax = oid_ent_to_oid(&prefsyn, oid); + if (elementSetNames) { req->recordComposition = &compo; @@ -1033,65 +1041,13 @@ int cmd_format(char *arg) printf("Usage: format \n"); return 0; } - if (!strcmp(arg, "sutrs")) - { - printf("Preferred format is SUTRS.\n"); - recordsyntax = VAL_SUTRS; - return 1; - } - else if (!strcmp(arg, "usmarc")) - { - printf("Preferred format is USMARC\n"); - recordsyntax = VAL_USMARC; - return 1; - } - else if (!strcmp(arg, "danmarc")) + recordsyntax = oid_getvalbyname (arg); + if (recordsyntax == VAL_NONE) { - printf("Preferred format is DANMARC\n"); - recordsyntax = VAL_DANMARC; - return 1; - } - else if (!strcmp(arg, "ukmarc")) - { - printf("Preferred format is UKMARC\n"); - recordsyntax = VAL_UKMARC; - return 1; - } - else if (!strcmp(arg, "unimarc")) - { - printf("Preferred format is UNIMARC\n"); - recordsyntax = VAL_UNIMARC; - return 1; - } - else if (!strcmp(arg, "grs1")) - { - printf("Preferred format is GRS1\n"); - recordsyntax = VAL_GRS1; - return 1; - } - else if (!strcmp(arg, "soif")) - { - printf("Preferred format is SOIF\n"); - recordsyntax = VAL_SOIF; - return 1; - } - else if (!strcmp(arg, "summary")) - { - printf("Preferred format is Summary\n"); - recordsyntax = VAL_SUMMARY; - return 1; - } - else if (!strcmp(arg, "explain")) - { - printf("Preferred format is Explain\n"); - recordsyntax = VAL_EXPLAIN; - return 1; - } - else - { - printf("Specify one of {sutrs,usmarc,danmarc,ukmarc,unimarc,grs1,summary,explain}.\n"); + printf ("unknown record syntax\n"); return 0; } + return 1; } int cmd_elements(char *arg) diff --git a/include/oid.h b/include/oid.h index f1357db..eab0ca7 100644 --- a/include/oid.h +++ b/include/oid.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, Index Data. + * Copyright (c) 1995-1997, Index Data. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation, in whole or in part, for any purpose, is hereby granted, @@ -24,7 +24,11 @@ * OF THIS SOFTWARE. * * $Log: oid.h,v $ - * Revision 1.23 1997-09-01 08:49:50 adam + * Revision 1.24 1997-09-29 13:18:59 adam + * Added function, oid_ent_to_oid, to replace the function + * oid_getoidbyent, which is not thread safe. + * + * Revision 1.23 1997/09/01 08:49:50 adam * New windows NT/95 port using MSV5.0. To export DLL functions the * YAZ_EXPORT modifier was added. Defined in yconfig.h. * @@ -106,7 +110,7 @@ extern "C" { #endif -#define OID_SIZE 100 +#define OID_SIZE 20 typedef enum oid_proto { @@ -208,6 +212,7 @@ typedef struct oident } oident; YAZ_EXPORT int *oid_getoidbyent(struct oident *ent); +YAZ_EXPORT int *oid_ent_to_oid(struct oident *ent, int *dst); YAZ_EXPORT struct oident *oid_getentbyoid(int *o); YAZ_EXPORT void oid_oidcpy(int *t, int *s); YAZ_EXPORT void oid_oidcat(int *t, int *s); diff --git a/retrieval/d1_espec.c b/retrieval/d1_espec.c index 209d0fa..0f36614 100644 --- a/retrieval/d1_espec.c +++ b/retrieval/d1_espec.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_espec.c,v $ - * Revision 1.10 1997-09-29 07:21:10 adam + * Revision 1.11 1997-09-29 13:18:59 adam + * Added function, oid_ent_to_oid, to replace the function + * oid_getoidbyent, which is not thread safe. + * + * Revision 1.10 1997/09/29 07:21:10 adam * Added typecast to avoid warnings on MSVC. * * Revision 1.9 1997/09/17 12:10:35 adam @@ -55,11 +59,12 @@ static Z_Variant *read_variant(int argc, char **argv, ODR o) Z_Variant *r = odr_malloc(o, sizeof(*r)); oident var1; int i; + int oid[OID_SIZE]; var1.proto = PROTO_Z3950; var1.oclass = CLASS_VARSET; var1.value = VAL_VAR1; - r->globalVariantSetId = odr_oiddup(o, oid_getoidbyent(&var1)); + r->globalVariantSetId = odr_oiddup(o, oid_ent_to_oid(&var1, oid)); if (argc) r->triples = odr_malloc(o, sizeof(Z_Triple*) * argc); diff --git a/server/seshigh.c b/server/seshigh.c index 953d08d..31ef866 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: seshigh.c,v $ - * Revision 1.67 1997-09-17 12:10:40 adam + * Revision 1.68 1997-09-29 13:18:59 adam + * Added function, oid_ent_to_oid, to replace the function + * oid_getoidbyent, which is not thread safe. + * + * Revision 1.67 1997/09/17 12:10:40 adam * YAZ version 1.4. * * Revision 1.66 1997/09/05 15:26:44 adam @@ -764,6 +768,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) */ static Z_Records *diagrec(association *assoc, int error, char *addinfo) { + int oid[OID_SIZE]; Z_Records *rec = odr_malloc (assoc->encode, sizeof(*rec)); oident bib1; int *err = odr_malloc (assoc->encode, sizeof(*err)); @@ -785,7 +790,7 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo) #else rec->u.nonSurrogateDiagnostic = dr; #endif - dr->diagnosticSetId = oid_getoidbyent(&bib1); + dr->diagnosticSetId = oid_ent_to_oid(&bib1, oid); dr->condition = err; dr->which = Z_DiagForm_v2AddInfo; dr->addinfo = addinfo ? addinfo : ""; @@ -798,6 +803,7 @@ 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 = odr_malloc (assoc->encode, sizeof(*rec)); int *err = odr_malloc (assoc->encode, sizeof(*err)); oident bib1; @@ -815,7 +821,7 @@ static Z_NamePlusRecord *surrogatediagrec(association *assoc, char *dbname, rec->u.surrogateDiagnostic = drec; drec->which = Z_DiagRec_defaultFormat; drec->u.defaultFormat = dr; - dr->diagnosticSetId = oid_getoidbyent(&bib1); + dr->diagnosticSetId = oid_ent_to_oid(&bib1, oid); dr->condition = err; dr->which = Z_DiagForm_v2AddInfo; dr->addinfo = addinfo ? addinfo : ""; @@ -827,6 +833,7 @@ 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 = odr_malloc (assoc->encode, sizeof(*recs)); int *err = odr_malloc (assoc->encode, sizeof(*err)); oident bib1; @@ -846,7 +853,7 @@ static Z_DiagRecs *diagrecs(association *assoc, int error, char *addinfo) drec->which = Z_DiagRec_defaultFormat; drec->u.defaultFormat = rec; - rec->diagnosticSetId = oid_getoidbyent(&bib1); + rec->diagnosticSetId = oid_ent_to_oid(&bib1, oid); rec->condition = err; rec->which = Z_DiagForm_v2AddInfo; rec->addinfo = addinfo ? addinfo : ""; @@ -857,6 +864,7 @@ static Z_Records *pack_records(association *a, char *setname, int start, int *num, Z_RecordComposition *comp, int *next, int *pres, oid_value format) { + int oid[OID_SIZE]; int recno, total_length = 0, toget = *num, dumped_records = 0; Z_Records *records = odr_malloc (a->encode, sizeof(*records)); Z_NamePlusRecordList *reclist = odr_malloc (a->encode, sizeof(*reclist)); @@ -960,7 +968,7 @@ static Z_Records *pack_records(association *a, char *setname, int start, recform.oclass = CLASS_RECSYN; recform.value = fres->format; thisext->direct_reference = odr_oiddup(a->encode, - oid_getoidbyent(&recform)); + oid_ent_to_oid(&recform, oid)); thisext->indirect_reference = 0; thisext->descriptor = 0; if (fres->len < 0) /* Structured data */ diff --git a/util/oid.c b/util/oid.c index 55ba752..d1ce750 100644 --- a/util/oid.c +++ b/util/oid.c @@ -1,10 +1,14 @@ /* - * Copyright (c) 1995, Index Data + * Copyright (c) 1995-1997, Index Data * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: oid.c,v $ - * Revision 1.23 1997-09-09 10:10:19 adam + * Revision 1.24 1997-09-29 13:19:00 adam + * Added function, oid_ent_to_oid, to replace the function + * oid_getoidbyent, which is not thread safe. + * + * Revision 1.23 1997/09/09 10:10:19 adam * Another MSV5.0 port. Changed projects to include proper * library/include paths. * Server starts server in test-mode when no options are given. @@ -359,13 +363,13 @@ struct oident *oid_getentbyoid(int *o) return 0; } + /* * To query, fill out proto, class, and value of the ent parameter. */ -int *oid_getoidbyent(struct oident *ent) +int *oid_ent_to_oid(struct oident *ent, int *ret) { struct oident *p; - static int ret[OID_SIZE]; for (p = oids; *p->oidsuffix >= 0; p++) if (ent->proto == p->proto && @@ -398,6 +402,15 @@ int *oid_getoidbyent(struct oident *ent) } return 0; } +/* + * To query, fill out proto, class, and value of the ent parameter. + */ +int *oid_getoidbyent(struct oident *ent) +{ + static int ret[OID_SIZE]; + + return oid_ent_to_oid (ent, ret); +} oid_value oid_getvalbyname(const char *name) { diff --git a/util/pquery.c b/util/pquery.c index ad22d34..7977ed6 100644 --- a/util/pquery.c +++ b/util/pquery.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: pquery.c,v $ - * Revision 1.15 1997-09-29 07:13:43 adam + * Revision 1.16 1997-09-29 13:19:00 adam + * Added function, oid_ent_to_oid, to replace the function + * oid_getoidbyent, which is not thread safe. + * + * Revision 1.15 1997/09/29 07:13:43 adam * Changed type of a few variables to avoid warnings. * * Revision 1.14 1997/09/22 12:33:41 adam @@ -195,13 +199,14 @@ static Z_AttributesPlusTerm *rpn_term (struct lex_info *li, ODR o, else { oident attrid; + int oid[OID_SIZE]; attrid.proto = PROTO_Z3950; attrid.oclass = CLASS_ATTSET; attrid.value = attr_set[i]; zapt->attributeList[i]->attributeSet = - odr_oiddup (o, oid_getoidbyent (&attrid)); + odr_oiddup (o, oid_ent_to_oid (&attrid, oid)); } zapt->attributeList[i]->which = Z_AttributeValue_numeric; zapt->attributeList[i]->value.numeric = &attr_tmp[2*i+1]; @@ -441,6 +446,7 @@ Z_RPNQuery *p_query_rpn_mk (ODR o, struct lex_info *li, oid_proto proto, oid_value attr_set[512]; oid_value topSet = VAL_NONE; oident oset; + int oid[OID_SIZE]; zq = odr_malloc (o, sizeof(*zq)); lex (li); @@ -461,7 +467,7 @@ Z_RPNQuery *p_query_rpn_mk (ODR o, struct lex_info *li, oid_proto proto, oset.oclass = CLASS_ATTSET; oset.value = topSet; - zq->attributeSetId = odr_oiddup (o, oid_getoidbyent (&oset)); + zq->attributeSetId = odr_oiddup (o, oid_ent_to_oid (&oset, oid)); if (!(zq->RPNStructure = rpn_structure (li, o, proto, 0, 512, attr_array, attr_set))) @@ -494,6 +500,7 @@ Z_AttributesPlusTerm *p_query_scan_mk (struct lex_info *li, const char *cp; oid_value topSet = VAL_NONE; oident oset; + int oid[OID_SIZE]; lex (li); if (li->query_look == 'r') @@ -511,7 +518,7 @@ Z_AttributesPlusTerm *p_query_scan_mk (struct lex_info *li, oset.oclass = CLASS_ATTSET; oset.value = topSet; - *attributeSetP = odr_oiddup (o, oid_getoidbyent (&oset)); + *attributeSetP = odr_oiddup (o, oid_ent_to_oid (&oset, oid)); while (li->query_look == 'l') { -- 1.7.10.4