1 /* system-dependent definitions for textutils programs.
2 Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 * $DragonFly: src/gnu/usr.bin/sort/system.h,v 1.2 2003/11/09 12:41:16 eirikn Exp $
20 /* Include sys/types.h before this file. */
24 #ifdef STAT_MACROS_BROKEN
35 #endif /* STAT_MACROS_BROKEN. */
37 #if !defined(S_ISBLK) && defined(S_IFBLK)
38 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
40 #if !defined(S_ISCHR) && defined(S_IFCHR)
41 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
43 #if !defined(S_ISDIR) && defined(S_IFDIR)
44 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
46 #if !defined(S_ISREG) && defined(S_IFREG)
47 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
49 #if !defined(S_ISFIFO) && defined(S_IFIFO)
50 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
52 #if !defined(S_ISLNK) && defined(S_IFLNK)
53 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
55 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
56 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
58 #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
59 #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
60 #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
62 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
63 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
65 #if !defined(HAVE_MKFIFO)
66 #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
73 #ifndef _POSIX_VERSION
78 #define STDIN_FILENO 0
82 #define STDOUT_FILENO 1
86 #define STDERR_FILENO 2
89 /* Don't use bcopy! Use memmove if source and destination may overlap,
93 # if !STDC_HEADERS && HAVE_MEMORY_H
114 # define EXIT_FAILURE 1
118 # define EXIT_SUCCESS 0
124 #include <sys/file.h>
127 #if !defined(SEEK_SET)
133 #ifndef _POSIX_SOURCE
134 #include <sys/param.h>
137 /* Get or fake the disk device blocksize.
138 Usually defined by sys/param.h (if at all). */
139 #if !defined(DEV_BSIZE) && defined(BSIZE)
140 #define DEV_BSIZE BSIZE
142 #if !defined(DEV_BSIZE) && defined(BBSIZE) /* SGI */
143 #define DEV_BSIZE BBSIZE
146 #define DEV_BSIZE 4096
149 /* Extract or fake data from a `struct stat'.
150 ST_BLKSIZE: Optimal I/O blocksize for the file, in bytes. */
151 #ifndef HAVE_ST_BLKSIZE
152 # define ST_BLKSIZE(statbuf) DEV_BSIZE
153 #else /* HAVE_ST_BLKSIZE */
154 /* Some systems, like Sequents, return st_blksize of 0 on pipes. */
155 # define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \
156 ? (statbuf).st_blksize : DEV_BSIZE)
157 #endif /* HAVE_ST_BLKSIZE */
164 #define RETSIGTYPE void
169 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
172 #define ISASCII(c) isascii((unsigned char)c)
176 #define ISBLANK(c) (ISASCII (c) && isblank ((unsigned char)c))
178 #define ISBLANK(c) ((c) == ' ' || (c) == '\t')
181 #define ISGRAPH(c) (ISASCII (c) && isgraph ((unsigned char)c))
183 #define ISGRAPH(c) (ISASCII (c) && isprint ((unsigned char)c) && !isspace ((unsigned char)c))
186 #define ISPRINT(c) (ISASCII (c) && isprint ((unsigned char)c))
187 #define ISDIGIT(c) (ISASCII (c) && isdigit ((unsigned char)c))
188 #define ISALNUM(c) (ISASCII (c) && isalnum ((unsigned char)c))
189 #define ISALPHA(c) (ISASCII (c) && isalpha ((unsigned char)c))
190 #define ISCNTRL(c) (ISASCII (c) && iscntrl ((unsigned char)c))
191 #define ISLOWER(c) (ISASCII (c) && islower ((unsigned char)c))
192 #define ISPUNCT(c) (ISASCII (c) && ispunct ((unsigned char)c))
193 #define ISSPACE(c) (ISASCII (c) && isspace ((unsigned char)c))
194 #define ISUPPER(c) (ISASCII (c) && isupper ((unsigned char)c))
195 #define ISXDIGIT(c) (ISASCII (c) && isxdigit ((unsigned char)c))
197 /* Disable string localization for the time being. */
199 #define _(String) String