Mercurial > masqmail
comparison src/header.c @ 366:41958685480d
Switched to `type *name' style
Andrew Koenig's ``C Traps and Pitfalls'' (Ch.2.1) convinced
me that it is best to go with the way C had been designed.
The ``declaration reflects use'' concept conflicts with a
``type* name'' notation. Hence I switched.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Thu, 22 Sep 2011 15:07:40 +0200 |
parents | 01d2f7a17bf0 |
children | b27f66555ba8 |
comparison
equal
deleted
inserted
replaced
365:934a223e4ee8 | 366:41958685480d |
---|---|
69 /* finds list of headers matching id | 69 /* finds list of headers matching id |
70 if id == HEAD_UNKNOWN and header == NULL finds all unknown headers | 70 if id == HEAD_UNKNOWN and header == NULL finds all unknown headers |
71 else finds all headers matching header | 71 else finds all headers matching header |
72 */ | 72 */ |
73 GList* | 73 GList* |
74 find_header(GList * hdr_list, header_id id, gchar * hdr_str) | 74 find_header(GList *hdr_list, header_id id, gchar *hdr_str) |
75 { | 75 { |
76 GList *found_list = NULL; | 76 GList *found_list = NULL; |
77 GList *node; | 77 GList *node; |
78 | 78 |
79 if ((id != HEAD_UNKNOWN) || !hdr_str) { | 79 if ((id != HEAD_UNKNOWN) || !hdr_str) { |
101 } | 101 } |
102 return found_list; | 102 return found_list; |
103 } | 103 } |
104 | 104 |
105 void | 105 void |
106 header_unfold(header * hdr) | 106 header_unfold(header *hdr) |
107 { | 107 { |
108 char *src = hdr->header; | 108 char *src = hdr->header; |
109 char *dest = src; | 109 char *dest = src; |
110 char *p; | 110 char *p; |
111 | 111 |
131 /* | 131 /* |
132 fold the header at maxlen chars (newline excluded) | 132 fold the header at maxlen chars (newline excluded) |
133 (We exclude the newline because the RFCs deal with it this way) | 133 (We exclude the newline because the RFCs deal with it this way) |
134 */ | 134 */ |
135 void | 135 void |
136 header_fold(header* hdr, unsigned int maxlen) | 136 header_fold(header *hdr, unsigned int maxlen) |
137 { | 137 { |
138 int len = strlen(hdr->header); | 138 int len = strlen(hdr->header); |
139 char* src = hdr->header; | 139 char *src = hdr->header; |
140 char* dest; | 140 char *dest; |
141 char* tmp; | 141 char *tmp; |
142 char* p; | 142 char *p; |
143 int valueoffset; | 143 int valueoffset; |
144 | 144 |
145 if (len <= maxlen) { | 145 if (len <= maxlen) { |
146 /* we don't need to do anything */ | 146 /* we don't need to do anything */ |
147 return; | 147 return; |
207 hdr->header = tmp; | 207 hdr->header = tmp; |
208 hdr->value = hdr->header + valueoffset; | 208 hdr->value = hdr->header + valueoffset; |
209 } | 209 } |
210 | 210 |
211 header* | 211 header* |
212 create_header(header_id id, gchar * fmt, ...) | 212 create_header(header_id id, gchar *fmt, ...) |
213 { | 213 { |
214 gchar *p; | 214 gchar *p; |
215 header *hdr; | 215 header *hdr; |
216 va_list args; | 216 va_list args; |
217 va_start(args, fmt); | 217 va_start(args, fmt); |
240 va_end(args); | 240 va_end(args); |
241 return hdr; | 241 return hdr; |
242 } | 242 } |
243 | 243 |
244 void | 244 void |
245 destroy_header(header * hdr) | 245 destroy_header(header *hdr) |
246 { | 246 { |
247 if (hdr) { | 247 if (hdr) { |
248 if (hdr->header) { | 248 if (hdr->header) { |
249 g_free(hdr->header); | 249 g_free(hdr->header); |
250 } | 250 } |
251 g_free(hdr); | 251 g_free(hdr); |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 header* | 255 header* |
256 copy_header(header * hdr) | 256 copy_header(header *hdr) |
257 { | 257 { |
258 header *new_hdr = NULL; | 258 header *new_hdr = NULL; |
259 | 259 |
260 if (hdr) { | 260 if (hdr) { |
261 new_hdr = g_malloc(sizeof(header)); | 261 new_hdr = g_malloc(sizeof(header)); |
265 } | 265 } |
266 return new_hdr; | 266 return new_hdr; |
267 } | 267 } |
268 | 268 |
269 header* | 269 header* |
270 get_header(gchar * line) | 270 get_header(gchar *line) |
271 { | 271 { |
272 gchar *p = line; | 272 gchar *p = line; |
273 gchar buf[64], *q = buf; | 273 gchar buf[64], *q = buf; |
274 gint i; | 274 gint i; |
275 header *hdr; | 275 header *hdr; |