1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
$NetBSD: patch-aa,v 1.2 2006/01/24 19:08:09 joerg Exp $
--- newmail.c.orig 1999-10-14 04:49:42.000000000 +0000
+++ newmail.c
@@ -28,6 +28,22 @@
static void usage();
static void version();
+#ifdef DT_REG
+#define DIRENT_IS_REG(x) ((x) == DT_REG)
+#elif defined(DTTOIF)
+#define DIRENT_IS_REG(x) (S_ISREG(DTTOIF((x))))
+#else
+#error "Neither DT_REG nor DTTOIF is defined."
+#endif
+
+#ifdef DT_DIR
+#define DIRENT_IS_DIR(x) ((x) == DT_DIR)
+#elif defined(DTTOIF)
+#define DIRENT_IS_DIR(x) (S_ISDIR(DTTOIF((x))))
+#else
+#error "Neither DT_REG nor DTTOIF is defined."
+#endif
+
unsigned char no_mail_message,
individual_messages,
use_exit_val;
@@ -98,7 +114,7 @@ int main(int argc, char *argv[]) {
continue;
}
/* see if its a regular file */
- if (S_ISREG(DTTOIF(curr_file->d_type))) {
+ if (DIRENT_IS_REG(curr_file->d_type)) {
/* stat it for check_mailbox */
if (stat(curr_file->d_name, &file_info) == -1) {
err(EX_NOINPUT, "couldn't stat %s/%s", argv[ui], curr_file->d_name);
@@ -106,7 +122,7 @@ int main(int argc, char *argv[]) {
check_mailbox(curr_file->d_name, &file_info, &found_mail);
} else if (warn_non_regular) {
/* just check its not a directory before warning */
- if (! S_ISDIR(DTTOIF(curr_file->d_type))) {
+ if (! DIRENT_IS_DIR(curr_file->d_type)) {
warnx("Found %s/%s: Not a regular file", argv[ui], curr_file->d_name);
}
} /* end of is dirent a regular file */
@@ -148,19 +164,19 @@ void check_mailbox(const char *const fn,
static void usage() {
- fprintf(stderr,"usage: newmail [-deirv] directory|file directory|file ...
-
-where:
- d: Prints messages when you do not have new mail
- e: Exits with 0 on no new mail, 1 on new mail, > 1 on error
- (normally exits with a value from sysexits(3)). May not be used
- with -d or -i.
- i: Prints a message for each mailbox that has new mail (and those
- that don't if -d is also used)
- r: Warns if it finds a non regular file
- v: Print version number and exit
-
-directory|file are, respectively, directories to look in for mailboxes
+ fprintf(stderr,"usage: newmail [-deirv] directory|file directory|file ...\n\
+\n\
+where:\n\
+ d: Prints messages when you do not have new mail\n\
+ e: Exits with 0 on no new mail, 1 on new mail, > 1 on error\n\
+ (normally exits with a value from sysexits(3)). May not be used\n\
+ with -d or -i.\n\
+ i: Prints a message for each mailbox that has new mail (and those\n\
+ that don't if -d is also used)\n\
+ r: Warns if it finds a non regular file\n\
+ v: Print version number and exit\n\
+ \n\
+directory|file are, respectively, directories to look in for mailboxes\n\
and mailboxes.\n");
exit(EX_USAGE);
|