home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool_main.zip / ool / include / XREXX.H < prev    next >
C/C++ Source or Header  |  1998-05-02  |  4KB  |  113 lines

  1. #ifndef __OOL_XCOMHDL_H__
  2. #define __OOL_XCOMHDL_H__
  3.  
  4. /*===========================================================================*/
  5. /* OOL ------------------- the Open Object Library ------------------- r 1.0 */
  6. /*===========================================================================*/
  7. /*                              class: XRexxInterface                        */
  8. /*                       derived from: XObject                               */
  9. /*                        last update: 1/97                                  */
  10. /*                      programmed by: Stefan von Brauk (sbrauk@gwdg.de)     */
  11. /*===========================================================================*/
  12.  
  13.  
  14. #include "xobject.h"
  15. #include "XString.h"
  16.  
  17. #define REXXINTERFACE ULONG APIENTRY
  18.  
  19. inline void RXStringToXString( RXSTRING& rx, XString& st)
  20. {
  21.    memcpy( st.GetBuffer(rx.strlength+1), rx.strptr, rx.strlength);
  22.    st.ReleaseBuffer( rx.strlength);
  23. }
  24.  
  25.  
  26. inline void PRXStringToXString( RXSTRING * rx, XString& st)
  27. {
  28.    memcpy( st.GetBuffer(rx->strlength+1), rx->strptr, rx->strlength);
  29.    st.ReleaseBuffer( rx->strlength);
  30. }
  31.  
  32.  
  33. inline void XStringToRXString( XString& st, RXSTRING& rx)
  34. {
  35.    if( st.GetLength() < 256 )
  36.       memcpy( rx.strptr, (char*) st, st.GetLength() + 1);
  37.    else
  38.    {
  39.       void * p;
  40.       DosAllocMem( &p, st.GetLength() + 1, PAG_COMMIT|PAG_READ|PAG_WRITE);
  41.       memcpy( p, (char*) st, st.GetLength() + 1);
  42.       #if !defined(__IBMCPP__) && !defined(__WATCOMC__)
  43.          rx.strptr = (unsigned char*) p;
  44.       #else
  45.          rx.strptr = (char*) p;
  46.       #endif
  47.    }
  48.    rx.strlength = st.GetLength();
  49. }
  50.  
  51.  
  52. inline void XStringToPRXString( XString st, RXSTRING * rx)
  53. {
  54.    if( st.GetLength() < 256)
  55.       memcpy( rx->strptr, (char*) st, st.GetLength() + 1);
  56. //      strcpy(rx->strptr, st);
  57.    else
  58.    {
  59.       void * p;
  60.       DosAllocMem( &p, st.GetLength() + 1, PAG_COMMIT|PAG_READ|PAG_WRITE);
  61.       memcpy( p, (char*) st, st.GetLength() + 1);
  62.       #if !defined(__IBMCPP__) && !defined(__WATCOMC__)
  63.          rx->strptr = (unsigned char*) p;
  64.       #else
  65.          rx->strptr = (char*) p;
  66.       #endif
  67.    }
  68.    rx->strlength = st.GetLength();
  69. /*
  70.    memcpy( rx->strptr, (char*) st, st.GetLength() + 1);
  71.    rx->strlength = st.GetLength();
  72. */
  73. }
  74.  
  75.  
  76. class _export_ XRexxScript : public XObject
  77. {
  78.         friend class XRexxInterface;
  79.  
  80.         private:
  81.                 RXSTRING arxsScript[2];
  82.  
  83.         public:
  84.                  XRexxScript() {}
  85.                  XRexxScript( const char* filename );
  86.                 ~XRexxScript();
  87.  
  88.                 BOOL Load( const char* filename );
  89.  
  90.                 XRexxScript operator = ( XString &aString );
  91. };
  92.  
  93.  
  94. class _export_ XRexxInterface: public XObject
  95. {
  96.       XString name, dll;
  97.    public:
  98.       XRexxInterface( char * handlerName, PFN routineName );
  99.       XRexxInterface( char * handlerName, char * dllName, char * routineName);
  100.       ~XRexxInterface();
  101.       static LONG DeregisterFunction( char * name);
  102.       LONG Execute( char * commandFile, XRexxScript*, LONG type, XString * resultBuffer, SHORT * returnCode, XString * argList);
  103.       static XRexxInterface * GetHandler( char * handlerName, char * dllName = NULL);
  104.       void GetName( XString * buffer) { *buffer = name; }
  105.       LONG GetVar( char* name, XString * value);
  106.       static BOOL IsFunctionRegistered(char*name);
  107.       static LONG RegisterFunction( char * name, PFN entry);
  108.       static LONG RegisterFunction( char * name, char * dllName, char * routine);
  109.       LONG SetVar( char * name, char* value);
  110. };
  111.  
  112. #endif
  113.