File: notspecial.c

package info (click to toggle)
libtext-markdown-discount-perl 0.18-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,524 kB
  • sloc: ansic: 5,765; pascal: 1,027; sh: 208; makefile: 196; perl: 184
file content (44 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (10)
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
/*
 * check a filename to see if it's a (fifo|character special|socket) object
 * (if a stat() function doesn't exist, we can't stat so we'll just return
 *  true no matter what.)
 */

#include "config.h"

#if HAVE_STAT && HAS_ISCHR && HAS_ISFIFO && HAS_ISSOCK
#include <sys/stat.h>

int
notspecial(char *file)
{
    struct stat info;

    if ( stat(file, &info) != 0 )
	return 1;
    
    return !( S_ISCHR(info.st_mode) || S_ISFIFO(info.st_mode) || S_ISSOCK(info.st_mode) );
}
#else
int
notspecial(char *file)
{
    return 1;
}
#endif


#if DEBUG

#include <stdio.h>

int
main(argc, argv)
char **argv;
{
    int i;

    for ( i=1; i < argc; i++ )
	printf("%s is %sspecial\n", argv[i], notspecial(argv[i]) ? "not " : "");
}
#endif