2 # $Id: z39util.tcl,v 1.35 1996/03/05 18:50:26 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} {
310 htmlToken l [join [$zset getWAIS $no text]] {
311 if {[string compare [string index $l 0] {<}]} {
312 set data($element) $l
320 set element dateOfLastModification
323 set element controlIdentifier
326 set element lastChecked
338 set element "$i,linkage"
341 set element "$i,title"
348 html {Title: } {<a href="} $data(linkage) {">} $data(title) "</a><br>\n"
349 html {URL: } $data(linkage) "<br>\n"
350 html {Score: } [$zset getWAIS $no score] "<br>\n"
351 html {Lines: } [$zset getWAIS $no lines] "<br>\n"
352 if {[info exists data(bytes)]} {
353 html {Bytes: } $data(bytes) "<br>\n"
355 if {[info exists data(dateOfLastModification)]} {
356 html {Last modified: } $data(dateOfLastModification) "<br>\n"
358 if {[info exists data(lastChecked)]} {
359 html {Last checked: } $data(lastChecked) "<br>\n"
362 for {set i 1} {[info exists data($i,linkage)]} {incr i} {
363 html {<li><a href="} $data($i,linkage) {">}
364 html $data($i,title) "</a><br>\n"
365 html "URL: " $data($i,linkage)
370 proc display-full {zset no tno} {
371 set type [$zset type $no]
373 set err [lindex [$zset diag $no] 1]
374 set add [lindex [$zset diag $no] 2]
378 html "Error ${err}${add} <br>\n"
384 set rtype [$zset recordType $no]
385 if {$rtype == "SUTRS"} {
386 html [join [$zset getSutrs $no]] "<br>\n"
389 if {$rtype == "WAIS"} {
390 display-full-wais $zset $no
393 if {[catch {set r [$zset getMarc $no line * * *]}]} {
394 html "Unknown record type: $rtype <br>\n"
398 set n [dl-marc-field $zset $no 700 a "Author" "Authors" "<br>\n"]
400 set n [dl-marc-field $zset $no 100 a "Author" "Authors" "<br>\n"]
402 set n [dl-marc-field $zset $no 710 a "Corporate Name" {} ", "]
404 set n [dl-marc-field $zset $no 110 a "Corporate Name" {} ", "]
406 set n [dl-marc-field $zset $no 711 a "Meeting Name" {} ", "]
408 dd-marc-field $zset $no 711 {[bndc]} " " ""
410 set n [dl-marc-field $zset $no 111 a "Meeting Name" {} ", "]
412 dd-marc-field $zset $no 111 {[bndc]} " " " "
415 set n [dl-marc-field $zset $no 245 {a} "Title" {} " "]
417 dd-marc-field $zset $no 245 b "<em>" "</em>"
418 dd-marc-field $zset $no 245 c " " ""
420 dl-marc-field $zset $no 245 {[ab]} "Title" {} " "
422 dl-marc-field $zset $no 520 a "Abstract" {} ", "
423 dl-marc-field $zset $no 072 * "Subject code" "Subject codes" ", "
424 dl-marc-field $zset $no 650 * "Subject" {} ", "
425 dl-marc-field $zset $no 260 * "Publisher" {} " "
426 dl-marc-field $zset $no 300 * "Physical Description" {} " "
428 dl-marc-field-rec $zset $no 500 "Notes" "" "<br>\n" "a" ", "
430 dl-marc-field-rec $zset $no 510 "References" "" "<br>\n" "a" ", "
432 dl-marc-field-rec $zset $no 511 "Participant note" "" "<br>\n" "a" ", "
434 dl-marc-field $zset $no 513 a "Report type" {} ", "
435 dl-marc-field $zset $no 513 b "Period covered" {} ", "
436 dl-marc-field-rec $zset $no 515 "Numbering notes" "" "<br>\n" "a" ", "
437 dl-marc-field-rec $zset $no 516 "Data notes" "" "<br>\n" "a" ", "
438 dl-marc-field-rec $zset $no 518 "Date/time notes" "" "<br>\n" "a" ", "
440 dl-marc-field $zset $no 350 a "Price" {} ", "
441 dl-marc-field $zset $no 362 a "Dates of publication" {} ", "
442 dl-marc-field $zset $no 850 a "Holdings" {} ", "
444 dl-marc-field-rec $zset $no 270 "Contact name" "" "<br>\n" p ", "
446 set n [dl-marc-field $zset $no 270 p "Contact name" {} ", "]
451 dl-marc-field $zset $no 270 a "Street" {} ", "
452 dl-marc-field $zset $no 270 b "City" {} ", "
453 dl-marc-field $zset $no 270 c "State" {} ", "
454 dl-marc-field $zset $no 270 e "Zip code" {} ", "
455 dl-marc-field $zset $no 270 d "Country" {} ", "
456 dl-marc-field $zset $no 270 m "Network address" {} ", "
457 dl-marc-field $zset $no 301 a "Service hours" {} ", "
458 dl-marc-field $zset $no 270 k "Phone" {} ", "
459 dl-marc-field $zset $no 270 l "Fax" {} ", "
461 dl-marc-field $zset $no 270 {[abcedmakl]} "Address" {} "<br>\n"
467 dl-marc-field $zset $no 010 a "LC control number" {} ", "
468 dl-marc-field $zset $no 010 b "NUCMC control number" {} ", "
469 dl-marc-field $zset $no 020 a "ISBN" {} ", "
470 dl-marc-field $zset $no 022 a "ISSN" {} ", "
471 set url [$zset getMarc $no field 856 * u]
472 set sp [$zset getMarc $no field 856 * 3]
473 if {"x$url" != "x"} {
474 html "<dt><b>URL</b>\n"
478 html {<dd><a href="} [join $url] {">} [join $sp] "</a>\n"
480 dl-marc-field $zset $no 037 {[abc]} "Acquisition" {} "<br>\n"
481 dl-marc-field $zset $no 037 {[f6]} "Form of issue" {} "<br>\n"
482 dl-marc-field $zset $no 537 * "Source of data" {} "<br>\n"
483 dl-marc-field $zset $no 538 * "System details" {} "<br>\n"
484 dl-marc-field $zset $no 787 {[rstw6]} "Related information" {} "<br>\n"
485 dl-marc-field $zset $no 001 * "Local control number" {} ", "
490 proc display-rec {from to dfunc tno} {
494 while {$from <= $to} {
495 eval "$dfunc z39${tno}.${setNo} $from $tno"
499 while {$from <= $to} {
500 eval "$dfunc z39.${setNo} $from 0"
506 proc build-scan {t i} {
509 set term [egw_form entry$i]
511 set field [join [egw_form menu$i]]
513 foreach x [lindex $targets($t) 2] {
514 if {[lindex $x 0] == $field} {
515 set attr [lindex $x 1]
518 return [list $term $attr]
523 proc build-query {t ilines} {
528 for {set i 1} {$i <= $ilines} {incr i} {
529 set term [join [egw_form entry$i]]
530 if {[lindex $targets($t) 6] == "1"} {
531 if {[string length $op] == 0} {
536 set op [egw_form logic$i]
539 if {[string length $term] > 0} {
540 set field [join [egw_form menu$i]]
541 foreach x [lindex $targets($t) 2] {
542 if {[lindex $x 0] == $field} {
543 set attr [lindex $x 1]
548 { set q "@and $q ${attr} \"${term}\"" }
550 { set q "@or $q ${attr} \"${term}\"" }
552 { set q "@not $q ${attr} \"${term}\"" }
554 { set q "${attr} \"${term}\"" }
556 set op [egw_form logic$i]
562 proc z39scan {setNo scanNo tno scanLines scanPos cache} {
569 set host $hist($setNo,$tno,host)
570 set idAuth $hist($setNo,$tno,idAuthentication)
571 set database $hist($setNo,$tno,database)
572 set scanAttr $hist($setNo,$tno,scanAttr)
573 set scanTerm $hist($setNo,$tno,$scanNo,scanTerm)
576 set host $hist($setNo,host)
577 set idAuth $hist($setNo,idAuthentication)
578 set database $hist($setNo,database)
579 set scanAttr $hist($setNo,scanAttr)
580 set scanTerm $hist($setNo,$scanNo,scanTerm)
583 if {[catch [list set oldHost [$zz connect]]]} {
586 set zs $zz.s$scanNo.$setNo
587 $zz callback ok-response
588 $zz failback fail-response
589 set thisHost [splitHostSpec $host]
590 if {[string compare $oldHost $thisHost]} {
591 catch [list $zz disconnect]
594 if {[catch [list $zz connect $thisHost]]} {
595 displayError "Cannot connect to target" $thisHost
597 } elseif {$sessionWait == 0} {
598 if {[catch {egw_wait sessionWait 300}]} {
600 displayError "Cannot connect to target" $thisHost
603 if {$sessionWait != 1} {
604 displayError "Cannot connect to target" $thisHost
608 $zz idAuthentication $idAuth
610 if {[catch {$zz init}]} {
611 displayError "Cannot initialize target" $thisHost
615 if {[catch {egw_wait sessionWait 60}]} {
616 displayError "Cannot initialize target" $thisHost
620 if {$sessionWait != "1"} {
621 displayError "Cannot initialize target" $thisHost
625 if {![$zz initResult]} {
626 set u [$zz userInformationField]
628 displayError "Cannot initialize target $thisHost" $u
632 if {$cache && ![catch [list $zs numberOfTermsRequested 5]]} {
636 eval $zz databaseNames $database
640 $zs numberOfTermsRequested $scanLines
641 $zs preferredPositionInResponse $scanPos
643 $zz callback [list scan-response $zs]
645 egw_log debug "scan: ${scanAttr} ${scanTerm}"
647 $zs scan "${scanAttr} ${scanTerm}"
649 if {[catch {egw_wait sessionWait 60}]} {
650 egw_log debug "timeout/cancel in scan"
651 displayError "Timeout in scan" {}
652 html "</body></html>\n"
656 if {$sessionWait == -1} {
657 displayError "Scan fail" "Connection closed"
658 html "</body></html>\n"
661 if {$sessionWait != 1} {
667 proc display-scan {setNo scanNo tno} {
678 set zs $zz.s$scanNo.$setNo
679 set m [$zs numberOfEntriesReturned]
682 set t [lindex [$zs scanLine 0] 1]
684 set hist($setNo,$tno,[expr $scanNo - 1],scanTerm) $t
686 set hist($setNo,[expr $scanNo - 1],scanTerm) $t
688 set t [lindex [$zs scanLine [expr $m - 1]] 1]
690 set hist($setNo,$tno,[expr $scanNo + 1],scanTerm) $t
692 set hist($setNo,[expr $scanNo + 1],scanTerm) $t
695 html {<table width=500 border=0><tr>}
696 html {<td align=left><b>Scan term</b>}
697 html {<td align=right><b>Hits</b>}
700 for {set i 0} {$i < $m} {incr i} {
701 html {<td align=left>}
703 regsub -all {\ } [lindex [$zs scanLine $i] 1] + tterm
704 html {<a href="http:} $env(SCRIPT_NAME)
705 html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo +
706 html $hist($setNo,scan) + $tterm {">}
708 regsub -all {\ } [lindex [$zs scanLine $i] 1] + tterm
709 html {<a href="http:} $env(SCRIPT_NAME)
710 html / $sessionId {/search.egw/} $setNo +
711 html hyper + $tterm {">}
713 html [lindex [$zs scanLine $i] 1]
715 html {<td align=right>}
716 html [lindex [$zs scanLine $i] 2]
722 proc z39search {setNo piggy tno elements} {
729 set host $hist($setNo,$tno,host)
730 set idAuth $hist($setNo,$tno,idAuthentication)
731 set database $hist($setNo,$tno,database)
732 set query $hist($setNo,$tno,query)
735 set host $hist($setNo,host)
736 set idAuth $hist($setNo,idAuthentication)
737 set database $hist($setNo,database)
738 set query $hist($setNo,query)
741 if {[catch [list set oldHost [$zz connect]]]} {
744 $zz callback ok-response
745 $zz failback fail-response
746 set thisHost [splitHostSpec $host]
747 if {[string compare $oldHost $thisHost]} {
748 catch [list $zz disconnect]
751 if {[catch [list $zz connect $thisHost]]} {
752 displayError "Cannot connect to target" $thisHost
754 } elseif {$sessionWait == 0} {
755 if {[catch {egw_wait sessionWait 300}]} {
757 displayError "Cannot connect to target" $thisHost
760 if {$sessionWait != 1} {
761 displayError "Cannot connect to target" $thisHost
765 $zz idAuthentication $idAuth
767 if {[catch {$zz init}]} {
768 displayError "Cannot initialize target" $thisHost
772 if {$sessionWait == 0 && [catch {egw_wait sessionWait 60}]} {
773 displayError "Cannot initialize target" $thisHost
777 if {$sessionWait != "1"} {
778 displayError "Cannot initialize target" $thisHost
782 if {![$zz initResult]} {
783 set u [$zz userInformationField]
785 displayError "Cannot initialize target $thisHost" $u
788 } elseif {![catch [list $zz.$setNo smallSetUpperBound 0]]} {
790 if {[info exists hist($setNo,$tno,hits)]} {
794 if {[info exists hist($setNo,hits)]} {
800 if {[lindex $targets($host) 6] == "1"} {
801 wais-set $zz.$setNo $zz
803 ir-set $zz.$setNo $zz
805 if {![lindex $targets($host) 5]} {
808 $zz.$setNo smallSetElementSetNames $elements
809 $zz.$setNo mediumSetElementSetNames $elements
810 $zz.$setNo recordElements $elements
812 egw_log debug "database=$database"
813 eval $zz.$setNo databaseNames $database
815 $zz.$setNo preferredRecordSyntax USMARC
817 $zz callback [list search-response $zz.$setNo]
819 $zz.$setNo largeSetLowerBound 999999
820 $zz.$setNo smallSetUpperBound 0
821 $zz.$setNo mediumSetPresentNumber $hist($setNo,maxPresent)
823 $zz.$setNo largeSetLowerBound 2
824 $zz.$setNo smallSetUpperBound 0
825 $zz.$setNo mediumSetPresentNumber 0
828 egw_log debug "search: $query"
829 if {[catch {$zz.$setNo search $query}]} {
830 displayError "Search fail" "Connection closed"
831 html "</body></html>\n"
836 if {[catch {egw_wait sessionWait 60}]} {
837 egw_log debug "timeout/cancel in search"
838 displayError "Timeout in search" {}
839 html "</body></html>\n"
844 if {$sessionWait == -1} {
845 displayError "Search fail" "Connection closed"
846 html "</body></html>\n"
849 if {$sessionWait != 1} {
852 set hist($setNo,hits) [$zz.$setNo resultCount]
856 proc init-m-response {i} {
860 egw_log debug "init-m-response"
863 if {![z39$i initResult]} {
871 proc connect-m-response {i} {
875 egw_log debug "connect-m-response"
876 z39$i callback [list init-m-response $i]
877 if {[catch {z39$i init}]} {
883 proc fail-m-response {i} {
887 egw_log debug "fail-m-response"
892 proc search-m-response {setNo i start number} {
897 egw_log debug "search-m-response"
898 set status [z39$i.$setNo responseStatus]
899 egw_log debug "search-m-response1"
900 if {[lindex $status 0] == "OK"} {
902 } elseif {[lindex $status 0] == "DBOSD"} {
903 set nor [z39$i.$setNo numberOfRecordsReturned]
905 egw_log debug "search-m-response2"
910 set hist($setNo,$i,hits) [z39$i.$setNo resultCount]
911 egw_log debug "search-m-response3"
912 set hist($setNo,$i,offset) [expr $start + $nor -1]
913 if {[expr $nor + $start] > [z39$i.$setNo resultCount]} {
914 egw_log debug "search-m-response4"
919 egw_log debug "search-m-response5"
920 if {$nor >= $number} {
921 egw_log debug "search-m-response6 nor=$nor number=$number"
926 egw_log debug "search-m-response7"
927 set start [expr $start + $nor]
928 set number [expr $number - $nor]
929 if {[expr $start + $number - 1] > [z39$i.$setNo resultCount]} {
930 set number [expr [z39$i.$setNo resultCount] - $start + 1]
932 z39$i callback [list search-m-response $setNo $i $start $number]
933 egw_log debug "mpresent start=$number number=$number"
934 z39$i.$setNo present $start $number
937 proc z39msearch {setNo elements start number cache} {
944 set not $hist($setNo,0,host)
946 egw_log debug "z39msearch start=$start number=$number elements=$elements"
947 for {set i 1} {$i <= $not} {incr i} {
948 set host $hist($setNo,$i,host)
950 set oldHost [z39$i connect]
951 set thisHost [splitHostSpec $host]
952 if {[string compare $oldHost $thisHost]} {
953 catch {z39$i disconnect}
955 z39$i callback [list connect-m-response $i]
956 z39$i failback [list fail-m-response $i]
959 for {set i 1} {$i <= $not} {incr i} {
960 set oldHost [z39$i connect]
961 set host $hist($setNo,$i,host)
962 set thisHost [splitHostSpec $host]
963 if {![string compare $oldHost $thisHost]} {
966 egw_log debug "old=$oldHost this=$thisHost"
967 z39$i idAuthentication $hist($setNo,$i,idAuthentication)
968 html "Connecting to target " $thisHost " <br>\n"
970 if {![catch {z39$i connect $thisHost}]} {
975 egw_log debug "Waiting for init response"
976 if {[catch {egw_wait zleft 20}]} {
981 for {set i 1} {$i <= $not} {incr i} {
982 set host $hist($setNo,$i,host)
984 html "host " [splitHostSpec $host] ": "
986 egw_log debug "i=$i zstatus=$zstatus($i)"
987 if {$zstatus($i) < 1} {
993 if {[catch [list z39$i.$setNo preferredRecordSyntax USMARC]]} {
998 if {[lindex $targets($host) 6] == "1"} {
999 wais-set z39$i.$setNo z39$i
1001 ir-set z39$i.$setNo z39$i
1003 set hist($setNo,$i,offset) 0
1004 eval z39$i.$setNo databaseNames $hist($setNo,$i,database)
1006 if {![lindex $targets($hist($setNo,$i,host)) 5]} {
1009 set thisElements $elements
1011 z39$i.$setNo smallSetElementSetNames $thisElements
1012 z39$i.$setNo mediumSetElementSetNames $thisElements
1013 z39$i.$setNo elementSetNames $thisElements
1014 z39$i.$setNo recordElements $thisElements
1016 z39$i.$setNo preferredRecordSyntax USMARC
1017 z39$i callback [list search-m-response $setNo $i $start $number]
1020 z39$i.$setNo largeSetLowerBound 999999
1021 z39$i.$setNo smallSetUpperBound 0
1022 z39$i.$setNo mediumSetPresentNumber $number
1024 z39$i.$setNo largeSetLowerBound 2
1025 z39$i.$setNo smallSetUpperBound 0
1026 z39$i.$setNo mediumSetPresentNumber 0
1030 egw_log debug "setNo=$setNo msearch " $hist($setNo,$i,query)
1031 z39$i.$setNo search $hist($setNo,$i,query)
1032 } elseif {[z39$i.$setNo resultCount] >= $start} {
1033 if {[expr $start + $number - 1] > [z39$i.$setNo resultCount]} {
1034 set tnumber [expr [z39$i.$setNo resultCount] - $start + 1]
1038 if {![lindex $targets($hist($setNo,$i,host)) 5]} {
1041 set thisElements $elements
1043 z39$i.$setNo smallSetElementSetNames $thisElements
1044 z39$i.$setNo mediumSetElementSetNames $thisElements
1045 z39$i.$setNo elementSetNames $thisElements
1046 z39$i.$setNo recordElements $thisElements
1048 for {set n 0} {$n < $tnumber} {incr n} {
1049 if {[z39$i.$setNo recordType [expr $start + $n]] == ""} {
1051 egw_log debug "failed on $n"
1054 html "no record at #" [expr $start + $n]
1055 html " el=-" $thisElements "-"
1060 if {$n == $tnumber} {
1067 html "present<br>\n"
1068 z39$i.$setNo preferredRecordSyntax USMARC
1069 z39$i callback [list search-m-response $setNo $i $start $tnumber]
1071 egw_log debug "mpresent start=$start number=$tnumber"
1072 z39$i.$setNo present $start $tnumber
1079 while {$zleft > 0} {
1080 egw_log debug "Waiting for search/present response"
1081 if {[catch {egw_wait zleft 60}]} {
1085 for {set i 1} {$i <= $not} {incr i} {
1086 if {$zstatus($i) != 2} continue
1087 set status [z39$i.$setNo responseStatus]
1088 if {0 && [lindex $status 0] != "NSD"} {
1089 set hist($setNo,$i,offset) [z39$i.$setNo numberOfRecordsReturned]
1094 proc z39present {setNo tno setOffset setMax dfunc elements} {
1101 set host $hist($setNo,$tno,host)
1104 set host $hist($setNo,host)
1107 if {![lindex $targets($host) 5]} {
1111 $zz.$setNo elementSetNames $elements
1112 $zz.$setNo recordElements $elements
1113 set toGet [expr 1 + $setMax - $setOffset]
1115 $zz callback [list search-response $zz.$setNo]
1117 while {$setMax > 0 && $toGet > 0} {
1118 for {set got 0} {$got < $toGet} {incr got} {
1119 if {[$zz.$setNo recordType [expr $setOffset + $got]] == ""} {
1123 if {$got < $toGet} {
1125 $zz.$setNo present $setOffset $toGet
1126 if {[catch {egw_wait sessionWait 300}]} {
1127 egw_log debug "timeout/cancel in present"
1131 if {$sessionWait == "0"} {
1134 if {$sessionWait != "1"} {
1137 set got [$zz.$setNo numberOfRecordsReturned]
1142 display-rec $setOffset [expr $got + $setOffset - 1] $dfunc $tno
1143 set setOffset [expr $got + $setOffset]
1144 set toGet [expr 1 + $setMax - $setOffset]
1149 proc z39history {} {
1157 if {![info exists nextSetNo]} {
1160 html "<h2>History</h2><br>\n"
1162 html {<table width=500 border=1><tr>}
1163 html {<td align=center><b>Target</b>}
1164 html {<td align=center><b>Database</b>}
1165 html {<td align=center><b>Hits</b>}
1166 html {<td align=center><b>Query</b>}
1171 for {set setNo 1} {$setNo < $nextSetNo} {incr setNo} {
1172 if {$hist($setNo,scan) > 0} continue
1173 set host $hist($setNo,host)
1175 html {<td align=left>}
1179 html [lindex $targets($host) 0]
1181 html {<td align=left>} [join $hist($setNo,database)]
1183 if {[llength [lindex $targets($host) 1]] > 1} {
1185 foreach b $hist($setNo,database) {
1192 html {<td align=right>}
1194 if {[info exists hist($setNo,hits)]} {
1195 html { <a href="http:} $env(SCRIPT_NAME)
1196 html / $sessionId {/search.egw/} $setNo + 1
1197 html + $hist($setNo,maxPresent)
1199 html {">} $hist($setNo,hits) {</a>}
1201 html {">Result</a>: } $hist($setNo,hits) { hits.}
1207 html {Search failed.}
1211 html {<td align=left>}
1215 html { <a href="http:} $env(SCRIPT_NAME)
1216 html / $sessionId {/query.egw/} $host + $setNo
1220 html {">Query</a>: }
1223 for {set i 1} {$i <= 3} {incr i} {
1224 if {[string length $hist($setNo,form,entry$i)] > 0} {
1225 html " <b>" [join $op " "] "</b> "
1226 html [join $hist($setNo,form,menu$i)] "="
1227 html $hist($setNo,form,entry$i)
1228 set op $hist($setNo,form,logic$i)
1232 html {</a><tr>} "\n"
1243 proc displayError {msga msgb} {
1244 html "<p><center>\n"
1245 html {<img src="/egwgif/noway.gif" alt="Error">}
1246 html "<h2>" $msga "</h2>\n"
1248 html "<h3>" $msgb "</h3>\n"
1250 html "</center><p>\n"
1253 proc button-europagate {} {
1255 html {<a href="http://europagate.dtv.dk/">}
1257 html {<img src="/egwgif/button-egw.gif" alt="Europagate" border=0></a>}
1259 html {Europagate</a> | }
1263 proc button-define-target {more} {
1268 html {<a href="http:} $env(SCRIPT_NAME)
1269 html / $sessionId {/tform.egw}
1271 html {"><img src="/egwgif/button-define-target.gif" }
1272 html {alt="Define Target" border=0></a>}
1274 html {">Define Target</a>}
1283 proc button-new-target {more} {
1289 html {<a href="http:} $env(SCRIPT_NAME)
1292 html {/mtargets.egw}
1297 html {"><img src="/egwgif/button-new-target.gif" }
1298 html {alt="New Target" border=0></a>}
1300 html {">New Target</a>}
1309 proc button-view-history {more} {
1315 html {<a href="http:} $env(SCRIPT_NAME)
1316 html / $sessionId {/history.egw;}
1317 catch { html "/" $nextSetNo}
1319 html {"><img src="/egwgif/button-view-history.gif" alt="View History" }
1320 html {border=0></a>}
1322 html {">View History</a>}
1331 proc button-new-query {more setNo} {
1338 html {<a href="http:} $env(SCRIPT_NAME)
1341 html {/mquery.egw/} $setNo
1343 html {/query.egw/} $hist($setNo,host) + $setNo
1347 html {<img src="/egwgif/button-new-query.gif" }
1348 html {alt="New Query" border=0></a>}
1350 html {New Query</a>}
1359 proc button-scan-window {more setNo} {
1365 html {<a href="http:} $env(SCRIPT_NAME)
1366 html / $sessionId {/search.egw/} $setNo + {scan} {">}
1368 html {<img src="/egwgif/button-scan-window.gif" }
1369 html {alt="Scan" border=0></a>}
1380 proc maintenance {} {
1381 html {<hr>This page is maintained by }
1382 html {<a href="mailto:pwh@dtv.dk"> Peter Wad Hansen </a>.}
1383 html {Last modified 29. january 1996. <br>}
1384 html {<em> This and the following pages are under construction and }
1385 html {will continue to be so until the end of January 1996.</em>}
1388 proc splitHostSpec {host} {
1389 set i [string last . $host]
1392 return [string range $host 0 $i]
1397 proc mergeHostSpec {host databases} {
1398 return ${host}.[join $databases -]
1401 proc mkAssoc {assoc host} {
1404 if {[catch {$assoc failback fail-response}]} {
1405 if {[lindex $targets($host) 6] == "1"} {
1411 if {[lindex $targets($host) 6] == "1"} {
1412 if {[$assoc comstack] == "wais"} return
1415 if {[$assoc comstack] == "tcpip"} return