oops.. only build it when it _is_ valid.
[AROS-Contrib.git] / regina / common / rxpack.h
blobc748ccba981e4470a21a46db91d524ac8bdb69f9
1 /*
2 * Copyright (C) 1998-2001 Mark Hessling <M.Hessling@qut.edu.au>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef _RXPACK_H
20 #define _RXPACK_H
22 #ifdef HAVE_CONFIG_H
23 # include "config.h"
24 #else
25 # include "defines.h"
26 #endif
28 #include <stdio.h>
30 #ifdef HAVE_CTYPE_H
31 # include <ctype.h>
32 #endif
34 #ifdef HAVE_STDLIB_H
35 # include <stdlib.h>
36 #endif
38 #ifdef HAVE_STRING_H
39 # include <string.h>
40 #endif
42 #ifdef HAVE_ERRNO_H
43 # include <errno.h>
44 #endif
46 #ifdef HAVE_ASSERT_H
47 # include <assert.h>
48 #endif
50 #ifdef HAVE_SYS_TYPES_H
51 # include <sys/types.h>
52 #endif
54 #ifdef HAVE_SYS_STAT_H
55 # include <sys/stat.h>
56 #endif
58 #ifdef HAVE_DIRENT_H
59 # include <dirent.h>
60 #endif
62 #ifdef HAVE_MALLOC_H
63 # include <malloc.h>
64 #endif
66 #ifdef HAVE_MATH_H
67 # include <math.h>
68 #endif
70 #ifdef HAVE_STDARG_H
71 # include <stdarg.h>
72 #endif
74 #ifdef HAVE_UNISTD_H
75 # include <unistd.h>
76 #endif
78 #ifdef HAVE_GETOPT_H
79 # include <getopt.h>
80 #endif
82 #ifdef HAVE_IO_H
83 # include <io.h>
84 #endif
86 #ifdef HAVE_FCNTL_H
87 # include <fcntl.h>
88 #endif
91 * All things that this application may require out of os2.h must be
92 * specified here in one place. This is because EMX includes all Rexx
93 * related stuff in os2.h, not in a serperate header file. This makes
94 * it difficult to use another Rexx interpreter with EMX :-(
96 #if defined(OS2) || defined(__OS2__)
97 # if !defined(EMXVIDEO)
98 # define INCL_VIO
99 # define INCL_KBD
100 # endif
101 # if defined(USE_OS2REXX)
102 # define INCL_RXSHV /* Shared variable support */
103 # define INCL_RXFUNC /* External functions support */
104 # define INCL_RXSYSEXIT /* System exit routines */
105 # define INCL_RXSUBCOM /* Subcommand routines */
106 # include <os2.h>
107 # else
108 # include <os2.h>
109 # define INCL_RXSHV /* Shared variable support */
110 # define INCL_RXFUNC /* External functions support */
111 # define INCL_RXSYSEXIT /* System exit routines */
112 # define INCL_RXSUBCOM /* Subcommand routines */
113 # endif
114 #else
115 # define INCL_RXSHV /* Shared variable support */
116 # define INCL_RXFUNC /* External functions support */
117 # define INCL_RXSYSEXIT /* System exit routines */
118 # define INCL_RXSUBCOM /* Subcommand routines */
119 #endif
122 * The following header file is supplied by the application package.
123 * It specifies any application-specific header files and #defines
124 * the following:
125 * RXPACKAGE_MAGIC_NUMBER 12345 - any number
126 * RXPACKAGE_DEBUG_VAR "ENV_VAR" - an env variable enclosed in quotes
128 #include "apphead.h"
130 #include "rxdef.h"
132 #define RETBUFLEN 250
134 #if defined(DYNAMIC)
135 # define DYNAMIC_LIBRARY 1
136 #endif
138 #ifndef TRUE
139 # define TRUE 1
140 # define FALSE 0
141 #endif
144 * Run time modes
146 #define MODE_DEBUG 1
147 #define MODE_VERBOSE 2
148 #define MODE_INTERNAL 4
149 #define MODE_HALTONERROR 8
151 #define REXX_FAIL 1
153 #define RXSTRCAT(dst,dstlen,src,srclen) \
155 memcpy((dst)+(dstlen),(src),(srclen)); \
156 (dstlen)+=(srclen); \
157 *((dst)+(dstlen))='\0'; \
159 #define RXSTRCPY(dst,dstlen,src,srclen) \
161 memcpy((dst),(src),(srclen)); \
162 (dstlen)=(srclen); \
163 *((dst)+(dstlen))='\0'; \
166 #if !defined(max)
167 # define max(a,b) (((a) > (b)) ? (a) : (b))
168 #endif
170 #if !defined(min)
171 # define min(a,b) (((a) < (b)) ? (a) : (b))
172 #endif
174 #if !defined(MAX_PATH)
175 # if defined(NAME_MAX)
176 # define MAX_PATH NAME_MAX
177 # elif defined(MAXNAMLEN)
178 # define MAX_PATH MAXNAMLEN
179 # else
180 # define MAX_PATH 255
181 # endif
182 #endif
184 typedef int RX_INT;
185 typedef unsigned int RX_UINT;
186 typedef long RX_LONG;
187 typedef unsigned long RX_ULONG;
190 * Typedef a common "long long"
192 #if defined(_MSC_VER) || defined(__LCC__)
193 /* MS VC++ or LCC on Win32 */
194 typedef signed __int64 rx_long_long;
195 # define RX_LL_FORMAT "%I64d"
196 #elif (defined(__WATCOMC__) && !defined(__QNX__)) || (defined(__GNUC__) && defined(WIN32))
197 /* Watcom C++ on WIn32 or OS/2 or Cygwin on Win32 */
198 typedef long long rx_long_long;
199 # define RX_LL_FORMAT "%I64d"
200 #elif defined(HAVE_LONG_LONG)
201 /* Any compiler that supports "long long" */
202 typedef long long rx_long_long;
203 # define RX_LL_FORMAT "%lld"
204 #else
205 /* No "long long" support; make it "long" */
206 typedef long rx_long_long;
207 # define RX_LL_FORMAT "%ld"
208 #endif
210 #ifdef USE_REXX6000
211 typedef USHORT RexxFunctionHandler(PSZ, ULONG, PRXSTRING, PSZ, PRXSTRING) ;
212 #endif
214 * Standard REXX API function - idea borrowed from Patrick McPhee's Regutil
216 #define rxfunc(x) APIRET APIENTRY x( RFH_ARG0_TYPE name, RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG3_TYPE stck, RFH_ARG4_TYPE retstr )
218 /*-----------------------------------------------------------------------------
219 * Definition of an external function
220 *----------------------------------------------------------------------------*/
221 typedef struct {
222 RRFD_ARG0_TYPE ExternalName;
223 RRFE_ARG1_TYPE EntryPoint;
224 RRFD_ARG2_TYPE InternalName;
225 int DllLoad;
226 } RexxFunction;
229 * The following structure contains all "global" data common to all
230 * external function packages. A similar structure should exists
231 * for package-specific data.
233 typedef struct
235 int RxRunFlags; /* debug/verbose flags */
236 char FName[100]; /* current function name */
237 char PreviousConstantPrefix[11]; /* previous constant variables prefix */
238 char ConstantPrefix[11]; /* constant variables prefix */
239 FILE *RxTraceFilePointer; /* file pointer for all output */
240 char RxTraceFileName[MAX_PATH]; /* filename of output file */
241 int deallocate; /* indicates if rxpack should deallocate this structure */
242 int terminated; /* indicates if rxpack has called RxTermPackage() for this structure */
243 } RxPackageGlobalDataDef;
246 * The following structure contains details of a package's constants
248 typedef struct
250 char *name; /* base name of constant */
251 int type; /* 0 (numeric), 1 (text), 2 (float), 3 (char) */
252 long numeric_value; /* numeric value of constant */
253 char *text_value; /* text value of constant */
254 double double_value; /* double value of constant */
255 char char_value; /* char value of constant */
256 } RxPackageConstantDef;
258 typedef int PackageInitialiser( RxPackageGlobalDataDef * );
259 typedef int PackageTerminator( RxPackageGlobalDataDef * );
261 #ifdef HAVE_PROTO
262 # define Args(a) a
263 #else
264 # define Args(a) ()
265 #endif
267 RxPackageGlobalDataDef *FunctionPrologue Args(( RxPackageGlobalDataDef *, PackageInitialiser *, char *, ULONG, RXSTRING * ));
268 void FunctionTrace Args(( RxPackageGlobalDataDef *, char *, ... ));
269 long FunctionEpilogue Args(( RxPackageGlobalDataDef *, char *, long ));
270 void InternalTrace Args(( RxPackageGlobalDataDef *, char *, ... ));
271 void RxDisplayError Args(( RxPackageGlobalDataDef *, RFH_ARG0_TYPE, ... ));
272 RxPackageGlobalDataDef *InitRxPackage Args(( RxPackageGlobalDataDef *, PackageInitialiser *, int * ));
273 int TermRxPackage Args(( RxPackageGlobalDataDef **, PackageTerminator *, RexxFunction *, char *, int ));
274 int RegisterRxFunctions Args(( RxPackageGlobalDataDef *, RexxFunction *, char * ));
275 int RegisterRxSubcom Args(( RxPackageGlobalDataDef *, RexxSubcomHandler ));
276 int RegisterRxInit Args(( RxPackageGlobalDataDef *, RexxExitHandler, char *));
277 int QueryRxFunction Args(( RxPackageGlobalDataDef *, char * ));
278 int DeregisterRxFunctions Args(( RxPackageGlobalDataDef *, RexxFunction *, int ));
279 int SetPackageConstants Args(( RxPackageGlobalDataDef *, RxPackageConstantDef *, char *, int ));
280 char *make_upper Args(( char * ));
281 char *AllocString Args(( char *, int ));
282 char *MkAsciz Args(( char *, int, char *, int ));
283 int SetRexxVariable Args(( RxPackageGlobalDataDef *,char *, int, char *, int ));
284 RXSTRING *GetRexxVariable Args(( RxPackageGlobalDataDef *, char *, RXSTRING *, int ));
285 int *GetRexxVariableInteger Args(( RxPackageGlobalDataDef *, char *, int *, int ));
286 int DropRexxVariable Args(( RxPackageGlobalDataDef *,char *, int ));
287 int StrToInt Args(( RXSTRING *, ULONG * ));
288 int StrToNumber Args(( RXSTRING *, LONG * ));
289 int StrToBool Args(( RXSTRING *, ULONG * ));
290 int RxSetTraceFile Args(( RxPackageGlobalDataDef *, char * ));
291 char *RxGetTraceFile Args(( RxPackageGlobalDataDef * ));
292 int RxSetConstantPrefix Args(( RxPackageGlobalDataDef *, char * ));
293 char *RxGetConstantPrefix Args(( RxPackageGlobalDataDef * ));
294 void RxSetRunFlags Args(( RxPackageGlobalDataDef *, int ));
295 int RxGetRunFlags Args(( RxPackageGlobalDataDef * ));
296 int RxReturn Args(( RxPackageGlobalDataDef *, RXSTRING * ));
297 int RxReturnString Args(( RxPackageGlobalDataDef *, RXSTRING *, char * ));
298 int RxReturnStringAndFree Args(( RxPackageGlobalDataDef *, RXSTRING *, char *, int ));
299 int RxReturnNumber Args(( RxPackageGlobalDataDef *, RXSTRING *, long ));
300 int RxReturnUnsignedNumber Args(( RxPackageGlobalDataDef *, RXSTRING *, ULONG ));
301 int RxReturnDouble Args(( RxPackageGlobalDataDef *, RXSTRING *, double ));
302 int RxReturnPointer Args(( RxPackageGlobalDataDef *, RXSTRING *, void * ));
303 int memcmpi Args(( char *, char *, int ));
304 int my_checkparam Args(( RxPackageGlobalDataDef *, RFH_ARG0_TYPE, int, int, int ));
305 int RxStrToInt Args(( RxPackageGlobalDataDef *, RXSTRING *, int * ));
306 int RxStrToUInt Args(( RxPackageGlobalDataDef *, RXSTRING *, unsigned int * ));
307 int RxStrToLong Args(( RxPackageGlobalDataDef *, RXSTRING *, long * ));
308 int RxStrToULong Args(( RxPackageGlobalDataDef *, RXSTRING *, unsigned long * ));
309 int RxStrToDouble Args(( RxPackageGlobalDataDef *, RXSTRING *, double * ));
310 int RxStemToCharArray Args(( RxPackageGlobalDataDef *, RXSTRING *, char *** ));
311 void RxFreeCharArray Args(( char **, int ));
312 int RxStemToIntArray Args(( RxPackageGlobalDataDef *, RXSTRING *, int ** ));
313 void RxFreeIntArray Args(( int * ));
314 int RxStemToUIntArray Args(( RxPackageGlobalDataDef *, RXSTRING *, unsigned int ** ));
315 void RxFreeUIntArray Args(( unsigned int * ));
316 int RxStemToLongArray Args(( RxPackageGlobalDataDef *, RXSTRING *, long ** ));
317 void RxFreeLongArray Args(( long * ));
318 int RxStemToULongArray Args(( RxPackageGlobalDataDef *, RXSTRING *, unsigned long ** ));
319 void RxFreeULongArray Args(( unsigned long * ));
320 int RxNumberToVariable Args(( RxPackageGlobalDataDef *, RXSTRING *, ULONG ));
322 #ifdef DEBUG
323 # define DEBUGDUMP(x) {x;}
324 #else
325 # define DEBUGDUMP(x) {}
326 #endif
328 * Directory and PATH separators
330 #if defined(MSDOS) || ( defined(__WATCOMC__) && !defined(__QNX__) ) || defined(_MSC_VER) || defined(DOS) || defined(OS2) ||defined(__OS2__) || defined(__WINS__) || defined(__EPOC32__) || defined(__LCC__)
331 # define FILE_SEPARATORS "\\/:"
332 # define FILE_SEPARATOR '\\'
333 # define FILE_SEPARATOR_STR "\\"
334 # define PATH_SEPARATOR ';'
335 # define PATH_SEPARATOR_STR ";"
336 #elif defined(VMS)
337 # define FILE_SEPARATORS "]"
338 # define FILE_SEPARATOR ']'
339 # define FILE_SEPARATOR_STR "]"
340 # define PATH_SEPARATOR '?'
341 # define PATH_SEPARATOR_STR "?"
342 #elif defined(MAC)
343 # define FILE_SEPARATOR "]"
344 # define FILE_SEPARATOR ']'
345 # define FILE_SEPARATOR_STR "]"
346 # define PATH_SEPARATOR '?'
347 # define PATH_SEPARATOR_STR "?"
348 #else
349 # define FILE_SEPARATORS "/"
350 # define FILE_SEPARATOR '/'
351 # define FILE_SEPARATOR_STR "/"
352 # define PATH_SEPARATOR ':'
353 # define PATH_SEPARATOR_STR ":"
354 #endif
356 #endif /* !_RXPACK_H */