aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/fakemail.c
diff options
context:
space:
mode:
authorStefan Monnier2010-07-23 17:23:09 +0200
committerStefan Monnier2010-07-23 17:23:09 +0200
commit0ee81a0ce066375eac701c06cdfbdebefe594fdc (patch)
treef0dccd24163316cfe688f927681a3032a9b1fe2f /lib-src/fakemail.c
parent894e369ddf48e191638b8e66ce732f24ff9abe2a (diff)
parent94da839793affa2a270bc26cee9c4d95d4dc4708 (diff)
downloademacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.tar.gz
emacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.zip
Merge from trunk
Diffstat (limited to 'lib-src/fakemail.c')
-rw-r--r--lib-src/fakemail.c83
1 files changed, 27 insertions, 56 deletions
diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c
index f98fb749476..f4d978b7d11 100644
--- a/lib-src/fakemail.c
+++ b/lib-src/fakemail.c
@@ -100,7 +100,7 @@ typedef struct header_record *header;
100struct stream_record 100struct stream_record
101{ 101{
102 FILE *handle; 102 FILE *handle;
103 int (*action)(); 103 int (*action)(FILE *);
104 struct stream_record *rest_streams; 104 struct stream_record *rest_streams;
105}; 105};
106typedef struct stream_record *stream_list; 106typedef struct stream_record *stream_list;
@@ -147,8 +147,8 @@ static line_list file_preface;
147static stream_list the_streams; 147static stream_list the_streams;
148static boolean no_problems = true; 148static boolean no_problems = true;
149 149
150extern FILE *popen (); 150extern FILE *popen (const char *, const char *);
151extern int fclose (), pclose (); 151extern int fclose (FILE *), pclose (FILE *);
152 152
153#ifdef CURRENT_USER 153#ifdef CURRENT_USER
154extern struct passwd *getpwuid (); 154extern struct passwd *getpwuid ();
@@ -164,8 +164,7 @@ static struct passwd *my_entry;
164/* Print error message. `s1' is printf control string, `s2' is arg for it. */ 164/* Print error message. `s1' is printf control string, `s2' is arg for it. */
165 165
166static void 166static void
167error (s1, s2) 167error (char *s1, char *s2)
168 char *s1, *s2;
169{ 168{
170 printf ("%s: ", my_name); 169 printf ("%s: ", my_name);
171 printf (s1, s2); 170 printf (s1, s2);
@@ -176,8 +175,7 @@ error (s1, s2)
176/* Print error message and exit. */ 175/* Print error message and exit. */
177 176
178static void 177static void
179fatal (s1) 178fatal (char *s1)
180 char *s1;
181{ 179{
182 error ("%s", s1); 180 error ("%s", s1);
183 exit (EXIT_FAILURE); 181 exit (EXIT_FAILURE);
@@ -186,8 +184,7 @@ fatal (s1)
186/* Like malloc but get fatal error if memory is exhausted. */ 184/* Like malloc but get fatal error if memory is exhausted. */
187 185
188static long * 186static long *
189xmalloc (size) 187xmalloc (int size)
190 int size;
191{ 188{
192 long *result = (long *) malloc (((unsigned) size)); 189 long *result = (long *) malloc (((unsigned) size));
193 if (result == ((long *) NULL)) 190 if (result == ((long *) NULL))
@@ -196,9 +193,7 @@ xmalloc (size)
196} 193}
197 194
198static long * 195static long *
199xrealloc (ptr, size) 196xrealloc (long int *ptr, int size)
200 long *ptr;
201 int size;
202{ 197{
203 long *result = (long *) realloc (ptr, ((unsigned) size)); 198 long *result = (long *) realloc (ptr, ((unsigned) size));
204 if (result == ((long *) NULL)) 199 if (result == ((long *) NULL))
@@ -209,8 +204,7 @@ xrealloc (ptr, size)
209/* Initialize a linebuffer for use */ 204/* Initialize a linebuffer for use */
210 205
211void 206void
212init_linebuffer (linebuffer) 207init_linebuffer (struct linebuffer *linebuffer)
213 struct linebuffer *linebuffer;
214{ 208{
215 linebuffer->size = INITIAL_LINE_SIZE; 209 linebuffer->size = INITIAL_LINE_SIZE;
216 linebuffer->buffer = ((char *) xmalloc (INITIAL_LINE_SIZE)); 210 linebuffer->buffer = ((char *) xmalloc (INITIAL_LINE_SIZE));
@@ -220,9 +214,7 @@ init_linebuffer (linebuffer)
220 Return the length of the line. */ 214 Return the length of the line. */
221 215
222long 216long
223readline (linebuffer, stream) 217readline (struct linebuffer *linebuffer, FILE *stream)
224 struct linebuffer *linebuffer;
225 FILE *stream;
226{ 218{
227 char *buffer = linebuffer->buffer; 219 char *buffer = linebuffer->buffer;
228 char *p = linebuffer->buffer; 220 char *p = linebuffer->buffer;
@@ -257,9 +249,7 @@ readline (linebuffer, stream)
257 If there is no keyword, return NULL and don't alter *REST. */ 249 If there is no keyword, return NULL and don't alter *REST. */
258 250
259char * 251char *
260get_keyword (field, rest) 252get_keyword (register char *field, char **rest)
261 register char *field;
262 char **rest;
263{ 253{
264 static char keyword[KEYWORD_SIZE]; 254 static char keyword[KEYWORD_SIZE];
265 register char *ptr; 255 register char *ptr;
@@ -284,8 +274,7 @@ get_keyword (field, rest)
284/* Nonzero if the string FIELD starts with a colon-terminated keyword. */ 274/* Nonzero if the string FIELD starts with a colon-terminated keyword. */
285 275
286boolean 276boolean
287has_keyword (field) 277has_keyword (char *field)
288 char *field;
289{ 278{
290 char *ignored; 279 char *ignored;
291 return (get_keyword (field, &ignored) != ((char *) NULL)); 280 return (get_keyword (field, &ignored) != ((char *) NULL));
@@ -302,9 +291,7 @@ has_keyword (field)
302 the caller has to make it big enough. */ 291 the caller has to make it big enough. */
303 292
304char * 293char *
305add_field (the_list, field, where) 294add_field (line_list the_list, register char *field, register char *where)
306 line_list the_list;
307 register char *field, *where;
308{ 295{
309 register char c; 296 register char c;
310 while (true) 297 while (true)
@@ -360,7 +347,7 @@ add_field (the_list, field, where)
360} 347}
361 348
362line_list 349line_list
363make_file_preface () 350make_file_preface (void)
364{ 351{
365 char *the_string, *temp; 352 char *the_string, *temp;
366 long idiotic_interface; 353 long idiotic_interface;
@@ -404,9 +391,7 @@ make_file_preface ()
404} 391}
405 392
406void 393void
407write_line_list (the_list, the_stream) 394write_line_list (register line_list the_list, FILE *the_stream)
408 register line_list the_list;
409 FILE *the_stream;
410{ 395{
411 for ( ; 396 for ( ;
412 the_list != ((line_list) NULL) ; 397 the_list != ((line_list) NULL) ;
@@ -419,7 +404,7 @@ write_line_list (the_list, the_stream)
419} 404}
420 405
421int 406int
422close_the_streams () 407close_the_streams (void)
423{ 408{
424 register stream_list rem; 409 register stream_list rem;
425 for (rem = the_streams; 410 for (rem = the_streams;
@@ -432,9 +417,7 @@ close_the_streams ()
432} 417}
433 418
434void 419void
435add_a_stream (the_stream, closing_action) 420add_a_stream (FILE *the_stream, int (*closing_action) (FILE *))
436 FILE *the_stream;
437 int (*closing_action)();
438{ 421{
439 stream_list old = the_streams; 422 stream_list old = the_streams;
440 the_streams = new_stream (); 423 the_streams = new_stream ();
@@ -445,8 +428,7 @@ add_a_stream (the_stream, closing_action)
445} 428}
446 429
447int 430int
448my_fclose (the_file) 431my_fclose (FILE *the_file)
449 FILE *the_file;
450{ 432{
451 putc ('\n', the_file); 433 putc ('\n', the_file);
452 fflush (the_file); 434 fflush (the_file);
@@ -454,8 +436,7 @@ my_fclose (the_file)
454} 436}
455 437
456boolean 438boolean
457open_a_file (name) 439open_a_file (char *name)
458 char *name;
459{ 440{
460 FILE *the_stream = fopen (name, "a"); 441 FILE *the_stream = fopen (name, "a");
461 if (the_stream != ((FILE *) NULL)) 442 if (the_stream != ((FILE *) NULL))
@@ -470,8 +451,7 @@ open_a_file (name)
470} 451}
471 452
472void 453void
473put_string (s) 454put_string (char *s)
474 char *s;
475{ 455{
476 register stream_list rem; 456 register stream_list rem;
477 for (rem = the_streams; 457 for (rem = the_streams;
@@ -482,8 +462,7 @@ put_string (s)
482} 462}
483 463
484void 464void
485put_line (string) 465put_line (char *string)
486 char *string;
487{ 466{
488 register stream_list rem; 467 register stream_list rem;
489 for (rem = the_streams; 468 for (rem = the_streams;
@@ -543,9 +522,7 @@ put_line (string)
543 Call open_a_file for each file. */ 522 Call open_a_file for each file. */
544 523
545void 524void
546setup_files (the_list, field) 525setup_files (register line_list the_list, register char *field)
547 register line_list the_list;
548 register char *field;
549{ 526{
550 register char *start; 527 register char *start;
551 register char c; 528 register char c;
@@ -581,8 +558,7 @@ setup_files (the_list, field)
581 The result says how big to make the buffer to pass to parse_header. */ 558 The result says how big to make the buffer to pass to parse_header. */
582 559
583int 560int
584args_size (the_header) 561args_size (header the_header)
585 header the_header;
586{ 562{
587 register header old = the_header; 563 register header old = the_header;
588 register line_list rem; 564 register line_list rem;
@@ -613,9 +589,7 @@ args_size (the_header)
613 Also, if the header has any FCC fields, call setup_files for each one. */ 589 Also, if the header has any FCC fields, call setup_files for each one. */
614 590
615void 591void
616parse_header (the_header, where) 592parse_header (header the_header, register char *where)
617 header the_header;
618 register char *where;
619{ 593{
620 register header old = the_header; 594 register header old = the_header;
621 do 595 do
@@ -647,7 +621,7 @@ parse_header (the_header, where)
647 Continuation lines are grouped in the headers they continue. */ 621 Continuation lines are grouped in the headers they continue. */
648 622
649header 623header
650read_header () 624read_header (void)
651{ 625{
652 register header the_header = ((header) NULL); 626 register header the_header = ((header) NULL);
653 register line_list *next_line = ((line_list *) NULL); 627 register line_list *next_line = ((line_list *) NULL);
@@ -701,8 +675,7 @@ read_header ()
701} 675}
702 676
703void 677void
704write_header (the_header) 678write_header (header the_header)
705 header the_header;
706{ 679{
707 register header old = the_header; 680 register header old = the_header;
708 do 681 do
@@ -719,9 +692,7 @@ write_header (the_header)
719} 692}
720 693
721int 694int
722main (argc, argv) 695main (int argc, char **argv)
723 int argc;
724 char **argv;
725{ 696{
726 char *command_line; 697 char *command_line;
727 header the_header; 698 header the_header;
@@ -731,7 +702,7 @@ main (argc, argv)
731 register int size; 702 register int size;
732 FILE *the_pipe; 703 FILE *the_pipe;
733 704
734 extern char *getenv (); 705 extern char *getenv (const char *);
735 706
736 mail_program_name = getenv ("FAKEMAILER"); 707 mail_program_name = getenv ("FAKEMAILER");
737 if (!(mail_program_name && *mail_program_name)) 708 if (!(mail_program_name && *mail_program_name))