home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxtk12.zip / rxpack.h < prev    next >
Text File  |  2002-08-07  |  7KB  |  254 lines

  1. /*
  2.  * Copyright (C) 1998-1999  Mark Hessling <M.Hessling@qut.edu.au>
  3.  *
  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.
  8.  *
  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.
  13.  *
  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.
  17.  */
  18.  
  19. #ifdef HAVE_CONFIG_H
  20. # include "config.h"
  21. #else
  22. # include "defines.h"
  23. #endif
  24.  
  25. #include <stdio.h>
  26.  
  27. #ifdef HAVE_CTYPE_H
  28. # include <ctype.h>
  29. #endif
  30.  
  31. #ifdef HAVE_STDLIB_H
  32. # include <stdlib.h>
  33. #endif
  34.  
  35. #ifdef HAVE_STRING_H
  36. # include <string.h>
  37. #endif
  38.  
  39. #ifdef HAVE_ERRNO_H
  40. # include <errno.h>
  41. #endif
  42.  
  43. #ifdef HAVE_ASSERT_H
  44. # include <assert.h>
  45. #endif
  46.  
  47. #ifdef HAVE_SYS_TYPES_H
  48. # include <sys/types.h>
  49. #endif
  50.  
  51. #ifdef HAVE_SYS_STAT_H
  52. # include <sys/stat.h>
  53. #endif
  54.  
  55. #ifdef HAVE_DIRENT_H
  56. # include <dirent.h>
  57. #endif
  58.  
  59. #ifdef HAVE_MALLOC_H
  60. # include <malloc.h>
  61. #endif
  62.  
  63. #ifdef HAVE_STDARG_H
  64. # include <stdarg.h>
  65. #endif
  66.  
  67. #ifdef HAVE_UNISTD_H
  68. # include <unistd.h>
  69. #endif
  70.  
  71. #ifdef HAVE_GETOPT_H
  72. # include <getopt.h>
  73. #endif
  74.  
  75. #ifdef HAVE_IO_H
  76. # include <io.h>
  77. #endif
  78.  
  79. /*
  80.  * All things that this application may require out of os2.h must be
  81.  * specified here in one place.  This is because EMX includes all Rexx
  82.  * related stuff in os2.h, not in a serperate header file.  This makes
  83.  * it difficult to use another Rexx interpreter with EMX :-(
  84.  */
  85. #if defined(OS2) || defined(__OS2__)
  86. # if !defined(EMXVIDEO)
  87. #  define INCL_VIO
  88. #  define INCL_KBD
  89. # endif
  90. # if defined(USE_OS2REXX)
  91. #  define INCL_RXSHV      /* Shared variable support */
  92. #  define INCL_RXFUNC     /* External functions support */
  93. #  define INCL_RXSYSEXIT  /* System exit routines */
  94. #  include <os2.h>
  95. # else
  96. #  include <os2.h>
  97. #  define INCL_RXSHV      /* Shared variable support */
  98. #  define INCL_RXFUNC     /* External functions support */
  99. #  define INCL_RXSYSEXIT  /* System exit routines */
  100. # endif
  101. #else
  102. # define INCL_RXSHV      /* Shared variable support */
  103. # define INCL_RXFUNC     /* External functions support */
  104. # define INCL_RXSYSEXIT  /* System exit routines */
  105. #endif
  106.  
  107. /*
  108.  * The following header file is supplied by the application package.
  109.  * It specifies any application-specific header files and #defines
  110.  * the following:
  111.  * RXPACKAGE_MAGIC_NUMBER  12345     - any number
  112.  * RXPACKAGE_DEBUG_VAR     "ENV_VAR" - an env variable enclosed in quotes
  113.  */
  114. #include "apphead.h"
  115.  
  116. #include "rxdef.h"
  117.  
  118. #define RETBUFLEN 250
  119.  
  120. #if defined(DYNAMIC)
  121. # define DYNAMIC_LIBRARY 1
  122. #endif
  123.  
  124. #ifndef TRUE
  125. # define TRUE   1
  126. # define FALSE  0
  127. #endif
  128.  
  129. /* 
  130.  * Run time modes 
  131.  */
  132. #define MODE_DEBUG      1
  133. #define MODE_VERBOSE    2
  134. #define MODE_INTERNAL   4
  135.  
  136. #define REXX_FAIL      1
  137.  
  138. #define RXSTRCAT(dst,dstlen,src,srclen) (memcpy((dst)+(dstlen),(src),(srclen)),(dstlen)+=(srclen),*((dst)+(dstlen))='\0')
  139. #define RXSTRCPY(dst,dstlen,src,srclen) (memcpy((dst),(src),(srclen)),(dstlen)=(srclen),*((dst)+(dstlen))='\0')
  140.  
  141. #if !defined(max)
  142. # define max(a,b)        (((a) > (b)) ? (a) : (b))
  143. #endif
  144.  
  145. #if !defined(min)
  146. # define min(a,b)        (((a) < (b)) ? (a) : (b))
  147. #endif
  148.  
  149. #if !defined(MAX_PATH)
  150. # if defined(NAME_MAX)
  151. #  define MAX_PATH NAME_MAX
  152. # elif defined(MAXNAMLEN)
  153. #  define MAX_PATH MAXNAMLEN
  154. # else
  155. #  define MAX_PATH 255
  156. # endif
  157. #endif
  158.  
  159. #ifdef USE_REXX6000
  160. typedef USHORT RexxFunctionHandler(PSZ, ULONG, PRXSTRING, PSZ, PRXSTRING) ;
  161. #endif
  162.  
  163. /*-----------------------------------------------------------------------------
  164.  * Definition of an external function
  165.  *----------------------------------------------------------------------------*/
  166. typedef struct {
  167.    RRFD_ARG0_TYPE      ExternalName;
  168.    RRFE_ARG1_TYPE      EntryPoint; 
  169.    RRFD_ARG2_TYPE      InternalName;
  170.    int                 DllLoad;
  171. } RexxFunction;
  172.  
  173. extern char *RxPackageName;
  174.  
  175. /*
  176.  * The following structure contains all "global" data common to all
  177.  * external function packages.  A similar structure should exists
  178.  * for package-specific data.
  179.  */
  180. typedef struct 
  181. {
  182.    int RxRunFlags;                    /* debug/verbose flags */
  183.    char FName[100];                   /* current function name */
  184.    FILE *RxTraceFilePointer;          /* file pointer for all output */
  185.    char RxTraceFileName[MAX_PATH];    /* filename of output file */
  186.    ULONG RxPackageInitialised;        /* needed ?? */
  187. } RxPackageGlobalDataDef;
  188.  
  189. #ifdef HAVE_PROTO
  190. void FunctionPrologue( char *, ULONG, RXSTRING * );
  191. long FunctionEpilogue( char *, long );
  192. void InternalTrace( char *, ... );
  193. void RxDisplayError( RFH_ARG0_TYPE, ... );
  194. int InitRxPackage( RxPackageGlobalDataDef * );
  195. int TermRxPackage( char *, int );
  196. int InitialisePackage( void );
  197. int TerminatePackage( void );
  198. int RegisterRxFunctions( void );
  199. int QueryRxFunction( char * );
  200. int DeregisterRxFunctions( int );
  201. char *make_upper( char * );
  202. char *AllocString( char *, int );
  203. char *MkAsciz( char *, int, char *, int );
  204. int SetRexxVariable( char *, int, char *, int );
  205. RXSTRING *GetRexxVariable(char *, RXSTRING *, int );
  206. int StrToInt( RXSTRING *, ULONG * );
  207. int StrToBool( RXSTRING *, ULONG * );
  208. int RxSetTraceFile( char * );
  209. char *RxGetTraceFile( void );
  210. void RxSetRunFlags( int );
  211. int RxGetRunFlags( void );
  212. int RxReturn( RXSTRING * );
  213. int RxReturnString( RXSTRING *, char * );
  214. int RxReturnStringAndFree( RXSTRING *, char *, int );
  215. int RxReturnNumber( RXSTRING *, long );
  216. int memcmpi( char *, char *, int );
  217. int my_checkparam(const char *, int, int, int);
  218. #else
  219. void FunctionPrologue( );
  220. long FunctionEpilogue( );
  221. void InternalTrace( );
  222. void RxDisplayError( );
  223. int InitRxPackage( );
  224. int TermRxPackage( );
  225. int InitialisePackage( );
  226. int TerminatePackage( );
  227. int RegisterRxFunctions( );
  228. int QueryRxFunction( );
  229. int DeregisterRxFunctions( );
  230. char *make_upper ( );
  231. char *AllocString( );
  232. char *MkAsciz( );
  233. int SetRexxVariable( );
  234. RXSTRING *GetRexxVariable( );
  235. int StrToInt( );
  236. int StrToBool( );
  237. int RxSetTraceFile( );
  238. char *RxGetTraceFile( );
  239. void RxSetRunFlags( );
  240. int RxGetRunFlags( );
  241. int RxReturn( );
  242. int RxReturnString( );
  243. int RxReturnStringAndFree( );
  244. int RxReturnNumber( );
  245. int memcmpi( );
  246. int my_checkparam( );
  247. #endif
  248.  
  249. #ifdef DEBUG
  250. # define DEBUGDUMP(x) {x;}
  251. #else
  252. # define DEBUGDUMP(x) {}
  253. #endif
  254.