create sys/cdefs.h for db.1.85, if missing
[nvi.git] / tcl_scripts / mailprocs.tcl
blob186f3f872531c79a33571fd70178d52400458e32
1 # $Id: mailprocs.tcl,v 8.3 1996/04/29 12:31:35 bostic Exp $ (Berkeley) $Date: 1996/04/29 12:31:35 $
3 proc validLine {} {
4 global viScreenId
5 set line [viGetLine $viScreenId [lindex [viGetCursor $viScreenId] 0]]
6 if {[string compare [lindex [split $line :] 0] "To"] == 0} {
7 set addrs [lindex [split $line :] 1]
8 foreach name [split $addrs ,] {
9 isValid [string trim $name]
14 proc valid {target} {
15 set found 0
16 set aliasFile [open "~/Mail/aliases" r]
17 while {[gets $aliasFile line] >= 0} {
18 set name [lindex [split $line :] 0]
19 set address [lindex [split $line :] 1]
20 if {[string compare $target $name] == 0} {
21 set found 1
22 break
25 close $aliasFile
26 if {$found == 1} {
27 return $address
28 } else {
29 return $found
33 proc isValid {target} {
34 global viScreenId
35 set address [valid $target]
36 if {$address != 0} {
37 viMsg $viScreenId "$target is [string trim $address]"
38 } else {
39 viMsg $viScreenId "$target not found"
43 proc isAliasedLine {} {
44 global viScreenId
45 set line [viGetLine $viScreenId [lindex [viGetCursor $viScreenId] 0]]
46 if {[string match [lindex [split $line :] 0] "*To"] == 0} {
47 set addrs [lindex [split $line :] 1]
48 foreach name [split $addrs ,] {
49 isAliased [string trim $name]
54 proc aliased {target} {
55 set found 0
56 set aliasFile [open "~/Mail/aliases" r]
57 while {[gets $aliasFile line] >= 0} {
58 set name [lindex [split $line :] 0]
59 set address [lindex [split $line :] 1]
60 if {[string compare $target [string trim $address]] == 0} {
61 set found 1
62 break
65 close $aliasFile
67 return $found
70 proc isAliased {target} {
71 global viScreenId
72 set found [aliased $target]
74 if {$found} {
75 viMsg $viScreenId "$target is aliased to [string trim $name]"
76 } else {
77 viMsg $viScreenId "$target not aliased"
81 proc appendAlias {target address} {
82 if {![aliased $target]} {
83 set aliasFile [open "~/Mail/aliases" a]
84 puts $aliasFile "$target: $address"
86 close $aliasFile
89 proc expand {} {
90 global viScreenId
91 set row [lindex [viGetCursor $viScreenId] 0]]
92 set column [lindex [viGetCursor $viScreenId] 1]]
93 set line [viGetLine $viScreenId $row]
94 while {$column < [string length $line] && \
95 [string index $line $column] != ' '} {
96 append $target [string index $line $column]
97 incr $column
99 set found [isValid $target]
102 proc cite {} {
103 global viScreenId
104 global viStartLine
105 global viStopLine
106 for {set i $viStartLine} {$i <= $viStopLine} {incr i} {
107 set newLine "> "
108 append newLine [viGetLine $viScreenId $i]
109 viSetLine $viScreenId $i $newLine
113 global viScreenId
114 viMapKey $viScreenId \x01 isAliasedLine
115 viMapKey $viScreenId \x02 validLine