]>
diplodocus.org Git - nmh/blob - docs/historical/SRI-NOSC/write.c
31 struct swit switches
[] {
32 "editor editor", 0, /* 0 */
33 "form formfile", 0, /* 1 */
45 int use
, cnt
, status
, intr
;
46 char buf
[512], path
[128], *ed
, *file
, *vec
[10], *form
;
48 char *arguments
[50], **argp
;
54 form
= use
= file
= ed
= 0;
60 if((cp
= m_find(ap
)) != -1) {
61 ap
= brkstring(cp
= getcpy(cp
), " ", '\n');
62 ap
= copyip(ap
, arguments
);
69 switch(smatch(++cp
, switches
)) {
70 case -2:ambigsw(cp
, switches
); /* ambiguous */
73 case -1:printf("-%s unknown\n", cp
);
75 case 0: if(!(ed
= *argp
++)) { /* -editor */
76 missing
: printf("Missing argument for %s switch\n", argp
[-2]);
80 case 1: if(!(form
= *argp
++)) /* -form */
83 case 2: use
= 1; continue; /* -use */
84 case 3: use
= 0; continue; /* -nouse */
85 case 4: help(concat( inp
, " [file] [switches]", 0),
93 if((in
= open(m_maildir(form
), 0)) < 0) {
94 printf("Can't open form file: %s\n", form
);
97 } else if((in
= open(m_maildir(components
), 0)) < 0 &&
98 (in
= open(stdcomps
, 0)) < 0) {
99 printf("Can't open default components file!!\n");
104 copy(m_maildir(file
), path
);
105 if((out
= open(path
, 0)) >= 0) {
106 if(use
|| fdcompare(in
, out
))
109 cp = concat("\"", path, "\" exists; delete? ", 0);
110 while((status = gans(cp, anyus)) == 3)
121 printf("\"%s\" doesn't exist!\n", path
);
124 if((out
= creat(path
, m_gmprot())) < 0) {
125 printf("Can't create \"%s\"\n", path
);
129 if(cnt
= read(in
, buf
, sizeof buf
))
130 write(out
, buf
, cnt
);
131 while(cnt
== sizeof buf
);
135 if(!ed
&& (ed
= m_find("editor")) == -1)
141 intr
= signal(SIGINT
, 1);
142 if((in
= fork()) == 0) {
145 execlsrh(ed
, path
, 0);
146 printf("Can't exec editor!!\n");
148 } else if(in
== -1) {
149 printf("No forks!\n");
152 while((out
= waita(&status
)) != -1 && out
!= in
) ;
154 printf("[command aborted--%s ", file
);
155 if(!use
&& status
> 0377) {
157 printf("deleted]\n");
159 printf("preserved]\n");
162 signal(SIGINT
, intr
);
164 printf("!! Test Version of SEND Being Run !!\n");
165 printf(" Send verbose !\n\n");
167 /* in = concat("Send \"", file, "\"? ", 0); */
169 /*** printf("Send \"%s\"? ", file); ***/
170 if((out
= gans(in
, anyv
)) > 0) {
172 vec
[in
++] = "mh-sndproc";
175 vec
[in
++] = "-verbose";
180 printf("Can't exec send process.\n");