diff options
| author | Stefan Monnier | 2010-07-23 17:23:09 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2010-07-23 17:23:09 +0200 |
| commit | 0ee81a0ce066375eac701c06cdfbdebefe594fdc (patch) | |
| tree | f0dccd24163316cfe688f927681a3032a9b1fe2f /lib-src/fakemail.c | |
| parent | 894e369ddf48e191638b8e66ce732f24ff9abe2a (diff) | |
| parent | 94da839793affa2a270bc26cee9c4d95d4dc4708 (diff) | |
| download | emacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.tar.gz emacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.zip | |
Merge from trunk
Diffstat (limited to 'lib-src/fakemail.c')
| -rw-r--r-- | lib-src/fakemail.c | 83 |
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; | |||
| 100 | struct stream_record | 100 | struct 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 | }; |
| 106 | typedef struct stream_record *stream_list; | 106 | typedef struct stream_record *stream_list; |
| @@ -147,8 +147,8 @@ static line_list file_preface; | |||
| 147 | static stream_list the_streams; | 147 | static stream_list the_streams; |
| 148 | static boolean no_problems = true; | 148 | static boolean no_problems = true; |
| 149 | 149 | ||
| 150 | extern FILE *popen (); | 150 | extern FILE *popen (const char *, const char *); |
| 151 | extern int fclose (), pclose (); | 151 | extern int fclose (FILE *), pclose (FILE *); |
| 152 | 152 | ||
| 153 | #ifdef CURRENT_USER | 153 | #ifdef CURRENT_USER |
| 154 | extern struct passwd *getpwuid (); | 154 | extern 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 | ||
| 166 | static void | 166 | static void |
| 167 | error (s1, s2) | 167 | error (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 | ||
| 178 | static void | 177 | static void |
| 179 | fatal (s1) | 178 | fatal (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 | ||
| 188 | static long * | 186 | static long * |
| 189 | xmalloc (size) | 187 | xmalloc (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 | ||
| 198 | static long * | 195 | static long * |
| 199 | xrealloc (ptr, size) | 196 | xrealloc (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 | ||
| 211 | void | 206 | void |
| 212 | init_linebuffer (linebuffer) | 207 | init_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 | ||
| 222 | long | 216 | long |
| 223 | readline (linebuffer, stream) | 217 | readline (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 | ||
| 259 | char * | 251 | char * |
| 260 | get_keyword (field, rest) | 252 | get_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 | ||
| 286 | boolean | 276 | boolean |
| 287 | has_keyword (field) | 277 | has_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 | ||
| 304 | char * | 293 | char * |
| 305 | add_field (the_list, field, where) | 294 | add_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 | ||
| 362 | line_list | 349 | line_list |
| 363 | make_file_preface () | 350 | make_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 | ||
| 406 | void | 393 | void |
| 407 | write_line_list (the_list, the_stream) | 394 | write_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 | ||
| 421 | int | 406 | int |
| 422 | close_the_streams () | 407 | close_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 | ||
| 434 | void | 419 | void |
| 435 | add_a_stream (the_stream, closing_action) | 420 | add_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 | ||
| 447 | int | 430 | int |
| 448 | my_fclose (the_file) | 431 | my_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 | ||
| 456 | boolean | 438 | boolean |
| 457 | open_a_file (name) | 439 | open_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 | ||
| 472 | void | 453 | void |
| 473 | put_string (s) | 454 | put_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 | ||
| 484 | void | 464 | void |
| 485 | put_line (string) | 465 | put_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 | ||
| 545 | void | 524 | void |
| 546 | setup_files (the_list, field) | 525 | setup_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 | ||
| 583 | int | 560 | int |
| 584 | args_size (the_header) | 561 | args_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 | ||
| 615 | void | 591 | void |
| 616 | parse_header (the_header, where) | 592 | parse_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 | ||
| 649 | header | 623 | header |
| 650 | read_header () | 624 | read_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 | ||
| 703 | void | 677 | void |
| 704 | write_header (the_header) | 678 | write_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 | ||
| 721 | int | 694 | int |
| 722 | main (argc, argv) | 695 | main (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)) |