From: Adam Dickmeiss Date: Wed, 21 Nov 2012 13:57:28 +0000 (+0100) Subject: ZOOM C refactor. Make helper ZOOM_send_GDU X-Git-Tag: v4.2.47~6 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=79f02618682f616509d80665126918a07d1f9e80;p=yaz-moved-to-github.git ZOOM C refactor. Make helper ZOOM_send_GDU --- diff --git a/src/zoom-c.c b/src/zoom-c.c index 2445215..2b6b80f 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -1549,15 +1549,26 @@ static zoom_ret send_HTTP_redirect(ZOOM_connection c, const char *uri, z_HTTP_header_add_basic_auth(c->odr_out, &gdu->u.HTTP_Request->headers, c->user, c->password); } - if (!z_GDU(c->odr_out, &gdu, 0, 0)) + return ZOOM_send_GDU(c, gdu); +} + +zoom_ret ZOOM_send_GDU(ZOOM_connection c, Z_GDU *gdu) +{ + ZOOM_Event event; + + int r = z_GDU(c->odr_out, &gdu, 0, 0); + if (!r) return zoom_complete; if (c->odr_print) z_GDU(c->odr_print, &gdu, 0, 0); if (c->odr_save) z_GDU(c->odr_save, &gdu, 0, 0); c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0); - odr_reset(c->odr_out); + + event = ZOOM_Event_create(ZOOM_EVENT_SEND_APDU); + ZOOM_connection_put_event(c, event); + return ZOOM_send_buf(c); } diff --git a/src/zoom-p.h b/src/zoom-p.h index be1107e..9113242 100644 --- a/src/zoom-p.h +++ b/src/zoom-p.h @@ -283,6 +283,7 @@ void ZOOM_set_HTTP_error(ZOOM_connection c, int error, ZOOM_Event ZOOM_connection_get_event(ZOOM_connection c); void ZOOM_connection_remove_events(ZOOM_connection c); void ZOOM_Event_destroy(ZOOM_Event event); +zoom_ret ZOOM_send_GDU(ZOOM_connection c, Z_GDU *gdu); /* * Local variables: diff --git a/src/zoom-sru.c b/src/zoom-sru.c index 687ca83..836f69e 100644 --- a/src/zoom-sru.c +++ b/src/zoom-sru.c @@ -34,7 +34,6 @@ static void set_SRU_error(ZOOM_connection c, Z_SRW_diagnostic *d) static zoom_ret send_srw(ZOOM_connection c, Z_SRW_PDU *sr) { Z_GDU *gdu; - ZOOM_Event event; const char *database = ZOOM_options_get(c->options, "databaseName"); gdu = z_get_HTTP_Request_uri(c->odr_out, c->host_port, @@ -57,18 +56,7 @@ static zoom_ret send_srw(ZOOM_connection c, Z_SRW_PDU *sr) { yaz_solr_encode_request(gdu->u.HTTP_Request, sr, c->odr_out, c->charset); } - if (!z_GDU(c->odr_out, &gdu, 0, 0)) - return zoom_complete; - if (c->odr_print) - z_GDU(c->odr_print, &gdu, 0, 0); - if (c->odr_save) - z_GDU(c->odr_save, &gdu, 0, 0); - c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0); - - event = ZOOM_Event_create(ZOOM_EVENT_SEND_APDU); - ZOOM_connection_put_event(c, event); - odr_reset(c->odr_out); - return ZOOM_send_buf(c); + return ZOOM_send_GDU(c, gdu); } #endif diff --git a/src/zoom-z3950.c b/src/zoom-z3950.c index 27a4d4e..b916115 100644 --- a/src/zoom-z3950.c +++ b/src/zoom-z3950.c @@ -959,7 +959,6 @@ ZOOM_API(void) } } - static void handle_Z3950_records(ZOOM_connection c, Z_Records *sr, int present_phase);