Home | History | Annotate | Line # | Download | only in tcl_scripts
      1  1.1  christos #	Id: mailprocs.tcl,v 8.3 1996/04/29 12:31:35 bostic Exp  (Berkeley) Date: 1996/04/29 12:31:35
      2  1.1  christos #
      3  1.1  christos proc validLine {} {
      4  1.1  christos 	global viScreenId
      5  1.1  christos 	set line [viGetLine $viScreenId [lindex [viGetCursor $viScreenId] 0]]
      6  1.1  christos 	if {[string compare [lindex [split $line :] 0]	"To"] == 0} {
      7  1.1  christos 		set addrs [lindex [split $line :] 1]
      8  1.1  christos 		foreach name [split $addrs ,] {
      9  1.1  christos 			isValid [string trim $name]
     10  1.1  christos 		}
     11  1.1  christos 	}
     12  1.1  christos }
     13  1.1  christos 
     14  1.1  christos proc valid {target} {
     15  1.1  christos 	set found 0
     16  1.1  christos 	set aliasFile [open "~/Mail/aliases" r]
     17  1.1  christos 	while {[gets $aliasFile line] >= 0} {
     18  1.1  christos 		set name [lindex [split $line :] 0]
     19  1.1  christos 		set address [lindex [split $line :] 1]
     20  1.1  christos 		if {[string compare $target $name] == 0} {
     21  1.1  christos 			set found 1
     22  1.1  christos 			break
     23  1.1  christos 		}
     24  1.1  christos 	}
     25  1.1  christos 	close $aliasFile
     26  1.1  christos 	if {$found == 1} {
     27  1.1  christos 		return $address
     28  1.1  christos 	} else {
     29  1.1  christos 		return $found
     30  1.1  christos 	}
     31  1.1  christos }
     32  1.1  christos 
     33  1.1  christos proc isValid {target} {
     34  1.1  christos 	global viScreenId
     35  1.1  christos 	set address [valid $target]
     36  1.1  christos 	if {$address != 0} {
     37  1.1  christos 		viMsg $viScreenId "$target is [string trim $address]"
     38  1.1  christos 	} else {
     39  1.1  christos 		viMsg $viScreenId "$target not found"
     40  1.1  christos 	}
     41  1.1  christos }
     42  1.1  christos 
     43  1.1  christos proc isAliasedLine {} {
     44  1.1  christos 	global viScreenId
     45  1.1  christos 	set line [viGetLine $viScreenId [lindex [viGetCursor $viScreenId] 0]]
     46  1.1  christos 	if {[string match [lindex [split $line :] 0] "*To"] == 0} {
     47  1.1  christos 		set addrs [lindex [split $line :] 1]
     48  1.1  christos 		foreach name [split $addrs ,] {
     49  1.1  christos 			isAliased [string trim $name]
     50  1.1  christos 		}
     51  1.1  christos 	}
     52  1.1  christos }
     53  1.1  christos 
     54  1.1  christos proc aliased {target} {
     55  1.1  christos 	set found 0
     56  1.1  christos 	set aliasFile [open "~/Mail/aliases" r]
     57  1.1  christos 	while {[gets $aliasFile line] >= 0} {
     58  1.1  christos 		set name [lindex [split $line :] 0]
     59  1.1  christos 		set address [lindex [split $line :] 1]
     60  1.1  christos 		if {[string compare $target [string trim $address]] == 0} {
     61  1.1  christos 			set found 1
     62  1.1  christos 			break
     63  1.1  christos 		}
     64  1.1  christos 	}
     65  1.1  christos 	close $aliasFile
     66  1.1  christos 
     67  1.1  christos 	return $found
     68  1.1  christos }
     69  1.1  christos 
     70  1.1  christos proc isAliased {target} {
     71  1.1  christos 	global viScreenId
     72  1.1  christos 	set found [aliased $target]
     73  1.1  christos 
     74  1.1  christos 	if {$found} {
     75  1.1  christos 		viMsg $viScreenId "$target is aliased to [string trim $name]"
     76  1.1  christos 	} else {
     77  1.1  christos 		viMsg $viScreenId "$target not aliased"
     78  1.1  christos 	}
     79  1.1  christos }
     80  1.1  christos 
     81  1.1  christos proc appendAlias {target address} {
     82  1.1  christos 	if {![aliased $target]} {
     83  1.1  christos 		set aliasFile [open "~/Mail/aliases" a]
     84  1.1  christos 		puts $aliasFile "$target: $address"
     85  1.1  christos 	}
     86  1.1  christos 	close $aliasFile
     87  1.1  christos }
     88  1.1  christos 
     89  1.1  christos proc expand {} {
     90  1.1  christos 	global viScreenId
     91  1.1  christos 	set row [lindex [viGetCursor $viScreenId] 0]]
     92  1.1  christos 	set column [lindex [viGetCursor $viScreenId] 1]]
     93  1.1  christos 	set line [viGetLine $viScreenId $row]
     94  1.1  christos 	while {$column < [string length $line] && \
     95  1.1  christos 		[string index $line $column] != ' '} {
     96  1.1  christos 		append $target [string index $line $column]
     97  1.1  christos 		incr $column
     98  1.1  christos 	}
     99  1.1  christos 	set found [isValid $target]
    100  1.1  christos }
    101  1.1  christos 
    102  1.1  christos proc cite {} {
    103  1.1  christos 	global viScreenId
    104  1.1  christos 	global viStartLine
    105  1.1  christos 	global viStopLine
    106  1.1  christos 	for {set i $viStartLine} {$i <= $viStopLine} {incr i} {
    107  1.1  christos 		set newLine "> "
    108  1.1  christos 		append newLine [viGetLine $viScreenId $i]
    109  1.1  christos 		viSetLine $viScreenId $i $newLine
    110  1.1  christos 	}
    111  1.1  christos }
    112  1.1  christos 
    113  1.1  christos global viScreenId
    114  1.1  christos viMapKey $viScreenId  isAliasedLine
    115  1.1  christos viMapKey $viScreenId  validLine
    116