minix/external/bsd/nvi/dist/tcl_scripts/mailprocs.tcl
Lionel Sambuc 84d9c625bf Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
2014-07-28 17:05:06 +02:00

116 lines
2.6 KiB
Tcl
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Id: mailprocs.tcl,v 8.3 1996/04/29 12:31:35 bostic Exp (Berkeley) Date: 1996/04/29 12:31:35
#
proc validLine {} {
global viScreenId
set line [viGetLine $viScreenId [lindex [viGetCursor $viScreenId] 0]]
if {[string compare [lindex [split $line :] 0] "To"] == 0} {
set addrs [lindex [split $line :] 1]
foreach name [split $addrs ,] {
isValid [string trim $name]
}
}
}
proc valid {target} {
set found 0
set aliasFile [open "~/Mail/aliases" r]
while {[gets $aliasFile line] >= 0} {
set name [lindex [split $line :] 0]
set address [lindex [split $line :] 1]
if {[string compare $target $name] == 0} {
set found 1
break
}
}
close $aliasFile
if {$found == 1} {
return $address
} else {
return $found
}
}
proc isValid {target} {
global viScreenId
set address [valid $target]
if {$address != 0} {
viMsg $viScreenId "$target is [string trim $address]"
} else {
viMsg $viScreenId "$target not found"
}
}
proc isAliasedLine {} {
global viScreenId
set line [viGetLine $viScreenId [lindex [viGetCursor $viScreenId] 0]]
if {[string match [lindex [split $line :] 0] "*To"] == 0} {
set addrs [lindex [split $line :] 1]
foreach name [split $addrs ,] {
isAliased [string trim $name]
}
}
}
proc aliased {target} {
set found 0
set aliasFile [open "~/Mail/aliases" r]
while {[gets $aliasFile line] >= 0} {
set name [lindex [split $line :] 0]
set address [lindex [split $line :] 1]
if {[string compare $target [string trim $address]] == 0} {
set found 1
break
}
}
close $aliasFile
return $found
}
proc isAliased {target} {
global viScreenId
set found [aliased $target]
if {$found} {
viMsg $viScreenId "$target is aliased to [string trim $name]"
} else {
viMsg $viScreenId "$target not aliased"
}
}
proc appendAlias {target address} {
if {![aliased $target]} {
set aliasFile [open "~/Mail/aliases" a]
puts $aliasFile "$target: $address"
}
close $aliasFile
}
proc expand {} {
global viScreenId
set row [lindex [viGetCursor $viScreenId] 0]]
set column [lindex [viGetCursor $viScreenId] 1]]
set line [viGetLine $viScreenId $row]
while {$column < [string length $line] && \
[string index $line $column] != ' '} {
append $target [string index $line $column]
incr $column
}
set found [isValid $target]
}
proc cite {} {
global viScreenId
global viStartLine
global viStopLine
for {set i $viStartLine} {$i <= $viStopLine} {incr i} {
set newLine "> "
append newLine [viGetLine $viScreenId $i]
viSetLine $viScreenId $i $newLine
}
}
global viScreenId
viMapKey $viScreenId  isAliasedLine
viMapKey $viScreenId  validLine