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