Work on WAIS part of gateway.
[egate.git] / www / z39util.tcl
index aa53782..d78e5d6 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: z39util.tcl,v 1.34 1996/02/29 15:41:40 adam Exp $
+# $Id: z39util.tcl,v 1.35 1996/03/05 18:50:26 adam Exp $
 #
 proc saveState {} {
     uplevel #0 {
@@ -305,79 +305,64 @@ proc dl-marc-field-rec {zset no tag lead start stop startid sep} {
 }
 
 proc display-full-wais {zset no} {
-    set i0 0
-    set i1 0
-    set refNo 0
-    set body [$zset getWAIS $no text]
-
-    while {[string length [set c [string index $body $i1]]]} {
-        if {[string compare $c \n]} {
-            incr i1
-            continue
-        }
-        set l [string trim [string range $body $i0 $i1]]
-        egw_log debug "line=$l"
-        incr i1
-        set i0 $i1
+    set i 0    
+    set element junk
+    htmlToken l [join [$zset getWAIS $no text]] {
         if {[string compare [string index $l 0] {<}]} {
-            egw_log "xxxxxxxxxxxxxxxx"
+            set data($element) $l
             continue
         }
-        if {[set mark [string first > $l ]] < 1} {
-            egw_log "yyyyyyyyyyyyyyyy"
-            continue
-        }
-        set data [string trim [string range $l [expr $mark +1] end]]
-        incr mark -1
-        set sw [string range $l 1 $mark]
-        egw_log debug "sw=$sw"
-        egw_log debug "data=$data"
-        switch -exact $sw {
-            ti {
-                set title $data
+        switch -exact $l {
+            <ti> {
+                set element title 
+            }
+            <dm> {
+                set element dateOfLastModification
             }
-            dm {
-                set dateOfLastModification $data
+            <ci> {
+                set element controlIdentifier
             }
-            ci {
-                set controlIdentifier $data
+            <lc> {
+                set element lastChecked
             }
-            lc {
-                set lastChecked $data
+            <by> {
+                set element bytes
             }
-            by {
-                set bytes $data
+            <avli> {
+                set element linkage
             }
-            avli {
-                set linkage $data
+            <cr> {
+                incr i
             }
-            cr {
-                incr refNo
+            <li> {
+                set element "$i,linkage"
             }
-            li {
-                set crossRef($refNo,linkage) $data
+            <cp> {
+                set element "$i,title"
             }
-            cp {
-                set crossRef($refNo,title) $data
+            default {
+                set element junk
             }
         }
     }
-    html {Title: } {<a href="} $linkage {">} $title "</a><br>\n"
-    html {URL: } $linkage "<br>\n"
-    if {[info exists bytes]} {
-        html {Bytes: } $bytes "<br>\n"
+    html {Title: } {<a href="} $data(linkage) {">} $data(title) "</a><br>\n"
+    html {URL: } $data(linkage) "<br>\n"
+    html {Score: } [$zset getWAIS $no score] "<br>\n"
+    html {Lines: } [$zset getWAIS $no lines] "<br>\n"
+    if {[info exists data(bytes)]} {
+        html {Bytes: } $data(bytes) "<br>\n"
     }
-    if {[info exists dateOfLastModification]} {
-        html {Last modified: } $dateOfLastModification "<br>\n"
+    if {[info exists data(dateOfLastModification)]} {
+        html {Last modified: } $data(dateOfLastModification) "<br>\n"
     }
-    if {[info exists lastChecked]} {
-        html {Last checked: } $lastChecked "<br>\n"
+    if {[info exists data(lastChecked)]} {
+        html {Last checked: } $data(lastChecked) "<br>\n"
     }
     html "<ul>\n"
-    for {set i 1} {$i <= $refNo} {incr i} {
-        html {<li><a href="} $crossRef($i,linkage) {">}
-        html $crossRef($i,title) "</a><br>\n"
-        html "URL: " $crossRef($i,linkage)
+    for {set i 1} {[info exists data($i,linkage)]} {incr i} {
+        html {<li><a href="} $data($i,linkage) {">}
+        html $data($i,title) "</a><br>\n"
+        html "URL: " $data($i,linkage)
     }
     html "</ul>\n"
 }
@@ -841,7 +826,12 @@ proc z39search {setNo piggy tno elements} {
     }
     set sessionWait 0
     egw_log debug "search: $query"
-    $zz.$setNo search $query
+    if {[catch {$zz.$setNo search $query}]} {
+        displayError "Search fail" "Connection closed"
+        html "</body></html>\n"
+        $zz disconnect
+        return 0
+    }
 
     if {[catch {egw_wait sessionWait 60}]} {
         egw_log debug "timeout/cancel in search"