]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/texinfo/lib/system.h
This commit was generated by cvs2svn to compensate for changes in r57416,
[FreeBSD/FreeBSD.git] / contrib / texinfo / lib / system.h
1 /* system.h: system-dependent declarations; include this first.
2    $Id: system.h,v 1.14 1999/07/17 21:11:34 karl Exp $
3
4    Copyright (C) 1997, 98, 99 Free Software Foundation, Inc.
5
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 2, or (at your option)
9    any later version.
10
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.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software Foundation,
18    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19
20 #ifndef TEXINFO_SYSTEM_H
21 #define TEXINFO_SYSTEM_H
22
23 #define _GNU_SOURCE
24
25 #include <config.h>
26
27 /* <unistd.h> should be included before any preprocessor test
28    of _POSIX_VERSION.  */
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif /* HAVE_UNISTD_H */
32
33 #include <stdio.h>
34 #include <sys/types.h>
35 #include <ctype.h>
36
37 #ifdef HAVE_LOCALE_H
38 #include <locale.h>
39 #endif
40 #ifndef HAVE_SETLOCALE
41 #define setlocale(category,locale) /* empty */
42 #endif
43
44 /* For gettext (NLS).  */
45 #include <libintl.h>
46 #define _(String) gettext (String)
47 #define N_(String) (String)
48
49 #ifdef STDC_HEADERS
50 #define getopt system_getopt
51 #include <stdlib.h>
52 #undef getopt
53 #else
54 extern char *getenv ();
55 #endif
56
57 /* Don't use bcopy!  Use memmove if source and destination may overlap,
58    memcpy otherwise.  */
59 #ifdef HAVE_STRING_H
60 # if !STDC_HEADERS && HAVE_MEMORY_H
61 #  include <memory.h>
62 # endif
63 # include <string.h>
64 #else
65 # include <strings.h>
66 char *memchr ();
67 #endif
68
69 #include <errno.h>
70 #ifndef errno
71 extern int errno;
72 #endif
73 #ifdef VMS
74 #include <perror.h>
75 #endif
76
77 #ifndef HAVE_DECL_STRERROR
78 extern char *strerror ();
79 #endif
80
81 #ifndef HAVE_DECL_STRCASECMP
82 extern int strcasecmp ();
83 #endif
84
85 #ifndef HAVE_DECL_STRNCASECMP
86 extern int strncasecmp ();
87 #endif
88
89 #ifndef HAVE_DECL_STRCOLL
90 extern int strcoll ();
91 #endif
92
93 #include <sys/stat.h>
94 #if STAT_MACROS_BROKEN
95 # undef S_ISDIR
96 #endif
97 #if !defined(S_ISDIR) && defined(S_IFDIR)
98 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
99 #endif
100
101 #ifdef HAVE_SYS_FILE_H
102 #include <sys/file.h>
103 #endif /* HAVE_SYS_FILE_H */
104
105 #ifndef O_RDONLY
106 /* Since <fcntl.h> is POSIX, prefer that to <sys/fcntl.h>.
107    This also avoids some useless warnings on (at least) Linux.  */
108 #ifdef HAVE_FCNTL_H
109 #include <fcntl.h>
110 #else /* not HAVE_FCNTL_H */
111 #ifdef HAVE_SYS_FCNTL_H
112 #include <sys/fcntl.h>
113 #endif /* not HAVE_SYS_FCNTL_H */
114 #endif /* not HAVE_FCNTL_H */
115 #endif /* not O_RDONLY */
116
117 /* MS-DOS and similar non-Posix systems have some peculiarities:
118     - they distinguish between binary and text files;
119     - they use both `/' and `\\' as directory separator in file names;
120     - they can have a drive letter X: prepended to a file name;
121     - they have a separate root directory on each drive;
122     - their filesystems are case-insensitive;
123     - directories in environment variables (like INFOPATH) are separated
124         by `;' rather than `:';
125     - text files can have their lines ended either with \n or with \r\n pairs;
126
127    These are all parameterized here except the last, which is
128    handled by the source code as appropriate (mostly, in info/).  */
129 #ifndef O_BINARY
130 # ifdef _O_BINARY
131 #  define O_BINARY _O_BINARY
132 # else
133 #  define O_BINARY 0
134 # endif
135 #endif /* O_BINARY */
136
137 #if O_BINARY
138 # include <io.h>
139 # ifdef __MSDOS__
140 #  include <limits.h>
141 #  ifdef __DJGPP__
142 #   define HAVE_LONG_FILENAMES(dir)  (pathconf (dir, _PC_NAME_MAX) > 12)
143 #   define NULL_DEVICE  "/dev/null"
144 #  else  /* !__DJGPP__ */
145 #   define HAVE_LONG_FILENAMES(dir)  (0)
146 #   define NULL_DEVICE  "NUL"
147 #  endif /* !__DJGPP__ */
148 #  define SET_SCREEN_SIZE_HELPER terminal_prep_terminal()
149 #  define DEFAULT_INFO_PRINT_COMMAND ">PRN"
150 # else   /* !__MSDOS__ */
151 #  define setmode(f,m)  _setmode(f,m)
152 #  define HAVE_LONG_FILENAMES(dir)   (1)
153 #  define NULL_DEVICE   "NUL"
154 # endif  /* !__MSDOS__ */
155 # define SET_BINARY(f)  do {if (!isatty(f)) setmode(f,O_BINARY);} while(0)
156 # define FOPEN_RBIN     "rb"
157 # define FOPEN_WBIN     "wb"
158 # define IS_SLASH(c)    ((c) == '/' || (c) == '\\')
159 # define HAVE_DRIVE(n)  ((n)[0] && (n)[1] == ':')
160 # define IS_ABSOLUTE(n) (IS_SLASH((n)[0]) || ((n)[0] && (n)[1] == ':'))
161 # define FILENAME_CMP   strcasecmp
162 # define FILENAME_CMPN  strncasecmp
163 # define PATH_SEP       ";"
164 # define STRIP_DOT_EXE  1
165 # define DEFAULT_TMPDIR "c:/"
166 # define PIPE_USE_FORK  0
167 #else  /* not O_BINARY */
168 # define SET_BINARY(f)  (void)0
169 # define FOPEN_RBIN     "r"
170 # define FOPEN_WBIN     "w"
171 # define IS_SLASH(c)    ((c) == '/')
172 # define HAVE_DRIVE(n)  (0)
173 # define IS_ABSOLUTE(n) ((n)[0] == '/')
174 # define FILENAME_CMP   strcmp
175 # define FILENAME_CMPN  strncmp
176 # define HAVE_LONG_FILENAMES(dir)   (1)
177 # define PATH_SEP       ":"
178 # define STRIP_DOT_EXE  0
179 # ifdef VMS
180 #  define DEFAULT_TMPDIR "sys$scratch:"
181 # else
182 #  define DEFAULT_TMPDIR "/tmp/"
183 # endif
184 # define NULL_DEVICE    "/dev/null"
185 # define PIPE_USE_FORK  1
186 #endif /* not O_BINARY */
187
188 #ifdef HAVE_PWD_H
189 #include <pwd.h>
190 #endif
191 /* Some systems don't declare this function in pwd.h. */
192 struct passwd *getpwnam ();
193
194 /* Our library routines not included in any system library.  */
195 extern void *xmalloc (), *xrealloc ();
196 extern char *xstrdup ();
197 extern void xexit ();
198 extern char *substring ();
199
200 /* For convenience.  */
201 #define STREQ(s1,s2) (strcmp (s1, s2) == 0)
202
203 #endif /* TEXINFO_SYSTEM_H */