1/* Return a string describing the type of a file.
2
3   Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc.
4
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)
8   any later version.
9
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.
14
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.  */
18
19/* Written by Paul Eggert and Jim Meyering.  */
20
21#ifndef FILE_TYPE_H
22# define FILE_TYPE_H 1
23
24# if ! defined S_ISREG && ! defined S_IFREG
25you must include <sys/stat.h> before including this file
26# endif
27
28char const *file_type (struct stat const *);
29
30# ifndef S_IFMT
31#  define S_IFMT 0170000
32# endif
33
34# if STAT_MACROS_BROKEN
35#  undef S_ISBLK
36#  undef S_ISCHR
37#  undef S_ISDIR
38#  undef S_ISDOOR
39#  undef S_ISFIFO
40#  undef S_ISLNK
41#  undef S_ISNAM
42#  undef S_ISMPB
43#  undef S_ISMPC
44#  undef S_ISNWK
45#  undef S_ISREG
46#  undef S_ISSOCK
47# endif
48
49
50# ifndef S_ISBLK
51#  ifdef S_IFBLK
52#   define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
53#  else
54#   define S_ISBLK(m) 0
55#  endif
56# endif
57
58# ifndef S_ISCHR
59#  ifdef S_IFCHR
60#   define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
61#  else
62#   define S_ISCHR(m) 0
63#  endif
64# endif
65
66# ifndef S_ISDIR
67#  ifdef S_IFDIR
68#   define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
69#  else
70#   define S_ISDIR(m) 0
71#  endif
72# endif
73
74# ifndef S_ISDOOR /* Solaris 2.5 and up */
75#  ifdef S_IFDOOR
76#   define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
77#  else
78#   define S_ISDOOR(m) 0
79#  endif
80# endif
81
82# ifndef S_ISFIFO
83#  ifdef S_IFIFO
84#   define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
85#  else
86#   define S_ISFIFO(m) 0
87#  endif
88# endif
89
90# ifndef S_ISLNK
91#  ifdef S_IFLNK
92#   define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
93#  else
94#   define S_ISLNK(m) 0
95#  endif
96# endif
97
98# ifndef S_ISMPB /* V7 */
99#  ifdef S_IFMPB
100#   define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
101#   define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
102#  else
103#   define S_ISMPB(m) 0
104#   define S_ISMPC(m) 0
105#  endif
106# endif
107
108# ifndef S_ISNAM /* Xenix */
109#  ifdef S_IFNAM
110#   define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
111#  else
112#   define S_ISNAM(m) 0
113#  endif
114# endif
115
116# ifndef S_ISNWK /* HP/UX */
117#  ifdef S_IFNWK
118#   define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
119#  else
120#   define S_ISNWK(m) 0
121#  endif
122# endif
123
124# ifndef S_ISREG
125#  ifdef S_IFREG
126#   define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
127#  else
128#   define S_ISREG(m) 0
129#  endif
130# endif
131
132# ifndef S_ISSOCK
133#  ifdef S_IFSOCK
134#   define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
135#  else
136#   define S_ISSOCK(m) 0
137#  endif
138# endif
139
140
141# ifndef S_TYPEISMQ
142#  define S_TYPEISMQ(p) 0
143# endif
144
145# ifndef S_TYPEISTMO
146#  define S_TYPEISTMO(p) 0
147# endif
148
149
150# ifndef S_TYPEISSEM
151#  ifdef S_INSEM
152#   define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
153#  else
154#   define S_TYPEISSEM(p) 0
155#  endif
156# endif
157
158# ifndef S_TYPEISSHM
159#  ifdef S_INSHD
160#   define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
161#  else
162#   define S_TYPEISSHM(p) 0
163#  endif
164# endif
165
166#endif /* FILE_TYPE_H */
167