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.
50 #ifdef HAVE_SYS_TYPES_H
51 # include <sys/types.h>
54 #ifdef HAVE_SYS_STAT_H
55 # include <sys/stat.h>
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)
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 */
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 */
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 */
122 * The following header file is supplied by the application package.
123 * It specifies any application-specific header files and #defines
125 * RXPACKAGE_MAGIC_NUMBER 12345 - any number
126 * RXPACKAGE_DEBUG_VAR "ENV_VAR" - an env variable enclosed in quotes
132 #define RETBUFLEN 250
135 # define DYNAMIC_LIBRARY 1
147 #define MODE_VERBOSE 2
148 #define MODE_INTERNAL 4
149 #define MODE_HALTONERROR 8
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)); \
163 *((dst)+(dstlen))='\0'; \
167 # define max(a,b) (((a) > (b)) ? (a) : (b))
171 # define min(a,b) (((a) < (b)) ? (a) : (b))
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
180 # define MAX_PATH 255
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"
205 /* No "long long" support; make it "long" */
206 typedef long rx_long_long
;
207 # define RX_LL_FORMAT "%ld"
211 typedef USHORT
RexxFunctionHandler(PSZ
, ULONG
, PRXSTRING
, PSZ
, PRXSTRING
) ;
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 *----------------------------------------------------------------------------*/
222 RRFD_ARG0_TYPE ExternalName
;
223 RRFE_ARG1_TYPE EntryPoint
;
224 RRFD_ARG2_TYPE InternalName
;
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.
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
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
* );
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
));
323 # define DEBUGDUMP(x) {x;}
325 # define DEBUGDUMP(x) {}
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 ";"
337 # define FILE_SEPARATORS "]"
338 # define FILE_SEPARATOR ']'
339 # define FILE_SEPARATOR_STR "]"
340 # define PATH_SEPARATOR '?'
341 # define PATH_SEPARATOR_STR "?"
343 # define FILE_SEPARATOR "]"
344 # define FILE_SEPARATOR ']'
345 # define FILE_SEPARATOR_STR "]"
346 # define PATH_SEPARATOR '?'
347 # define PATH_SEPARATOR_STR "?"
349 # define FILE_SEPARATORS "/"
350 # define FILE_SEPARATOR '/'
351 # define FILE_SEPARATOR_STR "/"
352 # define PATH_SEPARATOR ':'
353 # define PATH_SEPARATOR_STR ":"
356 #endif /* !_RXPACK_H */