7 /* move queue entries to another queue
11 /* void qmgr_move(from, to, time_stamp)
16 /* The \fBqmgr_move\fR routine scans the \fIfrom\fR queue for entries
17 /* with valid queue names and moves them to the \fIto\fR queue.
18 /* If \fItime_stamp\fR is non-zero, the queue file time stamps are
19 /* set to the specified value.
20 /* Entries with invalid names are left alone. No attempt is made to
21 /* look for other badness such as multiple links or weird file types.
22 /* These issues are dealt with when a queue file is actually opened.
26 /* The Secure Mailer license must be distributed with this software.
29 /* IBM T.J. Watson Research
31 /* Yorktown Heights, NY 10598, USA
42 /* Utility library. */
46 #include <recipient_list.h>
50 #include <mail_queue.h>
51 #include <mail_scan_dir.h>
53 /* Application-specific. */
57 /* qmgr_move - move queue entries to another queue, leave bad files alone */
59 void qmgr_move(const char *src_queue
, const char *dst_queue
,
62 const char *myname
= "qmgr_move";
68 if (strcmp(src_queue
, dst_queue
) == 0)
69 msg_panic("%s: source queue %s is destination", myname
, src_queue
);
71 msg_info("start move queue %s -> %s", src_queue
, dst_queue
);
73 queue_dir
= scan_dir_open(src_queue
);
74 while ((queue_id
= mail_scan_dir_next(queue_dir
)) != 0) {
75 if (mail_queue_id_ok(queue_id
)) {
77 tbuf
.actime
= tbuf
.modtime
= time_stamp
;
78 path
= mail_queue_path((VSTRING
*) 0, src_queue
, queue_id
);
79 if (utime(path
, &tbuf
) < 0) {
81 msg_fatal("%s: update %s time stamps: %m", myname
, path
);
82 msg_warn("%s: update %s time stamps: %m", myname
, path
);
86 if (mail_queue_rename(queue_id
, src_queue
, dst_queue
)) {
88 msg_fatal("%s: rename %s from %s to %s: %m",
89 myname
, queue_id
, src_queue
, dst_queue
);
90 msg_warn("%s: rename %s from %s to %s: %m",
91 myname
, queue_id
, src_queue
, dst_queue
);
95 msg_info("%s: moved %s from %s to %s",
96 myname
, queue_id
, src_queue
, dst_queue
);
98 msg_warn("%s: ignored: queue %s id %s",
99 myname
, src_queue
, queue_id
);
102 scan_dir_close(queue_dir
);
105 msg_info("end move queue %s -> %s", src_queue
, dst_queue
);