comparison src/masqmail.c @ 264:1e5e457dea18

comments and a small refactoring
author markus schnalke <meillo@marmaro.de>
date Fri, 03 Dec 2010 10:43:38 -0300
parents e9e73505ab2c
children ab39047ffe44
comparison
equal deleted inserted replaced
263:e9e73505ab2c 264:1e5e457dea18
127 } 127 }
128 logwrite(LOG_WARNING, "could not write pid file: %s\n", strerror(errno)); 128 logwrite(LOG_WARNING, "could not write pid file: %s\n", strerror(errno));
129 return FALSE; 129 return FALSE;
130 } 130 }
131 131
132 /* on -bd or if -q has an argument */
132 static void 133 static void
133 mode_daemon(gboolean do_listen, gint queue_interval, char *argv[]) 134 mode_daemon(gboolean do_listen, gint queue_interval, char *argv[])
134 { 135 {
135 guint pid; 136 guint pid;
136 137
169 170
170 logwrite(LOG_NOTICE, "%s %s daemon starting\n", PACKAGE, VERSION); 171 logwrite(LOG_NOTICE, "%s %s daemon starting\n", PACKAGE, VERSION);
171 listen_port(do_listen ? conf.listen_addresses : NULL, queue_interval, argv); 172 listen_port(do_listen ? conf.listen_addresses : NULL, queue_interval, argv);
172 } 173 }
173 174
175 /* -bs or called as smtpd or in.smtpd */
174 static void 176 static void
175 mode_smtp() 177 mode_smtp()
176 { 178 {
177 /* accept smtp message on stdin */ 179 /* accept smtp message on stdin */
178 /* write responses to stderr. */ 180 /* write responses to stderr. */
196 exit(1); 198 exit(1);
197 199
198 smtp_in(stdin, stderr, peername, NULL); 200 smtp_in(stdin, stderr, peername, NULL);
199 } 201 }
200 202
203 /* default mode if address args or -t is specified, or called as rmail */
201 static void 204 static void
202 mode_accept(address * return_path, gchar * full_sender_name, guint accept_flags, char **addresses, int addr_cnt) 205 mode_accept(address * return_path, gchar * full_sender_name, guint accept_flags, char **addresses, int addr_cnt)
203 { 206 {
204 /* accept message on stdin */ 207 /* accept message on stdin */
205 accept_error err; 208 accept_error err;
218 221
219 DEBUG(5) debugf("accepting message on stdin\n"); 222 DEBUG(5) debugf("accepting message on stdin\n");
220 223
221 msg->received_prot = PROT_LOCAL; 224 msg->received_prot = PROT_LOCAL;
222 for (i = 0; i < addr_cnt; i++) { 225 for (i = 0; i < addr_cnt; i++) {
223 if (addresses[i][0] != '|') 226 if (addresses[i][0] == '|')
224 msg->rcpt_list = g_list_append(msg->rcpt_list, create_address_qualified(addresses[i], TRUE, conf.host_name));
225 else {
226 logwrite(LOG_ALERT, "no pipe allowed as recipient address: %s\n", addresses[i]); 227 logwrite(LOG_ALERT, "no pipe allowed as recipient address: %s\n", addresses[i]);
227 exit(1); 228 exit(1);
228 } 229 }
230 msg->rcpt_list = g_list_append(msg->rcpt_list, create_address_qualified(addresses[i], TRUE, conf.host_name));
229 } 231 }
230 232
231 /* -f option */ 233 /* -f option */
232 msg->return_path = return_path; 234 msg->return_path = return_path;
233 235
276 exit(1); 278 exit(1);
277 } 279 }
278 } 280 }
279 281
280 /* 282 /*
283 if -Mrm is given
284
281 currently only the `rm' command is supported 285 currently only the `rm' command is supported
282 until this changes, we don't need any facility for further commands 286 until this changes, we don't need any facility for further commands
283 return success if at least one message had been deleted 287 return success if at least one message had been deleted
284 */ 288 */
285 static int 289 static int
339 ok = queue_delete(*id); 343 ok = queue_delete(*id);
340 } 344 }
341 return ok; 345 return ok;
342 } 346 }
343 347
348 /* -qo, -q (without argument), or called as runq */
349 /* TODO: are -qo and -q exclusively or not?
350 And how is this related to being a daemon? */
344 static int 351 static int
345 run_queue(gboolean do_runq, gboolean do_runq_online, char* route_name) 352 run_queue(gboolean do_runq, gboolean do_runq_online, char* route_name)
346 { 353 {
347 int ret; 354 int ret;
348 355
361 ret = queue_run_online(); 368 ret = queue_run_online();
362 } 369 }
363 return ret; 370 return ret;
364 } 371 }
365 372
373 /* -bV or default mode if neither addr arg nor -t */
366 static void 374 static void
367 mode_version(void) 375 mode_version(void)
368 { 376 {
369 gchar *with_resolver = ""; 377 gchar *with_resolver = "";
370 gchar *with_auth = ""; 378 gchar *with_auth = "";