X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=client%2Fclient.c;h=1c5523b996be2f575cc9839a6a3ffc2962ec5bbe;hp=e6dd25a8d37c7e1134cd1006a5abca55376894a0;hb=612ac7d30003582e44d4184c830eee7f1a1a0443;hpb=69b1d8e7b437179163fe97b7cbead51a56835f2a diff --git a/client/client.c b/client/client.c index e6dd25a..1c5523b 100644 --- a/client/client.c +++ b/client/client.c @@ -318,17 +318,9 @@ static void print_refid(Z_ReferenceId *id) static Z_ReferenceId *set_refid(ODR out) { - Z_ReferenceId *id; if (!refid) return 0; - id = (Z_ReferenceId *) odr_malloc(out, sizeof(*id)); - id->len = strlen(refid); -#if OCT_SIZE - id->size = id->len; -#endif - id->buf = (char *) odr_malloc(out, id->len); - memcpy(id->buf, refid, id->len); - return id; + return odr_create_Odr_oct(out, refid, strlen(refid)); } /* INIT SERVICE ------------------------------- */ @@ -1569,9 +1561,6 @@ static int send_Z3950_searchRequest(const char *arg) /* send a very big referenceid to test transport stack etc. */ memset(big, 'A', 2100); bigo.len = 2100; -#if OCT_SIZE - bigo.size = bigo.len; -#endif bigo.buf = big; req->referenceId = &bigo; } @@ -2135,18 +2124,8 @@ static Z_External *create_external_itemRequest(void) r->indirect_reference = 0; r->descriptor = 0; r->which = Z_External_single; - - r->u.single_ASN1_type = (Odr_oct *) - odr_malloc(out, sizeof(*r->u.single_ASN1_type)); - r->u.single_ASN1_type->buf = (char *) - odr_malloc(out, item_request_size); - r->u.single_ASN1_type->len = item_request_size; -#if OCT_SIZE - r->u.single_ASN1_type->size = item_request_size; -#endif - memcpy(r->u.single_ASN1_type->buf, item_request_buf, - item_request_size); - + r->u.single_ASN1_type = + odr_create_Odr_oct(out, item_request_buf, item_request_size); do_hex_dump(item_request_buf,item_request_size); } return r; @@ -2190,20 +2169,8 @@ static Z_External *create_external_ILL_APDU(void) r->indirect_reference = 0; r->descriptor = 0; r->which = Z_External_single; - - r->u.single_ASN1_type = (Odr_oct *) - odr_malloc(out, sizeof(*r->u.single_ASN1_type)); - r->u.single_ASN1_type->buf = (char *) - odr_malloc(out, ill_request_size); - r->u.single_ASN1_type->len = ill_request_size; -#if OCT_SIZE - r->u.single_ASN1_type->size = ill_request_size; -#endif - memcpy(r->u.single_ASN1_type->buf, ill_request_buf, ill_request_size); -/* printf("len = %d\n", ill_request_size); */ -/* do_hex_dump(ill_request_buf,ill_request_size); */ -/* printf("--- end of extenal\n"); */ - + r->u.single_ASN1_type = odr_create_Odr_oct(out, ill_request_buf, + ill_request_size); } return r; } @@ -2492,18 +2459,8 @@ static int send_Z3950_update(int version, int action_no, const char *recid, notToKeep->elements[0] = (Z_IU0SuppliedRecords_elem *) odr_malloc(out, sizeof(**notToKeep->elements)); notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque; - if (recid) - { - notToKeep->elements[0]->u.opaque = (Odr_oct *) - odr_malloc(out, sizeof(Odr_oct)); - notToKeep->elements[0]->u.opaque->buf = (char *) recid; -#if OCT_SIZE - notToKeep->elements[0]->u.opaque->size = strlen(recid); -#endif - notToKeep->elements[0]->u.opaque->len = strlen(recid); - } - else - notToKeep->elements[0]->u.opaque = 0; + notToKeep->elements[0]->u.opaque = recid ? + odr_create_Odr_oct(out, recid, strlen(recid)) : 0; notToKeep->elements[0]->supplementalId = 0; notToKeep->elements[0]->correlationInfo = 0; notToKeep->elements[0]->record = record_this; @@ -2541,18 +2498,8 @@ static int send_Z3950_update(int version, int action_no, const char *recid, notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *) odr_malloc(out, sizeof(**notToKeep->elements)); notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque; - if (recid) - { - notToKeep->elements[0]->u.opaque = (Odr_oct *) - odr_malloc(out, sizeof(Odr_oct)); - notToKeep->elements[0]->u.opaque->buf = (char *) recid; -#if OCT_SIZE - notToKeep->elements[0]->u.opaque->size = strlen(recid); -#endif - notToKeep->elements[0]->u.opaque->len = strlen(recid); - } - else - notToKeep->elements[0]->u.opaque = 0; + notToKeep->elements[0]->u.opaque = recid ? + odr_create_Odr_oct(out, recid, strlen(recid)) : 0; notToKeep->elements[0]->supplementalId = 0; notToKeep->elements[0]->correlationInfo = 0; notToKeep->elements[0]->record = record_this; @@ -3403,9 +3350,6 @@ static int send_Z3950_scanrequest(const char *set, const char *query, req->termListAndStartPoint->term->u.general->buf = odr_strdup(out, term); req->termListAndStartPoint->term->u.general->len = strlen(term); -#if OCT_SIZE - req->termListAndStartPoint->term->u.general->size = strlen(term); -#endif } } req->referenceId = set_refid(out);