annotate lib-src/fakemail.c @ 76:c0c698873ce1 r20-0b33

Import from CVS: tag r20-0b33
author cvs
date Mon, 13 Aug 2007 09:05:10 +0200
parents 376386a54a3c
children 1f0dabaa0855
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* sendmail-like interface to /bin/mail for system V,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.28. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 #define NO_SHORTNAMES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 #include <../src/config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #if defined (BSD) && !defined (BSD4_1) && !defined (USE_FAKEMAIL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 /* This program isnot used in BSD, so just avoid loader complaints. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 main ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #elif defined (LINUX)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include <stdlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 main ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 /* Linux /bin/mail, if it exists, is NOT the Unix v7 mail that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 fakemail depends on! This causes garbled mail. Better to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 output an error message. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 fprintf (stderr, "Sorry, fakemail does not work on Linux.\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 fprintf (stderr, "Make sure you have the sendmail program, and\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 fprintf (stderr, "set the Lisp variable `sendmail-program' to point\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 fprintf (stderr, "to the path of the sendmail binary.\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 exit (1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 #else /* not BSD 4.2 (or newer) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #ifdef MSDOS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 main ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 #else /* not MSDOS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 /* This conditional contains all the rest of the file. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 /* These are defined in config in some versions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #ifdef static
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #undef static
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 #ifdef read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 #undef read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 #undef write
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 #undef open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 #undef close
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 #if __STDC__ || defined(STDC_HEADERS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 #include <stdlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 #include <unistd.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 #include <string.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 #include <ctype.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 #include <time.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 #include <pwd.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 /* Type definitions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 #define boolean int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 #define true 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 #define false 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 /* Various lists */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 struct line_record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 char *string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 struct line_record *continuation;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 typedef struct line_record *line_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 struct header_record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 line_list text;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 struct header_record *next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 struct header_record *previous;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 typedef struct header_record *header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 struct stream_record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 FILE *handle;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 int (*action)();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 struct stream_record *rest_streams;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 typedef struct stream_record *stream_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 /* A `struct linebuffer' is a structure which holds a line of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 * `readline' reads a line from a stream into a linebuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 * and works regardless of the length of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 struct linebuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 long size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 char *buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 struct linebuffer lb;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 #define new_list() \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ((line_list) xmalloc (sizeof (struct line_record)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 #define new_header() \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ((header) xmalloc (sizeof (struct header_record)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 #define new_stream() \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ((stream_list) xmalloc (sizeof (struct stream_record)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 #define alloc_string(nchars) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ((char *) xmalloc ((nchars) + 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 /* Global declarations */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 #define BUFLEN 1024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 #define KEYWORD_SIZE 256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 #define FROM_PREFIX "From"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 #define MY_NAME "fakemail"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 #define NIL ((line_list) NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 #define INITIAL_LINE_SIZE 200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 #ifndef MAIL_PROGRAM_NAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 #define MAIL_PROGRAM_NAME "/bin/mail"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 static CONST char *my_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 static char *the_date;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 static char *the_user;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 static line_list file_preface;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 static stream_list the_streams;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 static boolean no_problems = true;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 #if !__STDC__ && !defined(STDC_HEADERS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 extern FILE *popen ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 extern int fclose (), pclose ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 extern char *malloc (), *realloc ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 #ifdef CURRENT_USER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 extern struct passwd *getpwuid ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 extern unsigned short geteuid ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 static struct passwd *my_entry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 #define cuserid(s) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (my_entry = getpwuid (((int) geteuid ())), \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 my_entry->pw_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 /* Utilities */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 error (CONST char *s1, CONST char *s2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 printf ("%s: ", my_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 printf (s1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 printf ("\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 no_problems = false;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 /* Print error message and exit. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 fatal (CONST char *s1, CONST char *s2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 error (s1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 exit (1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 /* Like malloc but get fatal error if memory is exhausted. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 xmalloc (size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 size_t size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 char *result = malloc (((unsigned) size));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 if (result == ((char *) NULL))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 fatal ("virtual memory exhausted", (char *) 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 xrealloc (ptr, size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 char *ptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 size_t size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 char *result = realloc (ptr, ((unsigned) size));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 if (result == ((char *) NULL))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 fatal ("virtual memory exhausted", (char *) 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 /* Initialize a linebuffer for use */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 init_linebuffer (struct linebuffer *linebuffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 linebuffer->size = INITIAL_LINE_SIZE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 linebuffer->buffer = ((char *) xmalloc (INITIAL_LINE_SIZE));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 /* Read a line of text from `stream' into `linebuffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 * Return the length of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 static long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 readline (struct linebuffer *linebuffer, FILE *stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 char *buffer = linebuffer->buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 char *p = linebuffer->buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 char *end = p + linebuffer->size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 while (true)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 int c = getc (stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 if (p == end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 linebuffer->size *= 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 buffer = ((char *) xrealloc ((char *) buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (size_t) (linebuffer->size)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 p = buffer + (p - linebuffer->buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 end = buffer + linebuffer->size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 linebuffer->buffer = buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 if (c < 0 || c == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 *p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 *p++ = c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 return p - buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 get_keyword (register char *field, char **rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 static char keyword[KEYWORD_SIZE];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 register char *ptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 register char c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ptr = &keyword[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 c = *field++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 if ((isspace (c)) || (c == ':'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 return ((char *) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 *ptr++ = ((islower (c)) ? (toupper (c)) : c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 while (((c = *field++) != ':') && (!(isspace (c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 *ptr++ = ((islower (c)) ? (toupper (c)) : c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 *ptr++ = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 while (isspace (c)) c = *field++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 if (c != ':') return ((char *) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 *rest = field;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 return &keyword[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 static boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 has_keyword (char *field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 char *ignored;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 return (get_keyword (field, &ignored) != ((char *) NULL));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 add_field (line_list the_list, register char *field, register char *where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 register char c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 while (true)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 *where++ = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 while ((c = *field++) != '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 if (c == '(')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 while (*field && *field != ')') ++field;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 if (! (*field++)) break; /* no closer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 if (! (*field)) break; /* closerNULL */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 c = *field;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 *where++ = ((c == ','||c=='>'||c=='<') ? ' ' : c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 if (the_list == NIL) break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 field = the_list->string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 the_list = the_list->continuation;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 return where;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 static line_list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 make_file_preface (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 char *the_string, *temp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 long idiotic_interface;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 long prefix_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 long user_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 long date_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 line_list result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 prefix_length = strlen (FROM_PREFIX);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 time (&idiotic_interface);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 the_date = ctime (&idiotic_interface);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 /* the_date has an unwanted newline at the end */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 date_length = strlen (the_date) - 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 the_date[date_length] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 temp = cuserid ((char *) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 user_length = strlen (temp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 the_user = alloc_string ((size_t) (user_length + 1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 strcpy (the_user, temp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 the_string = alloc_string ((size_t) (3 + prefix_length +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 user_length +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 date_length));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 temp = the_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 strcpy (temp, FROM_PREFIX);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 temp = &temp[prefix_length];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 *temp++ = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 strcpy (temp, the_user);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 temp = &temp[user_length];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 *temp++ = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 strcpy (temp, the_date);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 result = new_list ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 result->string = the_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 result->continuation = ((line_list) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 write_line_list (register line_list the_list, FILE *the_stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 for ( ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 the_list != ((line_list) NULL) ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 the_list = the_list->continuation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 fputs (the_list->string, the_stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 putc ('\n', the_stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 close_the_streams (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 register stream_list rem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 for (rem = the_streams;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 rem != ((stream_list) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 rem = rem->rest_streams)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 no_problems = (no_problems &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ((*rem->action) (rem->handle) == 0));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 the_streams = ((stream_list) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 return (no_problems ? 0 : 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 add_a_stream (FILE *the_stream, int (*closing_action)())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 stream_list old = the_streams;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 the_streams = new_stream ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 the_streams->handle = the_stream;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 the_streams->action = closing_action;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 the_streams->rest_streams = old;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 my_fclose (FILE *the_file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 putc ('\n', the_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 fflush (the_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 return fclose (the_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 static boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 open_a_file (char *name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 FILE *the_stream = fopen (name, "a");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 if (the_stream != ((FILE *) NULL))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 add_a_stream (the_stream, my_fclose);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 if (the_user == ((char *) NULL))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 file_preface = make_file_preface ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 write_line_list (file_preface, the_stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 return true;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 return false;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 put_string (char *s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 register stream_list rem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 for (rem = the_streams;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 rem != ((stream_list) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 rem = rem->rest_streams)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 fputs (s, rem->handle);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 put_line (CONST char *string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 register stream_list rem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 for (rem = the_streams;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 rem != ((stream_list) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 rem = rem->rest_streams)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 CONST char *s = string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 int column = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 /* Divide STRING into lines. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 while (*s != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 CONST char *breakpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 /* Find the last char that fits. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 for (breakpos = s; *breakpos && column < 78; ++breakpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 if (*breakpos == '\t')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 column += 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 column++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 /* If we didn't reach end of line, break the line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 if (*breakpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 /* Back up to just after the last comma that fits. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 while (breakpos != s && breakpos[-1] != ',') --breakpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 if (breakpos == s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 /* If no comma fits, move past the first address anyway. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 while (*breakpos != 0 && *breakpos != ',') ++breakpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 if (*breakpos != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 /* Include the comma after it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ++breakpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 /* Output that much, then break the line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 fwrite (s, 1, breakpos - s, rem->handle);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 column = 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 /* Skip whitespace and prepare to print more addresses. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 s = breakpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 while (*s == ' ' || *s == '\t') ++s;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 if (*s != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 fputs ("\n\t", rem->handle);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 putc ('\n', rem->handle);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 #define mail_error error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 setup_files (register line_list the_list, register char *field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 register char *start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 register char c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 while (true)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 while (((c = *field) != '\0') &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ((c == ' ') ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (c == '\t') ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (c == ',')))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 field += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 if (c != '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 start = field;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 while (((c = *field) != '\0') &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (c != ' ') &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (c != '\t') &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (c != ','))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 field += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 *field = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 if (!open_a_file (start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 mail_error ("Could not open file %s", start);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 *field = c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 if (c != '\0') continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 if (the_list == ((line_list) NULL)) return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 field = the_list->string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 the_list = the_list->continuation;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 args_size (header the_header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 register header old = the_header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 register line_list rem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 register int size = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 char *field;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 register char *keyword = get_keyword (the_header->text->string, &field);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 if ((strcmp (keyword, "TO") == 0) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (strcmp (keyword, "CC") == 0) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (strcmp (keyword, "BCC") == 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 size += 1 + strlen (field);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 for (rem = the_header->text->continuation;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 rem != NIL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 rem = rem->continuation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 size += 1 + strlen (rem->string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 the_header = the_header->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 } while (the_header != old);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 return size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 parse_header (header the_header, register char *where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 register header old = the_header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 char *field;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 register char *keyword = get_keyword (the_header->text->string, &field);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 if (strcmp (keyword, "TO") == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 where = add_field (the_header->text->continuation, field, where);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 else if (strcmp (keyword, "CC") == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 where = add_field (the_header->text->continuation, field, where);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 else if (strcmp (keyword, "BCC") == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 where = add_field (the_header->text->continuation, field, where);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 the_header->previous->next = the_header->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 the_header->next->previous = the_header->previous;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 else if (strcmp (keyword, "FCC") == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 setup_files (the_header->text->continuation, field);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 the_header = the_header->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 } while (the_header != old);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 *where = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 static header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 read_header (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 register header the_header = ((header) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 register line_list *next_line = ((line_list *) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 init_linebuffer (&lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 long length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 register char *line;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 readline (&lb, stdin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 line = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 length = strlen (line);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 if (length == 0) break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 if (has_keyword (line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 register header old = the_header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 the_header = new_header ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 if (old == ((header) NULL))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 the_header->next = the_header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 the_header->previous = the_header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 the_header->previous = old;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 the_header->next = old->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 old->next = the_header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 next_line = &(the_header->text);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 if (next_line == ((line_list *) NULL))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 /* Not a valid header */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 exit (1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 *next_line = new_list ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (*next_line)->string = alloc_string ((size_t) length);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 strcpy (((*next_line)->string), line);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 next_line = &((*next_line)->continuation);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 *next_line = NIL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 } while (true);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 return the_header->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 write_header (header the_header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 register header old = the_header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 register line_list the_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 for (the_list = the_header->text;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 the_list != NIL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 the_list = the_list->continuation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 put_line (the_list->string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 the_header = the_header->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 } while (the_header != old);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 put_line ("");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 main (argc, argv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 int argc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 char **argv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 char *command_line;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 header the_header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 long name_length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 char *mail_program_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 char buf[BUFLEN + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 register int size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 FILE *the_pipe;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 #if !(__STDC__ || defined(STDC_HEADERS))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 extern char *getenv ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 mail_program_name = getenv ("FAKEMAILER");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 if (!(mail_program_name && *mail_program_name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 mail_program_name = (char *) MAIL_PROGRAM_NAME;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 name_length = strlen (mail_program_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 my_name = MY_NAME;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 the_streams = ((stream_list) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 the_date = ((char *) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 the_user = ((char *) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 the_header = read_header ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 command_line = alloc_string ((size_t) (name_length +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 args_size (the_header)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 strcpy (command_line, mail_program_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 parse_header (the_header, &command_line[name_length]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 the_pipe = popen (command_line, "w");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 if (the_pipe == ((FILE *) NULL))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 fatal ("cannot open pipe to real mailer", (char *) 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 add_a_stream (the_pipe, pclose);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 write_header (the_header);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 /* Dump the message itself */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 while (!feof (stdin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 size = fread (buf, 1, BUFLEN, stdin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 buf[size] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 put_string (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 exit (close_the_streams ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 #endif /* not MSDOS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 #endif /* not BSD 4.2 (or newer) */