~ubuntu-branches/ubuntu/dapper/postfix/dapper-security

« back to all changes in this revision

Viewing changes to src/global/mail_scan_dir.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-02-27 09:33:07 UTC
  • Revision ID: james.westby@ubuntu.com-20050227093307-cn789t27ibnlh6tf
Tags: upstream-2.1.5
ImportĀ upstreamĀ versionĀ 2.1.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
43
char   *mail_scan_dir_next(SCAN_DIR *scan)
 
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
}