Commit fa4b22e0 fa4b22e0c2b3c2a3aca79850229d271b66266793 by Sergey Poznyakoff

Implemented "set ignore", "set ignoreeof", "set nosave".

Implemented using doubled escape character to insert a single escape
into the message body.
1 parent a8b65a40
...@@ -120,20 +120,40 @@ mail_send0 (struct send_environ *env, int save_to) ...@@ -120,20 +120,40 @@ mail_send0 (struct send_environ *env, int save_to)
120 120
121 if (ml_got_interrupt()) 121 if (ml_got_interrupt())
122 { 122 {
123 if (util_find_env("ignore")->set)
124 {
125 fprintf (stdout, "@\n");
126 }
127 else
128 {
123 if (++int_cnt == 2) 129 if (++int_cnt == 2)
124 break; 130 break;
125 util_error("(Interrupt -- one more to kill letter)"); 131 util_error("(Interrupt -- one more to kill letter)");
126 if (buf) 132 if (buf)
127 free (buf); 133 free (buf);
134 }
128 continue; 135 continue;
129 } 136 }
130 137
131 if (!buf) 138 if (!buf)
139 {
140 if (util_find_env ("ignoreeof")->set)
141 {
142 util_error ("Use \".\" to terminate letter.");
143 continue;
144 }
145 else
132 break; 146 break;
147 }
148
133 int_cnt = 0; 149 int_cnt = 0;
134 150
135 if (buf[0] == (util_find_env("escape"))->value[0]) 151 if (buf[0] == (util_find_env("escape"))->value[0])
136 { 152 {
153 if (buf[1] == buf[0])
154 fprintf (env->file, "%s\n", buf+1);
155 else
156 {
137 int argc; 157 int argc;
138 char **argv; 158 char **argv;
139 int status; 159 int status;
...@@ -158,20 +178,43 @@ mail_send0 (struct send_environ *env, int save_to) ...@@ -158,20 +178,43 @@ mail_send0 (struct send_environ *env, int save_to)
158 178
159 ofile = env->ofile; 179 ofile = env->ofile;
160 } 180 }
181 }
161 else 182 else
162 fprintf (env->file, "%s", buf); 183 fprintf (env->file, "%s\n", buf);
163 fflush (env->file); 184 fflush (env->file);
164 free (buf); 185 free (buf);
165 } 186 }
166 187
167 fclose (env->file);
168 if (int_cnt) 188 if (int_cnt)
169 { 189 {
190 if (util_find_env ("save")->set)
191 {
192 FILE *fp = fopen (getenv("DEAD"), "a");
193
194 if (!fp)
195 {
196 util_error("can't open file %s: %s", getenv("DEAD"),
197 strerror(errno));
198 }
199 else
200 {
201 char *buf = NULL;
202 int n;
203 rewind (env->file);
204 while (getline (&buf, &n, env->file) > 0)
205 fputs(buf, fp);
206 fclose(fp);
207 }
208 }
209
210 fclose (env->file);
170 remove (filename); 211 remove (filename);
171 free (filename); 212 free (filename);
172 return 1; 213 return 1;
173 } 214 }
174 215
216 fclose (env->file); /*FIXME: freopen would be better*/
217
175 file = fopen (filename, "r"); 218 file = fopen (filename, "r");
176 if (file != NULL) 219 if (file != NULL)
177 { 220 {
...@@ -203,6 +246,7 @@ mail_send0 (struct send_environ *env, int save_to) ...@@ -203,6 +246,7 @@ mail_send0 (struct send_environ *env, int save_to)
203 header_set_value (header, MU_HEADER_BCC , strdup (env->bcc), 0); 246 header_set_value (header, MU_HEADER_BCC , strdup (env->bcc), 0);
204 if (env->subj && *env->subj != '\0') 247 if (env->subj && *env->subj != '\0')
205 header_set_value (header, MU_HEADER_SUBJECT, strdup (env->subj), 1); 248 header_set_value (header, MU_HEADER_SUBJECT, strdup (env->subj), 1);
249 header_set_value (header, "X-Mailer", strdup (argp_program_version), 1);
206 } 250 }
207 251
208 /* Fill the body. */ 252 /* Fill the body. */
......