Switch from bioq_insert_tail() to bioqdisksort(). When the kernel is
[dragonfly.git] / contrib / diffutils-2.8 / lib / file-type.c
blob3c58c7fb06603e43f6f8c3707362fe7ecc59d5f4
1 /* Return a string describing the type of a file.
3 Copyright (C) 1993, 1994, 2001, 2002, 2004 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)
8 any later version.
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. */
21 #if HAVE_CONFIG_H
22 # include <config.h>
23 #endif
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include "file-type.h"
29 #include <gettext.h>
30 #define _(text) gettext (text)
32 char const *
33 file_type (struct stat const *st)
35 /* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107 for some of
36 these formats.
38 To keep diagnostics grammatical in English, the returned string
39 must start with a consonant. */
41 if (S_ISREG (st->st_mode))
42 return st->st_size == 0 ? _("regular empty file") : _("regular file");
44 if (S_ISDIR (st->st_mode))
45 return _("directory");
47 if (S_ISBLK (st->st_mode))
48 return _("block special file");
50 if (S_ISCHR (st->st_mode))
51 return _("character special file");
53 if (S_ISFIFO (st->st_mode))
54 return _("fifo");
56 if (S_ISLNK (st->st_mode))
57 return _("symbolic link");
59 if (S_ISSOCK (st->st_mode))
60 return _("socket");
62 if (S_TYPEISMQ (st))
63 return _("message queue");
65 if (S_TYPEISSEM (st))
66 return _("semaphore");
68 if (S_TYPEISSHM (st))
69 return _("shared memory object");
71 if (S_TYPEISTMO (st))
72 return _("typed memory object");
74 return _("weird file");