#
-# $Id: z39util.tcl,v 1.2 1995/11/07 14:57:00 adam Exp $
+# $Id: z39util.tcl,v 1.5 1995/11/08 18:07:23 adam Exp $
#
proc saveState {} {
uplevel #0 {
if {$var == "f"} continue
if {$var == "sessionId"} continue
if {$var == "errorInfo"} continue
- set names [array names $var]
- if {$names != ""} {
+ if {[catch {set names [array names $var]}]} {
+ eval "set v \$${var}"
+ puts $f "set ${var} \{$v\}"
+ } else {
foreach n $names {
eval "set v \$${var}(\$n)"
puts $f "set ${var}($n) \{$v\}"
}
- } else {
- eval "set v \$${var}"
- puts $f "set ${var} \{$v\}"
+ catch {
+ eval "set v \$${var}"
+ puts $f "set ${var} \{$v\}"
+ }
}
}
close $f
set rtype [$zset recordType $no]
if {$rtype == "SUTRS"} {
html [join [$zset getSutrs $no]]
- htmlr {<br>}
+ html "<br>\n"
return
}
if {![catch {
set title [lindex [$zset getMarc $no field 245 * a] 0]
set year [lindex [$zset getMarc $no field 260 * c] 0]
} ] } {
- html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME) /
+ html {<a href="http:} $env(SCRIPT_NAME) /
html $sessionId {/showfull.egw/} $setNo + $no {"> } $title {</a>}
html " <i> ${year} </i>"
}
- htmlr {<br>}
+ html "<br>\n"
}
proc display-full {zset no} {
if {$add != {}} {
set add " :${add}"
}
- htmlr "<hr> ${no} <br>"
- htmlr "Error ${err}${add} <br>"
+ html "<h3>${no}</h3>\n"
+ html "Error ${err}${add} <br>\n"
return
}
if {$type != "DB"} {
return
}
- htmlr "<hr> ${no} <br>"
+ html "<h3>${no}</h3>\n"
set rtype [$zset recordType $no]
if {$rtype == "SUTRS"} {
- htmlr [join [$zset getSutrs $no]]
+ html [join [$zset getSutrs $no]] "<br>\n"
return
}
if {[catch {set r [$zset getMarc $no line * * *]}]} {
- htmlr "Unknown record type: $rtype"
+ html "Unknown record type: $rtype <br>\n"
return
}
foreach line $r {
html "$tag "
if {$l > 0} {
for {set i 0} {$i < $l} {incr i} {
- if {[string index $tag $i] == " "} {
- html "_"
+ if {[string index $indicator $i] == " "} {
+ html "-"
} else {
html [string index $tag $i]
}
return 0
}
}
+ z39 idAuthentication $hist($setNo,idAuthentication)
set sessionWait 0
if {[catch {z39 init}]} {
html "Cannot initialize with target ${host} <br>\n"
return 0
}
- zwait sessionWait
+ if {[catch {zwait sessionWait 60}]} {
+ html "Cannot initialize with target ${host} <br>\n"
+ z39 disconnect
+ return 0
+ }
if {$sessionWait != "1"} {
html "Cannot initialize with target ${host} <br>\n"
+ z39 disconnect
return 0
}
}
set sessionWait 0
z39.$setNo search $hist($setNo,query)
- zwait sessionWait
+ if {[catch {zwait sessionWait 600}]} {
+ html "</body></html>\n"
+ z39 disconnect
+ return 0
+ }
+
if {$sessionWait != 1} {
html "</body></html>\n"
+ z39 disconnect
return 0
}
set status [z39.$setNo responseStatus]
if {$got < $toGet} {
set sessionWait 0
z39.$setNo present $setOffset $toGet
- zwait sessionWait
+ if {[catch {zwait sessionWait 300}]} {
+ z39 disconnect
+ break
+ }
if {$sessionWait != "1"} {
break
}
set got [z39.$setNo numberOfRecordsReturned]
}
- display-rec $setOffset [expr $got + $setOffset - 1] $dfunc
+ display-rec $setOffset [expr $got + $setOffset - 1] $dfunc z39
set setOffset [expr $got + $setOffset]
set toGet [expr 1 + $setMax - $setOffset]
wflush
global hist
global env
global sessionId
+ global targets
if {![info exists nextSetNo]} {
return
}
html "<hr><h3>History</h3><dl>\n"
for {set setNo 1} {$setNo < $nextSetNo} {incr setNo} {
- html {<dt> <a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+ html {<dt> <a href="http:} $env(SCRIPT_NAME)
html / $sessionId {/search.egw/} $setNo + 1
html + [expr $hist($setNo,maxPresent) - 1]
- html {"> } $hist($setNo,host)
+ html {"> } [lindex $targets($hist($setNo,host)) 0]
if {[llength $hist($setNo,database)] > 1} {
html ": "
foreach b $hist($setNo,database) {
html "\n"
}
html "</dl>\n"
-}
\ No newline at end of file
+}