Debian Codegraph @

utils/m-tx/mtx-src/libp2c/p2c.h

raw
1 #ifndef P2C_H
2 #define P2C_H
3
4
5 /* Header file for code generated by "p2c", the Pascal-to-C translator */
6
7 /* "p2c" Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation.
8 * By Dave Gillespie, [email protected]. Version 1.21alpha-07.Dec.93.
9 * This file may be copied, modified, etc. in any way. It is not restricted
10 * by the licence agreement accompanying p2c itself.
11 */
12
13
14 #include <stdio.h>
15
16 #define DOUBLE double
17
18
19
20 /* If the following heuristic fails, compile -DBSD=0 for non-BSD systems,
21 or -DBSD=1 for BSD systems. */
22
23 #ifdef M_XENIX
24 # define BSD 0
25 #endif
26
27 #ifdef vms
28 # define BSD 0
29 # ifndef __STDC__
30 # define __STDC__ 1
31 # endif
32 #endif
33
34 #ifdef __TURBOC__
35 # define MSDOS 1
36 #endif
37
38 #ifdef MSDOS
39 # define BSD 0
40 #endif
41
42 #ifdef FILE /* a #define in BSD, a typedef in SYSV (hp-ux, at least) */
43 # ifndef BSD /* (a convenient, but horrible kludge!) */
44 # define BSD 1
45 # endif
46 #endif
47
48 #ifdef BSD
49 # if !BSD
50 # undef BSD
51 # endif
52 #endif
53
54
55 #if (defined(__STDC__) && !defined(M_XENIX)) || defined(__TURBOC__)
56 # include <stdlib.h>
57 # include <stddef.h>
58 # define HAS_STDLIB
59 # if defined(vms) || defined(__TURBOC__)
60 # define NON_ANSI_CAT
61 # endif
62 #else
63 # ifndef BSD
64 # ifndef __TURBOC__
65 # include <memory.h>
66 # endif
67 # endif
68 # ifdef hpux
69 # ifdef _INCLUDE__STDC__
70 # include <stddef.h>
71 # include <stdlib.h>
72 # define HAS_STDLIB
73 # endif
74 # endif
75 # include <sys/types.h>
76 # if !defined(MSDOS) || defined(__TURBOC__)
77 # define NON_ANSI_CAT
78 # endif
79 #endif
80
81 #if defined(NON_ANSI_CAT) && !defined(ANSI_CAT)
82 # ifdef NON_ANSI_CAT_ALTERNATE
83 # define __CAT__(a,b)a/**/b
84 # else
85 # define __ID__(a)a
86 # define __CAT__(a,b)__ID__(a)b
87 # endif
88 #else
89 # define __CAT__(a,b)a##b
90 #endif
91
92
93 #ifdef BSD
94 # include <strings.h>
95 # define memcpy(a,b,n) (bcopy(b,a,n),a)
96 # define memcmp(a,b,n) bcmp(a,b,n)
97 # define strchr(s,c) index(s,c)
98 # define strrchr(s,c) rindex(s,c)
99 #else
100 # include <string.h>
101 #endif
102
103 #include <ctype.h>
104 #include <math.h>
105 #include <setjmp.h>
106 #include <assert.h>
107
108
109 #ifndef NO_LACK
110 #ifdef vms
111
112 #define LACK_LABS
113 #define LACK_MEMMOVE
114 #define LACK_MEMCPY
115
116 #else
117
118 #define LACK_LABS /* Undefine these if your library has these */
119 #define LACK_MEMMOVE
120
121 #endif
122 #endif
123
124
125 typedef struct __p2c_jmp_buf {
126 struct __p2c_jmp_buf *next;
127 jmp_buf jbuf;
128 } __p2c_jmp_buf;
129
130
131 /* Warning: The following will not work if setjmp is used simultaneously.
132 This also violates the ANSI restriction about using vars after longjmp,
133 but a typical implementation of longjmp will get it right anyway. */
134
135 #ifndef FAKE_TRY
136 # define TRY(x) do { __p2c_jmp_buf __try_jb; \
137 __try_jb.next = __top_jb; \
138 if (!setjmp((__top_jb = &__try_jb)->jbuf)) {
139 # define RECOVER(x) __top_jb = __try_jb.next; } else {
140 # define RECOVER2(x,L) __top_jb = __try_jb.next; } else { \
141 if (0) { L: __top_jb = __try_jb.next; }
142 # define ENDTRY(x) } } while (0)
143 #else
144 # define TRY(x) if (1) {
145 # define RECOVER(x) } else do {
146 # define RECOVER2(x,L) } else do { L: ;
147 # define ENDTRY(x) } while (0)
148 #endif
149
150
151
152 #ifdef M_XENIX /* avoid compiler bug */
153 # define SHORT_MAX (32767)
154 # define SHORT_MIN (-32768)
155 #endif
156
157
158 /* The following definitions work only on twos-complement machines */
159 #ifndef SHORT_MAX
160 # define SHORT_MAX ((short)(((unsigned short) -1) >> 1))
161 # define SHORT_MIN (~SHORT_MAX)
162 #endif
163
164 #ifndef INT_MAX
165 # define INT_MAX ((int)(((unsigned int) -1) >> 1))
166 # define INT_MIN (~INT_MAX)
167 #endif
168
169 #ifndef LONG_MAX
170 # define LONG_MAX ((long)(((unsigned long) -1) >> 1))
171 # define LONG_MIN (~LONG_MAX)
172 #endif
173
174 #ifndef SEEK_SET
175 # define SEEK_SET 0
176 # define SEEK_CUR 1
177 # define SEEK_END 2
178 #endif
179
180 #ifndef EXIT_SUCCESS
181 # ifdef vms
182 # define EXIT_SUCCESS 1
183 # define EXIT_FAILURE (02000000000L)
184 # else
185 # define EXIT_SUCCESS 0
186 # define EXIT_FAILURE 1
187 # endif
188 #endif
189
190
191 #define SETBITS 32
192
193
194 #if defined(__STDC__) || defined(__TURBOC__)
195 # if !defined(vms) && !defined(M_LINT)
196 # define Signed signed
197 # else
198 # define Signed
199 # endif
200 # define Void void /* Void f() = procedure */
201 # ifndef Const
202 # define Const const
203 # endif
204 # ifndef Volatile
205 # define Volatile volatile
206 # endif
207 # ifdef M_LINT
208 # define PP(x) ()
209 # define PV() ()
210 typedef char *Anyptr;
211 # else
212 # define PP(x) x /* function prototype */
213 # define PV() (void) /* null function prototype */
214 typedef void *Anyptr;
215 # endif
216 #else
217 # define Signed
218 # define Void void
219 # ifndef Const
220 # define Const
221 # endif
222 # ifndef Volatile
223 # define Volatile
224 # endif
225 # define PP(x) ()
226 # define PV() ()
227 typedef char *Anyptr;
228 #endif
229
230 #ifdef __GNUC__
231 # define Inline inline
232 #else
233 # define Inline
234 #endif
235
236 #define Register register /* Register variables */
237 typedef char Char; /* Characters (not bytes) */
238
239 #ifndef Static
240 # define Static static /* Private global funcs and vars */
241 #endif
242
243 #ifndef Local
244 # define Local static /* Nested functions */
245 #endif
246
247 typedef Signed char schar;
248 typedef unsigned char uchar;
249 typedef unsigned char boolean;
250
251 #ifndef NO_DECLARE_ALFA
252 typedef Char alfa[10];
253 #endif
254
255 #ifndef true
256 # define true 1
257 # define false 0
258 #endif
259
260 #ifndef TRUE
261 # define TRUE 1
262 # define FALSE 0
263 #endif
264
265
266 typedef struct {
267 Anyptr proc, link;
268 } _PROCEDURE;
269
270 #ifndef _FNSIZE
271 # define _FNSIZE 120
272 #endif
273
274
275 extern Void PASCAL_MAIN PP( (int, Char **) );
276 extern Char **P_argv;
277 extern int P_argc;
278 extern short P_escapecode;
279 extern int P_ioresult;
280 extern __p2c_jmp_buf *__top_jb;
281
282
283 #ifdef P2C_H_PROTO /* if you have Ansi C but non-prototyped header files */
284 extern Char *strcat PP( (Char *, Const Char *) );
285 extern Char *strchr PP( (Const Char *, int) );
286 extern int strcmp PP( (Const Char *, Const Char *) );
287 extern Char *strcpy PP( (Char *, Const Char *) );
288 extern size_t strlen PP( (Const Char *) );
289 extern Char *strncat PP( (Char *, Const Char *, size_t) );
290 extern int strncmp PP( (Const Char *, Const Char *, size_t) );
291 extern Char *strncpy PP( (Char *, Const Char *, size_t) );
292 extern Char *strrchr PP( (Const Char *, int) );
293
294 extern Anyptr memchr PP( (Const Anyptr, int, size_t) );
295 extern Anyptr memmove PP( (Anyptr, Const Anyptr, size_t) );
296 extern Anyptr memset PP( (Anyptr, int, size_t) );
297 #ifndef memcpy
298 extern Anyptr memcpy PP( (Anyptr, Const Anyptr, size_t) );
299 extern int memcmp PP( (Const Anyptr, Const Anyptr, size_t) );
300 #endif
301
302 extern int atoi PP( (Const Char *) );
303 extern double atof PP( (Const Char *) );
304 extern long atol PP( (Const Char *) );
305 extern double strtod PP( (Const Char *, Char **) );
306 extern long strtol PP( (Const Char *, Char **, int) );
307 #endif /*P2C_H_PROTO*/
308
309 #ifndef HAS_STDLIB
310 #ifndef NO_DECLARE_MALLOC
311 extern Anyptr malloc PP( (size_t) );
312 extern Void free PP( (Anyptr) );
313 #endif
314 #endif
315
316 extern int _OutMem PV();
317 extern int _CaseCheck PV();
318 extern int _NilCheck PV();
319 extern int _Escape PP( (int) );
320 extern int _EscIO PP( (int) );
321 extern int _EscIO2 PP( (int, Char *) );
322
323 extern long ipow PP( (long, long) );
324 extern long P_imax PP( (long, long) );
325 extern long P_imin PP( (long, long) );
326 extern double P_rmax PP( (double, double) );
327 extern double P_rmin PP( (double, double) );
328 extern Char *strsub PP( (Char *, Char *, int, int) );
329 extern Char *strltrim PP( (Char *) );
330 extern Char *strrtrim PP( (Char *) );
331 extern Char *strrpt PP( (Char *, Char *, int) );
332 extern Char *strpad PP( (Char *, Char *, int, int) );
333 extern int strpos2 PP( (Char *, Char *, int) );
334 extern long memavail PV();
335 extern int P_peek PP( (FILE *) );
336 extern int P_eof PP( (FILE *) );
337 extern int P_eoln PP( (FILE *) );
338 extern Void P_readpaoc PP( (FILE *, Char *, int) );
339 extern Void P_readlnpaoc PP( (FILE *, Char *, int) );
340 extern long P_maxpos PP( (FILE *) );
341 extern Char *P_trimname PP( (Char *, int) );
342 extern long *P_setunion PP( (long *, long *, long *) );
343 extern long *P_setint PP( (long *, long *, long *) );
344 extern long *P_setdiff PP( (long *, long *, long *) );
345 extern long *P_setxor PP( (long *, long *, long *) );
346 extern int P_inset PP( (unsigned, long *) );
347 extern int P_setequal PP( (long *, long *) );
348 extern int P_subset PP( (long *, long *) );
349 extern long *P_addset PP( (long *, unsigned) );
350 extern long *P_addsetr PP( (long *, unsigned, unsigned) );
351 extern long *P_remset PP( (long *, unsigned) );
352 extern long *P_setcpy PP( (long *, long *) );
353 extern long *P_expset PP( (long *, long) );
354 extern long P_packset PP( (long *) );
355 extern int P_getcmdline PP( (int, int, Char *) );
356 extern Void TimeStamp PP( (int *, int *, int *,
357 int *, int *, int *) );
358 extern Void P_sun_argv PP( (char *, int, int) );
359 extern FILE *_skipspaces PP( (FILE *) );
360 extern FILE *_skipnlspaces PP( (FILE *) );
361
362
363 /* I/O error handling */
364 #define _CHKIO(cond,ior,val,def) ((cond) ? P_ioresult=0,(val) \
365 : P_ioresult=(ior),(def))
366 #define _SETIO(cond,ior) (P_ioresult = (cond) ? 0 : (ior))
367
368 /* Following defines are suitable for the HP Pascal operating system */
369 #define FileNotFound 10
370 #define FileNotOpen 13
371 #define FileWriteError 38
372 #define BadInputFormat 14
373 #define EndOfFile 30
374
375 #define FILENOTFOUND 10
376 #define FILENOTOPEN 13
377 #define FILEWRITEERROR 38
378 #define BADINPUTFORMAT 14
379 #define ENDOFFILE 30
380
381 /* Creating temporary files */
382 #if (defined(BSD) || defined(NO_TMPFILE)) && !defined(HAVE_TMPFILE)
383 # define tmpfile() (fopen(tmpnam(NULL), "w+"))
384 #endif
385
386 /* File buffers */
387 #define FILEBUF(f,sc,type) sc int __CAT__(f,_BFLAGS); \
388 sc type __CAT__(f,_BUFFER)
389 #define FILEBUFNC(f,type) int __CAT__(f,_BFLAGS); \
390 type __CAT__(f,_BUFFER)
391
392 #define RESETBUF(f,type) (__CAT__(f,_BFLAGS) = 1)
393 #define SETUPBUF(f,type) (__CAT__(f,_BFLAGS) = 0)
394
395 #define GETFBUF(f,type) (*((__CAT__(f,_BFLAGS) == 1 && \
396 ((__CAT__(f,_BFLAGS) = 2), \
397 fread(&__CAT__(f,_BUFFER), \
398 sizeof(type),1,(f)))),\
399 &__CAT__(f,_BUFFER)))
400 #define AGETFBUF(f,type) ((__CAT__(f,_BFLAGS) == 1 && \
401 ((__CAT__(f,_BFLAGS) = 2), \
402 fread(__CAT__(f,_BUFFER), \
403 sizeof(type),1,(f)))),\
404 __CAT__(f,_BUFFER))
405
406 #define PUTFBUF(f,type,v) (GETFBUF(f,type) = (v))
407 #define CPUTFBUF(f,v) (PUTFBUF(f,char,v))
408 #define APUTFBUF(f,type,v) (memcpy(AGETFBUF(f,type), (v), \
409 sizeof(__CAT__(f,_BUFFER))))
410
411 #define GET(f,type) (__CAT__(f,_BFLAGS) == 1 ? \
412 fread(&__CAT__(f,_BUFFER),sizeof(type),1,(f)) : \
413 (__CAT__(f,_BFLAGS) = 1))
414
415 #define PUT(f,type) (fwrite(&__CAT__(f,_BUFFER),sizeof(type),1,(f)), \
416 (__CAT__(f,_BFLAGS) = 0))
417 #define CPUT(f) (PUT(f,char))
418
419 #define BUFEOF(f) (__CAT__(f,_BFLAGS) != 2 && P_eof(f))
420 #define BUFFPOS(f) (ftell(f) - (__CAT__(f,_BFLAGS) == 2))
421
422 typedef struct {
423 FILE *f;
424 int f_BFLAGS; /* FILEBUFNC(f,Char); */
425 Char f_BUFFER;
426 Char name[_FNSIZE];
427 } _TEXT;
428
429 /* Memory allocation */
430 #ifdef __GCC__
431 # define Malloc(n) (malloc(n) ?: (Anyptr)(size_t)_OutMem())
432 #else
433 extern Anyptr __MallocTemp__;
434 # define Malloc(n) ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)(size_t)_OutMem())
435 #endif
436 #define FreeR(p) (free((Anyptr)(p))) /* used if arg is an rvalue */
437 #define Free(p) (free((Anyptr)(p)), (p)=NULL)
438
439 /* sign extension */
440 #define SEXT(x,n) ((x) | -(((x) & (1L<<((n)-1))) << 1))
441
442 /* packed arrays */ /* BEWARE: these are untested! */
443 #define P_getbits_UB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] >> \
444 (((~(i))&((1<<(L)-(n))-1)) << (n)) & \
445 (1<<(1<<(n)))-1))
446
447 #define P_getbits_SB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] << \
448 (16 - ((((~(i))&((1<<(L)-(n))-1))+1) <<\
449 (n)) >> (16-(1<<(n))))))
450
451 #define P_putbits_UB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \
452 (x) << (((~(i))&((1<<(L)-(n))-1)) << (n)))
453
454 #define P_putbits_SB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \
455 ((x) & (1<<(1<<(n)))-1) << \
456 (((~(i))&((1<<(L)-(n))-1)) << (n)))
457
458 #define P_clrbits_B(a,i,n,L) ((a)[(i)>>(L)-(n)] &= \
459 ~( ((1<<(1<<(n)))-1) << \
460 (((~(i))&((1<<(L)-(n))-1)) << (n))) )
461
462 /* small packed arrays */
463 #define P_getbits_US(v,i,n) ((int)((v) >> ((i)<<(n)) & (1<<(1<<(n)))-1))
464 #define P_getbits_SS(v,i,n) ((int)((long)(v) << (SETBITS - (((i)+1) << (n))) >> (SETBITS-(1<<(n)))))
465 #define P_putbits_US(v,i,x,n) ((v) |= (x) << ((i) << (n)))
466 #define P_putbits_SS(v,i,x,n) ((v) |= ((x) & (1<<(1<<(n)))-1) << ((i)<<(n)))
467 #define P_clrbits_S(v,i,n) ((v) &= ~( ((1<<(1<<(n)))-1) << ((i)<<(n)) ))
468
469 #define P_max(a,b) ((a) > (b) ? (a) : (b))
470 #define P_min(a,b) ((a) < (b) ? (a) : (b))
471
472
473 /* Fix ANSI-isms */
474
475 #ifdef LACK_LABS
476 # ifndef labs
477 # define labs my_labs
478 extern long my_labs PP( (long) );
479 # endif
480 #endif
481
482 #ifdef LACK_MEMMOVE
483 # ifndef memmove
484 # define memmove my_memmove
485 extern Anyptr my_memmove PP( (Anyptr, Const Anyptr, size_t) );
486 # endif
487 #endif
488
489 #ifdef LACK_MEMCPY
490 # ifndef memcpy
491 # define memcpy my_memcpy
492 extern Anyptr my_memcpy PP( (Anyptr, Const Anyptr, size_t) );
493 # endif
494 # ifndef memcmp
495 # define memcmp my_memcmp
496 extern int my_memcmp PP( (Const Anyptr, Const Anyptr, size_t) );
497 # endif
498 # ifndef memset
499 # define memset my_memset
500 extern Anyptr my_memset PP( (Anyptr, int, size_t) );
501 # endif
502 #endif
503
504 /* Fix toupper/tolower on Suns and other stupid BSD systems */
505 #ifdef toupper
506 # undef toupper
507 # undef tolower
508 # define toupper(c) my_toupper(c)
509 # define tolower(c) my_tolower(c)
510 #endif
511
512 #ifndef _toupper
513 # if 'A' == 65 && 'a' == 97
514 # define _toupper(c) ((c)-'a'+'A')
515 # define _tolower(c) ((c)-'A'+'a')
516 # else
517 # ifdef toupper
518 # undef toupper /* hope these are shadowing real functions, */
519 # undef tolower /* because my_toupper calls _toupper! */
520 # endif
521 # define _toupper(c) toupper(c)
522 # define _tolower(c) tolower(c)
523 # endif
524 #endif
525
526
527 #endif /* P2C_H */
528
529
530
531 /* End. */
532
533