2 Proprietary Rand Corporation
, 1981.
3 Further distribution of
this software
4 subject to the terms of the Rand
16 struct swit anyul
[] = {
24 struct swit aleqs
[] = {
26 "edit [<editor>]", 0, /* 1 */
27 "quit [delete]", 0, /* 2 */
28 "send [switches]", 0, /* 3 */
33 struct swit switches
[] = {
34 "editor editor", 0, /* 0 */
35 "form formfile", 0, /* 1 */
49 char buf
[BUFSIZ
], *ed
, *file
, *form
;
50 static char path
[128];
52 char *arguments
[50], **argp
;
55 /*** setbuf(stdout, _sobuf); ***/
59 form
= 0; use
= 0; file
= 0; ed
= 0;
60 cp
= r1bindex(argv
[0], '/');
61 if((cp
= m_find(cp
)) != NULL
) {
62 ap
= brkstring(cp
= getcpy(cp
), " ", "\n");
63 ap
= copyip(ap
, arguments
);
66 VOID
copyip(argv
+1, ap
);
70 switch(smatch(++cp
, switches
)) {
71 case -2:ambigsw(cp
, switches
); /* ambiguous */
74 case -1:fprintf(stderr
, "comp: -%s unknown\n", cp
);
76 case 0: if(!(ed
= *argp
++)) { /* -editor */
77 missing
: fprintf(stderr
, "comp: Missing argument for %s switch\n", argp
[-2]);
81 case 1: if(!(form
= *argp
++)) /* -form */
84 case 2: use
= 1; continue; /* -use */
85 case 3: use
= 0; continue; /* -nouse */
86 case 4: help("comp [file] [switches]",
94 if((in
= open(m_maildir(form
), 0)) < 0) {
95 fprintf(stderr
, "comp: Can't open form file: %s\n", form
);
98 } else if((in
= open(m_maildir(components
), 0)) < 0 &&
99 (in
= open(stdcomps
, 0)) < 0) {
100 fprintf(stderr
, "comp: Can't open default components file!!\n");
105 VOID
copy(m_maildir(file
), path
);
106 if((out
= open(path
, 0)) >= 0) {
107 cp
= concat("\n\"", path
, "\" exists; delete? ", 0);
108 if(use
|| fdcompare(in
, out
))
110 while((status
= gans(cp
, anyul
)) == 3)
120 fprintf(stderr
, "comp: \"%s\" doesn't exist!\n", path
);
123 if((out
= creat(path
, m_gmprot())) < 0) {
124 fprintf(stderr
, "comp: Can't create \"%s\"\n", path
);
128 if(cnt
= read(in
, buf
, sizeof buf
))
129 if(write(out
, buf
, cnt
) != cnt
) {
130 fprintf(stderr
, "comp: error writing ");
134 while(cnt
== sizeof buf
);
138 if(m_edit(&ed
, path
, use
, NULLCP
) < 0)
141 fprintf(stderr
, "!! Test Version of SEND Being Run !!\n");
142 fprintf(stderr
, " Send verbose !\n\n");
146 if(!(argp
= getans("\nWhat now? ", aleqs
)))
148 switch(smatch(*argp
, aleqs
)) {
149 case 0: VOID
showfile(path
); /* list */
152 case 1: if(*++argp
) /* edit */
154 if(m_edit(&ed
, path
, use
, NULLCP
) == -1)
158 case 2: if(*++argp
&& (*argp
[0] == 'd' ||
159 (*argp
[0]=='-' && *argp
[1]=='d')))
160 if(unlink(path
) == -1) {
161 fprintf(stderr
, "Can't unlink %s ", path
);
166 case 3: VOID
m_send(++argp
, path
); /* send */
169 default:fprintf(stderr
, "comp: illegal option\n"); /*##*/