File: environ.h

package info (click to toggle)
funnelweb 3.2-4.2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,744 kB
  • sloc: ansic: 9,156; makefile: 17
file content (364 lines) | stat: -rw-r--r-- 12,370 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
/*##############################################################################

FUNNNELWEB COPYRIGHT
====================
FunnelWeb is a literate-programming macro preprocessor.
The FunnelWeb web is at http://www.ross.net/funnelweb/

Copyright (c) Ross N. Williams 1992. All rights reserved.

This program is free software; you can redistribute it and/or modify
it under the terms of Version 2 of the GNU General Public License as
published by the Free Software Foundation (http://www.gnu.org/).

This program is distributed WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See Version 2 of the GNU General Public License for more details.

You should have received a copy of Version 2 of the GNU General Public
License along with this program. If not, you can obtain a copy as follows:
   ftp://prep.ai.mit.edu/pub/gnu/COPYING-2.0
or write to:
    Free Software Foundation, Inc.,
    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA

Section 2a of the license requires that all changes to this file be
recorded prominently in this file. Please record all changes here.

Programmers:
   RNW  Ross N. Williams (ross@ross.net)

Changes:
   07-May-1992  RNW  Program prepared for release under GNU GPL V2.
   15-May-1999  RNW  Modified STDC definition for Digital Unix.
   15-May-1999  RNW  Added support for FreeBSD.

##############################################################################*/


/******************************************************************************/
/*                                   ENVIRON.H                                */
/******************************************************************************/
/*                                                                            */
/* WARNING: DO NOT ADD ANY PROGRAM-DEPENDENT DEFINITIONS.                     */
/*                                                                            */
/* This header file environ.h contains definitions and objects whose values   */
/* depends directly on the compilation and execution environment, but are     */
/* otherwise independent of any particular computer program.                  */
/*                                                                            */
/* This is one of two machine-dependent, program-independent modules. The     */
/* other module is machin (machin.h,machin.c). This "environ" module contains */
/* definitions and objects that are considered essential. The "machin" module */
/* contains less essential definitions. Motivation for the division came from */
/* the fact that style.h (used by almost every module) includes environ.h     */
/* (this file), and from the need for the stuff in style.h by some            */
/* environment-dependent definitions.                                         */
/*                                                                            */
/* There seems to be two ways to organize a module such as this one. The      */
/* first is to have a different version of this module for each target        */
/* environment. The second is to have a single file that uses #defines and    */
/* #ifs to select between code for each target environment. I have chosen the */
/* latter method as this allows many different environments to share the same */
/* definitions.                                                               */
/*                                                                            */
/******************************************************************************/

/* Ensure that the body of this header file is included at most once.         */
#ifndef DONE_ENVIRON
#define DONE_ENVIRON

/******************************************************************************/

/* Detecting The Environment                                                  */
/* -------------------------                                                  */
#define OS_MAC    0  /* Macintosh        */
#define OS_DOS    0  /* MS-DOS           */
#define OS_VMS    0  /* OpenVMS          */
#define OS_W32    0  /* Win32            */
#define OS_UNX    0  /* Unix             */
#define    OS_HPU 0  /*    HP/UX         */
#define    OS_OSF 0  /*    Digital Unix  */
#define    OS_SUN 0  /*    SunOS/Solaris */
#define    OS_IRX 0  /*    IRIX          */
#define    OS_B86 0  /*    BSDOS         */
#define    OS_L86 0  /*    Linux         */
#define    OS_AIX 0  /*    AIX           */
#define    OS_FBD 0  /*    FreeBSD       */


#ifdef  THINK_C      
#undef  OS_MAC 
#define  OS_MAC  1
#undef  OS_MAC 
#define  OS_MAC  1
#endif


#ifdef  __MWERKS__   
#undef  OS_MAC 
#define  OS_MAC  1
#undef  OS_MAC 
#define  OS_MAC  1
#endif


#ifdef  MSDOS        
#undef  OS_DOS 
#define  OS_DOS  1
#undef  OS_DOS 
#define  OS_DOS  1
#endif


#ifdef  __DOS__      
#undef  OS_DOS 
#define  OS_DOS  1
#undef  OS_DOS 
#define  OS_DOS  1
#endif


#ifdef  __BORLANDC__ 
#undef  OS_DOS 
#define  OS_DOS  1
#undef  OS_DOS 
#define  OS_DOS  1
#endif


#ifdef  VMS          
#undef  OS_VMS 
#define  OS_VMS  1
#undef  OS_VMS 
#define  OS_VMS  1
#endif


#ifdef  _WIN32       
#undef  OS_W32 
#define  OS_W32  1
#undef  OS_W32 
#define  OS_W32  1
#endif


#ifdef  __hpux       
#undef  OS_UNX 
#define  OS_UNX  1
#undef  OS_HPU 
#define  OS_HPU  1
#endif


#ifdef  __osf__      
#undef  OS_UNX 
#define  OS_UNX  1
#undef  OS_OSF 
#define  OS_OSF  1
#endif


#ifdef  sun          
#undef  OS_UNX 
#define  OS_UNX  1
#undef  OS_SUN 
#define  OS_SUN  1
#endif


#ifdef  __ultrix     
#undef  OS_UNX 
#define  OS_UNX  1
#undef  OS_ULT 
#define  OS_ULT  1
#endif


#ifdef  __sgi        
#undef  OS_UNX 
#define  OS_UNX  1
#undef  OS_IRX 
#define  OS_IRX  1
#endif


#ifdef  __386BSD__   
#undef  OS_UNX 
#define  OS_UNX  1
#undef  OS_B86 
#define  OS_B86  1
#endif


#if defined( __linux__) || defined(__GLIBC__) || defined(__GNU__)
#undef  OS_UNX 
#define  OS_UNX  1
#undef  OS_L86 
#define  OS_L86  1
#endif


#ifdef  _AIX         
#undef  OS_UNX 
#define  OS_UNX  1
#undef  OS_AIX 
#define  OS_AIX  1
#endif

#ifdef  __FreeBSD__         
#undef  OS_UNX 
#define  OS_UNX  1
#undef  OS_FBD 
#define  OS_FBD  1
#endif

#if (OS_MAC + OS_UNX + OS_VMS + OS_DOS + OS_W32) == 0
   #error Error: No operating system class has been selected.
#endif

#if (OS_MAC + OS_UNX + OS_VMS + OS_DOS + OS_W32) > 1
   #error Error: More than one operating system class has been selected.
#endif

#if OS_UNX
#define OS_UNXSUM1 (OS_HPU+OS_OSF+OS_SUN+OS_SOL+OS_ULT)
#define OS_UNXSUM2 (OS_IRX+OS_B86+OS_L86+OS_AIX+OS_FBD)
#if ((OS_UNXSUM1+OS_UNXSUM2) != 1)
   #error Error: Exactly one Unix operating system must be chosen.
#endif
#endif

#define BEGIN_OS
#define END_OS

/******************************************************************************/

/* Establish Presence or Absence of __STDC__                                  */
/* -----------------------------------------                                  */
/* The __STDC__ symbol is very useful for determining if the compiler is      */
/* ANSI. However, some "nearly ANSI" compilers don't set this symbol, and     */
/* experience shows that things turn out better if it is set.                 */
/* This section decides if __STDC__ should be defined.                        */

/* The Macintosh THINK C compiler seems to be ANSI standard but, strangely    */
/* does not define the standard preprocessor symbol __STDC__ that indicates   */
/* this. Instead it defines THINK_C. Here, we execute the link manually.      */
/* For more information see the THINK C User's Manual, Chapter 57: "Language  */
/* Reference", Section 12.10, p.442.                                          */
#if OS_VMS || OS_OSF
#define __STDC__ 1
#endif

#ifdef __VISUALC__
#define __STDC__ 1
#endif

#ifdef __MWERKS__
#undef __STDC__
#define __STDC__ 1
#endif

/******************************************************************************/

/* Switch From Definedness to Boolean Symbols                                 */
/* ------------------------------------------                                 */
/* Use of the definedness of a preprocessor symbol to detect a condition is   */
/* convenient if it is desired that only one condition be tested at a time.   */
/* However, if we want to OR conditions, it is more convenient to use defined */
/* symbols that are either 0 or 1. This section contains ifdefs that do this. */

#ifdef __STDC__
#define STDC 1
#else
#define STDC 0
#endif

/* Note: If THINK_C is predefined, it is predefined to be 1. */
#ifndef THINK_C
#define THINK_C 0
#endif

/******************************************************************************/

/* Void                                                                       */
/* ----                                                                       */
/* Define void if necessary and define pointer to void.                       */
/* This idea from the book "Portable C", p.41.                                */
/* If necessary, add a boolean condition to cover your environment.           */
/* Note: The "| OS_SUN" is a last minute desperate hack.                      */
#if STDC || OS_SUN || OS_AIX
#define p_void void *
#else
typedef int     void;
#define p_void char *
#endif

/* The following function is here solely to act as a first tripping point for */
/* environments with no "void" so that the users trying to port this code     */
/* will look here first instead of starting to delete voids in the program.   */
extern void test_void();

/******************************************************************************/

/* Const                                                                      */
/* -----                                                                      */
/* It's useful to be able to specify that certain objects are constants.      */
/* Unfortunately, the "const" construct is only available in ANSI C and so we */
/* have to have a macro so as to cope with non-ANSI compilers.                */
/* Note: THINK-C is nearly ANSI, but does not support "const".                */
#if STDC & !THINK_C
#define CONST const
#else
#define CONST
#endif

/******************************************************************************/

/* Prototypes                                                                 */
/* ----------                                                                 */
/* Define a macro to wrap around prototype parameter lists so as to support   */
/* compilers with and without prototypes.                                     */
/* This idea came from the book "Portable C", S3.1, p.32.                     */
#if STDC
#define P_(A) A
#else
#define P_(A) ()
#endif

/******************************************************************************/

/* Structure Assignments                                                      */
/* ---------------------                                                      */
/* Structure assignments are not supported on some of the older compilers and */
/* so we use a macro to perform such operations.                              */
/* This idea came from the book "Portable C", S8.2.2, p.184.                  */
#if STDC
#define ASSIGN(a,b) ((a)=(b))
#else
#define ASSIGN(a,b) (memcpy((char *)&(a),(char *)&(b),sizeof(a)))
#endif

/******************************************************************************/

/* VMS EXIT STATUS */
/* --------------- */
/* The VAX C compiler I used doesn't seem to be ANSI. This means that the    */
/* exit symbols aren't set up properly. Furthermore, the sensible defaults   */
/* in the style.h file don't work for VMS. The upshot is that we have to do  */
/* a special case. Note: The top bit set in a VMS exit status means suppress */
/* diagnostic message. Even status means failure. Odd means success.         */
#if OS_VMS
#undef  EXIT_SUCCESS
#undef  EXIT_FAILURE
#define EXIT_SUCCESS 1
#define EXIT_FAILURE (0x10000002)
#endif

/******************************************************************************/

/* For #ifndef preventing multiple inclusion of the body of this header file. */
#endif

/******************************************************************************/
/*                                End of ENVIRON.H                            */
/******************************************************************************/