2 # $Id: z39util.tcl,v 1.34 1996/02/29 15:41:40 adam Exp $
6 set f [open "tcl.state.${sessionId}" w]
7 foreach var [info globals] {
8 if {$var == "f"} continue
9 if {$var == "sessionId"} continue
10 if {$var == "errorInfo"} continue
11 if {[catch {set names [array names $var]}]} {
13 puts $f "set ${var} \{$v\}"
16 eval "set v \$${var}(\$n)"
17 puts $f "set ${var}($n) \{$v\}"
21 puts $f "set ${var} \{$v\}"
29 proc search-response {zz} {
32 set status [$zz responseStatus]
33 if {[lindex $status 0] == "NSD"} {
34 $zz nextResultSetPosition 0
35 set code [lindex $status 1]
36 set msg [lindex $status 2]
37 set addinfo [lindex $status 3]
38 displayError "Diagnostic message" \
39 "$msg: $addinfo<br>\n(error code $code)"
46 proc scan-response {zz} {
49 set status [$zz scanStatus]
51 displayError "Scan fail" ""
63 proc fail-response {} {
68 proc display-brief {zset no tno} {
74 set type [$zset type $no]
76 set err [lindex [$zset diag $no] 1]
77 set add [lindex [$zset diag $no] 2]
81 html "${no} Error ${err}${add} <br>\n"
87 set rtype [$zset recordType $no]
88 if {$rtype == "SUTRS"} {
89 html [join [$zset getSutrs $no]]
93 if {$rtype == "WAIS"} {
94 html { <a href="http:} $env(SCRIPT_NAME) /
95 html $sessionId {/showfull.egw/} $setNo + $tno + $no + full {">}
96 html [join [$zset getWAIS $no headline]]
102 set author [$zset getMarc $no field 100 * a]
103 set corp [$zset getMarc $no field 110 * a]
104 set meet [$zset getMarc $no field 111 * a]
105 set title [$zset getMarc $no field 245 * a]
106 if {[llength $author] == 0} {
107 set cover [$zset getMarc $no field 245 * {[bc]}]
109 set cover [$zset getMarc $no field 245 * b]
111 set location [$zset getMarc $no field 260 * a]
112 set publisher [$zset getMarc $no field 260 * b]
113 set year [$zset getMarc $no field 260 * c]
115 html { <a href="http:} $env(SCRIPT_NAME) /
116 html $sessionId {/showfull.egw/} $setNo + $tno + $no + full {">}
148 set v [join $cover ""]
149 if {[string length $v] > 40} {
151 html [string range $v 0 38] "..."
152 } elseif {[string length $v] > 0} {
161 html { <a href="http:} $env(SCRIPT_NAME) /
162 html $sessionId {/showfull.egw/} $setNo + $tno + $no + full {">}
165 html "Error: " $dispError "\n"
170 proc display-raw {zset no tno} {
171 set type [$zset type $no]
173 set err [lindex [$zset diag $no] 1]
174 set add [lindex [$zset diag $no] 2]
178 html "<h3>${no}</h3>\n"
179 html "Error ${err}${add} <br>\n"
185 set rtype [$zset recordType $no]
186 if {$rtype == "SUTRS"} {
187 html [join [$zset getSutrs $no]] "<br>\n"
190 if {[catch {set r [$zset getMarc $no line * * *]}]} {
191 html "Unknown record type: $rtype <br>\n"
195 set tag [lindex $line 0]
196 set indicator [lindex $line 1]
197 set fields [lindex $line 2]
198 set l [string length $indicator]
201 for {set i 0} {$i < $l} {incr i} {
202 if {[string index $indicator $i] == " "} {
205 html [string index $tag $i]
210 foreach field $fields {
211 set id [lindex $field 0]
212 set data [lindex $field 1]
214 html " <b>\$$id</b> "
222 proc put-marc-contents {cc} {
224 if {[string first :// $cc] > 0} {
225 foreach urltype {gopher http ftp mailto} {
226 if {[string first ${urltype}:// $cc] == 0} {
241 proc dl-marc-field {zset no tag id la lb sep} {
243 set c [$zset getMarc $no field $tag * $id]
248 if {$len > 1 && "x$lb" != "x"} {
249 html "<dt><b>$lb</b>\n<dd>"
251 html "<dt><b>$la</b>\n<dd>"
257 put-marc-contents $cc
263 proc dd-marc-field {zset no tag id start stop} {
265 set c [$zset getMarc $no field $tag * $id]
272 put-marc-contents $cc
279 proc dl-marc-field-rec {zset no tag lead start stop startid sep} {
281 set lines [$zset getMarc $no line $tag * *]
282 foreach line $lines {
283 foreach field [lindex $line 2] {
285 html "<dt><b>$lead</b>"
288 set id [lindex $field 0]
289 if {$id == $startid} {
295 html [lindex $field 1]
298 html [lindex $field 1]
307 proc display-full-wais {zset no} {
311 set body [$zset getWAIS $no text]
313 while {[string length [set c [string index $body $i1]]]} {
314 if {[string compare $c \n]} {
318 set l [string trim [string range $body $i0 $i1]]
319 egw_log debug "line=$l"
322 if {[string compare [string index $l 0] {<}]} {
323 egw_log "xxxxxxxxxxxxxxxx"
326 if {[set mark [string first > $l ]] < 1} {
327 egw_log "yyyyyyyyyyyyyyyy"
330 set data [string trim [string range $l [expr $mark +1] end]]
332 set sw [string range $l 1 $mark]
333 egw_log debug "sw=$sw"
334 egw_log debug "data=$data"
340 set dateOfLastModification $data
343 set controlIdentifier $data
346 set lastChecked $data
358 set crossRef($refNo,linkage) $data
361 set crossRef($refNo,title) $data
365 html {Title: } {<a href="} $linkage {">} $title "</a><br>\n"
366 html {URL: } $linkage "<br>\n"
367 if {[info exists bytes]} {
368 html {Bytes: } $bytes "<br>\n"
370 if {[info exists dateOfLastModification]} {
371 html {Last modified: } $dateOfLastModification "<br>\n"
373 if {[info exists lastChecked]} {
374 html {Last checked: } $lastChecked "<br>\n"
377 for {set i 1} {$i <= $refNo} {incr i} {
378 html {<li><a href="} $crossRef($i,linkage) {">}
379 html $crossRef($i,title) "</a><br>\n"
380 html "URL: " $crossRef($i,linkage)
385 proc display-full {zset no tno} {
386 set type [$zset type $no]
388 set err [lindex [$zset diag $no] 1]
389 set add [lindex [$zset diag $no] 2]
393 html "Error ${err}${add} <br>\n"
399 set rtype [$zset recordType $no]
400 if {$rtype == "SUTRS"} {
401 html [join [$zset getSutrs $no]] "<br>\n"
404 if {$rtype == "WAIS"} {
405 display-full-wais $zset $no
408 if {[catch {set r [$zset getMarc $no line * * *]}]} {
409 html "Unknown record type: $rtype <br>\n"
413 set n [dl-marc-field $zset $no 700 a "Author" "Authors" "<br>\n"]
415 set n [dl-marc-field $zset $no 100 a "Author" "Authors" "<br>\n"]
417 set n [dl-marc-field $zset $no 710 a "Corporate Name" {} ", "]
419 set n [dl-marc-field $zset $no 110 a "Corporate Name" {} ", "]
421 set n [dl-marc-field $zset $no 711 a "Meeting Name" {} ", "]
423 dd-marc-field $zset $no 711 {[bndc]} " " ""
425 set n [dl-marc-field $zset $no 111 a "Meeting Name" {} ", "]
427 dd-marc-field $zset $no 111 {[bndc]} " " " "
430 set n [dl-marc-field $zset $no 245 {a} "Title" {} " "]
432 dd-marc-field $zset $no 245 b "<em>" "</em>"
433 dd-marc-field $zset $no 245 c " " ""
435 dl-marc-field $zset $no 245 {[ab]} "Title" {} " "
437 dl-marc-field $zset $no 520 a "Abstract" {} ", "
438 dl-marc-field $zset $no 072 * "Subject code" "Subject codes" ", "
439 dl-marc-field $zset $no 650 * "Subject" {} ", "
440 dl-marc-field $zset $no 260 * "Publisher" {} " "
441 dl-marc-field $zset $no 300 * "Physical Description" {} " "
443 dl-marc-field-rec $zset $no 500 "Notes" "" "<br>\n" "a" ", "
445 dl-marc-field-rec $zset $no 510 "References" "" "<br>\n" "a" ", "
447 dl-marc-field-rec $zset $no 511 "Participant note" "" "<br>\n" "a" ", "
449 dl-marc-field $zset $no 513 a "Report type" {} ", "
450 dl-marc-field $zset $no 513 b "Period covered" {} ", "
451 dl-marc-field-rec $zset $no 515 "Numbering notes" "" "<br>\n" "a" ", "
452 dl-marc-field-rec $zset $no 516 "Data notes" "" "<br>\n" "a" ", "
453 dl-marc-field-rec $zset $no 518 "Date/time notes" "" "<br>\n" "a" ", "
455 dl-marc-field $zset $no 350 a "Price" {} ", "
456 dl-marc-field $zset $no 362 a "Dates of publication" {} ", "
457 dl-marc-field $zset $no 850 a "Holdings" {} ", "
459 dl-marc-field-rec $zset $no 270 "Contact name" "" "<br>\n" p ", "
461 set n [dl-marc-field $zset $no 270 p "Contact name" {} ", "]
466 dl-marc-field $zset $no 270 a "Street" {} ", "
467 dl-marc-field $zset $no 270 b "City" {} ", "
468 dl-marc-field $zset $no 270 c "State" {} ", "
469 dl-marc-field $zset $no 270 e "Zip code" {} ", "
470 dl-marc-field $zset $no 270 d "Country" {} ", "
471 dl-marc-field $zset $no 270 m "Network address" {} ", "
472 dl-marc-field $zset $no 301 a "Service hours" {} ", "
473 dl-marc-field $zset $no 270 k "Phone" {} ", "
474 dl-marc-field $zset $no 270 l "Fax" {} ", "
476 dl-marc-field $zset $no 270 {[abcedmakl]} "Address" {} "<br>\n"
482 dl-marc-field $zset $no 010 a "LC control number" {} ", "
483 dl-marc-field $zset $no 010 b "NUCMC control number" {} ", "
484 dl-marc-field $zset $no 020 a "ISBN" {} ", "
485 dl-marc-field $zset $no 022 a "ISSN" {} ", "
486 set url [$zset getMarc $no field 856 * u]
487 set sp [$zset getMarc $no field 856 * 3]
488 if {"x$url" != "x"} {
489 html "<dt><b>URL</b>\n"
493 html {<dd><a href="} [join $url] {">} [join $sp] "</a>\n"
495 dl-marc-field $zset $no 037 {[abc]} "Acquisition" {} "<br>\n"
496 dl-marc-field $zset $no 037 {[f6]} "Form of issue" {} "<br>\n"
497 dl-marc-field $zset $no 537 * "Source of data" {} "<br>\n"
498 dl-marc-field $zset $no 538 * "System details" {} "<br>\n"
499 dl-marc-field $zset $no 787 {[rstw6]} "Related information" {} "<br>\n"
500 dl-marc-field $zset $no 001 * "Local control number" {} ", "
505 proc display-rec {from to dfunc tno} {
509 while {$from <= $to} {
510 eval "$dfunc z39${tno}.${setNo} $from $tno"
514 while {$from <= $to} {
515 eval "$dfunc z39.${setNo} $from 0"
521 proc build-scan {t i} {
524 set term [egw_form entry$i]
526 set field [join [egw_form menu$i]]
528 foreach x [lindex $targets($t) 2] {
529 if {[lindex $x 0] == $field} {
530 set attr [lindex $x 1]
533 return [list $term $attr]
538 proc build-query {t ilines} {
543 for {set i 1} {$i <= $ilines} {incr i} {
544 set term [join [egw_form entry$i]]
545 if {[lindex $targets($t) 6] == "1"} {
546 if {[string length $op] == 0} {
551 set op [egw_form logic$i]
554 if {[string length $term] > 0} {
555 set field [join [egw_form menu$i]]
556 foreach x [lindex $targets($t) 2] {
557 if {[lindex $x 0] == $field} {
558 set attr [lindex $x 1]
563 { set q "@and $q ${attr} \"${term}\"" }
565 { set q "@or $q ${attr} \"${term}\"" }
567 { set q "@not $q ${attr} \"${term}\"" }
569 { set q "${attr} \"${term}\"" }
571 set op [egw_form logic$i]
577 proc z39scan {setNo scanNo tno scanLines scanPos cache} {
584 set host $hist($setNo,$tno,host)
585 set idAuth $hist($setNo,$tno,idAuthentication)
586 set database $hist($setNo,$tno,database)
587 set scanAttr $hist($setNo,$tno,scanAttr)
588 set scanTerm $hist($setNo,$tno,$scanNo,scanTerm)
591 set host $hist($setNo,host)
592 set idAuth $hist($setNo,idAuthentication)
593 set database $hist($setNo,database)
594 set scanAttr $hist($setNo,scanAttr)
595 set scanTerm $hist($setNo,$scanNo,scanTerm)
598 if {[catch [list set oldHost [$zz connect]]]} {
601 set zs $zz.s$scanNo.$setNo
602 $zz callback ok-response
603 $zz failback fail-response
604 set thisHost [splitHostSpec $host]
605 if {[string compare $oldHost $thisHost]} {
606 catch [list $zz disconnect]
609 if {[catch [list $zz connect $thisHost]]} {
610 displayError "Cannot connect to target" $thisHost
612 } elseif {$sessionWait == 0} {
613 if {[catch {egw_wait sessionWait 300}]} {
615 displayError "Cannot connect to target" $thisHost
618 if {$sessionWait != 1} {
619 displayError "Cannot connect to target" $thisHost
623 $zz idAuthentication $idAuth
625 if {[catch {$zz init}]} {
626 displayError "Cannot initialize target" $thisHost
630 if {[catch {egw_wait sessionWait 60}]} {
631 displayError "Cannot initialize target" $thisHost
635 if {$sessionWait != "1"} {
636 displayError "Cannot initialize target" $thisHost
640 if {![$zz initResult]} {
641 set u [$zz userInformationField]
643 displayError "Cannot initialize target $thisHost" $u
647 if {$cache && ![catch [list $zs numberOfTermsRequested 5]]} {
651 eval $zz databaseNames $database
655 $zs numberOfTermsRequested $scanLines
656 $zs preferredPositionInResponse $scanPos
658 $zz callback [list scan-response $zs]
660 egw_log debug "scan: ${scanAttr} ${scanTerm}"
662 $zs scan "${scanAttr} ${scanTerm}"
664 if {[catch {egw_wait sessionWait 60}]} {
665 egw_log debug "timeout/cancel in scan"
666 displayError "Timeout in scan" {}
667 html "</body></html>\n"
671 if {$sessionWait == -1} {
672 displayError "Scan fail" "Connection closed"
673 html "</body></html>\n"
676 if {$sessionWait != 1} {
682 proc display-scan {setNo scanNo tno} {
693 set zs $zz.s$scanNo.$setNo
694 set m [$zs numberOfEntriesReturned]
697 set t [lindex [$zs scanLine 0] 1]
699 set hist($setNo,$tno,[expr $scanNo - 1],scanTerm) $t
701 set hist($setNo,[expr $scanNo - 1],scanTerm) $t
703 set t [lindex [$zs scanLine [expr $m - 1]] 1]
705 set hist($setNo,$tno,[expr $scanNo + 1],scanTerm) $t
707 set hist($setNo,[expr $scanNo + 1],scanTerm) $t
710 html {<table width=500 border=0><tr>}
711 html {<td align=left><b>Scan term</b>}
712 html {<td align=right><b>Hits</b>}
715 for {set i 0} {$i < $m} {incr i} {
716 html {<td align=left>}
718 regsub -all {\ } [lindex [$zs scanLine $i] 1] + tterm
719 html {<a href="http:} $env(SCRIPT_NAME)
720 html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo +
721 html $hist($setNo,scan) + $tterm {">}
723 regsub -all {\ } [lindex [$zs scanLine $i] 1] + tterm
724 html {<a href="http:} $env(SCRIPT_NAME)
725 html / $sessionId {/search.egw/} $setNo +
726 html hyper + $tterm {">}
728 html [lindex [$zs scanLine $i] 1]
730 html {<td align=right>}
731 html [lindex [$zs scanLine $i] 2]
737 proc z39search {setNo piggy tno elements} {
744 set host $hist($setNo,$tno,host)
745 set idAuth $hist($setNo,$tno,idAuthentication)
746 set database $hist($setNo,$tno,database)
747 set query $hist($setNo,$tno,query)
750 set host $hist($setNo,host)
751 set idAuth $hist($setNo,idAuthentication)
752 set database $hist($setNo,database)
753 set query $hist($setNo,query)
756 if {[catch [list set oldHost [$zz connect]]]} {
759 $zz callback ok-response
760 $zz failback fail-response
761 set thisHost [splitHostSpec $host]
762 if {[string compare $oldHost $thisHost]} {
763 catch [list $zz disconnect]
766 if {[catch [list $zz connect $thisHost]]} {
767 displayError "Cannot connect to target" $thisHost
769 } elseif {$sessionWait == 0} {
770 if {[catch {egw_wait sessionWait 300}]} {
772 displayError "Cannot connect to target" $thisHost
775 if {$sessionWait != 1} {
776 displayError "Cannot connect to target" $thisHost
780 $zz idAuthentication $idAuth
782 if {[catch {$zz init}]} {
783 displayError "Cannot initialize target" $thisHost
787 if {$sessionWait == 0 && [catch {egw_wait sessionWait 60}]} {
788 displayError "Cannot initialize target" $thisHost
792 if {$sessionWait != "1"} {
793 displayError "Cannot initialize target" $thisHost
797 if {![$zz initResult]} {
798 set u [$zz userInformationField]
800 displayError "Cannot initialize target $thisHost" $u
803 } elseif {![catch [list $zz.$setNo smallSetUpperBound 0]]} {
805 if {[info exists hist($setNo,$tno,hits)]} {
809 if {[info exists hist($setNo,hits)]} {
815 if {[lindex $targets($host) 6] == "1"} {
816 wais-set $zz.$setNo $zz
818 ir-set $zz.$setNo $zz
820 if {![lindex $targets($host) 5]} {
823 $zz.$setNo smallSetElementSetNames $elements
824 $zz.$setNo mediumSetElementSetNames $elements
825 $zz.$setNo recordElements $elements
827 egw_log debug "database=$database"
828 eval $zz.$setNo databaseNames $database
830 $zz.$setNo preferredRecordSyntax USMARC
832 $zz callback [list search-response $zz.$setNo]
834 $zz.$setNo largeSetLowerBound 999999
835 $zz.$setNo smallSetUpperBound 0
836 $zz.$setNo mediumSetPresentNumber $hist($setNo,maxPresent)
838 $zz.$setNo largeSetLowerBound 2
839 $zz.$setNo smallSetUpperBound 0
840 $zz.$setNo mediumSetPresentNumber 0
843 egw_log debug "search: $query"
844 $zz.$setNo search $query
846 if {[catch {egw_wait sessionWait 60}]} {
847 egw_log debug "timeout/cancel in search"
848 displayError "Timeout in search" {}
849 html "</body></html>\n"
854 if {$sessionWait == -1} {
855 displayError "Search fail" "Connection closed"
856 html "</body></html>\n"
859 if {$sessionWait != 1} {
862 set hist($setNo,hits) [$zz.$setNo resultCount]
866 proc init-m-response {i} {
870 egw_log debug "init-m-response"
873 if {![z39$i initResult]} {
881 proc connect-m-response {i} {
885 egw_log debug "connect-m-response"
886 z39$i callback [list init-m-response $i]
887 if {[catch {z39$i init}]} {
893 proc fail-m-response {i} {
897 egw_log debug "fail-m-response"
902 proc search-m-response {setNo i start number} {
907 egw_log debug "search-m-response"
908 set status [z39$i.$setNo responseStatus]
909 egw_log debug "search-m-response1"
910 if {[lindex $status 0] == "OK"} {
912 } elseif {[lindex $status 0] == "DBOSD"} {
913 set nor [z39$i.$setNo numberOfRecordsReturned]
915 egw_log debug "search-m-response2"
920 set hist($setNo,$i,hits) [z39$i.$setNo resultCount]
921 egw_log debug "search-m-response3"
922 set hist($setNo,$i,offset) [expr $start + $nor -1]
923 if {[expr $nor + $start] > [z39$i.$setNo resultCount]} {
924 egw_log debug "search-m-response4"
929 egw_log debug "search-m-response5"
930 if {$nor >= $number} {
931 egw_log debug "search-m-response6 nor=$nor number=$number"
936 egw_log debug "search-m-response7"
937 set start [expr $start + $nor]
938 set number [expr $number - $nor]
939 if {[expr $start + $number - 1] > [z39$i.$setNo resultCount]} {
940 set number [expr [z39$i.$setNo resultCount] - $start + 1]
942 z39$i callback [list search-m-response $setNo $i $start $number]
943 egw_log debug "mpresent start=$number number=$number"
944 z39$i.$setNo present $start $number
947 proc z39msearch {setNo elements start number cache} {
954 set not $hist($setNo,0,host)
956 egw_log debug "z39msearch start=$start number=$number elements=$elements"
957 for {set i 1} {$i <= $not} {incr i} {
958 set host $hist($setNo,$i,host)
960 set oldHost [z39$i connect]
961 set thisHost [splitHostSpec $host]
962 if {[string compare $oldHost $thisHost]} {
963 catch {z39$i disconnect}
965 z39$i callback [list connect-m-response $i]
966 z39$i failback [list fail-m-response $i]
969 for {set i 1} {$i <= $not} {incr i} {
970 set oldHost [z39$i connect]
971 set host $hist($setNo,$i,host)
972 set thisHost [splitHostSpec $host]
973 if {![string compare $oldHost $thisHost]} {
976 egw_log debug "old=$oldHost this=$thisHost"
977 z39$i idAuthentication $hist($setNo,$i,idAuthentication)
978 html "Connecting to target " $thisHost " <br>\n"
980 if {![catch {z39$i connect $thisHost}]} {
985 egw_log debug "Waiting for init response"
986 if {[catch {egw_wait zleft 20}]} {
991 for {set i 1} {$i <= $not} {incr i} {
992 set host $hist($setNo,$i,host)
994 html "host " [splitHostSpec $host] ": "
996 egw_log debug "i=$i zstatus=$zstatus($i)"
997 if {$zstatus($i) < 1} {
1003 if {[catch [list z39$i.$setNo preferredRecordSyntax USMARC]]} {
1008 if {[lindex $targets($host) 6] == "1"} {
1009 wais-set z39$i.$setNo z39$i
1011 ir-set z39$i.$setNo z39$i
1013 set hist($setNo,$i,offset) 0
1014 eval z39$i.$setNo databaseNames $hist($setNo,$i,database)
1016 if {![lindex $targets($hist($setNo,$i,host)) 5]} {
1019 set thisElements $elements
1021 z39$i.$setNo smallSetElementSetNames $thisElements
1022 z39$i.$setNo mediumSetElementSetNames $thisElements
1023 z39$i.$setNo elementSetNames $thisElements
1024 z39$i.$setNo recordElements $thisElements
1026 z39$i.$setNo preferredRecordSyntax USMARC
1027 z39$i callback [list search-m-response $setNo $i $start $number]
1030 z39$i.$setNo largeSetLowerBound 999999
1031 z39$i.$setNo smallSetUpperBound 0
1032 z39$i.$setNo mediumSetPresentNumber $number
1034 z39$i.$setNo largeSetLowerBound 2
1035 z39$i.$setNo smallSetUpperBound 0
1036 z39$i.$setNo mediumSetPresentNumber 0
1040 egw_log debug "setNo=$setNo msearch " $hist($setNo,$i,query)
1041 z39$i.$setNo search $hist($setNo,$i,query)
1042 } elseif {[z39$i.$setNo resultCount] >= $start} {
1043 if {[expr $start + $number - 1] > [z39$i.$setNo resultCount]} {
1044 set tnumber [expr [z39$i.$setNo resultCount] - $start + 1]
1048 if {![lindex $targets($hist($setNo,$i,host)) 5]} {
1051 set thisElements $elements
1053 z39$i.$setNo smallSetElementSetNames $thisElements
1054 z39$i.$setNo mediumSetElementSetNames $thisElements
1055 z39$i.$setNo elementSetNames $thisElements
1056 z39$i.$setNo recordElements $thisElements
1058 for {set n 0} {$n < $tnumber} {incr n} {
1059 if {[z39$i.$setNo recordType [expr $start + $n]] == ""} {
1061 egw_log debug "failed on $n"
1064 html "no record at #" [expr $start + $n]
1065 html " el=-" $thisElements "-"
1070 if {$n == $tnumber} {
1077 html "present<br>\n"
1078 z39$i.$setNo preferredRecordSyntax USMARC
1079 z39$i callback [list search-m-response $setNo $i $start $tnumber]
1081 egw_log debug "mpresent start=$start number=$tnumber"
1082 z39$i.$setNo present $start $tnumber
1089 while {$zleft > 0} {
1090 egw_log debug "Waiting for search/present response"
1091 if {[catch {egw_wait zleft 60}]} {
1095 for {set i 1} {$i <= $not} {incr i} {
1096 if {$zstatus($i) != 2} continue
1097 set status [z39$i.$setNo responseStatus]
1098 if {0 && [lindex $status 0] != "NSD"} {
1099 set hist($setNo,$i,offset) [z39$i.$setNo numberOfRecordsReturned]
1104 proc z39present {setNo tno setOffset setMax dfunc elements} {
1111 set host $hist($setNo,$tno,host)
1114 set host $hist($setNo,host)
1117 if {![lindex $targets($host) 5]} {
1121 $zz.$setNo elementSetNames $elements
1122 $zz.$setNo recordElements $elements
1123 set toGet [expr 1 + $setMax - $setOffset]
1125 $zz callback [list search-response $zz.$setNo]
1127 while {$setMax > 0 && $toGet > 0} {
1128 for {set got 0} {$got < $toGet} {incr got} {
1129 if {[$zz.$setNo recordType [expr $setOffset + $got]] == ""} {
1133 if {$got < $toGet} {
1135 $zz.$setNo present $setOffset $toGet
1136 if {[catch {egw_wait sessionWait 300}]} {
1137 egw_log debug "timeout/cancel in present"
1141 if {$sessionWait == "0"} {
1144 if {$sessionWait != "1"} {
1147 set got [$zz.$setNo numberOfRecordsReturned]
1152 display-rec $setOffset [expr $got + $setOffset - 1] $dfunc $tno
1153 set setOffset [expr $got + $setOffset]
1154 set toGet [expr 1 + $setMax - $setOffset]
1159 proc z39history {} {
1167 if {![info exists nextSetNo]} {
1170 html "<h2>History</h2><br>\n"
1172 html {<table width=500 border=1><tr>}
1173 html {<td align=center><b>Target</b>}
1174 html {<td align=center><b>Database</b>}
1175 html {<td align=center><b>Hits</b>}
1176 html {<td align=center><b>Query</b>}
1181 for {set setNo 1} {$setNo < $nextSetNo} {incr setNo} {
1182 if {$hist($setNo,scan) > 0} continue
1183 set host $hist($setNo,host)
1185 html {<td align=left>}
1189 html [lindex $targets($host) 0]
1191 html {<td align=left>} [join $hist($setNo,database)]
1193 if {[llength [lindex $targets($host) 1]] > 1} {
1195 foreach b $hist($setNo,database) {
1202 html {<td align=right>}
1204 if {[info exists hist($setNo,hits)]} {
1205 html { <a href="http:} $env(SCRIPT_NAME)
1206 html / $sessionId {/search.egw/} $setNo + 1
1207 html + $hist($setNo,maxPresent)
1209 html {">} $hist($setNo,hits) {</a>}
1211 html {">Result</a>: } $hist($setNo,hits) { hits.}
1217 html {Search failed.}
1221 html {<td align=left>}
1225 html { <a href="http:} $env(SCRIPT_NAME)
1226 html / $sessionId {/query.egw/} $host + $setNo
1230 html {">Query</a>: }
1233 for {set i 1} {$i <= 3} {incr i} {
1234 if {[string length $hist($setNo,form,entry$i)] > 0} {
1235 html " <b>" [join $op " "] "</b> "
1236 html [join $hist($setNo,form,menu$i)] "="
1237 html $hist($setNo,form,entry$i)
1238 set op $hist($setNo,form,logic$i)
1242 html {</a><tr>} "\n"
1253 proc displayError {msga msgb} {
1254 html "<p><center>\n"
1255 html {<img src="/egwgif/noway.gif" alt="Error">}
1256 html "<h2>" $msga "</h2>\n"
1258 html "<h3>" $msgb "</h3>\n"
1260 html "</center><p>\n"
1263 proc button-europagate {} {
1265 html {<a href="http://europagate.dtv.dk/">}
1267 html {<img src="/egwgif/button-egw.gif" alt="Europagate" border=0></a>}
1269 html {Europagate</a> | }
1273 proc button-define-target {more} {
1278 html {<a href="http:} $env(SCRIPT_NAME)
1279 html / $sessionId {/tform.egw}
1281 html {"><img src="/egwgif/button-define-target.gif" }
1282 html {alt="Define Target" border=0></a>}
1284 html {">Define Target</a>}
1293 proc button-new-target {more} {
1299 html {<a href="http:} $env(SCRIPT_NAME)
1302 html {/mtargets.egw}
1307 html {"><img src="/egwgif/button-new-target.gif" }
1308 html {alt="New Target" border=0></a>}
1310 html {">New Target</a>}
1319 proc button-view-history {more} {
1325 html {<a href="http:} $env(SCRIPT_NAME)
1326 html / $sessionId {/history.egw;}
1327 catch { html "/" $nextSetNo}
1329 html {"><img src="/egwgif/button-view-history.gif" alt="View History" }
1330 html {border=0></a>}
1332 html {">View History</a>}
1341 proc button-new-query {more setNo} {
1348 html {<a href="http:} $env(SCRIPT_NAME)
1351 html {/mquery.egw/} $setNo
1353 html {/query.egw/} $hist($setNo,host) + $setNo
1357 html {<img src="/egwgif/button-new-query.gif" }
1358 html {alt="New Query" border=0></a>}
1360 html {New Query</a>}
1369 proc button-scan-window {more setNo} {
1375 html {<a href="http:} $env(SCRIPT_NAME)
1376 html / $sessionId {/search.egw/} $setNo + {scan} {">}
1378 html {<img src="/egwgif/button-scan-window.gif" }
1379 html {alt="Scan" border=0></a>}
1390 proc maintenance {} {
1391 html {<hr>This page is maintained by }
1392 html {<a href="mailto:pwh@dtv.dk"> Peter Wad Hansen </a>.}
1393 html {Last modified 29. january 1996. <br>}
1394 html {<em> This and the following pages are under construction and }
1395 html {will continue to be so until the end of January 1996.</em>}
1398 proc splitHostSpec {host} {
1399 set i [string last . $host]
1402 return [string range $host 0 $i]
1407 proc mergeHostSpec {host databases} {
1408 return ${host}.[join $databases -]
1411 proc mkAssoc {assoc host} {
1414 if {[catch {$assoc failback fail-response}]} {
1415 if {[lindex $targets($host) 6] == "1"} {
1421 if {[lindex $targets($host) 6] == "1"} {
1422 if {[$assoc comstack] == "wais"} return
1425 if {[$assoc comstack] == "tcpip"} return