+proc RobotStartJob {fname t} {
+ global control
+
+
+ set f [open $fname r]
+ set xml [read $f]
+ puts "Reading $fname"
+ regexp {<status>([^<]*)</status>} $xml x status
+ close $f
+ if {$status == "done"} {
+ puts "already done"
+ return
+ }
+ puts "status = $status"
+ if {![task $t]} {
+ return
+ }
+ htmlSwitch $xml \
+ url {
+ url $body
+ } filter {
+ set type $parm(type)
+ set action $parm(action)
+ if {$type == "domain"} {
+ $action url http://$body/*
+ }
+ if {$type == "url"} {
+ $action url $body
+ }
+ if {$type == "mime"} {
+ $action mime $body
+ }
+ } distance {
+ set control($t,distance) $body
+ } status {
+ set control($t,filestatus) $body
+ }
+ if {$status == "pending"} {
+ regsub {<status>[^<]*</status>} $xml {<status>running</status>} xml2
+ set f [open $fname w]
+ puts -nonewline $f $xml2
+ close $f
+ }
+}
+
+proc RobotDoneJob {t} {
+ global daemon_dir
+
+ if {![info exists daemon_dir]} {
+ return
+ }
+
+ set fname $t.tkl
+
+ set f [open $fname r]
+ set xml [read $f]
+ puts "Reading $fname"
+ regexp {<status>([^<]*)</status>} $xml x status
+ puts "------"
+ puts "status = $status"
+ close $f
+
+ regsub {<status>[^<]*</status>} $xml {<status>done</status>} xml2
+ set f [open $fname w]
+ puts -nonewline $f $xml2
+ close $f
+}
+
+proc RobotScanDir {} {
+ global daemon_dir
+
+ if {![info exists daemon_dir]} {
+ return
+ }
+ foreach d $daemon_dir {
+ if {[catch {set files [glob $d/*.tkl]}]} {
+ return
+ }
+ foreach fname $files {
+ if {[file isfile $fname] && [file readable $fname]} {
+ set t [file rootname $fname]
+ RobotStartJob $fname $t
+ }
+ }
+ }
+}
+
+proc RobotRR {task} {
+ global robotSeq robotsRunning tasks robotsMax status
+
+ puts "RobotRR -- running=$robotsRunning max=$robotsMax---------------"