5
/* move queue entries to another queue
9
/* void qmgr_move(from, to, time_stamp)
14
/* The \fBqmgr_move\fR routine scans the \fIfrom\fR queue for entries
15
/* with valid queue names and moves them to the \fIto\fR queue.
16
/* If \fItime_stamp\fR is non-zero, the queue file time stamps are
17
/* set to the specified value.
18
/* Entries with invalid names are left alone. No attempt is made to
19
/* look for other badness such as multiple links or weird file types.
20
/* These issues are dealt with when a queue file is actually opened.
24
/* The Secure Mailer license must be distributed with this software.
27
/* IBM T.J. Watson Research
29
/* Yorktown Heights, NY 10598, USA
40
/* Utility library. */
44
#include <recipient_list.h>
48
#include <mail_queue.h>
49
#include <mail_scan_dir.h>
51
/* Application-specific. */
55
/* qmgr_move - move queue entries to another queue, leave bad files alone */
57
void qmgr_move(const char *src_queue, const char *dst_queue,
60
char *myname = "qmgr_move";
66
if (strcmp(src_queue, dst_queue) == 0)
67
msg_panic("%s: source queue %s is destination", myname, src_queue);
69
msg_info("start move queue %s -> %s", src_queue, dst_queue);
71
queue_dir = scan_dir_open(src_queue);
72
while ((queue_id = mail_scan_dir_next(queue_dir)) != 0) {
73
if (mail_queue_id_ok(queue_id)) {
75
tbuf.actime = tbuf.modtime = time_stamp;
76
path = mail_queue_path((VSTRING *) 0, src_queue, queue_id);
77
if (utime(path, &tbuf) < 0) {
79
msg_fatal("%s: update %s time stamps: %m", myname, path);
80
msg_warn("%s: update %s time stamps: %m", myname, path);
84
if (mail_queue_rename(queue_id, src_queue, dst_queue)) {
86
msg_fatal("%s: rename %s from %s to %s: %m",
87
myname, queue_id, src_queue, dst_queue);
88
msg_warn("%s: rename %s from %s to %s: %m",
89
myname, queue_id, src_queue, dst_queue);
93
msg_info("%s: moved %s from %s to %s",
94
myname, queue_id, src_queue, dst_queue);
96
msg_warn("%s: ignored: queue %s id %s",
97
myname, src_queue, queue_id);
100
scan_dir_close(queue_dir);
103
msg_info("end move queue %s -> %s", src_queue, dst_queue);