This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / gnu / usr.bin / pr / system.h
CommitLineData
9a35093c
NW
1/* system-dependent definitions for textutils programs.
2 Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
3
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)
7 any later version.
8
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.
13
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18/* Include sys/types.h before this file. */
19
20#include <sys/stat.h>
21#ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */
22#define mode_t unsigned short
23#endif
24#if !defined(S_ISBLK) && defined(S_IFBLK)
25#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
26#endif
27#if !defined(S_ISCHR) && defined(S_IFCHR)
28#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
29#endif
30#if !defined(S_ISDIR) && defined(S_IFDIR)
31#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
32#endif
33#if !defined(S_ISREG) && defined(S_IFREG)
34#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
35#endif
36#if !defined(S_ISFIFO) && defined(S_IFIFO)
37#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
38#endif
39#if !defined(S_ISLNK) && defined(S_IFLNK)
40#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
41#endif
42#if !defined(S_ISSOCK) && defined(S_IFSOCK)
43#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
44#endif
45#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
46#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
47#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
48#endif
49#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
50#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
51#endif
52#if !defined(HAVE_MKFIFO)
53#define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
54#endif
55
56#ifdef HAVE_UNISTD_H
57#include <unistd.h>
58#endif
59#ifndef _POSIX_VERSION
60off_t lseek ();
61#endif
62
63#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
64#if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
65#include <memory.h>
66#endif
67#include <string.h>
68#ifndef index
69#define index strchr
70#endif
71#ifndef rindex
72#define rindex strrchr
73#endif
74/* Don't define bcopy; we need one that can handle overlaps. */
75#ifndef bzero
76#define bzero(s, n) memset ((s), 0, (n))
77#endif
78#ifndef bcmp
79#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
80#endif
81#else
82#include <strings.h>
6a80fcca 83#ifndef __386BSD__
9a35093c
NW
84char *memchr ();
85#endif
6a80fcca 86#endif
9a35093c
NW
87
88#include <errno.h>
89#ifdef STDC_HEADERS
90#include <stdlib.h>
91#else
92char *getenv ();
93extern int errno;
94#endif
95
96#if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION)
97#include <fcntl.h>
98#else
99#include <sys/file.h>
100#endif
101
102#if !defined(SEEK_SET)
103#define SEEK_SET 0
104#define SEEK_CUR 1
105#define SEEK_END 2
106#endif
107
108#ifndef _POSIX_SOURCE
109#include <sys/param.h>
110#endif
111
112/* Get or fake the disk device blocksize.
113 Usually defined by sys/param.h (if at all). */
114#if !defined(DEV_BSIZE) && defined(BSIZE)
115#define DEV_BSIZE BSIZE
116#endif
117#if !defined(DEV_BSIZE) && defined(BBSIZE) /* SGI */
118#define DEV_BSIZE BBSIZE
119#endif
120#ifndef DEV_BSIZE
121#define DEV_BSIZE 4096
122#endif
123
124/* Extract or fake data from a `struct stat'.
125 ST_BLKSIZE: Optimal I/O blocksize for the file, in bytes. */
126#ifndef HAVE_ST_BLKSIZE
127# define ST_BLKSIZE(statbuf) DEV_BSIZE
128#else /* HAVE_ST_BLKSIZE */
129/* Some systems, like Sequents, return st_blksize of 0 on pipes. */
130# define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \
131 ? (statbuf).st_blksize : DEV_BSIZE)
132#endif /* HAVE_ST_BLKSIZE */
133
134#ifndef S_ISLNK
135#define lstat stat
136#endif
137
138#ifndef RETSIGTYPE
139#define RETSIGTYPE void
140#endif
141
142#include <ctype.h>
143
144#ifndef isascii
145#define isascii(c) 1
146#endif
147
148#ifdef isblank
149#define ISBLANK(c) (isascii (c) && isblank (c))
150#else
151#define ISBLANK(c) ((c) == ' ' || (c) == '\t')
152#endif
153#ifdef isgraph
154#define ISGRAPH(c) (isascii (c) && isgraph (c))
155#else
156#define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c))
157#endif
158
159#define ISPRINT(c) (isascii (c) && isprint (c))
160#define ISDIGIT(c) (isascii (c) && isdigit (c))
161#define ISALNUM(c) (isascii (c) && isalnum (c))
162#define ISALPHA(c) (isascii (c) && isalpha (c))
163#define ISCNTRL(c) (isascii (c) && iscntrl (c))
164#define ISLOWER(c) (isascii (c) && islower (c))
165#define ISPUNCT(c) (isascii (c) && ispunct (c))
166#define ISSPACE(c) (isascii (c) && isspace (c))
167#define ISUPPER(c) (isascii (c) && isupper (c))
168#define ISXDIGIT(c) (isascii (c) && isxdigit (c))