annotate lib-src/fakemail.c @ 298:70ad99077275 r21-0b47

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