home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume25 / smail-deliver.pch / X.mn.post < prev   
Text File  |  1992-01-11  |  1KB  |  51 lines

  1. #!/bin/perl
  2. # Post-user delivery file that supports Xenix Micnet.
  3. #
  4. # If you want to support Micnet with Deliver, then install this file
  5. # as /usr/local/lib/deliver.post.  This file reads the Micnet topology
  6. # file and automatically converts "micnethost!user" to "micnethost:user".
  7. # It's a good example of the flexibility of Deliver and Perl.
  8. #
  9. # NOTE:  Be sure that you have Deliver 2.0 patchlevel 9 or higher.
  10.  
  11. # Various constants
  12.  
  13. $SENDER = $ENV{'SENDER'};
  14. $MAILCLN = "/usr/lib/mail/mail.cln";
  15.  
  16. # Figure out Micnet topology
  17.  
  18. &read_top;
  19.  
  20. # Parse addresses
  21.  
  22. for $a (@ARGV) {
  23.     if (($host, $rest) = ($a =~ /^([^!]+)!([^!]+)$/)) {
  24.         if ($MICNET{$host}) {
  25.             print "|$MAILCLN -h 0 '$host' '$SENDER' '$rest'\n";
  26.         }
  27.         else {
  28.             print $a, "\n";
  29.         }
  30.     }
  31.     else {
  32.         print $a, "\n";
  33.     }
  34. }
  35.  
  36. # Read Micnet topology file, collecting hostnames.
  37.  
  38. sub read_top {
  39.     return unless open(TOP, "/usr/lib/mail/top");
  40.     while (<TOP>) {
  41.         chop;
  42.         s/#.*//;
  43.         next if /^\s*$/;
  44.         ($host1, $tty1, $host2, $tty2, $speed) = split;
  45.         next unless $speed;
  46.         $MICNET{$host1} = 1;
  47.         $MICNET{$host2} = 1;
  48.     }
  49.     close(TOP);
  50. }
  51.