annotate src/do_all_the_voodoo_here.c @ 748:dfc9ab125fd4

Fix spelling of 'receive' and 'voodoo'; make mlmmj-recieve a symlink
author Chris Webb
date Sun, 03 Oct 2010 21:40:42 +1100
parents src/do_all_the_voodo_here.c@84189f529aee
children 1c13e314e5b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
b045203f558b Add GPL info in top of files where it was missing, and remove a file that
mmj
parents: 11
diff changeset
1 /* Copyright (C) 2004 Mads Martin Joergensen <mmj at mmj.dk>
b045203f558b Add GPL info in top of files where it was missing, and remove a file that
mmj
parents: 11
diff changeset
2 *
b045203f558b Add GPL info in top of files where it was missing, and remove a file that
mmj
parents: 11
diff changeset
3 * $Id$
b045203f558b Add GPL info in top of files where it was missing, and remove a file that
mmj
parents: 11
diff changeset
4 *
225
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
6 * of this software and associated documentation files (the "Software"), to
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
7 * deal in the Software without restriction, including without limitation the
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
9 * sell copies of the Software, and to permit persons to whom the Software is
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
10 * furnished to do so, subject to the following conditions:
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
11 *
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
12 * The above copyright notice and this permission notice shall be included in
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
13 * all copies or substantial portions of the Software.
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
14 *
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
3f177909efc8 Goodbye GPL license, Welcome MIT
mmj
parents: 184
diff changeset
21 * IN THE SOFTWARE.
17
b045203f558b Add GPL info in top of files where it was missing, and remove a file that
mmj
parents: 11
diff changeset
22 */
b045203f558b Add GPL info in top of files where it was missing, and remove a file that
mmj
parents: 11
diff changeset
23
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
24 #include <stdlib.h>
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
25 #include <string.h>
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
26 #include <unistd.h>
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
27
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
28 #include "mlmmj.h"
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
29 #include "mygetline.h"
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
30 #include "gethdrline.h"
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
31 #include "strgen.h"
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
32 #include "chomp.h"
89
mmj
parents: 27
diff changeset
33 #include "ctrlvalue.h"
748
dfc9ab125fd4 Fix spelling of 'receive' and 'voodoo'; make mlmmj-recieve a symlink
Chris Webb
parents: 501
diff changeset
34 #include "do_all_the_voodoo_here.h"
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
35 #include "log_error.h"
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
36 #include "wrappers.h"
245
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 227
diff changeset
37 #include "memory.h"
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
38
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
39 int findit(const char *line, const char **headers)
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
40 {
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
41 int i = 0;
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
42 size_t len;
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
43
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
44 while(headers[i]) {
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
45 len = strlen(headers[i]);
324
af441b7d0e69 Make header match case insensitive
mmj
parents: 310
diff changeset
46 if(strncasecmp(line, headers[i], len) == 0)
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
47 return 1;
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
48 i++;
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
49 }
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
50
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
51 return 0;
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
52 }
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
53
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
54 void getinfo(const char *line, struct mailhdr *readhdrs)
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
55 {
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
56 int i = 0;
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
57 size_t tokenlen, linelen, valuelen;
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
58
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
59 while(readhdrs[i].token) {
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
60 tokenlen = strlen(readhdrs[i].token);
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
61 linelen = strlen(line);
324
af441b7d0e69 Make header match case insensitive
mmj
parents: 310
diff changeset
62 if(strncasecmp(line, readhdrs[i].token, tokenlen) == 0) {
120
154b486fefd5 When retrieving header info, make sure to get all headers since we might have
mmj
parents: 89
diff changeset
63 readhdrs[i].valuecount++;
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
64 valuelen = linelen - tokenlen + 1;
120
154b486fefd5 When retrieving header info, make sure to get all headers since we might have
mmj
parents: 89
diff changeset
65 readhdrs[i].values =
245
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 227
diff changeset
66 (char **)myrealloc(readhdrs[i].values,
120
154b486fefd5 When retrieving header info, make sure to get all headers since we might have
mmj
parents: 89
diff changeset
67 readhdrs[i].valuecount * sizeof(char *));
154b486fefd5 When retrieving header info, make sure to get all headers since we might have
mmj
parents: 89
diff changeset
68 readhdrs[i].values[readhdrs[i].valuecount - 1] =
245
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 227
diff changeset
69 (char *)mymalloc(valuelen + 1);
120
154b486fefd5 When retrieving header info, make sure to get all headers since we might have
mmj
parents: 89
diff changeset
70 strncpy(readhdrs[i].values[readhdrs[i].valuecount - 1],
285
081ba983e6f1 Read header correctly
mmj
parents: 284
diff changeset
71 line+tokenlen, valuelen);
120
154b486fefd5 When retrieving header info, make sure to get all headers since we might have
mmj
parents: 89
diff changeset
72 chomp(readhdrs[i].values[readhdrs[i].valuecount - 1]);
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
73 }
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
74 i++;
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
75 }
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
76 }
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
77
748
dfc9ab125fd4 Fix spelling of 'receive' and 'voodoo'; make mlmmj-recieve a symlink
Chris Webb
parents: 501
diff changeset
78 int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd,
89
mmj
parents: 27
diff changeset
79 const char **delhdrs, struct mailhdr *readhdrs,
254
31a34f710c27 added access control
mortenp
parents: 245
diff changeset
80 struct strlist *allhdrs, const char *prefix)
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
81 {
265
f28ab75abba7 Quoted printable subjects are now matched against prefix as well
mmj
parents: 254
diff changeset
82 char *hdrline, *subject, *unqp;
298
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
83 int hdrsadded = 0;
497
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
84 int subject_present = 0;
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
85
254
31a34f710c27 added access control
mortenp
parents: 245
diff changeset
86 allhdrs->count = 0;
31a34f710c27 added access control
mortenp
parents: 245
diff changeset
87 allhdrs->strs = NULL;
31a34f710c27 added access control
mortenp
parents: 245
diff changeset
88
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
89 while((hdrline = gethdrline(infd))) {
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
90 /* Done with headers? Then add extra if wanted*/
307
489493e0fc15 NULL is 0 when strncasecmping
mmj
parents: 298
diff changeset
91 if((strncasecmp(hdrline, "mime", 4) == 0) ||
298
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
92 ((strlen(hdrline) == 1) && (hdrline[0] == '\n'))){
497
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
93
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
94 /* add extra headers */
298
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
95 if(!hdrsadded && hdrfd >= 0) {
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
96 if(dumpfd2fd(hdrfd, outfd) < 0) {
184
86d7d42fe996 Assorted bugfixes.
mmj
parents: 161
diff changeset
97 log_error(LOG_ARGS, "Could not "
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
98 "add extra headers");
245
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 227
diff changeset
99 myfree(hdrline);
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
100 return -1;
298
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
101 } else
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
102 hdrsadded = 1;
284
324780ed8d85 Clean up sub/unsub confirmation requests
mmj
parents: 281
diff changeset
103 }
324780ed8d85 Clean up sub/unsub confirmation requests
mmj
parents: 281
diff changeset
104
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
105 fsync(outfd);
497
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
106
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
107 /* end of headers, write single LF */
298
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
108 if(hdrline[0] == '\n') {
497
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
109 /* but first add Subject if none is present
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
110 * and a prefix is defined */
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
111 if (prefix && !subject_present)
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
112 {
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
113 subject = concatstr(3, "Subject: ",
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
114 prefix, "\n");
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
115 writen(outfd, subject, strlen(subject));
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
116 myfree(subject);
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
117 subject_present = 1;
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
118 }
293737f23ecf Add Subject: if none is present and prefix is wanted
mmj
parents: 352
diff changeset
119
298
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
120 if(writen(outfd, hdrline, strlen(hdrline))
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
121 < 0) {
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
122 myfree(hdrline);
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
123 log_error(LOG_ARGS,
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
124 "Error writing hdrs.");
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
125 return -1;
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
126 }
310
659a9d0d932f Fix free() in the wrong place and do RC3
mmj
parents: 307
diff changeset
127 myfree(hdrline);
298
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
128 break;
57d116ad0ea0 New perl-admin, hdradd before mime
mmj
parents: 285
diff changeset
129 }
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
130 }
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
131 /* Do we want info from hdrs? Get it before it's gone */
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
132 if(readhdrs)
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
133 getinfo(hdrline, readhdrs);
89
mmj
parents: 27
diff changeset
134
254
31a34f710c27 added access control
mortenp
parents: 245
diff changeset
135 /* Snatch a copy of the header */
31a34f710c27 added access control
mortenp
parents: 245
diff changeset
136 allhdrs->count++;
31a34f710c27 added access control
mortenp
parents: 245
diff changeset
137 allhdrs->strs = myrealloc(allhdrs->strs,
325
1bbb75dfcea8 why, why, why? BECAUSE you have to learn to add parenthesises
mmj
parents: 324
diff changeset
138 sizeof(char *) * (allhdrs->count + 1));
254
31a34f710c27 added access control
mortenp
parents: 245
diff changeset
139 allhdrs->strs[allhdrs->count-1] = mystrdup(hdrline);
31a34f710c27 added access control
mortenp
parents: 245
diff changeset
140 allhdrs->strs[allhdrs->count] = NULL; /* XXX why, why, why? */
31a34f710c27 added access control
mortenp
parents: 245
diff changeset
141
89
mmj
parents: 27
diff changeset
142 /* Add Subject: prefix if wanted */
mmj
parents: 27
diff changeset
143 if(prefix) {
352
8173978c2bfd - if(strncasecmp(hdrline, "Subject: ", 9) == 0) {
mmj
parents: 325
diff changeset
144 if(strncasecmp(hdrline, "Subject:", 8) == 0) {
499
d4634f323460 fix stuff for 1.2.6.1
mmj
parents: 497
diff changeset
145 subject_present = 1;
352
8173978c2bfd - if(strncasecmp(hdrline, "Subject: ", 9) == 0) {
mmj
parents: 325
diff changeset
146 unqp = cleanquotedp(hdrline + 8);
8173978c2bfd - if(strncasecmp(hdrline, "Subject: ", 9) == 0) {
mmj
parents: 325
diff changeset
147 if(strstr(hdrline + 8, prefix) == NULL &&
265
f28ab75abba7 Quoted printable subjects are now matched against prefix as well
mmj
parents: 254
diff changeset
148 strstr(unqp, prefix) == NULL) {
352
8173978c2bfd - if(strncasecmp(hdrline, "Subject: ", 9) == 0) {
mmj
parents: 325
diff changeset
149 subject = concatstr(3,
89
mmj
parents: 27
diff changeset
150 "Subject: ", prefix,
352
8173978c2bfd - if(strncasecmp(hdrline, "Subject: ", 9) == 0) {
mmj
parents: 325
diff changeset
151 hdrline + 8);
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
152 writen(outfd, subject,
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
153 strlen(subject));
245
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 227
diff changeset
154 myfree(subject);
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 227
diff changeset
155 myfree(hdrline);
265
f28ab75abba7 Quoted printable subjects are now matched against prefix as well
mmj
parents: 254
diff changeset
156 myfree(unqp);
89
mmj
parents: 27
diff changeset
157 continue;
mmj
parents: 27
diff changeset
158 }
265
f28ab75abba7 Quoted printable subjects are now matched against prefix as well
mmj
parents: 254
diff changeset
159 myfree(unqp);
89
mmj
parents: 27
diff changeset
160 }
mmj
parents: 27
diff changeset
161 }
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
162
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
163 /* Should it be stripped? */
89
mmj
parents: 27
diff changeset
164 if(delhdrs) {
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
165 if(!findit(hdrline, delhdrs))
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
166 writen(outfd, hdrline, strlen(hdrline));
89
mmj
parents: 27
diff changeset
167 } else
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
168 writen(outfd, hdrline, strlen(hdrline));
89
mmj
parents: 27
diff changeset
169
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
170
245
00eadc106b34 changed to use the new memory wrappers
mortenp
parents: 227
diff changeset
171 myfree(hdrline);
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
172 }
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
173
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
174 /* Just print the rest of the mail */
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
175 if(dumpfd2fd(infd, outfd) < 0) {
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
176 log_error(LOG_ARGS, "Error when dumping rest of mail");
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
177 return -1;
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
178 }
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
179
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
180 /* No more, lets add the footer if one */
184
86d7d42fe996 Assorted bugfixes.
mmj
parents: 161
diff changeset
181 if(footfd >= 0)
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
182 if(dumpfd2fd(footfd, outfd) < 0) {
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
183 log_error(LOG_ARGS, "Error when adding footer");
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
184 return -1;
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
185 }
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
186
161
4b17bdd59e54 Bye bye FILE * and welcome fd's
mmj
parents: 120
diff changeset
187 fsync(outfd);
11
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
188
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
189 return 0;
8e1ebc68ee62 do_all_the_voodo_here introducton plus a massive cleanup
mmj
parents:
diff changeset
190 }