File indexing completed on 2024-05-05 11:56:32

0001 /*
0002  * check a filename to see if it's a (fifo|character special|socket) object
0003  * (if a stat() function doesn't exist, we can't stat so we'll just return
0004  *  true no matter what.)
0005  */
0006 
0007 #include "config.h"
0008 
0009 #if HAVE_STAT && HAS_ISCHR && HAS_ISFIFO && HAS_ISSOCK
0010 #include <sys/stat.h>
0011 
0012 int
0013 notspecial(char *file)
0014 {
0015     struct stat info;
0016 
0017     if ( stat(file, &info) != 0 )
0018     return 1;
0019     
0020     return !( S_ISCHR(info.st_mode) || S_ISFIFO(info.st_mode) || S_ISSOCK(info.st_mode) );
0021 }
0022 #else
0023 int
0024 notspecial(char *file)
0025 {
0026     return 1;
0027 }
0028 #endif
0029 
0030 
0031 #if DEBUG
0032 
0033 #include <stdio.h>
0034 
0035 int
0036 main(argc, argv)
0037 char **argv;
0038 {
0039     int i;
0040 
0041     for ( i=1; i < argc; i++ )
0042     printf("%s is %sspecial\n", argv[i], notspecial(argv[i]) ? "not " : "");
0043 }
0044 #endif