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
24 char const *file_type (struct stat const *);
27 # define S_IFMT 0170000
30 #if STAT_MACROS_BROKEN
48 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
56 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
64 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
70 #ifndef S_ISDOOR /* Solaris 2.5 and up */
72 # define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
74 # define S_ISDOOR(m) 0
80 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
82 # define S_ISFIFO(m) 0
88 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
94 #ifndef S_ISMPB /* V7 */
96 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
97 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
100 # define S_ISMPC(m) 0
104 #ifndef S_ISNAM /* Xenix */
106 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
108 # define S_ISNAM(m) 0
112 #ifndef S_ISNWK /* HP/UX */
114 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
116 # define S_ISNWK(m) 0
122 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
124 # define S_ISREG(m) 0
130 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
132 # define S_ISSOCK(m) 0
139 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
141 # define S_TYPEISSEM(p) 0
147 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
149 # define S_TYPEISSHM(p) 0
154 # define S_TYPEISMQ(p) 0