X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=www%2Fz39util.tcl;h=6b56df4e5158d468fbdf49234378793a13bbb15a;hb=3d4b6045b8875099666b99edbf1457c91b5da928;hp=796fdd22259859e5b5db67c91fd2c8c4de2ed825;hpb=6e37e8e91bf35cb14c930e8988085cf78f11029a;p=egate.git diff --git a/www/z39util.tcl b/www/z39util.tcl index 796fdd2..6b56df4 100644 --- a/www/z39util.tcl +++ b/www/z39util.tcl @@ -1,5 +1,5 @@ # -# $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 { @@ -8,15 +8,18 @@ proc saveState {} { 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 @@ -71,18 +74,18 @@ proc display-brief {zset no} { set rtype [$zset recordType $no] if {$rtype == "SUTRS"} { html [join [$zset getSutrs $no]] - htmlr {
} + html "
\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 { } $title {} html " ${year} " } - htmlr {
} + html "
\n" } proc display-full {zset no} { @@ -93,21 +96,21 @@ proc display-full {zset no} { if {$add != {}} { set add " :${add}" } - htmlr "
${no}
" - htmlr "Error ${err}${add}
" + html "

${no}

\n" + html "Error ${err}${add}
\n" return } if {$type != "DB"} { return } - htmlr "
${no}
" + html "

${no}

\n" set rtype [$zset recordType $no] if {$rtype == "SUTRS"} { - htmlr [join [$zset getSutrs $no]] + html [join [$zset getSutrs $no]] "
\n" return } if {[catch {set r [$zset getMarc $no line * * *]}]} { - htmlr "Unknown record type: $rtype" + html "Unknown record type: $rtype
\n" return } foreach line $r { @@ -118,8 +121,8 @@ proc display-full {zset no} { 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] } @@ -205,14 +208,20 @@ proc z39search {setNo piggy} { return 0 } } + z39 idAuthentication $hist($setNo,idAuthentication) set sessionWait 0 if {[catch {z39 init}]} { html "Cannot initialize with target ${host}
\n" return 0 } - zwait sessionWait + if {[catch {zwait sessionWait 60}]} { + html "Cannot initialize with target ${host}
\n" + z39 disconnect + return 0 + } if {$sessionWait != "1"} { html "Cannot initialize with target ${host}
\n" + z39 disconnect return 0 } } @@ -237,9 +246,15 @@ proc z39search {setNo piggy} { set sessionWait 0 z39.$setNo search $hist($setNo,query) - zwait sessionWait + if {[catch {zwait sessionWait 600}]} { + html "\n" + z39 disconnect + return 0 + } + if {$sessionWait != 1} { html "\n" + z39 disconnect return 0 } set status [z39.$setNo responseStatus] @@ -391,13 +406,16 @@ proc z39present {setNo setOffset setMax dfunc} { 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 @@ -409,16 +427,17 @@ proc z39history {} { global hist global env global sessionId + global targets if {![info exists nextSetNo]} { return } html "

History

\n" for {set setNo 1} {$setNo < $nextSetNo} {incr setNo} { - html {
} $hist($setNo,host) + html {"> } [lindex $targets($hist($setNo,host)) 0] if {[llength $hist($setNo,database)] > 1} { html ": " foreach b $hist($setNo,database) { @@ -435,4 +454,4 @@ proc z39history {} { html "\n" } html "
\n" -} \ No newline at end of file +}