summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/queue.c
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-01-29 12:43:26 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-01-29 12:43:26 +0000
commitb9bfb27b66bb75007562fe135ffb4b1be9c4bd16 (patch)
tree3e55179a54e9e6ef1a8738c757431a88ef0ac674 /usr.sbin/smtpd/queue.c
parent396bc3cb8b875e7ec1ce1ff0020dd352ae7aecbe (diff)
Common queue walking code for smtpd and smtpctl. Kills majority of showqueue.c,
the remaining code was moved to queue_shared.c; ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/queue.c')
-rw-r--r--usr.sbin/smtpd/queue.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c
index d0715dfa2a3..0b4d1857d4a 100644
--- a/usr.sbin/smtpd/queue.c
+++ b/usr.sbin/smtpd/queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue.c,v 1.51 2009/01/28 17:29:11 jacekm Exp $ */
+/* $OpenBSD: queue.c,v 1.52 2009/01/29 12:43:25 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -24,10 +24,10 @@
#include <sys/socket.h>
#include <sys/stat.h>
-#include <dirent.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
+#include <libgen.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -670,21 +670,13 @@ message_by_id(struct smtpd *env, struct batch *batchp, u_int64_t id)
void
queue_purge_incoming(void)
{
- DIR *dirp;
- struct dirent *dp;
+ char path[MAXPATHLEN];
+ struct qwalk *q;
- dirp = opendir(PATH_INCOMING);
- if (dirp == NULL)
- fatal("queue_purge_incoming: opendir");
+ q = qwalk_new(PATH_INCOMING);
- while ((dp = readdir(dirp)) != NULL) {
- if (strcmp(dp->d_name, ".") == 0 ||
- strcmp(dp->d_name, "..") == 0) {
- continue;
- }
- queue_delete_incoming_message(dp->d_name);
- }
+ while (qwalk(q, path))
+ queue_delete_incoming_message(basename(path));
- closedir(dirp);
+ qwalk_close(q);
}
-