home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / BM2FON20 / P2C.H < prev    next >
C/C++ Source or Header  |  1993-03-01  |  14KB  |  516 lines

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