Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / global / mail_scan_dir.c
blob384675c75ea386de96457a200913378f46f8d45e
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* mail_scan_dir 3
6 /* SUMMARY
7 /* mail queue directory scanning support
8 /* SYNOPSIS
9 /* #include <mail_scan_dir.h>
11 /* char *mail_scan_dir_next(scan)
12 /* SCAN_DIR *scan;
13 /* DESCRIPTION
14 /* The \fBmail_scan_dir_next\fR() routine is a wrapper around
15 /* scan_dir_next() that understands the structure of a Postfix
16 /* mail queue. The result is a queue ID or a null pointer.
17 /* SEE ALSO
18 /* scan_dir(3) directory scanner
19 /* LICENSE
20 /* .ad
21 /* .fi
22 /* The Secure Mailer license must be distributed with this software.
23 /* AUTHOR(S)
24 /* Wietse Venema
25 /* IBM T.J. Watson Research
26 /* P.O. Box 704
27 /* Yorktown Heights, NY 10598, USA
28 /*--*/
30 /* System library. */
32 #include <sys_defs.h>
33 #include <string.h>
35 /* Utility library. */
37 #include <scan_dir.h>
39 /* Global library. */
41 #include <mail_scan_dir.h>
43 /* mail_scan_dir_next - return next queue file */
45 char *mail_scan_dir_next(SCAN_DIR *scan)
47 char *name;
50 * Exploit the fact that mail queue subdirectories have one-letter names,
51 * so we don't have to stat() every file in sight. This is a win because
52 * many dirent implementations do not return file type information.
54 for (;;) {
55 if ((name = scan_dir_next(scan)) == 0) {
56 if (scan_dir_pop(scan) == 0)
57 return (0);
58 } else if (strlen(name) == 1) {
59 scan_dir_push(scan, name);
60 } else {
61 return (name);