1 /*** general.h ****************************************************************
2 **
3 ** This file is part of BibTool.
4 ** It is distributed under the GNU General Public License.
5 ** See the file COPYING for details.
6 **
7 ** (c) 1996-2020 Gerd Neugebauer
8 **
9 ** Net: gene@gerd-neugebauer.de
10 **
11 ** This program is free software; you can redistribute it and/or modify
12 ** it under the terms of the GNU General Public License as published by
13 ** the Free Software Foundation; either version 2, or (at your option)
14 ** any later version.
15 **
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ** GNU General Public License for more details.
20 **
21 ** You should have received a copy of the GNU General Public License
22 ** along with this program; if not, write to the Free Software
23 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 **
25 ******************************************************************************/
26 
27 /*-----------------------------------------------------------------------------
28 **
29 **---------------------------------------------------------------------------*/
30 
31 #include <bibtool/config.h>
32 
33 #include <stdio.h>
34 
35 #ifdef __STDC__
36 #include <stdlib.h>
37 #include <stddef.h>
38 #include <string.h>
39 
40 #ifdef LINT
41  int fputs(char*,FILE*);
42  int fputc(char,FILE*);
43  int fclose(FILE*);
44  int fflush(FILE*);
45  int fprintf(FILE*,char*, ...);
46  int printf(char*, ...);
47 #endif
48 
49 #else
50 #ifdef HAVE_STRING_H
51 #include <string.h>
52 #else
53 #include <strings.h>
54 #define strchr(A,B)  index(A,B)
55 #define strrchr(A,B) rindex(A,B)
56 #endif
57 
58 #ifdef HAVE_STDLIB_H
59 #include <stdlib.h>
60 #else
61  extern void    exit();
62  extern VoidPTR malloc();
63  extern VoidPTR realloc();
64  extern char    *getenv();
65 #ifdef SIZE_T
66 #define size_t		SIZE_T
67 #else
68 #define size_t		unsigned
69 #endif
70 #endif
71 #endif
72 
73 #ifdef HAVE_STDINT_H
74 #include <stdint.h>
75 #else
76 typedef intptr_t int;
77 #endif
78 
79 #ifdef HAVE_STDBOOL_H
80 #include <stdbool.h>
81 #else
82 typedef int bool;
83 #define true  (1)
84 #define false (0)
85 #endif
86 
87 /*-----------------------------------------------------------------------------
88 **	Misc definitions
89 **---------------------------------------------------------------------------*/
90 
91 /*-----------------------------------------------------------------------------
92 ** Constant:	TRUE
93 ** Type:	int
94 ** Purpose:	Just in case that this constant is not defined in any
95 **		used system header file it will be defined here. It
96 **		represents the |TRUE| condition.
97 **___________________________________________________			     */
98 #ifndef TRUE
99 #define TRUE  (1)
100 #endif
101 /*-----------------------------------------------------------------------------
102 ** Constant:	FALSE
103 ** Type:	int
104 ** Purpose:	Just in case that this constant is not defined in any
105 **		used system header file it will be defined here. It
106 **		represents the |FALSE| condition.
107 **___________________________________________________			     */
108 #ifndef FALSE
109 #define FALSE (0)
110 #endif
111 
112 /*-----------------------------------------------------------------------------
113 ** Macro:	FOREVER
114 ** Purpose:	This is an infinite loop.
115 **
116 ** Arguments:	none
117 **___________________________________________________			     */
118 #define FOREVER for (;;)
119 
120 /*-----------------------------------------------------------------------------
121 ** Macro:	POSSIBLY_UNUSED
122 ** Purpose:	Mark a variable as possibly unused. It silences a gcc
123 **		compiler warning.
124 **
125 ** Arguments:	none
126 **___________________________________________________			     */
127 #define POSSIBLY_UNUSED(X) (void)(X)
128