* src/include/lib.h: Provide a fix for Mac OS X to not include
[s-roff.git] / src / include / lib.h
blobf6dd35fa6bb9e81c87c201ea5b79f41996d2e8d9
1 // -*- C++ -*-
2 /* Copyright (C) 1989-2000, 2001, 2002, 2003, 2005
3 Free Software Foundation, Inc.
4 Written by James Clark (jjc@jclark.com)
6 This file is part of groff.
8 groff is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
11 version.
13 groff is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License along
19 with groff; see the file COPYING. If not, write to the Free Software
20 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
26 extern "C" {
27 #ifndef HAVE_STRERROR
28 char *strerror(int);
29 #endif
30 const char *i_to_a(int);
31 const char *ui_to_a(unsigned int);
32 const char *if_to_a(int, int);
35 /* stdio.h on IRIX, OSF/1, emx, UWIN, and MinGW include getopt.h */
36 /* unistd.h on CYGWIN and Mac OS X include getopt.h */
38 #if !(defined(__sgi) \
39 || (defined(__osf__) && defined(__alpha)) \
40 || defined(_UWIN) \
41 || defined(__EMX__) \
42 || defined(__CYGWIN__) \
43 || defined(__MINGW32__) \
44 || defined(__APPLE__))
45 #include <groff-getopt.h>
46 #else
47 #include <getopt.h>
48 #endif
50 #ifdef HAVE_SETLOCALE
51 #include <locale.h>
52 #else
53 #define setlocale(category, locale) do {} while(0)
54 #endif
56 char *strsave(const char *s);
57 int is_prime(unsigned);
58 double groff_hypot(double, double);
60 #include <stdio.h>
61 #include <string.h>
62 #ifdef HAVE_STRINGS_H
63 #include <strings.h>
64 #endif
66 #include <stdarg.h>
68 /* HP-UX 10.20 and LynxOS 4.0.0 don't declare snprintf() */
69 #if !defined(HAVE_SNPRINTF) || defined(NEED_DECLARATION_SNPRINTF)
70 extern "C" { int snprintf(char *, size_t, const char *, /*args*/ ...); }
71 #endif
73 /* LynxOS 4.0.0 has snprintf() but no vsnprintf() */
74 #if !defined(HAVE_VSNPRINTF) || defined(NEED_DECLARATION_VSNPRINTF)
75 extern "C" { int vsnprintf(char *, size_t, const char *, va_list); }
76 #endif
78 /* LynxOS 4.0.0 doesn't declare vfprintf() */
79 #ifdef NEED_DECLARATION_VFPRINTF
80 extern "C" { int vfprintf(FILE *, const char *, va_list); }
81 #endif
83 #ifndef HAVE_MKSTEMP
84 /* since mkstemp() is defined as a real C++ function if taken from
85 groff's mkstemp.cpp we need a declaration */
86 int mkstemp(char *tmpl);
87 #endif /* HAVE_MKSTEMP */
89 int mksdir(char *tmpl);
91 FILE *xtmpfile(char **namep = 0,
92 const char *postfix_long = 0, const char *postfix_short = 0,
93 int do_unlink = 1);
94 char *xtmptemplate(const char *postfix_long, const char *postfix_short);
96 #ifdef NEED_DECLARATION_POPEN
97 extern "C" { FILE *popen(const char *, const char *); }
98 #endif /* NEED_DECLARATION_POPEN */
100 #ifdef NEED_DECLARATION_PCLOSE
101 extern "C" { int pclose (FILE *); }
102 #endif /* NEED_DECLARATION_PCLOSE */
104 size_t file_name_max(const char *fname);
105 size_t path_name_max();
107 int interpret_lf_args(const char *p);
109 extern char invalid_char_table[];
111 inline int invalid_input_char(int c)
113 return c >= 0 && invalid_char_table[c];
116 #ifdef HAVE_STRCASECMP
117 #ifdef NEED_DECLARATION_STRCASECMP
118 // Ultrix4.3's string.h fails to declare this.
119 extern "C" { int strcasecmp(const char *, const char *); }
120 #endif /* NEED_DECLARATION_STRCASECMP */
121 #else /* not HAVE_STRCASECMP */
122 extern "C" { int strcasecmp(const char *, const char *); }
123 #endif /* HAVE_STRCASECMP */
125 #if !defined(_AIX) && !defined(sinix) && !defined(__sinix__)
126 #ifdef HAVE_STRNCASECMP
127 #ifdef NEED_DECLARATION_STRNCASECMP
128 // SunOS's string.h fails to declare this.
129 extern "C" { int strncasecmp(const char *, const char *, int); }
130 #endif /* NEED_DECLARATION_STRNCASECMP */
131 #else /* not HAVE_STRNCASECMP */
132 extern "C" { int strncasecmp(const char *, const char *, size_t); }
133 #endif /* HAVE_STRNCASECMP */
134 #endif /* !_AIX && !sinix && !__sinix__ */
136 #ifdef HAVE_CC_LIMITS_H
137 #include <limits.h>
138 #else /* not HAVE_CC_LIMITS_H */
139 #define INT_MAX 2147483647
140 #endif /* not HAVE_CC_LIMITS_H */
142 /* It's not safe to rely on people getting INT_MIN right (ie signed). */
144 #ifdef INT_MIN
145 #undef INT_MIN
146 #endif
148 #ifdef CFRONT_ANSI_BUG
150 /* This works around a bug in cfront 2.0 used with ANSI C compilers. */
152 #define INT_MIN ((long)(-INT_MAX-1))
154 #else /* not CFRONT_ANSI_BUG */
156 #define INT_MIN (-INT_MAX-1)
158 #endif /* not CFRONT_ANSI_BUG */
160 /* Maximum number of digits in the decimal representation of an int
161 (not including the -). */
163 #define INT_DIGITS 10
165 #ifdef PI
166 #undef PI
167 #endif
169 const double PI = 3.14159265358979323846;
171 /* ad_delete deletes an array of objects with destructors;
172 a_delete deletes an array of objects without destructors */
174 #ifdef ARRAY_DELETE_NEEDS_SIZE
175 /* for 2.0 systems */
176 #define ad_delete(size) delete [size]
177 #define a_delete delete
178 #else /* not ARRAY_DELETE_NEEDS_SIZE */
179 /* for ARM systems */
180 #define ad_delete(size) delete []
181 #define a_delete delete []
182 #endif /* not ARRAY_DELETE_NEEDS_SIZE */