1 /* Return a string describing the type of a file.
3 Copyright (C) 1993, 1994, 2001, 2002 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 /* Written by Paul Eggert and Jim Meyering. */
21 /* Include <sys/types.h> and <sys/stat.h> before including this
25 # define FILE_TYPE_H 1
27 # if 2 <= __GLIBC__ && 2 <= __GLIBC_MINOR__
28 # if !defined _SYS_STAT_H || !defined _SYS_TYPES_H
29 you must include <sys/types.h> and <sys/stat.h> before including this file
33 char const *file_type (struct stat const *);
36 # define S_IFMT 0170000
39 # if STAT_MACROS_BROKEN
57 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
65 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
73 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
79 # ifndef S_ISDOOR /* Solaris 2.5 and up */
81 # define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
83 # define S_ISDOOR(m) 0
89 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
91 # define S_ISFIFO(m) 0
97 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
103 # ifndef S_ISMPB /* V7 */
105 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
106 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
108 # define S_ISMPB(m) 0
109 # define S_ISMPC(m) 0
113 # ifndef S_ISNAM /* Xenix */
115 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
117 # define S_ISNAM(m) 0
121 # ifndef S_ISNWK /* HP/UX */
123 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
125 # define S_ISNWK(m) 0
131 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
133 # define S_ISREG(m) 0
139 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
141 # define S_ISSOCK(m) 0
148 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
150 # define S_TYPEISSEM(p) 0
156 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
158 # define S_TYPEISSHM(p) 0
163 # define S_TYPEISMQ(p) 0
166 #endif /* FILE_TYPE_H */