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