From c126b2a625462f95475f00efdfdf9ce41a0e9c79 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 31 Jan 2000 13:15:21 +0000 Subject: [PATCH] Removed uses of assert(3). Cleanup of ODR. CCL parser update so that some characters are not surrounded by spaces in resulting term. ILL-code updates. --- ccl/cclfind.c | 32 +++-- ccl/cclptree.c | 10 +- ccl/cclqfile.c | 8 +- ccl/cclqual.c | 23 +-- ccl/cclsh.c | 11 +- ccl/ccltoken.c | 16 ++- client/client.c | 99 ++++++++++--- ill/ill-get.c | 411 ++++++++++++++++++++++++++++++++++++----------------- include/yaz/ccl.h | 11 +- include/yaz/ill.h | 20 ++- include/yaz/odr.h | 42 +++--- odr/ber_any.c | 14 +- odr/ber_bit.c | 10 +- odr/ber_bool.c | 9 +- odr/ber_int.c | 8 +- odr/ber_null.c | 8 +- odr/ber_oct.c | 9 +- odr/ber_oid.c | 10 +- odr/ber_tag.c | 10 +- odr/odr.c | 40 +++--- odr/odr_cons.c | 14 +- odr/odr_mem.c | 36 +++-- odr/odr_seq.c | 10 +- odr/odr_util.c | 11 +- ztest/ztest.c | 9 +- zutil/logrpn.c | 10 +- zutil/yaz-ccl.c | 30 ++-- 27 files changed, 612 insertions(+), 309 deletions(-) diff --git a/ccl/cclfind.c b/ccl/cclfind.c index 99cc3b5..812d124 100644 --- a/ccl/cclfind.c +++ b/ccl/cclfind.c @@ -45,7 +45,12 @@ * Europagate, 1995 * * $Log: cclfind.c,v $ - * Revision 1.13 1999-12-22 13:13:32 adam + * Revision 1.14 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.13 1999/12/22 13:13:32 adam * Search terms may include "operators" without causing error. * * Revision 1.12 1999/11/30 13:47:11 adam @@ -127,7 +132,6 @@ #include #include -#include #include #include @@ -185,7 +189,7 @@ static void strxcat (char *n, const char *src, int len) static char *copy_token_name (struct ccl_token *tp) { char *str = (char *)malloc (tp->len + 1); - assert (str); + ccl_assert (str); memcpy (str, tp->name, tp->len); str[tp->len] = '\0'; return str; @@ -200,7 +204,7 @@ static struct ccl_rpn_node *mk_node (int kind) { struct ccl_rpn_node *p; p = (struct ccl_rpn_node *)malloc (sizeof(*p)); - assert (p); + ccl_assert (p); p->kind = kind; return p; } @@ -266,7 +270,7 @@ static void add_attr (struct ccl_rpn_node *p, int type, int value) struct ccl_rpn_attr *n; n = (struct ccl_rpn_attr *)malloc (sizeof(*n)); - assert (n); + ccl_assert (n); n->type = type; n->value = value; n->next = p->u.t.attr_list; @@ -311,7 +315,7 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp, /* no qualifier(s) applied. Use 'term' if it is defined */ qa = (struct ccl_rpn_attr **)malloc (2*sizeof(*qa)); - assert (qa); + ccl_assert (qa); qa[0] = ccl_qual_search (cclp, "term", 4); qa[1] = NULL; } @@ -389,7 +393,7 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp, /* make the RPN token */ p->u.t.term = (char *)malloc (len); - assert (p->u.t.term); + ccl_assert (p->u.t.term); p->u.t.term[0] = '\0'; for (i = 0; iu.t.term, " "); + if (src_len) + { + int len = strlen(p->u.t.term); + if (len && + !strchr("-+", *src_str) && + !strchr("-+", p->u.t.term[len-1])) + { + strcat (p->u.t.term, " "); + } + } strxcat (p->u.t.term, src_str, src_len); ADVANCE; } @@ -484,7 +496,7 @@ static struct ccl_rpn_node *qualifiers (CCL_parser cclp, struct ccl_token *la, for (i=0; qa[i]; i++) no++; ap = (struct ccl_rpn_attr **)malloc ((no+1) * sizeof(*ap)); - assert (ap); + ccl_assert (ap); for (i = 0; cclp->look_token != la; i++) { ap[i] = ccl_qual_search (cclp, cclp->look_token->name, diff --git a/ccl/cclptree.c b/ccl/cclptree.c index 2c37bd9..4e42e00 100644 --- a/ccl/cclptree.c +++ b/ccl/cclptree.c @@ -45,7 +45,12 @@ * Europagate, 1995 * * $Log: cclptree.c,v $ - * Revision 1.6 1999-11-30 13:47:11 adam + * Revision 1.7 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.6 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.5 1997/04/30 08:52:06 quinn @@ -75,7 +80,6 @@ */ #include -#include #include #include @@ -126,6 +130,6 @@ void ccl_pr_tree (struct ccl_rpn_node *rpn, FILE *fd_out) fprintf (fd_out, ")"); break; default: - assert (0); + ccl_assert (0); } } diff --git a/ccl/cclqfile.c b/ccl/cclqfile.c index 2263291..9e0957a 100644 --- a/ccl/cclqfile.c +++ b/ccl/cclqfile.c @@ -45,7 +45,12 @@ * Europagate, 1995 * * $Log: cclqfile.c,v $ - * Revision 1.3 1999-11-30 13:47:11 adam + * Revision 1.4 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.3 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.2 1997/04/30 08:52:06 quinn @@ -69,7 +74,6 @@ #include #include -#include #include #include diff --git a/ccl/cclqual.c b/ccl/cclqual.c index 9777521..c8be663 100644 --- a/ccl/cclqual.c +++ b/ccl/cclqual.c @@ -45,7 +45,12 @@ * Europagate, 1995 * * $Log: cclqual.c,v $ - * Revision 1.12 1999-11-30 13:47:11 adam + * Revision 1.13 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.12 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.11 1999/03/31 11:15:37 adam @@ -104,7 +109,6 @@ #include #include -#include #include #include @@ -128,20 +132,21 @@ void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs) struct ccl_qualifier *q; struct ccl_rpn_attr **attrp; - assert (b); + ccl_assert (b); for (q = b->list; q; q = q->next) if (!strcmp (name, q->name)) break; if (!q) { - struct ccl_qualifier *new_qual = (struct ccl_qualifier *)malloc (sizeof(*new_qual)); - assert (new_qual); + struct ccl_qualifier *new_qual = + (struct ccl_qualifier *)malloc (sizeof(*new_qual)); + ccl_assert (new_qual); new_qual->next = b->list; b->list = new_qual; new_qual->name = (char *)malloc (strlen(name)+1); - assert (new_qual->name); + ccl_assert (new_qual->name); strcpy (new_qual->name, name); attrp = &new_qual->attr_list; } @@ -156,7 +161,7 @@ void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs) struct ccl_rpn_attr *attr; attr = (struct ccl_rpn_attr *)malloc (sizeof(*attr)); - assert (attr); + ccl_assert (attr); attr->type = *pairs++; attr->value = *pairs++; *attrp = attr; @@ -172,7 +177,7 @@ void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs) CCL_bibset ccl_qual_mk (void) { CCL_bibset b = (CCL_bibset)malloc (sizeof(*b)); - assert (b); + ccl_assert (b); b->list = NULL; return b; } @@ -216,7 +221,7 @@ struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp, { struct ccl_qualifier *q; - assert (cclp); + ccl_assert (cclp); if (!cclp->bibset) return NULL; for (q = cclp->bibset->list; q; q = q->next) diff --git a/ccl/cclsh.c b/ccl/cclsh.c index 0902419..d2aaf46 100644 --- a/ccl/cclsh.c +++ b/ccl/cclsh.c @@ -45,7 +45,12 @@ * Europagate 1995 * * $Log: cclsh.c,v $ - * Revision 1.5 1999-12-16 23:36:19 adam + * Revision 1.6 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.5 1999/12/16 23:36:19 adam * Implemented ILL protocol. Minor updates ASN.1 compiler. * * Revision 1.4 1999/03/31 11:15:37 adam @@ -96,7 +101,6 @@ #include #include -#include #include @@ -174,8 +178,7 @@ int main (int argc, char **argv) } else { - assert (rpn); - if (i == 0) + if (rpn && i == 0) { ccl_pr_tree (rpn, stdout); putchar ('\n'); diff --git a/ccl/ccltoken.c b/ccl/ccltoken.c index 1521c90..81af662 100644 --- a/ccl/ccltoken.c +++ b/ccl/ccltoken.c @@ -45,7 +45,12 @@ * Europagate, 1995 * * $Log: ccltoken.c,v $ - * Revision 1.11 1999-11-30 13:47:11 adam + * Revision 1.12 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.11 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.10 1998/07/07 15:49:41 adam @@ -107,7 +112,6 @@ #include #include #include -#include #include @@ -167,13 +171,13 @@ struct ccl_token *ccl_token_simple (const char *command) if (!first) { first = last = (struct ccl_token *)malloc (sizeof (*first)); - assert (first); + ccl_assert (first); last->prev = NULL; } else { last->next = (struct ccl_token *)malloc (sizeof(*first)); - assert (last->next); + ccl_assert (last->next); last->next->prev = last; last = last->next; } @@ -230,13 +234,13 @@ struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command) if (!first) { first = last = (struct ccl_token *)malloc (sizeof (*first)); - assert (first); + ccl_assert (first); last->prev = NULL; } else { last->next = (struct ccl_token *)malloc (sizeof(*first)); - assert (last->next); + ccl_assert (last->next); last->next->prev = last; last = last->next; } diff --git a/client/client.c b/client/client.c index 5789d7c..b48fabe 100644 --- a/client/client.c +++ b/client/client.c @@ -1,10 +1,15 @@ /* - * Copyright (c) 1995-1999, Index Data + * Copyright (c) 1995-2000, Index Data * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: client.c,v $ - * Revision 1.93 2000-01-15 09:39:50 adam + * Revision 1.94 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.93 2000/01/15 09:39:50 adam * Implemented ill_get_ILLRequest. More ILL testing for client. * * Revision 1.92 1999/12/21 16:24:48 adam @@ -308,7 +313,6 @@ #include #include #include -#include #include @@ -392,6 +396,7 @@ static void send_apdu(Z_APDU *a) odr_reset(print); } buf = odr_getbuf(out, &len, 0); + /* printf ("sending APDU of size %d\n", len); */ if (cs_put(conn, buf, len) < 0) { fprintf(stderr, "cs_put: %s", cs_errmsg(cs_errno(conn))); @@ -1000,7 +1005,11 @@ static int send_searchRequest(char *arg) case QueryType_CCL2RPN: query.which = Z_Query_type_1; RPNquery = ccl_rpn_query(out, rpn); - assert(RPNquery); + if (!RPNquery) + { + printf ("Couldn't convert from CCL to RPN\n"); + return 0; + } bib1.proto = protocol; bib1.oclass = CLASS_ATTSET; bib1.value = VAL_BIB1; @@ -1216,19 +1225,49 @@ void process_ESResponse(Z_ExtendedServicesResponse *res) } #ifdef ASN_COMPILED + +const char *get_ill_element (void *clientData, const char *element) +{ + /* printf ("asking for %s\n", element); */ + if (!strcmp (element, "ill,transaction-id,transaction-group-qualifier")) + return "1"; + if (!strcmp (element, "ill,transaction-id,transaction-qualifier")) + return "1"; + return 0; +} + static Z_External *create_external_itemRequest() { - ILL_ItemRequest *req = ill_get_ItemRequest(out); + struct ill_get_ctl ctl; + ILL_ItemRequest *req; Z_External *r = 0; + int item_request_size = 0; + char *item_request_buf = 0; + + ctl.odr = out; + ctl.clientData = 0; + ctl.f = get_ill_element; + + req = ill_get_ItemRequest(&ctl, "ill", 0); if (!ill_ItemRequest (out, &req, 0, 0)) + { + if (apdu_file) + { + ill_ItemRequest(print, &req, 0, 0); + odr_reset(print); + } + item_request_buf = odr_getbuf (out, &item_request_size, 0); + if (item_request_buf) + odr_setbuf (out, item_request_buf, item_request_size, 1); + printf ("Couldn't encode ItemRequest, size %d\n", item_request_size); return 0; + } else { oident oid; - int itemRequest_size = 0; - char *itemRequest_buf = odr_getbuf (out, &itemRequest_size, 0); + item_request_buf = odr_getbuf (out, &item_request_size, 0); oid.proto = PROTO_GENERAL; oid.oclass = CLASS_GENERAL; oid.value = VAL_ISO_ILL_1; @@ -1241,11 +1280,12 @@ static Z_External *create_external_itemRequest() r->u.single_ASN1_type = (Odr_oct *) odr_malloc (out, sizeof(*r->u.single_ASN1_type)); - r->u.single_ASN1_type->buf = odr_malloc (out, itemRequest_size); - r->u.single_ASN1_type->len = itemRequest_size; - r->u.single_ASN1_type->size = itemRequest_size; - memcpy (r->u.single_ASN1_type->buf, itemRequest_buf, itemRequest_size); - printf ("len = %d\n", itemRequest_size); + r->u.single_ASN1_type->buf = odr_malloc (out, item_request_size); + r->u.single_ASN1_type->len = item_request_size; + r->u.single_ASN1_type->size = item_request_size; + memcpy (r->u.single_ASN1_type->buf, item_request_buf, + item_request_size); + printf ("len = %d\n", item_request_size); } return r; } @@ -1259,16 +1299,37 @@ static Z_External *create_external_itemRequest() #ifdef ASN_COMPILED static Z_External *create_external_ILLRequest() { - ILL_Request *req = ill_get_ILLRequest(out); + struct ill_get_ctl ctl; + ILL_Request *req; Z_External *r = 0; + int ill_request_size = 0; + char *ill_request_buf = 0; + + ctl.odr = out; + ctl.clientData = 0; + ctl.f = get_ill_element; + + req = ill_get_ILLRequest(&ctl, "ill", 0); if (!ill_Request (out, &req, 0, 0)) + { + if (apdu_file) + { + printf ("-------------------\n"); + ill_Request(print, &req, 0, 0); + odr_reset(print); + printf ("-------------------\n"); + } + ill_request_buf = odr_getbuf (out, &ill_request_size, 0); + if (ill_request_buf) + odr_setbuf (out, ill_request_buf, ill_request_size, 1); + printf ("Couldn't encode ILL-Request, size %d\n", ill_request_size); return 0; + } else { oident oid; - int ill_request_size = 0; - char *ill_request_buf = odr_getbuf (out, &ill_request_size, 0); + ill_request_buf = odr_getbuf (out, &ill_request_size, 0); oid.proto = PROTO_GENERAL; oid.oclass = CLASS_GENERAL; @@ -1348,10 +1409,12 @@ static Z_External *create_ItemOrderExternal(const char *type, int itemno) switch (*type) { case '2': + printf ("using item-request\n"); r->u.itemOrder->u.esRequest->notToKeep->itemRequest = create_external_itemRequest(); break; case '1': + printf ("using ILL-request\n"); r->u.itemOrder->u.esRequest->notToKeep->itemRequest = create_external_ILLRequest(); break; @@ -1441,12 +1504,12 @@ static int cmd_itemorder(char *arg) { char type[12]; int itemno; - printf("Item order request\n"); - fflush(stdout); if (sscanf (arg, "%10s %d", type, &itemno) != 2) return 0; + printf("Item order request\n"); + fflush(stdout); send_itemorder(type, itemno); return(2); } @@ -2289,6 +2352,8 @@ static int client(int wait) fprintf(stderr, "Packet dump:\n---------\n"); odr_dumpBER(stderr, netbuffer, res); fprintf(stderr, "---------\n"); + if (apdu_file) + z_APDU(print, &apdu, 0, 0); exit(1); } if (apdu_file && !z_APDU(print, &apdu, 0, 0)) diff --git a/ill/ill-get.c b/ill/ill-get.c index bcf345a..fd86291 100644 --- a/ill/ill-get.c +++ b/ill/ill-get.c @@ -3,7 +3,12 @@ * See the file LICENSE for details. * * $Log: ill-get.c,v $ - * Revision 1.2 2000-01-15 09:38:51 adam + * Revision 1.3 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.2 2000/01/15 09:38:51 adam * Implemented ill_get_ILLRequest. Added some type mappings for ILL protocol. * * Revision 1.1 1999/12/16 23:36:19 adam @@ -13,204 +18,348 @@ #include -ILL_String *ill_get_ILL_String (ODR o, const char *str) +bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name, + const char *sub, int val) { - ILL_String *r = (ILL_String *) odr_malloc (o, sizeof(*r)); + ODR o = gc->odr; + char element[128]; + const char *v; + bool_t *r = odr_malloc (o, sizeof(*r)); + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } - r->which = ILL_String_GeneralString; - r->u.GeneralString = odr_strdup (o, str); + v = (gc->f)(gc->clientData, element); + if (v) + val = atoi(v); + else if (val < 0) + return 0; + *r = val; return r; } -ILL_Transaction_Id *ill_get_Transaction_Id (ODR o) +int *ill_get_int (struct ill_get_ctl *gc, const char *name, + const char *sub, int val) { - ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r)); + ODR o = gc->odr; + char element[128]; + const char *v; + int *r = odr_malloc (o, sizeof(*r)); - r->initial_requester_id = 0; - r->transaction_group_qualifier = ill_get_ILL_String (o, "group"); - r->transaction_qualifier = ill_get_ILL_String (o, "qual"); - r->sub_transaction_qualifier = 0; + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + v = (gc->f)(gc->clientData, element); + if (v) + val = atoi(v); + *r = val; return r; } - -ILL_Service_Date_this *ill_get_Service_Date_this (ODR o) +int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name, + const char *sub, int val) { - ILL_Service_Date_this *r = - (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r)); - r->date = odr_strdup (o, "14012000"); - r->time = 0; - return r; + return ill_get_int(gc, name, sub, val); } -ILL_Service_Date_Time *ill_get_Service_Date_Time (ODR o) +ILL_String *ill_get_ILL_String (struct ill_get_ctl *gc, const char *name, + const char *sub) { - ILL_Service_Date_Time *r = - (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r)); - r->date_time_of_this_service = ill_get_Service_Date_this (o); - r->date_time_of_original_service = 0; + ILL_String *r = (ILL_String *) odr_malloc (gc->odr, sizeof(*r)); + char element[128]; + const char *v; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + v = (gc->f)(gc->clientData, element); + if (!v) + return 0; + r->which = ILL_String_GeneralString; + r->u.GeneralString = odr_strdup (gc->odr, v); return r; } -ILL_Transaction_Type *ill_get_Transaction_Type (ODR o) +ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol ( + struct ill_get_ctl *gc, const char *name, const char *sub) { - ILL_Transaction_Type *r = - (ILL_Transaction_Type *) odr_malloc (o, sizeof(*r)); - *r = 1; - return r; + char element[128]; + ODR o = gc->odr; + ILL_Person_Or_Institution_Symbol *p = odr_malloc (o, sizeof(*p)); + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + p->which = ILL_Person_Or_Institution_Symbol_person_symbol; + if ((p->u.person_symbol = ill_get_ILL_String (gc, element, "person"))) + return p; + + p->which = ILL_Person_Or_Institution_Symbol_institution_symbol; + if ((p->u.institution_symbol = + ill_get_ILL_String (gc, element, "institution"))) + return p; + return 0; } +static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution( + struct ill_get_ctl *gc, const char *name, const char *sub) +{ + char element[128]; + ODR o = gc->odr; + ILL_Name_Of_Person_Or_Institution *p = odr_malloc (o, sizeof(*p)); + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + p->which = ILL_Name_Of_Person_Or_Institution_name_of_person; + if ((p->u.name_of_person = + ill_get_ILL_String (gc, element, "name-of-person"))) + return p; -bool_t *ill_get_bool (ODR o, int val) + p->which = ILL_Name_Of_Person_Or_Institution_name_of_institution; + if ((p->u.name_of_institution = + ill_get_ILL_String (gc, element, "name-of-institution"))) + return p; + return 0; +} + +ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc, + const char *name, const char *sub) { - bool_t *r = odr_malloc (o, sizeof(*r)); - *r = val; - return r; + ODR o = gc->odr; + char element[128]; + ILL_System_Id *p; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + p = (ILL_System_Id *) odr_malloc (o, sizeof(*p)); + p->person_or_institution_symbol = + ill_get_Person_Or_Insitution_Symbol (gc, element, + "person-or-institution-symbol"); + p->name_of_person_or_institution = + ill_get_Name_Of_Person_Or_Institution (gc, element, + "name-of-person-or-institution"); + return p; } -int *ill_get_enumerated (ODR o, int val) +ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc, + const char *name, const char *sub) { - int *r = odr_malloc (o, sizeof(*r)); - *r = val; + ODR o = gc->odr; + ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r)); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->initial_requester_id = + ill_get_System_Id (gc, element, "initial-requester-id"); + r->transaction_group_qualifier = + ill_get_ILL_String (gc, element, "transaction-group-qualifier"); + r->transaction_qualifier = + ill_get_ILL_String (gc, element, "transaction-qualifier"); + r->sub_transaction_qualifier = + ill_get_ILL_String (gc, element, "sub-transaction-qualifier"); return r; } -int *ill_get_int (ODR o, int val) + +ILL_Service_Date_this *ill_get_Service_Date_this ( + struct ill_get_ctl *gc, const char *name, const char *sub) { - return ill_get_enumerated (o, val); + ODR o = gc->odr; + ILL_Service_Date_this *r = + (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r)); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->date = odr_strdup (o, "14012000"); + r->time = 0; + return r; } +ILL_Service_Date_Time *ill_get_Service_Date_Time ( + struct ill_get_ctl *gc, const char *name, const char *sub) +{ + ODR o = gc->odr; + ILL_Service_Date_Time *r = + (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r)); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->date_time_of_this_service = ill_get_Service_Date_this (gc, element, + "this"); + r->date_time_of_original_service = 0; + return r; +} -ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type (ODR o) +ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type ( + struct ill_get_ctl *gc, const char *name, const char *sub) { + ODR o = gc->odr; ILL_Requester_Optional_Messages_Type *r = (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r)); - r->can_send_RECEIVED = ill_get_bool (o, 0); - r->can_send_RETURNED = ill_get_bool (o, 0); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->can_send_RECEIVED = ill_get_bool (gc, element, "can-send-RECEIVED", 0); + r->can_send_RETURNED = ill_get_bool (gc, element, "can-send-RETURNED", 0); r->requester_SHIPPED = - ill_get_enumerated (o, ILL_Requester_Optional_Messages_Type_requires); + ill_get_enumerated (gc, element, "requester-SHIPPED", 1); r->requester_CHECKED_IN = - ill_get_enumerated (o, ILL_Requester_Optional_Messages_Type_requires); + ill_get_enumerated (gc, element, "requester-CHECKED-IN", 1); return r; } -ILL_Item_Id *ill_get_Item_Id (ODR o) +ILL_Item_Id *ill_get_Item_Id ( + struct ill_get_ctl *gc, const char *name, const char *sub) { + ODR o = gc->odr; ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc (o, sizeof(*r)); - - r->item_type = ill_get_enumerated (o, ILL_Item_Id_monograph); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->item_type = ill_get_enumerated (gc, element, "item-type", + ILL_Item_Id_monograph); r->held_medium_type = 0; - r->call_number = 0; - r->author = 0; - r->title = 0; - r->sub_title = 0; - r->sponsoring_body = 0; - r->place_of_publication = 0; - r->publisher = 0; - r->series_title_number = 0; - r->volume_issue = 0; - r->edition = 0; - r->publication_date = 0; - r->publication_date_of_component = 0; - r->author_of_article = 0; - r->title_of_article = 0; - r->pagination = 0; + r->call_number = ill_get_ILL_String(gc, element, "call-number"); + r->author = ill_get_ILL_String(gc, element, "author"); + r->title = ill_get_ILL_String(gc, element, "title"); + r->sub_title = ill_get_ILL_String(gc, element, "sub-title"); + r->sponsoring_body = ill_get_ILL_String(gc, element, "sponsoring-body"); + r->place_of_publication = + ill_get_ILL_String(gc, element, "place-of-publication"); + r->publisher = ill_get_ILL_String(gc, element, "publisher"); + r->series_title_number = + ill_get_ILL_String(gc, element, "series-title-number"); + r->volume_issue = ill_get_ILL_String(gc, element, "volume-issue"); + r->edition = ill_get_ILL_String(gc, element, "edition"); + r->publication_date = ill_get_ILL_String(gc, element, "publication-date"); + r->publication_date_of_component = + ill_get_ILL_String(gc, element, "publication-date-of-component"); + r->author_of_article = ill_get_ILL_String(gc, element, + "author-of-article"); + r->title_of_article = ill_get_ILL_String(gc, element, "title-or-article"); + r->pagination = ill_get_ILL_String(gc, element, "pagination"); r->national_bibliography_no = 0; - r->iSBN = 0; - r->iSSN = 0; + r->iSBN = ill_get_ILL_String(gc, element, "ISBN"); + r->iSSN = ill_get_ILL_String(gc, element, "ISSN"); r->system_no = 0; - r->additional_no_letters = 0; - r->verification_reference_source = 0; + r->additional_no_letters = + ill_get_ILL_String(gc, element, "additional-no-letters"); + r->verification_reference_source = + ill_get_ILL_String(gc, element, "verification-reference-source"); return r; } -ILL_ItemRequest *ill_get_ItemRequest (ODR o) +ILL_ItemRequest *ill_get_ItemRequest ( + struct ill_get_ctl *gc, const char *name, const char *sub) { + ODR o = gc->odr; ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r)); - - r->protocol_version_num = ill_get_enumerated (o, ILL_Request_version_2); - - r->transaction_id = 0; - r->service_date_time = 0; - r->requester_id = 0; - r->responder_id = 0; - r->transaction_type = ill_get_Transaction_Type (o); - r->delivery_address = 0; - r->delivery_service = 0; - r->billing_address = 0; - - r->num_iLL_service_type = 1; - r->iLL_service_type = (ILL_Service_Type **) - odr_malloc (o, sizeof(*r->iLL_service_type)); - *r->iLL_service_type = - ill_get_enumerated (o, ILL_Service_Type_copy_non_returnable); - - r->responder_specific_service = 0; - r->requester_optional_messages = 0; - r->search_type = 0; - r->num_supply_medium_info_type = 0; - r->supply_medium_info_type = 0; - - r->place_on_hold = (int*) odr_malloc(o, sizeof(int)); - *r->place_on_hold = ILL_Place_On_Hold_Type_according_to_responder_policy; - - r->client_id = 0; - r->item_id = 0; - r->supplemental_item_description = 0; - r->cost_info_type = 0; - r->copyright_compliance = 0; - r->third_party_info_type = 0; - r->retry_flag = ill_get_bool (o, 0); - r->forward_flag = ill_get_bool (o, 0); - r->requester_note = 0; - r->forward_note = 0; - r->num_iLL_request_extensions = 0; - r->iLL_request_extensions = 0; - return r; + return 0; } -ILL_Request *ill_get_ILLRequest (ODR o) +ILL_Request *ill_get_ILLRequest ( + struct ill_get_ctl *gc, const char *name, const char *sub) { + ODR o = gc->odr; ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r)); - - r->protocol_version_num = ill_get_enumerated (o, ILL_Request_version_2); - - r->transaction_id = ill_get_Transaction_Id (o); - - r->service_date_time = ill_get_Service_Date_Time (o); - r->requester_id = 0; - r->responder_id = 0; - r->transaction_type = ill_get_Transaction_Type(o); - r->delivery_address = 0; - r->delivery_service = 0; - r->billing_address = 0; + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->protocol_version_num = + ill_get_enumerated (gc, element, "protocol-version-num", + ILL_Request_version_2); + + r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id"); + r->service_date_time = + ill_get_Service_Date_Time (gc, element, "service-date-time"); + r->requester_id = ill_get_System_Id (gc, element, "requester-id"); + r->responder_id = ill_get_System_Id (gc, element, "responder-id"); + r->transaction_type = + ill_get_enumerated(gc, element, "transaction-type", 1); + r->delivery_address = 0; /* TODO */ + r->delivery_service = 0; /* TODO */ + r->billing_address = 0; /* TODO */ r->num_iLL_service_type = 1; r->iLL_service_type = (ILL_Service_Type **) odr_malloc (o, sizeof(*r->iLL_service_type)); *r->iLL_service_type = - ill_get_enumerated (o, ILL_Service_Type_copy_non_returnable); + ill_get_enumerated (gc, element, "ill-service-type", + ILL_Service_Type_copy_non_returnable); r->responder_specific_service = 0; r->requester_optional_messages = - ill_get_Requester_Optional_Messages_Type (o);; - r->search_type = 0; + ill_get_Requester_Optional_Messages_Type ( + gc, element,"requester-optional-messages"); + r->search_type = 0; /* TODO */ r->num_supply_medium_info_type = 0; r->supply_medium_info_type = 0; - r->place_on_hold = (int*) odr_malloc(o, sizeof(int)); - *r->place_on_hold = ILL_Place_On_Hold_Type_according_to_responder_policy; - - r->client_id = 0; - r->item_id = ill_get_Item_Id (o); + r->place_on_hold = + ill_get_enumerated (gc, element, "place-on-hold", + ILL_Place_On_Hold_Type_according_to_responder_policy); + r->client_id = 0; /* TODO */ + r->item_id = ill_get_Item_Id (gc, element, "item-id"); r->supplemental_item_description = 0; r->cost_info_type = 0; - r->copyright_compliance = 0; + r->copyright_compliance = + ill_get_ILL_String(gc, element, "copyright-complicance"); r->third_party_info_type = 0; - r->retry_flag = ill_get_bool (o, 0); - r->forward_flag = ill_get_bool (o, 0); - r->requester_note = 0; - r->forward_note = 0; + r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0); + r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0); + r->requester_note = ill_get_ILL_String(gc, element, "requester-note"); + r->forward_note = ill_get_ILL_String(gc, element, "forward-note"); r->num_iLL_request_extensions = 0; r->iLL_request_extensions = 0; return r; diff --git a/include/yaz/ccl.h b/include/yaz/ccl.h index 2c99421..5c8909f 100644 --- a/include/yaz/ccl.h +++ b/include/yaz/ccl.h @@ -46,7 +46,12 @@ * CCL - header file * * $Log: ccl.h,v $ - * Revision 1.1 1999-11-30 13:47:11 adam + * Revision 1.2 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.1 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.9 1998/02/11 11:53:33 adam @@ -308,6 +313,10 @@ CCL_parser ccl_parser_create (void); /* Destroy CCL parser */ void ccl_parser_destroy (CCL_parser p); +#ifndef ccl_assert +#define ccl_assert(x) ; +#endif + #ifdef __cplusplus } #endif diff --git a/include/yaz/ill.h b/include/yaz/ill.h index d533fd8..6506340 100644 --- a/include/yaz/ill.h +++ b/include/yaz/ill.h @@ -3,7 +3,12 @@ * See the file LICENSE for details. * * $Log: ill.h,v $ - * Revision 1.2 2000-01-15 09:39:50 adam + * Revision 1.3 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.2 2000/01/15 09:39:50 adam * Implemented ill_get_ILLRequest. More ILL testing for client. * * Revision 1.1 1999/12/16 23:36:19 adam @@ -20,8 +25,17 @@ extern "C" { #endif -YAZ_EXPORT ILL_ItemRequest *ill_get_ItemRequest (ODR o); -YAZ_EXPORT ILL_Request *ill_get_ILLRequest (ODR o); +struct ill_get_ctl { + ODR odr; + void *clientData; + const char *(*f)(void *clientData, const char *element); +}; + +YAZ_EXPORT ILL_ItemRequest *ill_get_ItemRequest ( + struct ill_get_ctl *gs, const char *name, const char *sub); + +YAZ_EXPORT ILL_Request *ill_get_ILLRequest ( + struct ill_get_ctl *gs, const char *name, const char *sub); #ifdef __cplusplus } diff --git a/include/yaz/odr.h b/include/yaz/odr.h index 5b1019a..4751281 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995-1999, Index Data. + * Copyright (c) 1995-2000, 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, @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: odr.h,v 1.1 1999-11-30 13:47:11 adam Exp $ + * $Id: odr.h,v 1.2 2000-01-31 13:15:21 adam Exp $ */ #ifndef ODR_H @@ -123,15 +123,6 @@ typedef struct odr_constack #define ODR_S_CUR 1 #define ODR_S_END 2 -typedef struct odr_ecblock -{ - int can_grow; /* are we allowed to reallocate */ - unsigned char *buf; /* memory handle */ - int pos; /* current position */ - int top; /* top of buffer */ - int size; /* current buffer size */ -} odr_ecblock; - typedef struct { /* used to be statics in ber_tag... */ int lclass; int ltag; @@ -144,12 +135,15 @@ typedef struct odr int direction; /* the direction of this stream */ int error; /* current error state (0==OK) */ - const unsigned char *buf; /* for encoding or decoding */ - int buflen; /* size of buffer for encoding, len for decoding */ - const unsigned char *bp; /* position in buffer */ - int left; /* bytes remaining in buffer */ - odr_ecblock ecb; /* memory control block */ + int can_grow; /* are we allowed to reallocate */ + unsigned char *buf; /* memory handle */ + int size; /* current buffer size */ + + int pos; /* current position */ + int top; /* top of buffer (max pos when decoding) */ + + const unsigned char *bp; /* position in buffer (decoding) */ int t_class; /* implicit tagging (-1==default tag) */ int t_tag; @@ -255,15 +249,15 @@ YAZ_EXPORT Odr_null *odr_nullval(void); #define odr_putc(o, c) \ ( \ ( \ - (o)->ecb.pos < (o)->ecb.size ? \ + (o)->pos < (o)->size ? \ ( \ - (o)->ecb.buf[(o)->ecb.pos++] = (c), \ + (o)->buf[(o)->pos++] = (c), \ 0 \ ) : \ ( \ - odr_grow_block(&(o)->ecb, 1) == 0 ? \ + odr_grow_block((o), 1) == 0 ? \ ( \ - (o)->ecb.buf[(o)->ecb.pos++] = (c), \ + (o)->buf[(o)->pos++] = (c), \ 0 \ ) : \ ( \ @@ -273,9 +267,9 @@ YAZ_EXPORT Odr_null *odr_nullval(void); ) \ ) == 0 ? \ ( \ - (o)->ecb.pos > (o)->ecb.top ? \ + (o)->pos > (o)->top ? \ ( \ - (o)->ecb.top = (o)->ecb.pos, \ + (o)->top = (o)->pos, \ 0 \ ) : \ 0 \ @@ -283,7 +277,7 @@ YAZ_EXPORT Odr_null *odr_nullval(void); -1 \ ) \ -#define odr_tell(o) ((o)->ecb.pos) +#define odr_tell(o) ((o)->pos) #define odr_offset(o) ((o)->bp - (o)->buf) #define odr_ok(o) (!(o)->error) #define odr_getmem(o) ((o)->mem) @@ -338,7 +332,7 @@ YAZ_EXPORT void odr_begin(ODR o); YAZ_EXPORT void odr_end(ODR o); YAZ_EXPORT Odr_oid *odr_oiddup(ODR odr, Odr_oid *o); YAZ_EXPORT Odr_oid *odr_oiddup_nmem(NMEM nmem, Odr_oid *o); -YAZ_EXPORT int odr_grow_block(odr_ecblock *b, int min_bytes); +YAZ_EXPORT int odr_grow_block(ODR b, int min_bytes); YAZ_EXPORT int odr_write(ODR o, unsigned char *buf, int bytes); YAZ_EXPORT int odr_seek(ODR o, int whence, int offset); YAZ_EXPORT int odr_dumpBER(FILE *f, const char *buf, int len); diff --git a/odr/ber_any.c b/odr/ber_any.c index a669294..39ebd25 100644 --- a/odr/ber_any.c +++ b/odr/ber_any.c @@ -1,10 +1,14 @@ /* - * Copyright (c) 1995-1999, Index Data + * Copyright (c) 1995-2000, Index Data * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: ber_any.c,v $ - * Revision 1.16 1999-11-30 13:47:11 adam + * Revision 1.17 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.16 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.15 1999/01/08 11:23:20 adam @@ -60,11 +64,12 @@ int ber_any(ODR o, Odr_any **p) { int res; + int left = o->size - (o->bp - o->buf); switch (o->direction) { case ODR_DECODE: - if ((res = completeBER(o->bp, o->left)) <= 0) /* FIX THIS */ + if ((res = completeBER(o->bp, left)) <= 0) /* FIX THIS */ { o->error = OPROTO; return 0; @@ -73,7 +78,6 @@ int ber_any(ODR o, Odr_any **p) memcpy((*p)->buf, o->bp, res); (*p)->len = (*p)->size = res; o->bp += res; - o->left -= res; return 1; case ODR_ENCODE: if (odr_write(o, (*p)->buf, (*p)->len) < 0) diff --git a/odr/ber_bit.c b/odr/ber_bit.c index 3ab4ed0..7d84422 100644 --- a/odr/ber_bit.c +++ b/odr/ber_bit.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ber_bit.c,v $ - * Revision 1.10 1999-11-30 13:47:11 adam + * Revision 1.11 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.10 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.9 1999/04/20 09:56:48 adam @@ -55,7 +60,6 @@ int ber_bitstring(ODR o, Odr_bitmask *p, int cons) return 0; } o->bp += res; - o->left -= res; if (cons) /* fetch component strings */ { base = o->bp; @@ -78,12 +82,10 @@ int ber_bitstring(ODR o, Odr_bitmask *p, int cons) return 0; } o->bp++; /* silently ignore the unused-bits field */ - o->left--; len--; memcpy(p->bits + p->top + 1, o->bp, len); p->top += len; o->bp += len; - o->left -= len; return 1; case ODR_ENCODE: if ((res = ber_enclen(o, p->top + 2, 5, 0)) < 0) diff --git a/odr/ber_bool.c b/odr/ber_bool.c index cee4090..ea7990b 100644 --- a/odr/ber_bool.c +++ b/odr/ber_bool.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ber_bool.c,v $ - * Revision 1.9 1999-11-30 13:47:11 adam + * Revision 1.10 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.9 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.8 1995/09/29 17:12:16 quinn @@ -64,10 +69,8 @@ int ber_boolean(ODR o, int *val) return 0; } o->bp+= res; - o->left -= res; *val = *o->bp; o->bp++; - o->left--; #ifdef ODR_DEBUG fprintf(stderr, "[val=%d]\n", *val); #endif diff --git a/odr/ber_int.c b/odr/ber_int.c index 09ed5a4..5d5ce7c 100644 --- a/odr/ber_int.c +++ b/odr/ber_int.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ber_int.c,v $ - * Revision 1.15 1999-11-30 13:47:11 adam + * Revision 1.16 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.15 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.14 1999/05/26 07:49:35 adam @@ -74,7 +79,6 @@ int ber_integer(ODR o, int *val) return 0; } o->bp += res; - o->left -= res; return 1; case ODR_ENCODE: if ((res = ber_encinteger(o, *val)) < 0) diff --git a/odr/ber_null.c b/odr/ber_null.c index ef5871e..6b8b749 100644 --- a/odr/ber_null.c +++ b/odr/ber_null.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ber_null.c,v $ - * Revision 1.9 1999-11-30 13:47:11 adam + * Revision 1.10 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.9 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.8 1995/09/29 17:12:18 quinn @@ -56,7 +61,6 @@ int ber_null(ODR o) o->error = OPROTO; return 0; } - o->left--; #ifdef ODR_DEBUG fprintf(stderr, "[NULL]\n"); #endif diff --git a/odr/ber_oct.c b/odr/ber_oct.c index 91c0e9d..9680424 100644 --- a/odr/ber_oct.c +++ b/odr/ber_oct.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ber_oct.c,v $ - * Revision 1.14 1999-11-30 13:47:11 adam + * Revision 1.15 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.14 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.13 1999/04/20 09:56:48 adam @@ -67,7 +72,6 @@ int ber_octetstring(ODR o, Odr_oct *p, int cons) return 0; } o->bp += res; - o->left -= res; if (cons) /* fetch component strings */ { base = o->bp; @@ -93,7 +97,6 @@ int ber_octetstring(ODR o, Odr_oct *p, int cons) memcpy(p->buf + p->len, o->bp, len); p->len += len; o->bp += len; - o->left -= len; return 1; case ODR_ENCODE: if ((res = ber_enclen(o, p->len, 5, 0)) < 0) diff --git a/odr/ber_oid.c b/odr/ber_oid.c index 92208d0..3ecd59b 100644 --- a/odr/ber_oid.c +++ b/odr/ber_oid.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ber_oid.c,v $ - * Revision 1.10 1999-11-30 13:47:11 adam + * Revision 1.11 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.10 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.9 1995/09/29 17:12:19 quinn @@ -59,7 +64,6 @@ int ber_oidc(ODR o, Odr_oid *p) return 0; } o->bp += res; - o->left -= res; if (len == 0) { *p = -1; @@ -70,7 +74,6 @@ int ber_oidc(ODR o, Odr_oid *p) p[0] = 2; p[1] = *o->bp - p[0] * 40; o->bp++; - o->left--; pos = 2; len--; while (len) @@ -86,7 +89,6 @@ int ber_oidc(ODR o, Odr_oid *p) p[pos] <<= 7; p[pos] |= *o->bp & 0X7F; len--; - o->left--; } while (*(o->bp++) & 0X80); pos++; diff --git a/odr/ber_tag.c b/odr/ber_tag.c index 840ff58..0787d61 100644 --- a/odr/ber_tag.c +++ b/odr/ber_tag.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ber_tag.c,v $ - * Revision 1.20 1999-11-30 13:47:11 adam + * Revision 1.21 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.20 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.19 1999/01/08 11:23:25 adam @@ -94,7 +99,7 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt) if (o->stackp < 0) { odr_seek(o, ODR_S_SET, 0); - o->ecb.top = 0; + o->top = 0; o->bp = o->buf; odr_ber_tag->lclass = -1; } @@ -140,7 +145,6 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt) if (zclass == odr_ber_tag->lclass && tag == odr_ber_tag->ltag) { o->bp += odr_ber_tag->br; - o->left -= odr_ber_tag->br; *constructed = odr_ber_tag->lcons; odr_ber_tag->lclass = -1; return 1; diff --git a/odr/odr.c b/odr/odr.c index 520673d..787b56e 100644 --- a/odr/odr.c +++ b/odr/odr.c @@ -1,10 +1,14 @@ /* - * Copyright (c) 1995-1999, Index Data + * Copyright (c) 1995-2000, Index Data * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: odr.c,v $ - * Revision 1.31 1999-11-30 13:47:11 adam + * Revision 1.32 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.31 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.30 1999/08/27 09:40:32 adam @@ -167,10 +171,8 @@ ODR odr_createmem(int direction) r->direction = direction; r->print = stderr; r->buf = 0; - r->ecb.buf = 0; - r->ecb.size = r->ecb.pos = r->ecb.top = 0; - r->ecb.can_grow = 1; - r->buflen = 0; + r->size = r->pos = r->top = 0; + r->can_grow = 1; r->mem = nmem_create(); r->enable_bias = 1; r->odr_ber_tag.lclass = -1; @@ -184,8 +186,7 @@ void odr_reset(ODR o) o->error = ONONE; o->bp = o->buf; odr_seek(o, ODR_S_SET, 0); - o->ecb.top = 0; - o->left = o->buflen; + o->top = 0; o->t_class = -1; o->t_tag = -1; o->indent = 0; @@ -199,8 +200,8 @@ void odr_reset(ODR o) void odr_destroy(ODR o) { nmem_destroy(o->mem); - if (o->ecb.buf && o->ecb.can_grow) - xfree(o->ecb.buf); + if (o->buf && o->can_grow) + xfree(o->buf); if (o->print && o->print != stderr) fclose(o->print); xfree(o); @@ -209,19 +210,18 @@ void odr_destroy(ODR o) void odr_setbuf(ODR o, char *buf, int len, int can_grow) { - o->buf = o->bp = (unsigned char *) buf; - o->buflen = o->left = len; + o->bp = (unsigned char *) buf; - o->ecb.buf = (unsigned char *) buf; - o->ecb.can_grow = can_grow; - o->ecb.top = o->ecb.pos = 0; - o->ecb.size = len; + o->buf = (unsigned char *) buf; + o->can_grow = can_grow; + o->top = o->pos = 0; + o->size = len; } char *odr_getbuf(ODR o, int *len, int *size) { - *len = o->ecb.top; + *len = o->top; if (size) - *size = o->ecb.size; - return (char*) o->ecb.buf; + *size = o->size; + return (char*) o->buf; } diff --git a/odr/odr_cons.c b/odr/odr_cons.c index 360e831..e26a748 100644 --- a/odr/odr_cons.c +++ b/odr/odr_cons.c @@ -1,10 +1,14 @@ /* - * Copyright (c) 1995-1999, Index Data + * Copyright (c) 1995-2000, Index Data * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: odr_cons.c,v $ - * Revision 1.20 1999-11-30 13:47:11 adam + * Revision 1.21 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.20 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.19 1999/04/20 09:56:48 adam @@ -68,7 +72,6 @@ * */ -#include #include void odr_setlenlen(ODR o, int len) @@ -121,7 +124,6 @@ int odr_constructed_begin(ODR o, void *p, int zclass, int tag, return 0; o->stack[o->stackp].lenlen = res; o->bp += res; - o->left -= res; } else if (o->direction == ODR_PRINT) { @@ -170,7 +172,6 @@ int odr_constructed_end(ODR o) { if (*o->bp++ == 0 && *(o->bp++) == 0) { - o->left -= 2; o->stackp--; return 1; } @@ -215,7 +216,6 @@ int odr_constructed_end(ODR o) o->stackp--; return 1; case ODR_PRINT: - assert(o->indent > 0); o->stackp--; o->indent--; odr_prname(o, 0); diff --git a/odr/odr_mem.c b/odr/odr_mem.c index 77af041..02b78dc 100644 --- a/odr/odr_mem.c +++ b/odr/odr_mem.c @@ -1,10 +1,14 @@ /* - * Copyright (c) 1995-1998, Index Data + * Copyright (c) 1995-2000, Index Data * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: odr_mem.c,v $ - * Revision 1.16 1999-11-30 13:47:11 adam + * Revision 1.17 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.16 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.15 1999/03/31 11:18:25 adam @@ -93,7 +97,7 @@ int odr_total(ODR o) /* ---------- memory management for data encoding ----------*/ -int odr_grow_block(odr_ecblock *b, int min_bytes) +int odr_grow_block(ODR b, int min_bytes) { int togrow; @@ -105,9 +109,11 @@ int odr_grow_block(odr_ecblock *b, int min_bytes) togrow = b->size; if (togrow < min_bytes) togrow = min_bytes; - if (b->size && !(b->buf =(unsigned char *)xrealloc(b->buf, b->size += togrow))) + if (b->size && !(b->buf = + (unsigned char *) xrealloc(b->buf, b->size += togrow))) abort(); - else if (!b->size && !(b->buf = (unsigned char *)xmalloc(b->size = togrow))) + else if (!b->size && !(b->buf = (unsigned char *) + xmalloc(b->size = togrow))) abort(); #ifdef ODR_DEBUG fprintf(stderr, "New size for encode_buffer: %d\n", b->size); @@ -117,29 +123,29 @@ int odr_grow_block(odr_ecblock *b, int min_bytes) int odr_write(ODR o, unsigned char *buf, int bytes) { - if (o->ecb.pos + bytes >= o->ecb.size && odr_grow_block(&o->ecb, bytes)) + if (o->pos + bytes >= o->size && odr_grow_block(o, bytes)) { o->error = OSPACE; return -1; } - memcpy(o->ecb.buf + o->ecb.pos, buf, bytes); - o->ecb.pos += bytes; - if (o->ecb.pos > o->ecb.top) - o->ecb.top = o->ecb.pos; + memcpy(o->buf + o->pos, buf, bytes); + o->pos += bytes; + if (o->pos > o->top) + o->top = o->pos; return 0; } int odr_seek(ODR o, int whence, int offset) { if (whence == ODR_S_CUR) - offset += o->ecb.pos; + offset += o->pos; else if (whence == ODR_S_END) - offset += o->ecb.top; - if (offset > o->ecb.size && odr_grow_block(&o->ecb, offset - o->ecb.size)) + offset += o->top; + if (offset > o->size && odr_grow_block(o, offset - o->size)) { o->error = OSPACE; return -1; } - o->ecb.pos = offset; + o->pos = offset; return 0; } diff --git a/odr/odr_seq.c b/odr/odr_seq.c index 1373e19..17e9af2 100644 --- a/odr/odr_seq.c +++ b/odr/odr_seq.c @@ -1,10 +1,15 @@ /* - * Copyright (c) 1995-1999, Index Data + * Copyright (c) 1995-2000, Index Data * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: odr_seq.c,v $ - * Revision 1.25 1999-11-30 13:47:11 adam + * Revision 1.26 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.25 1999/11/30 13:47:11 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.24 1999/04/20 09:56:48 adam @@ -84,7 +89,6 @@ * */ -#include #include int odr_sequence_begin(ODR o, void *p, int size, const char *name) diff --git a/odr/odr_util.c b/odr/odr_util.c index dc280d7..427c16a 100644 --- a/odr/odr_util.c +++ b/odr/odr_util.c @@ -1,10 +1,14 @@ /* - * Copyright (c) 1995-1999, Index Data + * Copyright (c) 1995-2000, Index Data * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: odr_util.c,v $ - * Revision 1.17 1999-11-30 13:47:12 adam + * Revision 1.18 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.17 1999/11/30 13:47:12 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.16 1999/04/20 09:56:48 adam @@ -50,7 +54,6 @@ int odp_more_chunks(ODR o, const unsigned char *base, int len) if (*o->bp == 0 && *(o->bp + 1) == 0) { o->bp += 2; - o->left -= 2; return 0; } else diff --git a/ztest/ztest.c b/ztest/ztest.c index a2164d7..2e36956 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -6,7 +6,12 @@ * Chas Woodfield, Fretwell Downing Datasystems. * * $Log: ztest.c,v $ - * Revision 1.30 2000-01-13 23:05:50 adam + * Revision 1.31 2000-01-31 13:15:21 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.30 2000/01/13 23:05:50 adam * Fixed tagging for member requester-CHECKED-IN in ILL ASN.1 spec. * * Revision 1.29 2000/01/12 14:36:07 adam @@ -106,7 +111,6 @@ #include #include #include -#include #include #include @@ -438,7 +442,6 @@ static char *dummy_database_record (int num, ODR odr) if (num == 98) { buf = (char*) odr_malloc(odr, 2101); - assert(buf); memset(buf, 'A', 2100); buf[2100] = '\0'; break; diff --git a/zutil/logrpn.c b/zutil/logrpn.c index b64dd4c..b56e6a8 100644 --- a/zutil/logrpn.c +++ b/zutil/logrpn.c @@ -1,10 +1,15 @@ /* - * Copyright (C) 1995-1999, Index Data + * Copyright (C) 1995-2000, Index Data * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: logrpn.c,v $ - * Revision 1.3 1999-11-30 13:47:12 adam + * Revision 1.4 2000-01-31 13:15:22 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.3 1999/11/30 13:47:12 adam * Improved installation. Moved header files to include/yaz. * * Revision 1.2 1999/08/27 09:40:33 adam @@ -52,7 +57,6 @@ * */ #include -#include #include #include diff --git a/zutil/yaz-ccl.c b/zutil/yaz-ccl.c index 2740396..6b80f72 100644 --- a/zutil/yaz-ccl.c +++ b/zutil/yaz-ccl.c @@ -1,10 +1,15 @@ /* - * Copyright (c) 1996-1999, Index Data. + * Copyright (c) 1996-2000, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-ccl.c,v $ - * Revision 1.4 1999-12-20 15:20:13 adam + * Revision 1.5 2000-01-31 13:15:22 adam + * Removed uses of assert(3). Cleanup of ODR. CCL parser update so + * that some characters are not surrounded by spaces in resulting term. + * ILL-code updates. + * + * Revision 1.4 1999/12/20 15:20:13 adam * Implemented ccl_pquery to convert from CCL tree to prefix query. * * Revision 1.3 1999/11/30 13:47:12 adam @@ -40,7 +45,6 @@ #include #include #include -#include #include @@ -56,13 +60,10 @@ static Z_AttributesPlusTerm *ccl_rpn_term (ODR o, struct ccl_rpn_node *p) Z_AttributeElement **elements; zapt = (Z_AttributesPlusTerm *)odr_malloc (o, sizeof(*zapt)); - assert (zapt); term_octet = (Odr_oct *)odr_malloc (o, sizeof(*term_octet)); - assert (term_octet); term = (Z_Term *)odr_malloc (o, sizeof(*term)); - assert(term); for (attr = p->u.t.attr_list; attr; attr = attr->next) num++; @@ -77,7 +78,6 @@ static Z_AttributesPlusTerm *ccl_rpn_term (ODR o, struct ccl_rpn_node *p) { elements[i] = (Z_AttributeElement *) odr_malloc (o, sizeof(**elements)); - assert (elements[i]); elements[i]->attributeType = (int *)odr_malloc(o, sizeof(int)); *elements[i]->attributeType = attr->type; @@ -111,7 +111,6 @@ static Z_Operand *ccl_rpn_simple (ODR o, struct ccl_rpn_node *p) Z_Operand *zo; zo = (Z_Operand *)odr_malloc (o, sizeof(*zo)); - assert (zo); switch (p->kind) { @@ -124,7 +123,7 @@ static Z_Operand *ccl_rpn_simple (ODR o, struct ccl_rpn_node *p) zo->u.resultSetId = p->u.setname; break; default: - assert (0); + return 0; } return zo; } @@ -135,9 +134,7 @@ static Z_Complex *ccl_rpn_complex (ODR o, struct ccl_rpn_node *p) Z_Operator *zo; zc = (Z_Complex *)odr_malloc (o, sizeof(*zc)); - assert (zc); zo = (Z_Operator *)odr_malloc (o, sizeof(*zo)); - assert (zo); zc->roperator = zo; switch (p->kind) @@ -185,7 +182,7 @@ static Z_Complex *ccl_rpn_complex (ODR o, struct ccl_rpn_node *p) #endif break; default: - assert (0); + return 0; } zc->s1 = ccl_rpn_structure (o, p->u.p[0]); zc->s2 = ccl_rpn_structure (o, p->u.p[1]); @@ -197,7 +194,6 @@ static Z_RPNStructure *ccl_rpn_structure (ODR o, struct ccl_rpn_node *p) Z_RPNStructure *zs; zs = (Z_RPNStructure *)odr_malloc (o, sizeof(*zs)); - assert (zs); switch (p->kind) { case CCL_RPN_AND: @@ -213,7 +209,7 @@ static Z_RPNStructure *ccl_rpn_structure (ODR o, struct ccl_rpn_node *p) zs->u.simple = ccl_rpn_simple (o, p); break; default: - assert (0); + return 0; } return zs; } @@ -223,7 +219,6 @@ Z_RPNQuery *ccl_rpn_query (ODR o, struct ccl_rpn_node *p) Z_RPNQuery *zq; zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq)); - assert (zq); zq->attributeSetId = NULL; zq->RPNStructure = ccl_rpn_structure (o, p); return zq; @@ -253,7 +248,7 @@ static void ccl_pquery_complex (WRBUF w, struct ccl_rpn_node *p) wrbuf_puts(w, "@prox 0 2 0 1 known 2 "); break; default: - assert(0); + wrbuf_puts(w, "@ bad op (unknown) "); }; ccl_pquery(w, p->u.p[0]); ccl_pquery(w, p->u.p[1]); @@ -288,6 +283,5 @@ void ccl_pquery (WRBUF w, struct ccl_rpn_node *p) wrbuf_puts (w, "} "); break; default: - assert (0); - }; + } } -- 1.7.10.4