send.exp
2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2004, Free Software Foundation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.
set chan [open ${srcdir}/Data r]
set state 0
set command ""
for {gets $chan line} {![eof $chan]} {gets $chan line} {
verbose "LINE $line" 1
switch -regexp -- "$line" {
"^#.*" { }
"^MESSAGE END" {
verbose "MAIL FROM $from" 1
verbose "MAIL TO $to" 1
verbose "INPUT $input" 1
verbose "OPTIONS $options" 1
verbose "PATTERN $pattern" 1
set args ""
if {$from != ""} {
append args " --from $from"
}
if {$options != ""} {
append args " $options"
}
if {$to != ""} {
append args " $to"
}
mail_remote_test -message $message -input $input \
-pattern $pattern -args $args
set state 0
}
"^MESSAGE" {
regexp "^MESSAGE (.*)" $line dummy message
set from ""
set to ""
set options ""
set input [list]
set pattern [list]
set state 1
}
"^FROM" {
regexp "^FROM (.*)" $line dummy from
}
"^TO" {
regexp "^TO (.*)" $line dummy to
}
"^OPTIONS" {
regexp "^OPTIONS (.*)" $line dummy options
}
"^BODY BEGIN" {
set state 2
}
"^BODY END" {
set state 1
}
"^PATTERN BEGIN" {
set state 3
}
"^PATTERN END" {
set state 1
}
"^STOP" {
break
}
default {
if {$state == 2} {
lappend input $line
} elseif {$state == 3} {
lappend pattern $line
}
}
}
}
close $chan
# End of send.exp