Mercurial > masqmail
comparison src/spool.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 | b45dc53f2829 |
children | b27f66555ba8 |
comparison
equal
deleted
inserted
replaced
365:934a223e4ee8 | 366:41958685480d |
---|---|
21 | 21 |
22 #include "masqmail.h" | 22 #include "masqmail.h" |
23 #include "dotlock.h" | 23 #include "dotlock.h" |
24 | 24 |
25 static gint | 25 static gint |
26 read_line(FILE * in, gchar * buf, gint buf_len) | 26 read_line(FILE *in, gchar *buf, gint buf_len) |
27 { | 27 { |
28 gint p = 0; | 28 gint p = 0; |
29 gint c; | 29 gint c; |
30 | 30 |
31 while ((c = getc(in)) != '\n' && (c != EOF)) { | 31 while ((c = getc(in)) != '\n' && (c != EOF)) { |
47 | 47 |
48 return p; | 48 return p; |
49 } | 49 } |
50 | 50 |
51 static void | 51 static void |
52 spool_write_rcpt(FILE * out, address * rcpt) | 52 spool_write_rcpt(FILE *out, address *rcpt) |
53 { | 53 { |
54 gchar dlvrd_char = addr_is_delivered(rcpt) ? 'X' : (addr_is_failed(rcpt) ? 'F' : ' '); | 54 gchar dlvrd_char = addr_is_delivered(rcpt) ? 'X' : (addr_is_failed(rcpt) ? 'F' : ' '); |
55 | 55 |
56 if (rcpt->local_part[0] != '|') { | 56 if (rcpt->local_part[0] != '|') { |
57 /* this is a paranoid check, in case it slipped through: */ | 57 /* this is a paranoid check, in case it slipped through: */ |
66 fprintf(out, "RT:%c%s\n", dlvrd_char, rcpt->local_part); | 66 fprintf(out, "RT:%c%s\n", dlvrd_char, rcpt->local_part); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 static address* | 70 static address* |
71 spool_scan_rcpt(gchar * line) | 71 spool_scan_rcpt(gchar *line) |
72 { | 72 { |
73 address *rcpt = NULL; | 73 address *rcpt = NULL; |
74 | 74 |
75 if (line[3] != '\0') { | 75 if (line[3] != '\0') { |
76 if (line[4] != '|') { | 76 if (line[4] != '|') { |
86 } | 86 } |
87 return rcpt; | 87 return rcpt; |
88 } | 88 } |
89 | 89 |
90 gboolean | 90 gboolean |
91 spool_read_data(message * msg) | 91 spool_read_data(message *msg) |
92 { | 92 { |
93 FILE *in; | 93 FILE *in; |
94 gchar *spool_file; | 94 gchar *spool_file; |
95 | 95 |
96 DEBUG(5) debugf("spool_read_data entered\n"); | 96 DEBUG(5) debugf("spool_read_data entered\n"); |
117 fclose(in); | 117 fclose(in); |
118 return TRUE; | 118 return TRUE; |
119 } | 119 } |
120 | 120 |
121 gboolean | 121 gboolean |
122 spool_read_header(message * msg) | 122 spool_read_header(message *msg) |
123 { | 123 { |
124 FILE *in; | 124 FILE *in; |
125 gchar *spool_file; | 125 gchar *spool_file; |
126 | 126 |
127 /* header spool: */ | 127 /* header spool: */ |
199 fclose(in); | 199 fclose(in); |
200 return TRUE; | 200 return TRUE; |
201 } | 201 } |
202 | 202 |
203 message* | 203 message* |
204 msg_spool_read(gchar * uid) | 204 msg_spool_read(gchar *uid) |
205 { | 205 { |
206 message *msg; | 206 message *msg; |
207 gboolean ok = FALSE; | 207 gboolean ok = FALSE; |
208 | 208 |
209 msg = create_message(); | 209 msg = create_message(); |
218 | 218 |
219 /* write header. uid and gid should already be set to the | 219 /* write header. uid and gid should already be set to the |
220 mail ids. Better call spool_write(msg, FALSE). | 220 mail ids. Better call spool_write(msg, FALSE). |
221 */ | 221 */ |
222 static gboolean | 222 static gboolean |
223 spool_write_header(message * msg) | 223 spool_write_header(message *msg) |
224 { | 224 { |
225 GList *node; | 225 GList *node; |
226 gchar *spool_file, *tmp_file; | 226 gchar *spool_file, *tmp_file; |
227 FILE *out; | 227 FILE *out; |
228 gboolean ok = TRUE; | 228 gboolean ok = TRUE; |
293 | 293 |
294 return ok; | 294 return ok; |
295 } | 295 } |
296 | 296 |
297 gboolean | 297 gboolean |
298 spool_write(message * msg, gboolean do_write_data) | 298 spool_write(message *msg, gboolean do_write_data) |
299 { | 299 { |
300 GList *list; | 300 GList *list; |
301 gchar *spool_file, *tmp_file; | 301 gchar *spool_file, *tmp_file; |
302 FILE *out; | 302 FILE *out; |
303 gboolean ok = TRUE; | 303 gboolean ok = TRUE; |
358 } | 358 } |
359 | 359 |
360 #define MAX_LOCKAGE 300 | 360 #define MAX_LOCKAGE 300 |
361 | 361 |
362 gboolean | 362 gboolean |
363 spool_lock(gchar * uid) | 363 spool_lock(gchar *uid) |
364 { | 364 { |
365 uid_t saved_uid, saved_gid; | 365 uid_t saved_uid, saved_gid; |
366 gchar *hitch_name; | 366 gchar *hitch_name; |
367 gchar *lock_name; | 367 gchar *lock_name; |
368 gboolean ok = FALSE; | 368 gboolean ok = FALSE; |
389 | 389 |
390 return ok; | 390 return ok; |
391 } | 391 } |
392 | 392 |
393 gboolean | 393 gboolean |
394 spool_unlock(gchar * uid) | 394 spool_unlock(gchar *uid) |
395 { | 395 { |
396 uid_t saved_uid, saved_gid; | 396 uid_t saved_uid, saved_gid; |
397 gchar *lock_name; | 397 gchar *lock_name; |
398 | 398 |
399 /* set uid and gid to the mail ids */ | 399 /* set uid and gid to the mail ids */ |
411 } | 411 } |
412 return TRUE; | 412 return TRUE; |
413 } | 413 } |
414 | 414 |
415 gboolean | 415 gboolean |
416 spool_delete_all(message * msg) | 416 spool_delete_all(message *msg) |
417 { | 417 { |
418 uid_t saved_uid, saved_gid; | 418 uid_t saved_uid, saved_gid; |
419 gchar *spool_file; | 419 gchar *spool_file; |
420 | 420 |
421 /* set uid and gid to the mail ids */ | 421 /* set uid and gid to the mail ids */ |