X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fsrw.c;h=e926af44be4262d1f7acda6aba336222d793a621;hp=759e06e114843b57831902501ef119e910b0edbd;hb=2cb1374ad9b888dcb3462ec15b977fbb3a97c7cf;hpb=0d191bf4a0a8f0196e0ba1c42f0070255c04c1b4 diff --git a/src/srw.c b/src/srw.c index 759e06e..e926af4 100644 --- a/src/srw.c +++ b/src/srw.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: srw.c,v 1.37 2005-11-08 15:08:02 adam Exp $ + * $Id: srw.c,v 1.42 2006-01-20 10:34:52 adam Exp $ */ /** * \file srw.c @@ -234,7 +234,7 @@ static int yaz_srw_record(ODR o, xmlNodePtr pptr, Z_SRW_record *rec, char *spack = 0; int pack = Z_SRW_recordPacking_string; xmlNodePtr ptr; - xmlNodePtr data_ptr; + xmlNodePtr data_ptr = 0; rec->recordSchema = 0; rec->recordData_buf = 0; rec->recordData_len = 0; @@ -244,8 +244,8 @@ static int yaz_srw_record(ODR o, xmlNodePtr pptr, Z_SRW_record *rec, { if (match_xsd_string(ptr, "recordSchema", o, - &rec->recordSchema)){ - } + &rec->recordSchema)) + ; else if (match_xsd_string(ptr, "recordPacking", o, &spack)) { if (spack && !strcmp(spack, "xml")) @@ -258,39 +258,40 @@ static int yaz_srw_record(ODR o, xmlNodePtr pptr, Z_SRW_record *rec, else if (match_xsd_integer(ptr, "recordPosition", o, &rec->recordPosition)) ; - else if (match_element(ptr, "recordData")){ + else if (match_element(ptr, "recordData")) + { /* save position of Data until after the loop then we will know the packing (hopefully), and unpacking is done once */ data_ptr = ptr; } - else if (match_element(ptr, "extraRecordData")){ + else if (match_element(ptr, "extraRecordData")) + { *extra = (Z_SRW_extra_record *) odr_malloc(o, sizeof(Z_SRW_extra_record)); yaz_srw_extra_record(o, ptr, *extra, client_data, ns); } } - switch(pack) + if (data_ptr) { - case Z_SRW_recordPacking_XML: - match_xsd_XML_n(data_ptr, "recordData", o, - &rec->recordData_buf, &rec->recordData_len); - break; - case Z_SRW_recordPacking_URL: - /* just store it as a string. - leave it to the backend to collect the document */ - match_xsd_string_n(ptr, "recordData", o, - &rec->recordData_buf, &rec->recordData_len); - break; - case Z_SRW_recordPacking_string: - match_xsd_string_n(ptr, "recordData", o, - &rec->recordData_buf, &rec->recordData_len); - break; - default: - rec->recordData_buf = 0; - rec->recordData_len = 0; - /* need some way to signal diagnostic here */ + switch(pack) + { + case Z_SRW_recordPacking_XML: + match_xsd_XML_n(data_ptr, "recordData", o, + &rec->recordData_buf, &rec->recordData_len); + break; + case Z_SRW_recordPacking_URL: + /* just store it as a string. + leave it to the backend to collect the document */ + match_xsd_string_n(data_ptr, "recordData", o, + &rec->recordData_buf, &rec->recordData_len); + break; + case Z_SRW_recordPacking_string: + match_xsd_string_n(data_ptr, "recordData", o, + &rec->recordData_buf, &rec->recordData_len); + break; + } } rec->recordPacking = pack; } @@ -320,7 +321,7 @@ static int yaz_srw_record(ODR o, xmlNodePtr pptr, Z_SRW_record *rec, } if (rec->recordPosition) add_xsd_integer(ptr, "recordPosition", rec->recordPosition ); - if (*extra) + if (extra && *extra) { xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "extraRecordData", 0); @@ -366,7 +367,8 @@ static int yaz_srw_records(ODR o, xmlNodePtr pptr, Z_SRW_record **recs, { xmlNodePtr rptr = xmlNewChild(pptr, 0, BAD_CAST "record", 0); - yaz_srw_record(o, rptr, (*recs)+i, *extra + i, client_data, ns); + yaz_srw_record(o, rptr, (*recs)+i, (*extra ? *extra + i : 0), + client_data, ns); } } return 0; @@ -972,6 +974,7 @@ int yaz_ucp_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, { xmlNodePtr ptr = method->children; Z_SRW_updateRequest *req; + char *oper = 0; (*p)->which = Z_SRW_update_request; req = (*p)->u.update_request = (Z_SRW_updateRequest *) @@ -989,8 +992,6 @@ int yaz_ucp_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, req->extraRequestData = 0; req->stylesheet = 0; - char *oper = 0; - for (; ptr; ptr = ptr->next) { if (match_xsd_string(ptr, "version", o, @@ -1100,7 +1101,8 @@ int yaz_ucp_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, else if ((*p)->which == Z_SRW_update_response) { Z_SRW_updateResponse *res = (*p)->u.update_response; - xmlNodePtr ptr = xmlNewChild(pptr, 0, "updateResponse", 0); + xmlNodePtr ptr = xmlNewChild(pptr, 0, (xmlChar *) + "updateResponse", 0); ns_srw = xmlNewNs(ptr, ns, "zu"); xmlSetNs(ptr, ns_srw);