|
|
1.1 root 1: # include "defs.h"
2:
3: /*
4: Usage:
5: sendberkmail [-m mach ] [-f addrfrom] [-h hopcnt] -t addrto
6:
7: Archaic Usage:
8: sendberkmail mach:user
9:
10: Send remote mail to user on mach.
11: Only one addrto allowed.
12:
13: Sendberkmail uses the network to send an mmail command
14: to the remote machine. It specifies the source, destination,
15: and a hop count only.
16:
17: Sendberkmail uses the -q option of net, so only error msgs
18: and non-zero return codes will be sent back.
19:
20: It is best to think of sendberkmail as a transport mechanism:
21: It takes mail from one machine to another machine (specified
22: using the -m option) and executes the local mail program
23: there with a to-address of "addrto", and a from-address
24: of "addrfrom". If the -m option is not given, it parses the
25: "addrto" field to get a berkeley network address.
26: This extreme generality is necessary when destinations are on
27: different networks, consider a command from the Ing70:
28:
29: sendberkmail -m csvax -f schmidt@parc -t research!chuck
30:
31: This is clearly a forwarding function- send mail from the Arpanet
32: to the Bell Net, which calls our CSVAX.
33: Alternatively, executed on the CSVAX,
34: sendberkmail -m ing70 -f research!chuck -t schmidt@parc
35: sends mail the other way.
36:
37: There is duplication in the arguments because of
38: a need to convert to labelled parameters.
39: See the note in mmail.c to that effect.
40:
41:
42: Options:
43: -t addrto mail command on remote machine will be
44: fed "addrto" as address
45: -f addrfrom mail will be "From" addrfrom
46: -m mach send this mail to the "mach" machine
47: -h hopcnt if this hopcnt hits a threshold, there
48: is presumed to be an infinite loop.
49:
50: Exit Codes:
51: Returns the net commands return code normally.
52: 101 The net cmd wont exec.
53: 102 Bad userid/name.
54: 103 Mail is to the local machine.
55: 104 Wrong # arguments.
56: */
57: main(argc,argv)
58: char **argv; {
59: char addrto[BUFSIZ], addrfrom[BUFSIZ];
60: char mchto = 0, snto[NS], *snfrom, smchto[20];
61: int cmdstr[BUFSIZ], hopcntstr[20];
62: char rcmd[BUFSIZ];
63: int hopcnt = 0;
64:
65: argc[argv] = 0;
66: debugflg = DBV;
67: addrfrom[0] = 0;
68: addrto[0] = 0;
69:
70: while(argc > 1 && argv[1][0] == '-'){
71: argc--; argv++;
72: switch(argv[0][1]){
73: case 'f':
74: harg(addrfrom,&argc,&argv);
75: break;
76: case 'h':
77: harg(hopcntstr,&argc,&argv);
78: hopcnt = atoi(hopcntstr);
79: break;
80: case 'm':
81: harg(smchto,&argc,&argv);
82: mchto = lookup(smchto);
83: break;
84: case 't':
85: harg(addrto,&argc,&argv);
86: break;
87: /* it is important to ignore unknown flags
88: for compatibility reasons */
89: }
90: }
91:
92: /* handle to address */
93: if(argc > 1)strcpy(addrto,argv[1]);
94: if(addrto[0] == 0){
95: fprintf(stderr,"Usage: sendberkmail mach:user\n");
96: exit(104);
97: }
98: if(mchto == 0)
99: mchto = MchSFromAddr(snto,addrto);
100: else
101: strcpy(snto,addrto);
102: if(mchto == 0 || mchto == local){
103: fprintf(stderr,
104: "Use mail to send to %s on this machine. Mail not delivered.\n",
105: addrto);
106: exit(103);
107: }
108: sprintf(rcmd,"mail %s",addrto);
109:
110: /* handle from address */
111: snfrom = SnCurrent();
112: if(snfrom == NULL){
113: fprintf(stderr,"Unknown userid\n");
114: exit(102);
115: }
116: if(addrfrom[0] == 0)
117: sprintf(addrfrom,"%s:%s",longname(local),snfrom);
118:
119: /* uses both old and new options of mmail */
120: /* compatibility problems
121: sprintf(cmdstr,"%s %s %s %s -f %s -t %s -h %d", MMAILCMD,snfrom,
122: longname(local),snto,addrfrom,addrto,hopcnt);
123: */
124: sprintf(cmdstr,"%s %s %s %s", MMAILCMD,snfrom,
125: longname(local),snto);
126:
127:
128: mexecl(netcmd,"net","-m",longname(mchto),"-q","-l","network",
129: "-","-c",rcmd,cmdstr,0);
130: fprintf(stderr,"Network is down\n");
131: exit(101);
132: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.