Mercurial > masqmail
comparison src/header.c @ 15:f671821d8222
code beautifying; 0 -> \0 if appropriate
author | meillo@marmaro.de |
---|---|
date | Thu, 06 Nov 2008 09:18:38 +0100 |
parents | 26e34ae9a3e3 |
children | 3708b655a371 |
comparison
equal
deleted
inserted
replaced
14:a8f3424347dc | 15:f671821d8222 |
---|---|
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 */ | 17 */ |
18 #include "masqmail.h" | 18 #include "masqmail.h" |
19 | 19 |
20 header_name header_names[] = { | 20 header_name header_names[] = { |
21 {"From", HEAD_FROM,} | 21 {"From", HEAD_FROM,}, |
22 , | 22 {"Sender", HEAD_SENDER,}, |
23 {"Sender", HEAD_SENDER,} | 23 {"To", HEAD_TO,}, |
24 , | 24 {"Cc", HEAD_CC,}, |
25 {"To", HEAD_TO,} | 25 {"Bcc", HEAD_BCC,}, |
26 , | 26 {"Date", HEAD_DATE,}, |
27 {"Cc", HEAD_CC,} | 27 {"Message-Id", HEAD_MESSAGE_ID,}, |
28 , | 28 {"Reply-To", HEAD_REPLY_TO,}, |
29 {"Bcc", HEAD_BCC,} | 29 {"Subject", HEAD_SUBJECT,}, |
30 , | 30 {"Return-Path", HEAD_RETURN_PATH,}, |
31 {"Date", HEAD_DATE,} | 31 {"Envelope-To", HEAD_ENVELOPE_TO,}, |
32 , | 32 {"Received", HEAD_RECEIVED}, |
33 {"Message-Id", HEAD_MESSAGE_ID,} | |
34 , | |
35 {"Reply-To", HEAD_REPLY_TO,} | |
36 , | |
37 {"Subject", HEAD_SUBJECT,} | |
38 , | |
39 {"Return-Path", HEAD_RETURN_PATH,} | |
40 , | |
41 {"Envelope-To", HEAD_ENVELOPE_TO,} | |
42 , | |
43 {"Received", HEAD_RECEIVED} | |
44 , | |
45 }; | 33 }; |
46 | 34 |
47 /* this was borrowed from exim and slightly changed */ | 35 /* this was borrowed from exim and slightly changed */ |
48 gchar* | 36 gchar* |
49 rec_timestamp() | 37 rec_timestamp() |
98 header *hdr = (header *) (node->data); | 86 header *hdr = (header *) (node->data); |
99 gchar buf[64], *q = buf, *p = hdr->header; | 87 gchar buf[64], *q = buf, *p = hdr->header; |
100 | 88 |
101 while (*p != ':' && q < buf + 63 && *p) | 89 while (*p != ':' && q < buf + 63 && *p) |
102 *(q++) = *(p++); | 90 *(q++) = *(p++); |
103 *q = 0; | 91 *q = '\0'; |
104 | 92 |
105 if (strcasecmp(buf, hdr_str) == 0) | 93 if (strcasecmp(buf, hdr_str) == 0) |
106 found_list = g_list_append(found_list, hdr); | 94 found_list = g_list_append(found_list, hdr); |
107 } | 95 } |
108 } | 96 } |
147 | 135 |
148 p = hdr->header; | 136 p = hdr->header; |
149 q = tmp_hdr; | 137 q = tmp_hdr; |
150 | 138 |
151 if (p[len - 1] == '\n') | 139 if (p[len - 1] == '\n') |
152 p[len - 1] = 0; | 140 p[len - 1] = '\0'; |
153 | 141 |
154 while (*p) { | 142 while (*p) { |
155 gint i, l; | 143 gint i, l; |
156 gchar *pp; | 144 gchar *pp; |
157 | 145 |
182 while (i < l) { | 170 while (i < l) { |
183 *(q++) = *(p++); | 171 *(q++) = *(p++); |
184 i++; | 172 i++; |
185 } | 173 } |
186 *(q++) = '\n'; | 174 *(q++) = '\n'; |
187 *(q++) = *(p++); /* this is either space, tab or 0 */ | 175 *(q++) = *(p++); /* this is either space, tab or 0 */ |
188 } | 176 } |
189 { | 177 { |
190 gchar *new_hdr; | 178 gchar *new_hdr; |
191 | 179 |
192 g_free(hdr->header); | 180 g_free(hdr->header); |
255 gint i; | 243 gint i; |
256 header *hdr; | 244 header *hdr; |
257 | 245 |
258 while (*p && (*p != ':') && (q < buf + 63)) | 246 while (*p && (*p != ':') && (q < buf + 63)) |
259 *(q++) = *(p++); | 247 *(q++) = *(p++); |
260 *q = 0; | 248 *q = '\0'; |
261 | 249 |
262 if (*p != ':') | 250 if (*p != ':') |
263 return NULL; | 251 return NULL; |
264 | 252 |
265 hdr = g_malloc(sizeof(header)); | 253 hdr = g_malloc(sizeof(header)); |