From dd307c65deac044b20c13e99aad2de0d8608a8b7 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 18 Nov 1997 09:51:08 +0000 Subject: [PATCH] Removed element num_children from data1_node. Minor changes in data1 to Explain. --- CHANGELOG | 5 +- include/data1.h | 12 ++- retrieval/d1_expout.c | 218 +++++++++++++++++++++++++++++-------------------- retrieval/d1_grs.c | 18 ++-- retrieval/d1_map.c | 9 +- retrieval/d1_read.c | 12 ++- tab/explain.abs | 5 +- tab/explain.tag | 2 +- 8 files changed, 164 insertions(+), 117 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c24aaf5..2cd2920 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,11 @@ +Possible compatibility problems with earlier versions marked with '*'. + +* Removed member num_children from data1_node (in data1.h). + Made NT service interface part of the server library. The function statserv_main uses the NT service when required and calls the statserv_start / statserv_close routines. -Possible compatibility problems with earlier versions marked with '*'. Routine zget_SearchRequest fills resultSetName member with "default" instead of "Default". diff --git a/include/data1.h b/include/data1.h index f6e6448..e6e2584 100644 --- a/include/data1.h +++ b/include/data1.h @@ -24,7 +24,11 @@ * OF THIS SOFTWARE. * * $Log: data1.h,v $ - * Revision 1.30 1997-10-31 12:20:07 adam + * Revision 1.31 1997-11-18 09:51:08 adam + * Removed element num_children from data1_node. Minor changes in + * data1 to Explain. + * + * Revision 1.30 1997/10/31 12:20:07 adam * Improved memory debugging for xmalloc/nmem.c. References to NMEM * instead of ODR in n ESPEC-1 handling in source d1_espec.c. * Bug fix: missing fclose in data1_read_espec1. @@ -385,18 +389,12 @@ typedef struct data1_node data1_vartype *type; char *value; } variant; - - struct - { - char *ind; - } indicator; } u; void (*destroy)(struct data1_node *n); #define DATA1_LOCALDATA 40 char lbuf[DATA1_LOCALDATA]; /* small buffer for local data */ int line; - int num_children; struct data1_node *next; struct data1_node *child; struct data1_node *last_child; diff --git a/retrieval/d1_expout.c b/retrieval/d1_expout.c index ed6ce3d..1b1bfdc 100644 --- a/retrieval/d1_expout.c +++ b/retrieval/d1_expout.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_expout.c,v $ - * Revision 1.3 1997-09-17 12:10:36 adam + * Revision 1.4 1997-11-18 09:51:08 adam + * Removed element num_children from data1_node. Minor changes in + * data1 to Explain. + * + * Revision 1.3 1997/09/17 12:10:36 adam * YAZ version 1.4. * * Revision 1.2 1995/12/14 16:28:30 quinn @@ -24,7 +28,7 @@ #include #include -static int *f_integer(data1_node *c, ODR o) +static int *f_integer(data1_handle dh, data1_node *c, ODR o) { int *r; char intbuf[64]; @@ -38,7 +42,7 @@ static int *f_integer(data1_node *c, ODR o) return r; } -static char *f_string(data1_node *c, ODR o) +static char *f_string(data1_handle dh, data1_node *c, ODR o) { char *r; @@ -50,17 +54,45 @@ static char *f_string(data1_node *c, ODR o) return r; } -static bool_t *f_bool(data1_node *c, ODR o) +static bool_t *f_bool(data1_handle dh, data1_node *c, ODR o) { + bool_t *tf; + char intbuf[64]; + + if (!c->child || c->child->which != DATA1N_data || + c->child->u.data.len > 63) + return 0; + tf = odr_malloc (o, sizeof(*tf)); + sprintf(intbuf, "%.*s", 63, c->child->u.data.data); + *tf = atoi(intbuf); return 0; } -static Z_IntUnit *f_intunit(data1_node *c, ODR o) +static Z_IntUnit *f_intunit(data1_handle dh, data1_node *c, ODR o) { return 0; } -static Z_HumanString *f_humstring(data1_node *c, ODR o) +static int numeric_tag (data1_handle dh, data1_node *c, ODR o, int select) +{ + if (c->which != DATA1N_tag) + return 0; + if (!c->u.tag.element) + { + logf(LOG_WARN, "Malformed tag (no element)"); + return 0; + } + if (c->u.tag.element->tag->which != DATA1T_numeric) + { + logf(LOG_WARN, "Malformed tag (must be numeric)"); + return 0; + } + if (select && !c->u.tag.node_selected) + return 0; + return 1; +} + +static Z_HumanString *f_humstring(data1_handle dh, data1_node *c, ODR o) { Z_HumanString *r; Z_HumanStringUnit *u; @@ -78,7 +110,8 @@ static Z_HumanString *f_humstring(data1_node *c, ODR o) return r; } -static Z_CommonInfo *f_commonInfo(data1_node *n, int select, ODR o) +static Z_CommonInfo *f_commonInfo(data1_handle dh, data1_node *n, + int select, ODR o) { Z_CommonInfo *res = odr_malloc(o, sizeof(*res)); data1_node *c; @@ -100,10 +133,10 @@ static Z_CommonInfo *f_commonInfo(data1_node *n, int select, ODR o) continue; switch (c->u.tag.element->tag->value.numeric) { - case 601: res->dateAdded = f_string(c, o); break; - case 602: res->dateChanged = f_string(c, o); break; - case 603: res->expiry = f_string(c, o); break; - case 604: res->humanStringLanguage = f_string(c, o); break; + case 601: res->dateAdded = f_string(dh, c, o); break; + case 602: res->dateChanged = f_string(dh, c, o); break; + case 603: res->expiry = f_string(dh, c, o); break; + case 604: res->humanStringLanguage = f_string(dh, c, o); break; /* otherInfo? */ default: logf(LOG_WARN, "Bad child in commonInfo"); @@ -113,7 +146,8 @@ static Z_CommonInfo *f_commonInfo(data1_node *n, int select, ODR o) return res; } -static Z_AccessInfo *f_accessInfo(data1_node *n, int select, ODR o) +static Z_AccessInfo *f_accessInfo(data1_handle dh, data1_node *n, + int select, ODR o) { Z_AccessInfo *res = odr_malloc(o, sizeof(*res)); data1_node *c; @@ -153,7 +187,7 @@ static Z_AccessInfo *f_accessInfo(data1_node *n, int select, ODR o) return res; } -static int *f_recordCount(data1_node *c, ODR o, void *which) +static int *f_recordCount(data1_handle dh, data1_node *c, ODR o, void *which) { int *r= odr_malloc(o, sizeof(*r)); int *wp = which; @@ -175,12 +209,13 @@ static int *f_recordCount(data1_node *c, ODR o, void *which) return r; } -static Z_ContactInfo *f_contactInfo(data1_node *n, ODR o) +static Z_ContactInfo *f_contactInfo(data1_handle dh, data1_node *n, ODR o) { return 0; } -static Z_TargetInfo *f_targetInfo(data1_node *n, int select, ODR o) +static Z_TargetInfo *f_targetInfo(data1_handle dh, data1_node *n, + int select, ODR o) { Z_TargetInfo *res = odr_malloc(o, sizeof(*res)); data1_node *c; @@ -191,8 +226,8 @@ static Z_TargetInfo *f_targetInfo(data1_node *n, int select, ODR o) res->name = 0; res->recentNews = 0; res->icon = 0; - res->namedResultSets = fl; - res->multipleDbSearch = fl; + res->namedResultSets = 0; + res->multipleDbSearch = 0; res->maxResultSets = 0; res->maxResultSize = 0; res->maxTerms = 0; @@ -213,43 +248,44 @@ static Z_TargetInfo *f_targetInfo(data1_node *n, int select, ODR o) for (c = n->child; c; c = c->next) { - if (c->which != DATA1N_tag || !c->u.tag.element) - { - logf(LOG_WARN, "Malformed explain record"); - return 0; - } - if (select && !c->u.tag.node_selected) + if (!numeric_tag (dh, c, o, select)) continue; switch (c->u.tag.element->tag->value.numeric) { - case 600: res->commonInfo = f_commonInfo(c, select, o);break; - case 102: res->name = f_string(c, o); break; - case 103: res->recentNews = f_humstring(c, o); break; + case 600: res->commonInfo = f_commonInfo(dh, c, select, o);break; + case 102: res->name = f_string(dh, c, o); break; + case 103: res->recentNews = f_humstring(dh, c, o); break; case 104: break; /* icon */ - case 105: res->namedResultSets = f_bool(c, o); break; - case 106: res->multipleDbSearch = f_bool(c, o); break; - case 107: res->maxResultSets = f_integer(c, o); break; - case 108: res->maxResultSize = f_integer(c, o); break; - case 109: res->maxTerms = f_integer(c, o); break; - case 110: res->timeoutInterval = f_intunit(c, o); break; - case 111: res->welcomeMessage = f_humstring(c, o); break; - case 112: res->contactInfo = f_contactInfo(c, o); break; - case 113: res->description = f_humstring(c, o); break; + case 105: res->namedResultSets = f_bool(dh, c, o); break; + case 106: res->multipleDbSearch = f_bool(dh, c, o); break; + case 107: res->maxResultSets = f_integer(dh, c, o); break; + case 108: res->maxResultSize = f_integer(dh, c, o); break; + case 109: res->maxTerms = f_integer(dh, c, o); break; + case 110: res->timeoutInterval = f_intunit(dh, c, o); break; + case 111: res->welcomeMessage = f_humstring(dh, c, o); break; + case 112: res->contactInfo = f_contactInfo(dh, c, o); break; + case 113: res->description = f_humstring(dh, c, o); break; case 114: break; /* nicknames */ - case 115: res->usageRest = f_humstring(c, o); break; - case 116: res->paymentAddr = f_humstring(c, o); break; - case 117: res->hours = f_humstring(c, o); break; + case 115: res->usageRest = f_humstring(dh, c, o); break; + case 116: res->paymentAddr = f_humstring(dh, c, o); break; + case 117: res->hours = f_humstring(dh, c, o); break; case 118: break; /* dbcombinations */ case 119: break; /* addresses */ - case 500: res->commonAccessInfo = f_accessInfo(c, select, o); break; + case 500: res->commonAccessInfo = f_accessInfo(dh, c, + select, o); break; default: logf(LOG_WARN, "Unknown target-info element"); } } + if (!res->namedResultSets) + res->namedResultSets = fl; + if (!res->multipleDbSearch) + res->multipleDbSearch = fl; return res; } -static Z_DatabaseInfo *f_databaseInfo(data1_node *n, int select, ODR o) +static Z_DatabaseInfo *f_databaseInfo(data1_handle dh, data1_node *n, + int select, ODR o) { Z_DatabaseInfo *res = odr_malloc(o, sizeof(*res)); data1_node *c; @@ -264,8 +300,8 @@ static Z_DatabaseInfo *f_databaseInfo(data1_node *n, int select, ODR o) res->num_nicknames = 0; res->nicknames = 0; res->icon = 0; - res->userFee = fl; - res->available = tr; + res->userFee = 0; + res->available = 0; res->titleString = 0; res->num_keywords = 0; res->keywords = 0; @@ -290,54 +326,52 @@ static Z_DatabaseInfo *f_databaseInfo(data1_node *n, int select, ODR o) res->supplierContactInfo = 0; res->submissionContactInfo = 0; res->accessInfo = 0; - + for (c = n->child; c; c = c->next) { - if (c->which != DATA1N_tag || !c->u.tag.element) - { - logf(LOG_WARN, "Malformed explain record"); - return 0; - } - if (select && !c->u.tag.node_selected) + if (!numeric_tag (dh, c, o, select)) continue; switch (c->u.tag.element->tag->value.numeric) { - case 600: res->commonInfo = f_commonInfo(c, select, o); break; - case 102: res->name = f_string(c, o); break; - case 226: res->explainDatabase = ODR_NULLVAL; break; - case 114: - res->num_nicknames = 0; res->nicknames = 0; break; /* fix */ - case 104: res->icon = 0; break; /* fix */ - case 201: res->userFee = f_bool(c, o); break; - case 202: res->available = f_bool(c, o); break; - case 203: res->titleString = f_humstring(c, o); break; - case 227: res->num_keywords = 0; res->keywords = 0; break; /* fix */ - case 113: res->description = f_humstring(c, o); break; - case 205: res->associatedDbs = 0; break; /* fix */ - case 206: res->subDbs = 0; break; /* fix */ - case 207: res->disclaimers = f_humstring(c, o); break; - case 103: res->news = f_humstring(c, o); break; - case 209: res->recordCount = - f_recordCount(c, o, &res->recordCount_which); break; - case 212: res->defaultOrder = f_humstring(c, o); break; - case 213: res->avRecordSize = f_integer(c, o); break; - case 214: res->maxRecordSize = f_integer(c, o); break; - case 215: res->hours = f_humstring(c, o); break; - case 216: res->bestTime = f_humstring(c, o); break; - case 217: res->lastUpdate = f_string(c, o); break; - case 218: res->updateInterval = f_intunit(c, o); break; - case 219: res->coverage = f_humstring(c, o); break; - case 220: res->proprietary = f_bool(c, o); break; - case 221: res->copyrightText = f_humstring(c, o); break; - case 222: res->copyrightNotice = f_humstring(c, o); break; - case 223: res->producerContactInfo = f_contactInfo(c, o); break; - case 224: res->supplierContactInfo = f_contactInfo(c, o); break; - case 225: res->submissionContactInfo = f_contactInfo(c, o); break; - case 500: res->accessInfo = f_accessInfo(c, select, o); break; - default: - logf(LOG_WARN, "Unknown element in databaseInfo"); + case 600: res->commonInfo = f_commonInfo(dh, c, select, o); break; + case 102: res->name = f_string(dh, c, o); break; + case 226: res->explainDatabase = ODR_NULLVAL; break; + case 114: res->num_nicknames = 0; res->nicknames = 0; break; /* fix */ + case 104: res->icon = 0; break; /* fix */ + case 201: res->userFee = f_bool(dh, c, o); break; + case 202: res->available = f_bool(dh, c, o); break; + case 203: res->titleString = f_humstring(dh, c, o); break; + case 227: res->num_keywords = 0; res->keywords = 0; break; /* fix */ + case 113: res->description = f_humstring(dh, c, o); break; + case 205: res->associatedDbs = 0; break; /* fix */ + case 206: res->subDbs = 0; break; /* fix */ + case 207: res->disclaimers = f_humstring(dh, c, o); break; + case 103: res->news = f_humstring(dh, c, o); break; + case 209: res->recordCount = + f_recordCount(dh, c, o, &res->recordCount_which); break; + case 212: res->defaultOrder = f_humstring(dh, c, o); break; + case 213: res->avRecordSize = f_integer(dh, c, o); break; + case 214: res->maxRecordSize = f_integer(dh, c, o); break; + case 215: res->hours = f_humstring(dh, c, o); break; + case 216: res->bestTime = f_humstring(dh, c, o); break; + case 217: res->lastUpdate = f_string(dh, c, o); break; + case 218: res->updateInterval = f_intunit(dh, c, o); break; + case 219: res->coverage = f_humstring(dh, c, o); break; + case 220: res->proprietary = f_bool(dh, c, o); break; + case 221: res->copyrightText = f_humstring(dh, c, o); break; + case 222: res->copyrightNotice = f_humstring(dh, c, o); break; + case 223: res->producerContactInfo = f_contactInfo(dh, c, o); break; + case 224: res->supplierContactInfo = f_contactInfo(dh, c, o); break; + case 225: res->submissionContactInfo = f_contactInfo(dh, c, o); break; + case 500: res->accessInfo = f_accessInfo(dh, c, select, o); break; + default: + logf(LOG_WARN, "Unknown element in databaseInfo"); } } + if (!res->userFee) + res->userFee = fl; + if (!res->available) + res->available = tr; return res; } @@ -352,20 +386,24 @@ Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n, logf(LOG_WARN, "Attempt to convert a non-Explain record"); return 0; } - if (n->num_children != 1 || n->child->which != DATA1N_tag || - !n->u.tag.element) + n = n->child; + if (!n || n->next) { logf(LOG_WARN, "Explain record should have one exactly one child"); return 0; } - switch (n->child->u.tag.element->tag->value.numeric) + if (!numeric_tag (dh, n, o, select)) + return 0; + switch (n->u.tag.element->tag->value.numeric) { - case 0: res->which = Z_Explain_targetInfo; - if (!(res->u.targetInfo = f_targetInfo(n->child, select, o))) + case 0: + res->which = Z_Explain_targetInfo; + if (!(res->u.targetInfo = f_targetInfo(dh, n, select, o))) return 0; break; - case 1: res->which = Z_Explain_databaseInfo; - if (!(res->u.databaseInfo = f_databaseInfo(n->child, select, o))) + case 1: + res->which = Z_Explain_databaseInfo; + if (!(res->u.databaseInfo = f_databaseInfo(dh, n, select, o))) return 0; break; default: diff --git a/retrieval/d1_grs.c b/retrieval/d1_grs.c index 46b34ae..30397c9 100644 --- a/retrieval/d1_grs.c +++ b/retrieval/d1_grs.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: d1_grs.c,v $ - * Revision 1.10 1997-09-17 12:10:36 adam + * Revision 1.11 1997-11-18 09:51:09 adam + * Removed element num_children from data1_node. Minor changes in + * data1 to Explain. + * + * Revision 1.10 1997/09/17 12:10:36 adam * YAZ version 1.4. * * Revision 1.9 1997/05/14 06:54:03 adam @@ -157,7 +161,7 @@ static Z_ElementData *nodetoelementdata(data1_handle dh, data1_node *n, res->which = Z_ElementData_elementNotThere; res->u.elementNotThere = ODR_NULLVAL; } - else if (n->which == DATA1N_data && (leaf || n->parent->num_children == 1)) + else if (n->which == DATA1N_data && (leaf || n->next == NULL)) { char str[512]; int toget; @@ -268,7 +272,7 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n, res->appliedVariant = 0; res->metaData = 0; if (n->which == DATA1N_variant || (data && data->which == - DATA1N_variant && data->parent->num_children == 1)) + DATA1N_variant && data->next == NULL)) { int nvars = 0; @@ -302,8 +306,12 @@ Z_GenericRecord *data1_nodetogr(data1_handle dh, data1_node *n, { Z_GenericRecord *res = odr_malloc(o, sizeof(*res)); data1_node *c; + int num_children = 0; + + for (c = n->child; c; c = c->next) + num_children++; - res->elements = odr_malloc(o, sizeof(Z_TaggedElement *) * n->num_children); + res->elements = odr_malloc(o, sizeof(Z_TaggedElement *) * num_children); res->num_elements = 0; for (c = n->child; c; c = c->next) { diff --git a/retrieval/d1_map.c b/retrieval/d1_map.c index 7a5a323..c0d8d92 100644 --- a/retrieval/d1_map.c +++ b/retrieval/d1_map.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_map.c,v $ - * Revision 1.11 1997-09-17 12:10:36 adam + * Revision 1.12 1997-11-18 09:51:09 adam + * Removed element num_children from data1_node. Minor changes in + * data1 to Explain. + * + * Revision 1.11 1997/09/17 12:10:36 adam * YAZ version 1.4. * * Revision 1.10 1997/09/05 09:50:56 adam @@ -286,7 +290,6 @@ static int map_children(data1_handle dh, data1_node *n, data1_maptab *map, if (pn->last_child) pn->last_child->next = cur; pn->last_child = cur; - pn->num_children++; } if (mt->next) @@ -295,10 +298,8 @@ static int map_children(data1_handle dh, data1_node *n, data1_maptab *map, { cur->child = c->child; cur->last_child = c->last_child; - cur->num_children = c->num_children; c->child = 0; c->last_child = 0; - c->num_children = 0; } } break; diff --git a/retrieval/d1_read.c b/retrieval/d1_read.c index e71cbd0..38dd683 100644 --- a/retrieval/d1_read.c +++ b/retrieval/d1_read.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_read.c,v $ - * Revision 1.17 1997-11-05 09:20:51 adam + * Revision 1.18 1997-11-18 09:51:09 adam + * Removed element num_children from data1_node. Minor changes in + * data1 to Explain. + * + * Revision 1.17 1997/11/05 09:20:51 adam * Minor change. * * Revision 1.16 1997/09/17 12:10:37 adam @@ -128,7 +132,6 @@ data1_node *data1_mk_node (data1_handle dh, NMEM m) r = nmem_malloc(m, sizeof(*r)); r->next = r->child = r->last_child = r->parent = 0; - r->num_children = 0; r->destroy = 0; return r; } @@ -171,7 +174,6 @@ data1_node *data1_insert_taggeddata(data1_handle dh, data1_node *root, 0, tagname))) return 0; tagn->child = datn = data1_mk_node (dh, m); - tagn->num_children = 1; datn->parent = tagn; datn->root = root; datn->which = DATA1N_data; @@ -179,7 +181,6 @@ data1_node *data1_insert_taggeddata(data1_handle dh, data1_node *root, tagn->next = at->child; tagn->parent = at; at->child = tagn; - at->num_children++; return datn; } @@ -366,8 +367,6 @@ data1_node *data1_read_node (data1_handle dh, char **buf, } res->parent = parent; - res->num_children = 0; - pp = &res->child; /* * Read child nodes. @@ -375,7 +374,6 @@ data1_node *data1_read_node (data1_handle dh, char **buf, while ((*pp = data1_read_node(dh, buf, res, line, absyn, m))) { res->last_child = *pp; - res->num_children++; pp = &(*pp)->next; } } diff --git a/tab/explain.abs b/tab/explain.abs index 1a7ebd3..fb3706c 100644 --- a/tab/explain.abs +++ b/tab/explain.abs @@ -32,6 +32,7 @@ elm (4,0)/(4,111) welcomeMessage - elm (4,0)/(4,112) contactInfo - elm (4,0)/(4,113) description - elm (4,0)/(4,114) nicknames - +elm (4,0)/(4,114)/(4,102) nickname - elm (4,0)/(4,115) usageRest - elm (4,0)/(4,116) paymentAddr - elm (4,0)/(4,117) hours - @@ -69,9 +70,9 @@ elm (4,1)/(4,600)/(4,604) languageCode HumanStringLanguage elm (4,1)/(4,102) databaseName DatabaseName elm (4,1)/(4,226) explainDatabase - elm (4,1)/(4,114) nicknames - -elm (4,1)/(4,114)/(4,1000) nickname - +elm (4,1)/(4,114)/(4,102) nickname - elm (4,1)/(4,104) icon - -elm (4,1)/(4,201) userFee ! +elm (4,1)/(4,201) userFee - elm (4,1)/(4,202) available Availability elm (4,1)/(4,203) titleString - elm (4,1)/(4,227) keywords - diff --git a/tab/explain.tag b/tab/explain.tag index 226d594..48cc27c 100644 --- a/tab/explain.tag +++ b/tab/explain.tag @@ -43,7 +43,7 @@ tag 119 address structured # tag 201 userFee bool tag 202 available bool -tag 203 titleString bool +tag 203 titleString string tag 205 associatedDbs structured tag 206 subDbs structured tag 207 disclaimers string -- 1.7.10.4