kernel - Implement RLIMIT_RSS, Increase maximum supported swap
[dragonfly.git] / contrib / diffutils / lib / file-type.c
blob0d542692163f74669be04de8e51cd88d6b2adab1
1 /* Return a string describing the type of a file.
3 Copyright (C) 1993-1994, 2001-2002, 2004-2006, 2009-2013 Free Software
4 Foundation, Inc.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 /* Written by Paul Eggert. */
21 #include <config.h>
23 #include "file-type.h"
25 #include <gettext.h>
26 #define _(text) gettext (text)
28 char const *
29 file_type (struct stat const *st)
31 /* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107 for some of
32 these formats.
34 To keep diagnostics grammatical in English, the returned string
35 must start with a consonant. */
37 if (S_ISREG (st->st_mode))
38 return st->st_size == 0 ? _("regular empty file") : _("regular file");
40 if (S_ISDIR (st->st_mode))
41 return _("directory");
43 if (S_ISBLK (st->st_mode))
44 return _("block special file");
46 if (S_ISCHR (st->st_mode))
47 return _("character special file");
49 if (S_ISFIFO (st->st_mode))
50 return _("fifo");
52 if (S_ISLNK (st->st_mode))
53 return _("symbolic link");
55 if (S_ISSOCK (st->st_mode))
56 return _("socket");
58 if (S_TYPEISMQ (st))
59 return _("message queue");
61 if (S_TYPEISSEM (st))
62 return _("semaphore");
64 if (S_TYPEISSHM (st))
65 return _("shared memory object");
67 if (S_TYPEISTMO (st))
68 return _("typed memory object");
70 return _("weird file");