2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: p2c.h /main/3 1995/10/31 12:00:53 rswiston $ */
28 /* Header file for code generated by "p2c", the Pascal-to-C translator */
30 /* "p2c" Copyright (C) 1989 Dave Gillespie, version 1.14.
31 * This file may be copied, modified, etc. in any way. It is not restricted
32 * by the licence agreement accompanying p2c itself.
40 /* If the following heuristic fails, compile -DBSD=0 for non-BSD systems,
41 or -DBSD=1 for BSD systems. */
47 #ifdef FILE /* a #define in BSD, a typedef in SYSV (hp-ux, at least) */
48 # ifndef BSD /* (a convenient, but horrible kludge!) */
64 # define __CAT__(a,b)a##b
69 # include <sys/types.h>
71 # define __CAT__(a,b)__ID__(a)b
77 # define memcpy(a,b,n) (bcopy(b,a,n),a)
78 # define memcmp(a,b,n) bcmp(a,b,n)
79 # define strchr(s,c) index(s,c)
80 # define strrchr(s,c) rindex(s,c)
91 typedef struct __p2c_jmp_buf {
92 struct __p2c_jmp_buf *next;
97 /* Warning: The following will not work if setjmp is used simultaneously.
98 This also violates the ANSI restriction about using vars after longjmp,
99 but a typical implementation of longjmp will get it right anyway. */
102 # define TRY(x) do { __p2c_jmp_buf __try_jb; \
103 __try_jb.next = __top_jb; \
104 if (!setjmp((__top_jb = &__try_jb)->jbuf)) {
105 # define RECOVER(x) __top_jb = __try_jb.next; } else {
106 # define RECOVER2(x,L) __top_jb = __try_jb.next; } else { \
107 if (0) { L: __top_jb = __try_jb.next; }
108 # define ENDTRY(x) } } while (0)
110 # define TRY(x) if (1) {
111 # define RECOVER(x) } else do {
112 # define RECOVER2(x,L) } else do { L: ;
113 # define ENDTRY(x) } while (0)
118 #ifdef M_XENIX /* avoid compiler bug */
119 # define SHORT_MAX (32767)
120 # define SHORT_MIN (-32768)
124 /* The following definitions work only on twos-complement machines */
126 # define SHORT_MAX (((unsigned short) -1) >> 1)
127 # define SHORT_MIN (~SHORT_MAX)
131 # define INT_MAX (((unsigned int) -1) >> 1)
132 # define INT_MIN (~INT_MAX)
136 # define LONG_MAX (((unsigned long) -1) >> 1)
137 # define LONG_MIN (~LONG_MAX)
147 # define EXIT_SUCCESS 0
148 # define EXIT_FAILURE 1
156 # define Signed signed
157 # define Void void /* Void f() = procedure */
162 # define Volatile volatile
164 # define PP(x) x /* function prototype */
165 # define PV() (void) /* null function prototype */
166 typedef void *Anyptr;
178 typedef char *Anyptr;
182 # define Inline inline
187 #define Register register /* Register variables */
188 #define Char char /* Characters (not bytes) */
191 # define Static static /* Private global funcs and vars */
195 # define Local static /* Nested functions */
198 typedef Signed char schar;
200 typedef unsigned char uchar;
202 typedef unsigned char boolean;
218 /* Most of the following vars were "Unsatisfied symbols at load time
219 extern Void PASCAL_MAIN PP( (int, Char **) );
220 extern Char **P_argv;
222 extern short P_escapecode;
223 extern int P_ioresult;
224 extern __p2c_jmp_buf *__top_jb;
227 #ifdef P2C_H_PROTO /* if you have Ansi C but non-prototyped header files */
228 extern Char *strcat PP( (Char *, Const Char *) );
229 extern Char *strchr PP( (Const Char *, int) );
230 extern int strcmp PP( (Const Char *, Const Char *) );
231 extern Char *strcpy PP( (Char *, Const Char *) );
232 extern size_t strlen PP( (Const Char *) );
233 extern Char *strncat PP( (Char *, Const Char *, size_t) );
234 extern int strncmp PP( (Const Char *, Const Char *, size_t) );
235 extern Char *strncpy PP( (Char *, Const Char *, size_t) );
236 extern Char *strrchr PP( (Const Char *, int) );
238 extern Anyptr memchr PP( (Const Anyptr, int, size_t) );
239 extern Anyptr memmove PP( (Anyptr, Const Anyptr, size_t) );
240 extern Anyptr memset PP( (Anyptr, int, size_t) );
242 extern Anyptr memcpy PP( (Anyptr, Const Anyptr, size_t) );
243 extern int memcmp PP( (Const Anyptr, Const Anyptr, size_t) );
246 extern int atoi PP( (Const Char *) );
247 extern double atof PP( (Const Char *) );
248 extern long atol PP( (Const Char *) );
249 extern double strtod PP( (Const Char *, Char **) );
250 extern long strtol PP( (Const Char *, Char **, int) );
251 #endif /*P2C_H_PROTO*/
255 extern Anyptr malloc PP( (size_t) );
257 extern Void free PP( (Anyptr) );
258 #endif /* HAS_STDLIB */
260 extern int _OutMem PV();
261 extern int _CaseCheck PV();
262 extern int _NilCheck PV();
263 extern int _Escape PP( (int) );
264 extern int _EscIO PP( (int) );
266 extern long ipow PP( (long, long) );
267 /* strsub defined in qalib.c */
268 /* extern Char *strsub PP( (Char *, Char *, int, int) ); */
269 extern Char *strltrim PP( (Char *) );
270 extern Char *strrtrim PP( (Char *) );
271 extern Char *strrpt PP( (Char *, Char *, int) );
272 extern Char *strpad PP( (Char *, Char *, int, int) );
274 /* strpos2 defined in qalib.c */
275 /* extern int strpos2 PP( (Char *, Char *, int) ); */
276 extern long memavail PV();
277 extern int P_peek PP( (FILE *) );
278 extern int P_eof PP( (FILE *) );
279 extern int P_eoln PP( (FILE *) );
280 extern Void P_readpaoc PP( (FILE *, Char *, int) );
281 extern Void P_readlnpaoc PP( (FILE *, Char *, int) );
282 extern long P_maxpos PP( (FILE *) );
283 extern long *P_setunion PP( (long *, long *, long *) );
284 extern long *P_setint PP( (long *, long *, long *) );
285 extern long *P_setdiff PP( (long *, long *, long *) );
286 extern long *P_setxor PP( (long *, long *, long *) );
287 extern int P_inset PP( (unsigned, long *) );
288 extern int P_setequal PP( (long *, long *) );
289 extern int P_subset PP( (long *, long *) );
290 extern long *P_addset PP( (long *, unsigned) );
291 extern long *P_addsetr PP( (long *, unsigned, unsigned) );
292 extern long *P_remset PP( (long *, unsigned) );
293 extern long *P_setcpy PP( (long *, long *) );
294 extern long *P_expset PP( (long *, long) );
295 extern long P_packset PP( (long *) );
296 extern int P_getcmdline PP( (int l, int h, Char *line) );
297 extern Void TimeStamp PP( (int *Day, int *Month, int *Year,
298 int *Hour, int *Min, int *Sec) );
299 extern Void P_sun_argv PP( (char *, int, int) );
302 /* I/O error handling */
303 #define _CHKIO(cond,ior,val,def) ((cond) ? P_ioresult=0,(val) \
304 : P_ioresult=(ior),(def))
305 #define _SETIO(cond,ior) (P_ioresult = (cond) ? 0 : (ior))
307 /* Following defines are suitable for the HP Pascal operating system */
308 #define FileNotFound 10
309 #define FileNotOpen 13
310 #define FileWriteError 38
311 #define BadInputFormat 14
314 /* Creating temporary files */
315 #if (defined(BSD) || defined(NO_TMPFILE)) && !defined(HAVE_TMPFILE)
316 # define tmpfile() (fopen(tmpnam(NULL), "w+"))
320 #define FILEBUF(f,sc,type) sc int __CAT__(f,_BFLAGS); \
321 sc type __CAT__(f,_BUFFER)
323 #define RESETBUF(f,type) (__CAT__(f,_BFLAGS) = 1)
324 #define SETUPBUF(f,type) (__CAT__(f,_BFLAGS) = 0)
326 #define GETFBUF(f,type) (*((__CAT__(f,_BFLAGS) == 1 && \
327 ((__CAT__(f,_BFLAGS) = 2), \
328 fread(&__CAT__(f,_BUFFER), \
329 sizeof(type),1,(f)))),\
330 &__CAT__(f,_BUFFER)))
331 #define AGETFBUF(f,type) ((__CAT__(f,_BFLAGS) == 1 && \
332 ((__CAT__(f,_BFLAGS) = 2), \
333 fread(&__CAT__(f,_BUFFER), \
334 sizeof(type),1,(f)))),\
337 #define PUTFBUF(f,type,v) (GETFBUF(f,type) = (v))
338 #define CPUTFBUF(f,v) (PUTFBUF(f,char,v))
339 #define APUTFBUF(f,type,v) (memcpy(GETFBUF(f,type), (v), \
340 sizeof(__CAT__(f,_BUFFER))))
342 #define GET(f,type) (__CAT__(f,_BFLAGS) == 1 ? \
343 fread(&__CAT__(f,_BUFFER),sizeof(type),1,(f)) : \
344 (__CAT__(f,_BFLAGS) = 1))
346 #define PUT(f,type) (fwrite(&__CAT__(f,_BUFFER),sizeof(type),1,(f)), \
347 (__CAT__(f,_BFLAGS) = 0))
348 #define CPUT(f) (PUT(f,char))
350 /* Memory allocation */
352 # define Malloc(n) (malloc(n) ?: (Anyptr)_OutMem())
354 extern Anyptr __MallocTemp__;
355 # define Malloc(n) ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)_OutMem())
357 #define FreeR(p) (free((Anyptr)(p))) /* used if arg is an rvalue */
358 #define Free(p) (free((Anyptr)(p)), (p)=NULL)
361 #define SEXT(x,n) ((x) | -(((x) & (1L<<((n)-1))) << 1))
363 /* packed arrays */ /* BEWARE: these are untested! */
364 #define P_getbits_UB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] >> \
365 (((~(i))&((1<<(L)-(n))-1)) << (n)) & \
368 #define P_getbits_SB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] << \
369 (16 - ((((~(i))&((1<<(L)-(n))-1))+1) <<\
370 (n)) >> (16-(1<<(n))))))
372 #define P_putbits_UB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \
373 (x) << (((~(i))&((1<<(L)-(n))-1)) << (n)))
375 #define P_putbits_SB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \
376 ((x) & (1<<(1<<(n)))-1) << \
377 (((~(i))&((1<<(L)-(n))-1)) << (n)))
379 #define P_clrbits_B(a,i,n,L) ((a)[(i)>>(L)-(n)] &= \
380 ~( ((1<<(1<<(n)))-1) << \
381 (((~(i))&((1<<(L)-(n))-1)) << (n))) )
383 /* small packed arrays */
384 #define P_getbits_US(v,i,n) ((int)((v) >> (~(i) << (n)) & (1<<(1<<(n)))-1))
385 #define P_getbits_SS(v,i,n) ((int)((long)(v) << (32 - (((~(i))+1) << (n))) >> (32-(1<<(n)))))
386 #define P_putbits_US(v,i,x,n) ((v) |= (x) << (~(i) << (n)))
387 #define P_putbits_SS(v,i,x,n) ((v) |= ((x) & (1<<(1<<(n)))-1) << (~(i) << (n)))
388 #define P_clrbits_S(v,i,n) ((v) &= ~( ((1<<(1<<(n)))-1) << (~(i) << (n)) ))
390 #define P_max(a,b) ((a) > (b) ? (a) : (b))
391 #define P_min(a,b) ((a) < (b) ? (a) : (b))
394 /* Fix toupper/tolower on Suns and other stupid BSD systems */
398 # define toupper(c) my_toupper(c)
399 # define tolower(c) my_tolower(c)
403 # if 'A' == 65 && 'a' == 97
404 # define _toupper(c) ((c)-'a'+'A')
405 # define _tolower(c) ((c)-'A'+'a')
407 # define _toupper(c) toupper(c)
408 # define _tolower(c) tolower(c)