1 /*	$NetBSD: mail_flush.c,v 1.1.1.1 2009/06/23 10:08:46 tron Exp $	*/
2 
3 /*++
4 /* NAME
5 /*	mail_flush 3
6 /* SUMMARY
7 /*	flush backed up mail
8 /* SYNOPSIS
9 /*	#include <mail_flush.h>
10 /*
11 /*	int	mail_flush_deferred()
12 /*
13 /*	int	mail_flush_maildrop()
14 /* DESCRIPTION
15 /*	This module triggers delivery of backed up mail.
16 /*
17 /*	mail_flush_deferred() triggers delivery of all deferred
18 /*	or incoming mail. This function tickles the queue manager.
19 /*
20 /*	mail_flush_maildrop() triggers delivery of all mail in
21 /*	the maildrop directory. This function tickles the pickup
22 /*	service.
23 /* DIAGNOSTICS
24 /*	The result is 0 in case of success, -1 in case of failure.
25 /* LICENSE
26 /* .ad
27 /* .fi
28 /*	The Secure Mailer license must be distributed with this software.
29 /* AUTHOR(S)
30 /*	Wietse Venema
31 /*	IBM T.J. Watson Research
32 /*	P.O. Box 704
33 /*	Yorktown Heights, NY 10598, USA
34 /*--*/
35 
36 /* System library. */
37 
38 #include "sys_defs.h"
39 
40 /* Utility library. */
41 
42 /* Global library. */
43 
44 #include <mail_params.h>
45 #include <mail_proto.h>
46 #include <mail_flush.h>
47 
48 /* mail_flush_deferred - flush deferred/incoming queue */
49 
50 int     mail_flush_deferred(void)
51 {
52     static char qmgr_trigger[] = {
53 	QMGR_REQ_FLUSH_DEAD,		/* all hosts, all transports */
54 	QMGR_REQ_SCAN_ALL,		/* all time stamps */
55 	QMGR_REQ_SCAN_DEFERRED,		/* scan deferred queue */
56 	QMGR_REQ_SCAN_INCOMING,		/* scan incoming queue */
57     };
58 
59     /*
60      * Trigger the flush queue service.
61      */
62     return (mail_trigger(MAIL_CLASS_PUBLIC, var_queue_service,
63 			 qmgr_trigger, sizeof(qmgr_trigger)));
64 }
65 
66 /* mail_flush_maildrop - flush maildrop queue */
67 
68 int     mail_flush_maildrop(void)
69 {
70     static char wakeup[] = {TRIGGER_REQ_WAKEUP};
71 
72     /*
73      * Trigger the pickup service.
74      */
75     return (mail_trigger(MAIL_CLASS_PUBLIC, var_pickup_service,
76 			 wakeup, sizeof(wakeup)));
77 }
78