# Copyright for the Uniform Repository Service (c) 1995 - 2000, # by Gerald Banon. All rights reserved. # Version 2.1 # mirrorfind2-.tcl # not used # example: http://banon-pc.dpi.inpe.br:1905/find2-/dpi.inpe.br/banon/1999/06.19.17.00?query=ti+Zip # opens the target file (if the repository exists) # example: http://banon-pc.dpi.inpe.br:1905/find2-/dpi.inpe.br/banon/1999/06.19.17.00?query=ti+Zip&file=zip/README # opens the named file (if the repository exists) # # example: http://banon-pc.dpi.inpe.br:1907/find-/dpi.inpe.br/banon/2000/02.15.11.38.51?query=tit+Framing # opens the target file (if the repository exists) # example: http://banon-pc.dpi.inpe.br:1907/find-/dpi.inpe.br/banon/2000/02.15.11.38.51?query=tit+Framing&file=ch12.htm # opens the named file (if the repository exists) # example: http://banon-pc.dpi.inpe.br:1907/find-/dpi.inpe.br/banon/2000/02.15.11.38.51?query=tit+Framing&file=ch12.htm&repository=dpi.inpe.br/banon/1999/07.30.23.45 # example: http://banon-pc.dpi.inpe.br:1907/find-/dpi.inpe.br/banon/2000/02.15.11.38.51?query=tit+Framing&file=ch2.htm&repository=dpi.inpe.br/banon/1999/07.30.23.45 # opens the named file if it exists otherwise opens the target file # of the named repository. # ---------------------------------------------------------------------- # Submit proc Submit {sock line {async {0}}} { global x y ;# for unix if $async { # set x 0 ;# doesn't work properly with this line (mosaic) fileevent $sock writable {set x 1}; vwait x } puts $sock $line # set y 0 ;# doesn't work properly with this line (mosaic) fileevent $sock readable {set y 1}; vwait y gets $sock line # puts [list $sock eof = [eof $sock]
] # close $sock return $line } # Submit - end # ---------------------------------------------------------------------- # StartCommunication # async values are 0 or 1 # 1 means -async proc StartCommunication {host port {async {0}}} { if $async { set s [socket -async $host $port] } else { set s [socket $host $port] } fconfigure $s -buffering line return $s } # StartCommunication - end # ---------------------------------------------------------------------- # Execute # example: # set metadata2List [Execute $site \ [list GetMetadata $callingRep-0,metadatalastupdate]] proc Execute {site command} { regexp {(.*):(.*)} $site m serverName serverPort set localURLibClientSocketId \ [StartCommunication $serverName ${serverPort}0 1] set output [Submit $localURLibClientSocketId $command 1] close $localURLibClientSocketId return $output } # Execute - end # ---------------------------------------------------------------------- # Find2- proc Find2- {} { global env # site # set site $env(HTTP_HOST) set site $env(SERVER_NAME):$env(SERVER_PORT) set envList {} set envList [concat $envList [array get env QUERY_STRING]] set envList [concat $envList [array get env PATH_INFO]] set envList [concat $envList [array get env SERVER_NAME]] set envList [concat $envList [array get env SERVER_PORT]] set envList [concat $envList [array get env DOCUMENT_ROOT]] set envList [concat $envList [array get env LOCOINREP]] set output [Execute $site [list Find- [pid] $envList]] foreach line $output { puts $line } } # Find2- - end # ----------------------------------------------------------------------