Add binary relocation support for Windows platforms.
[s-roff.git] / src / include / lib.h
blobe560c0d212157e1cc189ad0364c88add892f66ef
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 includes getopt.h */
38 #if !(defined(__sgi) \
39 || (defined(__osf__) && defined(__alpha)) \
40 || defined(_UWIN) \
41 || defined(__EMX__) \
42 || defined(__CYGWIN__) \
43 || defined(__MINGW32__))
44 #include <groff-getopt.h>
45 #else
46 #include <getopt.h>
47 #endif
49 #ifdef HAVE_SETLOCALE
50 #include <locale.h>
51 #else
52 #define setlocale(category, locale) do {} while(0)
53 #endif
55 char *strsave(const char *s);
56 int is_prime(unsigned);
57 double groff_hypot(double, double);
59 #include <stdio.h>
60 #include <string.h>
61 #ifdef HAVE_STRINGS_H
62 #include <strings.h>
63 #endif
65 #include <stdarg.h>
67 /* HP-UX 10.20 and LynxOS 4.0.0 don't declare snprintf() */
68 #if !defined(HAVE_SNPRINTF) || defined(NEED_DECLARATION_SNPRINTF)
69 extern "C" { int snprintf(char *, size_t, const char *, /*args*/ ...); }
70 #endif
72 /* LynxOS 4.0.0 has snprintf() but no vsnprintf() */
73 #if !defined(HAVE_VSNPRINTF) || defined(NEED_DECLARATION_VSNPRINTF)
74 extern "C" { int vsnprintf(char *, size_t, const char *, va_list); }
75 #endif
77 /* LynxOS 4.0.0 doesn't declare vfprintf() */
78 #ifdef NEED_DECLARATION_VFPRINTF
79 extern "C" { int vfprintf(FILE *, const char *, va_list); }
80 #endif
82 #ifndef HAVE_MKSTEMP
83 /* since mkstemp() is defined as a real C++ function if taken from
84 groff's mkstemp.cpp we need a declaration */
85 int mkstemp(char *tmpl);
86 #endif /* HAVE_MKSTEMP */
88 int mksdir(char *tmpl);
90 FILE *xtmpfile(char **namep = 0,
91 const char *postfix_long = 0, const char *postfix_short = 0,
92 int do_unlink = 1);
93 char *xtmptemplate(const char *postfix_long, const char *postfix_short);
95 #ifdef NEED_DECLARATION_POPEN
96 extern "C" { FILE *popen(const char *, const char *); }
97 #endif /* NEED_DECLARATION_POPEN */
99 #ifdef NEED_DECLARATION_PCLOSE
100 extern "C" { int pclose (FILE *); }
101 #endif /* NEED_DECLARATION_PCLOSE */
103 size_t file_name_max(const char *fname);
104 size_t path_name_max();
106 int interpret_lf_args(const char *p);
108 extern char invalid_char_table[];
110 inline int invalid_input_char(int c)
112 return c >= 0 && invalid_char_table[c];
115 #ifdef HAVE_STRCASECMP
116 #ifdef NEED_DECLARATION_STRCASECMP
117 // Ultrix4.3's string.h fails to declare this.
118 extern "C" { int strcasecmp(const char *, const char *); }
119 #endif /* NEED_DECLARATION_STRCASECMP */
120 #else /* not HAVE_STRCASECMP */
121 extern "C" { int strcasecmp(const char *, const char *); }
122 #endif /* HAVE_STRCASECMP */
124 #if !defined(_AIX) && !defined(sinix) && !defined(__sinix__)
125 #ifdef HAVE_STRNCASECMP
126 #ifdef NEED_DECLARATION_STRNCASECMP
127 // SunOS's string.h fails to declare this.
128 extern "C" { int strncasecmp(const char *, const char *, int); }
129 #endif /* NEED_DECLARATION_STRNCASECMP */
130 #else /* not HAVE_STRNCASECMP */
131 extern "C" { int strncasecmp(const char *, const char *, size_t); }
132 #endif /* HAVE_STRNCASECMP */
133 #endif /* !_AIX && !sinix && !__sinix__ */
135 #ifdef HAVE_CC_LIMITS_H
136 #include <limits.h>
137 #else /* not HAVE_CC_LIMITS_H */
138 #define INT_MAX 2147483647
139 #endif /* not HAVE_CC_LIMITS_H */
141 /* It's not safe to rely on people getting INT_MIN right (ie signed). */
143 #ifdef INT_MIN
144 #undef INT_MIN
145 #endif
147 #ifdef CFRONT_ANSI_BUG
149 /* This works around a bug in cfront 2.0 used with ANSI C compilers. */
151 #define INT_MIN ((long)(-INT_MAX-1))
153 #else /* not CFRONT_ANSI_BUG */
155 #define INT_MIN (-INT_MAX-1)
157 #endif /* not CFRONT_ANSI_BUG */
159 /* Maximum number of digits in the decimal representation of an int
160 (not including the -). */
162 #define INT_DIGITS 10
164 #ifdef PI
165 #undef PI
166 #endif
168 const double PI = 3.14159265358979323846;
170 /* ad_delete deletes an array of objects with destructors;
171 a_delete deletes an array of objects without destructors */
173 #ifdef ARRAY_DELETE_NEEDS_SIZE
174 /* for 2.0 systems */
175 #define ad_delete(size) delete [size]
176 #define a_delete delete
177 #else /* not ARRAY_DELETE_NEEDS_SIZE */
178 /* for ARM systems */
179 #define ad_delete(size) delete []
180 #define a_delete delete []
181 #endif /* not ARRAY_DELETE_NEEDS_SIZE */