Removed retired code; eliminated some dead yaz_marc stuff
authorSebastian Hammer <quinn@indexdata.com>
Tue, 22 Jul 2008 10:25:12 +0000 (10:25 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Tue, 22 Jul 2008 10:25:12 +0000 (10:25 +0000)
m4
src/client.c
src/logic.c
src/pazpar2.h

diff --git a/m4 b/m4
index b076b76..a3d7a33 160000 (submodule)
--- a/m4
+++ b/m4
@@ -1 +1 @@
-Subproject commit b076b768162950579fb9831b1f8dd8be5fdc3154
+Subproject commit a3d7a3375702caae9794ae3a724e51ae9ee46ac3
index 26d1f51..98a2916 100644 (file)
@@ -259,15 +259,6 @@ static void client_show_raw_error(struct client *cl, const char *addinfo)
     }
 }
 
-static void client_show_raw_cancel(struct client *cl)
-{
-    while (cl->show_raw)
-    {
-        cl->show_raw->error_handler(cl->show_raw->data, "cancel");
-        client_show_raw_dequeue(cl);
-    }
-}
-
 static void client_send_raw_present(struct client *cl)
 {
     struct session_database *sdb = client_get_database(cl);
@@ -345,70 +336,6 @@ static void ingest_raw_record(struct client *cl, ZOOM_record rec)
     client_show_raw_dequeue(cl);
 }
 
-#ifdef RETIRED
-
-static void ingest_raw_records(struct client *cl, Z_Records *r)
-{
-    Z_NamePlusRecordList *rlist;
-    Z_NamePlusRecord *npr;
-    xmlDoc *doc;
-    xmlChar *buf_out;
-    int len_out;
-    if (r->which != Z_Records_DBOSD)
-    {
-        client_show_raw_error(cl, "non-surrogate diagnostics");
-        return;
-    }
-
-    rlist = r->u.databaseOrSurDiagnostics;
-    if (rlist->num_records != 1 || !rlist->records || !rlist->records[0])
-    {
-        client_show_raw_error(cl, "no records");
-        return;
-    }
-    npr = rlist->records[0];
-    if (npr->which != Z_NamePlusRecord_databaseRecord)
-    {
-        client_show_raw_error(cl, "surrogate diagnostic");
-        return;
-    }
-
-    if (cl->show_raw && cl->show_raw->binary)
-    {
-        Z_External *rec = npr->u.databaseRecord;
-        if (rec->which == Z_External_octet)
-        {
-            cl->show_raw->record_handler(cl->show_raw->data,
-                                         (const char *)
-                                         rec->u.octet_aligned->buf,
-                                         rec->u.octet_aligned->len);
-            client_show_raw_dequeue(cl);
-        }
-        else
-            client_show_raw_error(cl, "no records");
-    }
-
-    doc = record_to_xml(client_get_database(cl), npr->u.databaseRecord);
-    if (!doc)
-    {
-        client_show_raw_error(cl, "unable to convert record to xml");
-        return;
-    }
-
-    xmlDocDumpMemory(doc, &buf_out, &len_out);
-    xmlFreeDoc(doc);
-
-    if (cl->show_raw)
-    {
-        cl->show_raw->record_handler(cl->show_raw->data,
-                                     (const char *) buf_out, len_out);
-        client_show_raw_dequeue(cl);
-    }
-    xmlFree(buf_out);
-}
-
-#endif // RETIRED show raw
-
 void client_search_response(struct client *cl)
 {
     struct connection *co = cl->connection;
@@ -500,96 +427,6 @@ void client_record_response(struct client *cl)
     }
 }
 
-#ifdef RETIRED
-
-void client_present_response(struct client *cl, Z_APDU *a)
-{
-    Z_PresentResponse *r = a->u.presentResponse;
-    Z_Records *recs = r->records;
-        
-    if (recs && recs->which == Z_Records_NSD)
-    {
-        WRBUF w = wrbuf_alloc();
-        
-        Z_DiagRec dr, *dr_p = &dr;
-        dr.which = Z_DiagRec_defaultFormat;
-        dr.u.defaultFormat = recs->u.nonSurrogateDiagnostic;
-        
-        wrbuf_printf(w, "Present response NSD %s: ",
-                     cl->database->database->url);
-        
-        cl->diagnostic = diag_to_wrbuf(&dr_p, 1, w);
-        
-        yaz_log(YLOG_WARN, "%s", wrbuf_cstr(w));
-        
-        cl->state = Client_Error;
-        wrbuf_destroy(w);
-
-        client_show_raw_error(cl, "non surrogate diagnostics");
-    }
-    else if (recs && recs->which == Z_Records_multipleNSD)
-    {
-        WRBUF w = wrbuf_alloc();
-        
-        wrbuf_printf(w, "Present response multipleNSD %s: ",
-                     cl->database->database->url);
-        cl->diagnostic = 
-            diag_to_wrbuf(recs->u.multipleNonSurDiagnostics->diagRecs,
-                          recs->u.multipleNonSurDiagnostics->num_diagRecs,
-                          w);
-        yaz_log(YLOG_WARN, "%s", wrbuf_cstr(w));
-        cl->state = Client_Error;
-        wrbuf_destroy(w);
-    }
-    else if (recs && !*r->presentStatus && cl->state != Client_Error)
-    {
-        yaz_log(YLOG_DEBUG, "Good Present response %s",
-                cl->database->database->url);
-
-        // we can mix show raw and normal show ..
-        if (cl->show_raw && cl->show_raw->active)
-        {
-            cl->show_raw->active = 0; // no longer active
-            ingest_raw_records(cl, recs);
-        }
-        else
-            ingest_records(cl, recs);
-        cl->state = Client_Continue;
-    }
-    else if (*r->presentStatus) 
-    {
-        yaz_log(YLOG_WARN, "Bad Present response %s",
-                cl->database->database->url);
-        cl->state = Client_Error;
-        client_show_raw_error(cl, "bad present response");
-    }
-}
-
-void client_close_response(struct client *cl, Z_APDU *a)
-{
-    struct connection *co = cl->connection;
-    /* Z_Close *r = a->u.close; */
-
-    yaz_log(YLOG_WARN, "Close response %s", cl->database->database->url);
-
-    cl->state = Client_Failed;
-    connection_destroy(co);
-}
-
-#endif // RETIRED show raw
-
-#ifdef RETIRED
-int client_is_our_response(struct client *cl)
-{
-    struct session *se = client_get_session(cl);
-
-    if (cl && (cl->requestid == se->requestid || 
-               cl->state == Client_Initializing))
-        return 1;
-    return 0;
-}
-#endif
-
 void client_start_search(struct client *cl)
 {
     struct session_database *sdb = client_get_database(cl);
index c268a01..70b3879 100644 (file)
@@ -318,44 +318,6 @@ const char *session_setting_oneval(struct session_database *db, int offset)
     return db->settings[offset]->value;
 }
 
-
-
-// Initialize YAZ Map structures for MARC-based targets
-static int prepare_yazmarc(struct session_database *sdb)
-{
-    const char *s;
-
-    if (!sdb->settings)
-    {
-        yaz_log(YLOG_WARN, "No settings for %s", sdb->database->url);
-        return -1;
-    }
-    if ((s = session_setting_oneval(sdb, PZ_NATIVESYNTAX)) 
-        && !strncmp(s, "iso2709", 7))
-    {
-        char *encoding = "marc-8s", *e;
-        yaz_iconv_t cm;
-
-        // See if a native encoding is specified
-        if ((e = strchr(s, ';')))
-            encoding = e + 1;
-
-        sdb->yaz_marc = yaz_marc_create();
-        yaz_marc_subfield_str(sdb->yaz_marc, "\t");
-        
-        cm = yaz_iconv_open("utf-8", encoding);
-        if (!cm)
-        {
-            yaz_log(YLOG_FATAL, 
-                    "Unable to map from %s to UTF-8 for target %s", 
-                    encoding, sdb->database->url);
-            return -1;
-        }
-        yaz_marc_iconv(sdb->yaz_marc, cm);
-    }
-    return 0;
-}
-
 // Prepare XSLT stylesheets for record normalization
 // Structures are allocated on the session_wide nmem to avoid having
 // to recompute this for every search. This would lead
@@ -430,11 +392,6 @@ static int prepare_session_database(struct session *se,
                 "No settings associated with %s", sdb->database->url);
         return -1;
     }
-    if (sdb->settings[PZ_NATIVESYNTAX] && !sdb->yaz_marc)
-    {
-        if (prepare_yazmarc(sdb) < 0)
-            return -1;
-    }
     if (sdb->settings[PZ_XSLT] && !sdb->map)
     {
         if (prepare_map(se, sdb) < 0)
@@ -629,7 +586,6 @@ static void session_init_databases_fun(void *context, struct database *db)
     int i;
 
     new->database = db;
-    new->yaz_marc = 0;
     
     new->map = 0;
     new->settings 
@@ -652,8 +608,6 @@ static void session_database_destroy(struct session_database *sdb)
 
     for (m = sdb->map; m; m = m->next)
         xsltFreeStylesheet(m->stylesheet);
-    if (sdb->yaz_marc)
-        yaz_marc_destroy(sdb->yaz_marc);
 }
 
 // Initialize session_database list -- this represents this session's view
@@ -718,13 +672,6 @@ void session_apply_setting(struct session *se, char *dbname, char *setting,
     // (happens when a search starts and client connections are prepared)
     switch (offset)
     {
-    case PZ_NATIVESYNTAX:
-        if (sdb->yaz_marc)
-        {
-            yaz_marc_destroy(sdb->yaz_marc);
-            sdb->yaz_marc = 0;
-        }
-        break;
     case PZ_XSLT:
         if (sdb->map)
         {
index c4989d0..728bc3d 100644 (file)
@@ -94,7 +94,9 @@ struct session_database
 {
     struct database *database;
     struct setting **settings;
+#ifdef RETIRED
     yaz_marc_t yaz_marc;
+#endif
     struct database_retrievalmap *map;
     struct session_database *next;
 };