116 |
set sw "" |
set sw "" |
117 |
} |
} |
118 |
|
|
119 |
anubis_version |
default_anubis_version |
120 |
|
|
121 |
set default 0 |
set default 0 |
122 |
set message "" |
set message "" |
183 |
} |
} |
184 |
set regexp 0 |
set regexp 0 |
185 |
|
|
186 |
switch -regexp -- "[lindex $args $i]" { |
switch -exact -- "[lindex $args $i]" { |
187 |
^-re { set regexp 1; incr i } |
-re { set regexp 1; incr i } |
188 |
^-ex - |
-ex - |
189 |
^-- { incr i } |
-- { incr i } |
190 |
} |
} |
191 |
|
|
192 |
set pattern [lindex $args $i] |
set pattern [lindex $args $i] |
238 |
return $result |
return $result |
239 |
} |
} |
240 |
|
|
241 |
proc anubis_version {} { |
proc default_anubis_version {} { |
242 |
global ANUBIS_TOOL |
global ANUBIS_TOOL |
243 |
global ANUBIS_TOOL_FLAGS |
global ANUBIS_TOOL_FLAGS |
244 |
global ANUBIS_TOOL_VERSION |
global ANUBIS_TOOL_VERSION |
245 |
global ANUBIS_CAPABILITY |
global ANUBIS_CAPABILITY |
246 |
|
|
247 |
if [info exists ANUBIS_TOOL_VERSION] { |
if [info exists ANUBIS_TOOL_VERSION] { |
248 |
return |
return |
249 |
} |
} |
251 |
set output [remote_exec host "$ANUBIS_TOOL --show-config-options"] |
set output [remote_exec host "$ANUBIS_TOOL --show-config-options"] |
252 |
set flg [split [lindex $output 1]] |
set flg [split [lindex $output 1]] |
253 |
for {set i 0} {$i < [llength $flg]} {incr i} { |
for {set i 0} {$i < [llength $flg]} {incr i} { |
254 |
if [regexp "(.*)=(.*)" [lindex $flg $i] var name value] { |
if [regexp "(.*)=(.*)$" [lindex $flg $i] var name value] { |
255 |
set ANUBIS_CAPABILITY($name) $value |
set ANUBIS_CAPABILITY($name) $value |
256 |
} else { |
} elseif {[lindex $flg $i] != ""} { |
257 |
set ANUBIS_CAPABILITY([lindex $flg $i]) 1 |
set ANUBIS_CAPABILITY([lindex $flg $i]) 1 |
258 |
} |
} |
259 |
} |
} |
264 |
} |
} |
265 |
} |
} |
266 |
|
|
267 |
|
proc anubis_version {} { |
268 |
|
default_anubis_version |
269 |
|
} |
270 |
|
|
271 |
|
proc anubis_check_capability {args} { |
272 |
|
global ANUBIS_CAPABILITY |
273 |
|
|
274 |
|
set name [lindex $args 0] |
275 |
|
|
276 |
|
if {![info exists ANUBIS_CAPABILITY] || \ |
277 |
|
![info exists ANUBIS_CAPABILITY($name)]} { |
278 |
|
return 0 |
279 |
|
} else { |
280 |
|
return $ANUBIS_CAPABILITY($name) |
281 |
|
} |
282 |
|
} |
283 |
|
|
284 |
proc anubis_send { string } { |
proc anubis_send { string } { |
285 |
global suppress_flag; |
global suppress_flag; |
286 |
if {[info exists suppress_flag] && $suppress_flag} { |
if {[info exists suppress_flag] && $suppress_flag} { |
386 |
set result 0 |
set result 0 |
387 |
for {set i 0} {$i < [llength $pattern]} {incr i} { |
for {set i 0} {$i < [llength $pattern]} {incr i} { |
388 |
set regexp 0 |
set regexp 0 |
389 |
switch -regexp -- "[lindex ${pattern} $i]" { |
switch -exact -- "[lindex ${pattern} $i]" { |
390 |
^-re.*$ { set regexp 1; incr i } |
-re { set regexp 1; incr i } |
391 |
^-- { incr i } |
-- { incr i } |
392 |
} |
} |
393 |
|
|
394 |
regsub "\[ \t\]*$" [lindex ${pattern} $i] "" pat |
regsub "\[ \t\]*$" [lindex ${pattern} $i] "" pat |
395 |
verbose "i=$i, pat=$pat" 2 |
verbose "i=$i, pat=$pat, regexp=$regexp" 2 |
396 |
|
|
397 |
if {$regexp} { |
if {$regexp} { |
398 |
verbose "REGEX for $pat / [llength $pat] " 3 |
verbose "REGEX for $pat / [llength $pat] " 3 |
499 |
|
|
500 |
set result 0 |
set result 0 |
501 |
for {set i 0} {$result == 0 && $i < [llength $pattern]} {incr i} { |
for {set i 0} {$result == 0 && $i < [llength $pattern]} {incr i} { |
502 |
|
verbose "NEXT ($i)" |
503 |
set regexp 0 |
set regexp 0 |
504 |
switch -regexp -- "[lindex ${pattern} $i]" { |
switch -exact -- "[lindex ${pattern} $i]" { |
505 |
^-re.*$ { set regexp 1; incr i } |
-re { set regexp 1; incr i } |
506 |
^-- { incr i } |
-- { incr i } |
507 |
} |
} |
508 |
|
|
509 |
regsub "\[ \t\]*$" [lindex ${pattern} $i] "" pat |
regsub "\[ \t\]*$" [lindex ${pattern} $i] "" pat |
510 |
verbose "i=$i, pat=$pat" 2 |
verbose "i=$i, pat=$pat, regexp=$regexp" 2 |
511 |
|
|
512 |
if {$regexp} { |
if {$regexp} { |
513 |
verbose "REGEX for $pat / [llength $pat] " 3 |
verbose "REGEX for $pat / [llength $pat] " 3 |
568 |
|
|
569 |
set default "" |
set default "" |
570 |
set message "" |
set message "" |
571 |
|
set catprog "/bin/cat" |
572 |
|
|
573 |
for {set i 0} {$i < [llength $args]} {incr i} { |
for {set i 0} {$i < [llength $args]} {incr i} { |
574 |
set a [lindex $args $i] |
set a [lindex $args $i] |
575 |
if {"$a" == "-default"} { |
if {"$a" == "-default"} { |
581 |
} elseif {"$a" == "-message"} { |
} elseif {"$a" == "-message"} { |
582 |
incr i |
incr i |
583 |
set message [lindex $args $i] |
set message [lindex $args $i] |
584 |
|
} elseif {"$a" == "-catprog"} { |
585 |
|
incr i |
586 |
|
set catprog [lindex $args $i] |
587 |
} else { |
} else { |
588 |
set args [lrange $args $i end] |
set args [lrange $args $i end] |
589 |
break |
break |
603 |
set pattern [lrange $args 1 end] |
set pattern [lrange $args 1 end] |
604 |
} |
} |
605 |
|
|
606 |
set res [remote_spawn host "/bin/cat $filename"] |
set res [remote_spawn host "$catprog $filename"] |
607 |
if { $res < 0 || $res == "" } { |
if { $res < 0 || $res == "" } { |
608 |
perror "Reading $filename failed." |
perror "Reading $filename failed." |
609 |
return 1; |
return 1; |
632 |
# 0 -- command |
# 0 -- command |
633 |
# 1 -- pattern |
# 1 -- pattern |
634 |
proc anubis_pat {patname} { |
proc anubis_pat {patname} { |
635 |
|
global ANUBIS_DATA_DIR |
636 |
global ANUBIS_ETC_DIR |
global ANUBIS_ETC_DIR |
637 |
global ANUBIS_RC_DIR |
global ANUBIS_RC_DIR |
638 |
|
global gpg_prog |
639 |
|
|
640 |
verbose "ANUBIS_PAT $patname" 1 |
verbose "ANUBIS_PAT $patname" 1 |
641 |
set chan [open $ANUBIS_ETC_DIR/$patname r] |
set chan [open $ANUBIS_ETC_DIR/$patname r] |
658 |
} |
} |
659 |
"^:OPTIONS" { |
"^:OPTIONS" { |
660 |
regexp "^:OPTIONS (.*)" $line dummy opt |
regexp "^:OPTIONS (.*)" $line dummy opt |
661 |
lappend options $opt |
set x [split $opt] |
662 |
|
for {set n 0} {$n < [llength $x]} {incr n} { |
663 |
|
set opt [lindex $x $n] |
664 |
|
switch -re -- "$opt" { |
665 |
|
"^\\$.*" { lappend options [expr $opt] } |
666 |
|
default { if {$opt != ""} { |
667 |
|
lappend options $opt |
668 |
|
} |
669 |
|
} |
670 |
|
} |
671 |
|
} |
672 |
} |
} |
673 |
"^:RCFILE" { |
"^:RCFILE" { |
674 |
regexp "^:RCFILE (.*)" $line dummy rcfile |
regexp "^:RCFILE (.*)" $line dummy rcfile |
680 |
set state 1 |
set state 1 |
681 |
} |
} |
682 |
"^:END" { |
"^:END" { |
683 |
|
verbose "MODE $mode" |
684 |
if {$mode == "EXEC"} { |
if {$mode == "EXEC"} { |
685 |
set inv anubis_exec |
set inv anubis_exec |
686 |
if {$options != ""} { |
if {$options != ""} { |
716 |
if [regexp "^:EXPECT (.*)" $line dummy expect] { |
if [regexp "^:EXPECT (.*)" $line dummy expect] { |
717 |
anubis_expect {-re "$expect\[^\n\]*\n"} |
anubis_expect {-re "$expect\[^\n\]*\n"} |
718 |
} elseif [regexp "^:ADD (.*)" $line dummy expect] { |
} elseif [regexp "^:ADD (.*)" $line dummy expect] { |
719 |
lappend file_pattern $expect |
if [regexp "^-- (.*)" $expect dummy str] { |
720 |
|
lappend file_pattern "--" |
721 |
|
set expect $str |
722 |
|
} elseif [regexp "^-re (.*)" $expect dummy str] { |
723 |
|
lappend file_pattern "-re" |
724 |
|
set expect $str |
725 |
|
} |
726 |
|
lappend file_pattern "$expect" |
727 |
} elseif [regexp "^:DEL (.*)" $line dummy expect] { |
} elseif [regexp "^:DEL (.*)" $line dummy expect] { |
728 |
verbose "DEL:: $expect" |
verbose "DEL:: $expect" |
729 |
anubis_command "$expect" |
anubis_command "$expect" |
739 |
} |
} |
740 |
lappend inv "$ANUBIS_RC_DIR/mta.log" |
lappend inv "$ANUBIS_RC_DIR/mta.log" |
741 |
eval $inv $file_pattern |
eval $inv $file_pattern |
742 |
|
} elseif {$mode == "CAT"} { |
743 |
|
verbose "OPT $options" |
744 |
|
set inv anubis_test_file |
745 |
|
lappend inv -catprog [concat $options] |
746 |
|
lappend inv "$ANUBIS_RC_DIR/mta.log" |
747 |
|
eval $inv $pattern |
748 |
} |
} |
|
|
|
749 |
## Reset all variables |
## Reset all variables |
750 |
|
set pattern "" |
751 |
|
set file_pattern "" |
752 |
set options "" |
set options "" |
753 |
set testname "" |
set testname "" |
754 |
set mode "" |
set mode "" |