ZOOM C refactor. Make helper ZOOM_send_GDU
[yaz-moved-to-github.git] / src / zoom-c.c
index 37c866c..2b6b80f 100644 (file)
@@ -329,14 +329,7 @@ char **ZOOM_connection_get_databases(ZOOM_connection con, ZOOM_options options,
     const char *cp = ZOOM_options_get(options, "databaseName");
 
     if ((!cp || !*cp) && con->host_port)
-    {
-        if (strncmp(con->host_port, "unix:", 5) == 0)
-            cp = strchr(con->host_port+5, ':');
-        else
-            cp = strchr(con->host_port, '/');
-        if (cp)
-            cp++;
-    }
+        cs_get_host_args(con->host_port, &cp);
     if (!cp || !*cp)
         cp = "Default";
     nmem_strsplit(odr_getmem(odr), "+", cp,  &databaseNames, num);
@@ -1556,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);
 }