Mercurial > masqmail
comparison src/header.c @ 367:b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
Now we use:
/*
** comment
*/
This makes the indent style simpler, too.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Thu, 20 Oct 2011 10:20:59 +0200 |
parents | 41958685480d |
children | 028bc124d744 |
comparison
equal
deleted
inserted
replaced
366:41958685480d | 367:b27f66555ba8 |
---|---|
1 /* MasqMail | 1 /* |
2 Copyright (C) 2000 Oliver Kurth | 2 ** MasqMail |
3 | 3 ** Copyright (C) 2000 Oliver Kurth |
4 This program is free software; you can redistribute it and/or modify | 4 ** |
5 it under the terms of the GNU General Public License as published by | 5 ** This program is free software; you can redistribute it and/or modify |
6 the Free Software Foundation; either version 2 of the License, or | 6 ** it under the terms of the GNU General Public License as published by |
7 (at your option) any later version. | 7 ** the Free Software Foundation; either version 2 of the License, or |
8 | 8 ** (at your option) any later version. |
9 This program is distributed in the hope that it will be useful, | 9 ** |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 ** This program is distributed in the hope that it will be useful, |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 GNU General Public License for more details. | 12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 13 ** GNU General Public License for more details. |
14 You should have received a copy of the GNU General Public License | 14 ** |
15 along with this program; if not, write to the Free Software | 15 ** You should have received a copy of the GNU General Public License |
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 16 ** along with this program; if not, write to the Free Software |
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 */ | 18 */ |
18 #include "masqmail.h" | 19 #include "masqmail.h" |
19 | 20 |
20 header_name header_names[] = { | 21 header_name header_names[] = { |
21 {"From", HEAD_FROM,}, | 22 {"From", HEAD_FROM,}, |
64 g_snprintf(buf + len, sizeof(buf) - len, " %+03d%02d", diff_hour, diff_min); | 65 g_snprintf(buf + len, sizeof(buf) - len, " %+03d%02d", diff_hour, diff_min); |
65 | 66 |
66 return buf; | 67 return buf; |
67 } | 68 } |
68 | 69 |
69 /* finds list of headers matching id | 70 /* |
70 if id == HEAD_UNKNOWN and header == NULL finds all unknown headers | 71 ** finds list of headers matching id |
71 else finds all headers matching header | 72 ** if id == HEAD_UNKNOWN and header == NULL finds all unknown headers |
73 ** else finds all headers matching header | |
72 */ | 74 */ |
73 GList* | 75 GList* |
74 find_header(GList *hdr_list, header_id id, gchar *hdr_str) | 76 find_header(GList *hdr_list, header_id id, gchar *hdr_str) |
75 { | 77 { |
76 GList *found_list = NULL; | 78 GList *found_list = NULL; |
127 *(dest++) = '\n'; | 129 *(dest++) = '\n'; |
128 *(dest++) = '\0'; | 130 *(dest++) = '\0'; |
129 } | 131 } |
130 | 132 |
131 /* | 133 /* |
132 fold the header at maxlen chars (newline excluded) | 134 ** fold the header at maxlen chars (newline excluded) |
133 (We exclude the newline because the RFCs deal with it this way) | 135 ** (We exclude the newline because the RFCs deal with it this way) |
134 */ | 136 */ |
135 void | 137 void |
136 header_fold(header *hdr, unsigned int maxlen) | 138 header_fold(header *hdr, unsigned int maxlen) |
137 { | 139 { |
138 int len = strlen(hdr->header); | 140 int len = strlen(hdr->header); |
153 len--; | 155 len--; |
154 printf(" trailing whitespace\n"); | 156 printf(" trailing whitespace\n"); |
155 } | 157 } |
156 printf("stripped len: %d\n", len); | 158 printf("stripped len: %d\n", len); |
157 | 159 |
158 /* FIXME: would be nice to have a better size calculation */ | 160 /* |
159 /* (the current size + what we insert as break, twice as often as | 161 ** FIXME: would be nice to have a better size calculation |
160 we have breaks in the optimal case) */ | 162 ** (the current size + what we insert as break, twice as often as |
163 ** we have breaks in the optimal case) | |
164 */ | |
161 tmp = malloc(len + 2 * (len/maxlen) * strlen("\n\t")); | 165 tmp = malloc(len + 2 * (len/maxlen) * strlen("\n\t")); |
162 dest = tmp; | 166 dest = tmp; |
163 | 167 |
164 /* the position in hdr->header where the value part start */ | 168 /* the position in hdr->header where the value part start */ |
165 valueoffset = hdr->value - hdr->header; | 169 valueoffset = hdr->value - hdr->header; |
221 | 225 |
222 hdr->id = id; | 226 hdr->id = id; |
223 hdr->header = g_strdup_vprintf(fmt, args); | 227 hdr->header = g_strdup_vprintf(fmt, args); |
224 hdr->value = NULL; | 228 hdr->value = NULL; |
225 | 229 |
226 /* value shall point to the first non-whitespace char in the | 230 /* |
227 value part of the header line (i.e. after the first colon) */ | 231 ** value shall point to the first non-whitespace char in the |
232 ** value part of the header line (i.e. after the first colon) | |
233 */ | |
228 p = strchr(hdr->header, ':'); | 234 p = strchr(hdr->header, ':'); |
229 if (p) { | 235 if (p) { |
230 p++; | 236 p++; |
231 while (*p == ' ' || *p == '\t' || *p == '\n') { | 237 while (*p == ' ' || *p == '\t' || *p == '\n') { |
232 p++; | 238 p++; |
290 | 296 |
291 while (*p && (*p == ' ' || *p == '\t')) { | 297 while (*p && (*p == ' ' || *p == '\t')) { |
292 p++; | 298 p++; |
293 } | 299 } |
294 hdr->value = p; | 300 hdr->value = p; |
295 /* Note: an empty value can also mean that it's only the first part | 301 /* |
296 of a folded header line */ | 302 ** Note: an empty value can also mean that it's only the first part |
303 ** of a folded header line | |
304 */ | |
297 | 305 |
298 for (i = 0; i < HEAD_NUM_IDS; i++) { | 306 for (i = 0; i < HEAD_NUM_IDS; i++) { |
299 if (strcasecmp(header_names[i].header, buf) == 0) { | 307 if (strcasecmp(header_names[i].header, buf) == 0) { |
300 break; | 308 break; |
301 } | 309 } |