Debian Codegraph @

ext/notspecial.c

raw symbols SCIP
1 /*
2 * check a filename to see if it's a (fifo|character special|socket) object
3 * (if a stat() function doesn't exist, we can't stat so we'll just return
4 * true no matter what.)
5 */
6
7 #include "config.h"
8
9 #if HAVE_STAT && HAS_ISCHR && HAS_ISFIFO && HAS_ISSOCK
10 #include <sys/stat.h>
11
12 int
13 notspecial(char *file)
14 {
15 struct stat info;
16
17 if ( stat(file, &info) != 0 )
18 return 1;
19
20 return !( S_ISCHR(info.st_mode) || S_ISFIFO(info.st_mode) || S_ISSOCK(info.st_mode) );
21 }
22 #else
23 int
24 notspecial(char *file)
25 {
26 return 1;
27 }
28 #endif
29
30
31 #if DEBUG
32
33 #include <stdio.h>
34
35 int
36 main(argc, argv)
37 char **argv;
38 {
39 int i;
40
41 for ( i=1; i < argc; i++ )
42 printf("%s is %sspecial\n", argv[i], notspecial(argv[i]) ? "not " : "");
43 }
44 #endif