comparison lib-src/b2m.c @ 6215:226d490216f7

Clean up indentation and whitespace.
author Richard M. Stallman <rms@gnu.org>
date Sat, 05 Mar 1994 21:53:42 +0000
parents 512963eb02fe
children a4a9a0d9b53a
comparison
equal deleted inserted replaced
6214:512963eb02fe 6215:226d490216f7
13 * Ed Wilkinson 13 * Ed Wilkinson
14 * E.Wilkinson@massey.ac.nz 14 * E.Wilkinson@massey.ac.nz
15 * Mon Nov 7 15:54:06 PDT 1988 15 * Mon Nov 7 15:54:06 PDT 1988
16 */ 16 */
17 17
18 /* Serious bug: This program uses `gets', which is intrinsically
19 unreliable--long lines will cause crashes.
20 Someone should fix this program not to use `gets'. */
18 #include <stdio.h> 21 #include <stdio.h>
19 #include <time.h> 22 #include <time.h>
20 #include <sys/types.h> 23 #include <sys/types.h>
21 #ifdef MSDOS 24 #ifdef MSDOS
22 #include <fcntl.h> 25 #include <fcntl.h>
47 main (argc, argv) 50 main (argc, argv)
48 int argc; 51 int argc;
49 char **argv; 52 char **argv;
50 { 53 {
51 #ifdef MSDOS 54 #ifdef MSDOS
52 _fmode = O_BINARY; /* all of files are treated as binary files */ 55 _fmode = O_BINARY; /* all of files are treated as binary files */
53 (stdout)->_flag &= ~_IOTEXT; 56 (stdout)->_flag &= ~_IOTEXT;
54 (stdin)->_flag &= ~_IOTEXT; 57 (stdin)->_flag &= ~_IOTEXT;
55 #endif 58 #endif
56 if (strcmp(argv[1], "--help") == 0) 59 if (strcmp (argv[1], "--help") == 0)
57 { 60 {
58 fprintf(stderr, "Usage: %s <babylmailbox >unixmailbox\n", argv[0]); 61 fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", argv[0]);
59 exit (0); 62 exit (0);
60 } 63 }
61 ltoday = time(0); 64 ltoday = time (0);
62 today = ctime(&ltoday); 65 today = ctime (&ltoday);
63 66
64 if (gets(data)) 67 /* BUG! Must not use gets in a reliable program! */
65 if (strncmp(data, "BABYL OPTIONS:", 14)) 68 if (gets (data))
66 { 69 {
67 fprintf(stderr, "%s: not a Babyl mailfile!\n", argv[0]); 70 if (strncmp (data, "BABYL OPTIONS:", 14))
68 exit (-1); 71 {
69 } else 72 fprintf (stderr, "%s: not a Babyl mailfile!\n", argv[0]);
73 exit (-1);
74 }
75 else
70 printing = FALSE; 76 printing = FALSE;
77 }
71 else 78 else
72 exit(-1); 79 exit (-1);
73 if (printing) 80 if (printing)
74 puts(data); 81 puts (data);
75 82
76 while (gets(data)) { 83 while (gets (data))
84 {
77 85
78 #if 0 86 #if 0
79 /* What was this for? Does somebody have something against blank 87 /* What was this for? Does somebody have something against blank
80 lines? */ 88 lines? */
81 if (!strcmp(data, "")) 89 if (!strcmp (data, ""))
82 exit(0); 90 exit (0);
83 #endif 91 #endif
84 92
85 if (!strcmp(data, "*** EOOH ***") && !printing) { 93 if (!strcmp (data, "*** EOOH ***") && !printing)
86 printing = header = TRUE; 94 {
87 printf("From %s %s", argv[0], today); 95 printing = header = TRUE;
88 continue; 96 printf ("From %s %s", argv[0], today);
97 continue;
98 }
99
100 if (!strcmp (data, "\037\f"))
101 {
102 /* save labels */
103 gets (data);
104 p = strtok (data, " ,\r\n\t");
105 strcpy (labels, "X-Babyl-Labels: ");
106
107 while (p = strtok (NULL, " ,\r\n\t"))
108 {
109 strcat (labels, p);
110 strcat (labels, ", ");
111 }
112
113 labels[strlen (labels) - 2] = '\0';
114 printing = header = FALSE;
115 continue;
116 }
117
118 if (!strlen (data) && header)
119 {
120 header = FALSE;
121 if (strcmp (labels, "X-Babyl-Labels"))
122 puts (labels);
123 }
124
125 if (printing)
126 puts (data);
89 } 127 }
90
91 if (!strcmp(data, "\037\f")) {
92 /* save labels */
93 gets(data);
94 p = strtok(data, " ,\r\n\t");
95 strcpy(labels, "X-Babyl-Labels: ");
96
97 while (p = strtok(NULL, " ,\r\n\t")) {
98 strcat(labels, p);
99 strcat(labels, ", ");
100 }
101
102 labels[strlen(labels) - 2] = '\0';
103 printing = header = FALSE;
104 continue;
105 }
106
107 if (!strlen(data) && header) {
108 header = FALSE;
109 if (strcmp(labels, "X-Babyl-Labels"))
110 puts(labels);
111 }
112
113 if (printing)
114 puts(data);
115 }
116 } 128 }