home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / rexx / rexxfunc / ezrxfunc / c / funcload.c < prev    next >
C/C++ Source or Header  |  1993-07-28  |  2KB  |  104 lines

  1. /*
  2.  * funcload.c -- Defines the two functions 'EZLoadFuncs' and 'EZDropFuncs',
  3.  *               which load/drop all the functions defined in this DLL.
  4.  */
  5.  
  6. #include "standard.h"
  7. #include "rxsutils.h"
  8.  
  9. /* Change this if you're changing the DLL name... */
  10.  
  11. #ifndef DLLNAME
  12. #define DLLNAME "EZRXFUNC"
  13. #endif
  14.  
  15. /*
  16.  * Declare our functions.  Make sure to export these in the * .DEF file!
  17.  */
  18.  
  19. RexxFunctionHandler EZLoadFuncs;
  20. RexxFunctionHandler EZDropFuncs;
  21.  
  22. /*
  23.  * Define the table that lists REXX function names and the corresponding
  24.  * DLL entry point.  You must change this table whenever you add/remove
  25.  * a function or entry point.
  26.  */
  27.  
  28. typedef struct fncEntry {
  29.     PSZ     rxName;
  30.     PSZ     cName;
  31. } fncEntry, *fncEntryPtr;
  32.  
  33. static fncEntry RxFncTable[] =
  34.    {
  35.         /* function */  /* entry point */
  36.       { "EZLoadFuncs",  "EZLoadFuncs"   },
  37.       { "EZDropFuncs",  "EZDropFuncs"   },
  38.       { "EZFunc1",      "EZFunc1"       },
  39.       { "EZFunc2",      "EZFunc2"       },
  40.       { "EZFunc3",      "EZFunc2"       }  /* yes, EZFunc2 is intentional! */
  41.    };
  42.  
  43. /*
  44.  * EZLoadFuncs -- Register all the functions with REXX.
  45.  */
  46.  
  47. ULONG EZLoadFuncs( CHAR *name, ULONG numargs, RXSTRING args[],
  48.                    CHAR *queuename, RXSTRING *retstr )
  49.   {
  50.     int entries;
  51.     int j;
  52.  
  53.     place_holder( args );
  54.     place_holder( queuename );
  55.     place_holder( name );
  56.     
  57.     retstr->strlength = 0;
  58.  
  59.     if( numargs > 0 ) goto error;
  60.  
  61.     entries = sizeof( RxFncTable ) / sizeof( fncEntry );
  62.  
  63.     for( j = 0; j < entries; ++j ){
  64.         RexxRegisterFunctionDll( RxFncTable[ j ].rxName, DLLNAME,
  65.           RxFncTable[ j ].cName );
  66.     }
  67.  
  68.     return( VALID_ROUTINE );
  69.  
  70.   error:
  71.     return( INVALID_ROUTINE );
  72. }
  73.  
  74. /*
  75.  * EZDropFuncs -- Deregister all the functions with REXX.
  76.  */
  77.  
  78. ULONG EZDropFuncs( CHAR *name, ULONG numargs, RXSTRING args[],
  79.                    CHAR *queuename, RXSTRING *retstr )
  80.   {
  81.     int entries;
  82.     int j;
  83.  
  84.     place_holder( args );
  85.     place_holder( queuename );
  86.     place_holder( name );
  87.  
  88.     retstr->strlength = 0;
  89.  
  90.     if( numargs > 0 ) goto error;
  91.  
  92.     entries = sizeof( RxFncTable ) / sizeof( fncEntry );
  93.  
  94.     for( j = 0; j < entries; ++j ){
  95.         RexxDeregisterFunction( RxFncTable[ j ].rxName );
  96.     }
  97.  
  98.     return( VALID_ROUTINE );
  99.  
  100.   error:
  101.     return( INVALID_ROUTINE );
  102. }
  103.  
  104.