Debian Codegraph @

rexxbif.h

raw
1 /*
2 * The Regina Rexx Interpreter
3 * Copyright (C) 2000 Mark Hessling <[email protected]>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 #ifndef _REXXBIF_H_INCLUDED
20 #define _REXXBIF_H_INCLUDED
21
22 #if defined(HAVE_CONFIG_H)
23 # include "config.h"
24 #else
25 # include "configur.h"
26 #endif
27
28 #include <stdlib.h>
29 #include <stdio.h>
30 #if defined(VMS) || defined(MAC)
31 # include <types.h>
32 #else
33 # include <sys/types.h>
34 #endif
35
36 #if defined(TIME_WITH_SYS_TIME)
37 # include <sys/time.h>
38 # include <time.h>
39 #else
40 # if defined(HAVE_SYS_TIME_H)
41 # include <sys/time.h>
42 # else
43 # include <time.h>
44 # endif
45 #endif
46
47 #if defined(WIN32) && defined(__BORLANDC__)
48 # include <mem.h>
49 #endif
50 #include <string.h>
51
52 #ifdef HAVE_UNISTD_H
53 #include <unistd.h>
54 #endif
55
56 #ifdef HAVE_ERRNO_H
57 #include <errno.h>
58 #endif
59
60 #ifdef HAVE_CTYPE_H
61 #include <ctype.h>
62 #endif
63
64 #ifdef EXTERNAL_TO_REGINA
65 typedef struct tsdtype { /* FGC: This will lead to severe troubles. Imagine
66 * some called routines which are compiled with the
67 * other typedef and linked with a routine using this
68 * kind. Strange things MUST happen. To avoid the
69 * ugliest errors ALWAYS add a scratch space of
70 * at least 4KB. This is a heuristic value.
71 * This is one of the most errorneous programming
72 * techniques to import features and functions from
73 * different programs.
74 * MH. This is included just in case there is an
75 * overlap problem when rexxbif.h is included in the
76 * base Regina code. When used in programs independent
77 * from Regina, the filler is not required.
78 */
79 char filler_never_touch[0x1000];
80 int called_from_saa;
81 } dummy_tsd_t ;
82
83 # define tsd_t dummy_tsd_t
84 # define MAKESTRENG( size ) MakeStreng( size )
85 # define DROPSTRENG( x ) DropStreng( x )
86 # define REXX_RIGHT( s,l,p ) Rexx_right( NULL,s,l,p )
87 # define REXX_X2D( x,err ) Rexx_x2d( NULL,x,err )
88 # define REXX_D2X( x ) Rexx_d2x( NULL,x )
89 # define REXX_UPPER( x ) Rexx_upper( NULL,x )
90 # ifndef STRENG_TYPEDEFED
91 /*
92 * typedef a streng type
93 */
94 typedef struct strengtype {
95 int len, max;
96 #if 0
97 char *value;
98 #else
99 char value[4];
100 #endif
101 } streng ;
102 # endif
103 #else
104 /*
105 * We are including this from within the Regina Interpreter
106 */
107 # include "rexx.h"
108 # define MAKESTRENG( size ) Str_makeTSD( size )
109 # define DROPSTRENG( x ) FreeTSD( x )
110 # define REXX_RIGHT( s,l,p ) Rexx_right( TSD,s,l,p )
111 # define REXX_X2D( x,err ) Rexx_x2d( TSD,x,err )
112 # define REXX_D2X( x ) Rexx_d2x( TSD,x )
113 # define REXX_UPPER( x ) Rexx_upper( TSD,x )
114 #endif
115
116 extern streng *Rexx_right( const tsd_t *TSD, streng *str, int length, char padch );
117 extern int Rexx_x2d( const tsd_t *TSD, const streng *hex, int *error );
118 extern streng *Rexx_d2x( const tsd_t *TSD, int num );
119 extern streng *Rexx_upper( const tsd_t *TSD, streng *str );
120
121 #ifdef EXTERNAL_TO_REGINA
122 extern void DropStreng( streng *str );
123 extern streng *MakeStreng( int num );
124 #endif
125
126 #define PSTRENGLEN(x) ((x)->value ? (x)->len : 0)
127 #define PSTRENGVAL(x) ((x)->value)
128
129 #if 0
130 /*
131 * Define the RXSTRING type, but only if we haven't already included
132 * a SAA header file, which #defines RXSTRLEN()
133 */
134 #ifndef RXSTRLEN
135 # define MAKERXSTRING(x,c,l) ((x).strptr=(c),(x).strlength=(l))
136 # define RXNULLSTRING(x) (!(x).strptr)
137 # define RXSTRLEN(x) ((x).strptr ? (x).strlength : 0UL)
138 # define RXSTRPTR(x) ((x).strptr)
139
140 #endif /* RXSTRLEN */
141 #endif
142
143 #endif