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

  1. /*
  2.  * func2.c -- Another example of a simple REXX function.
  3.  */
  4.  
  5. #include "standard.h"
  6. #include "rxsutils.h"
  7.  
  8. /*
  9.  * Declare our exported function.  Export it!
  10.  */
  11.  
  12. RexxFunctionHandler EZFunc2;
  13.  
  14. /*
  15.  * EZFunc2 -- Returns the name of the function that you called.  This
  16.  *            function will be registered as both 'EZFunc2' and 'EZFunc3'.
  17.  */
  18.  
  19. ULONG EZFunc2( CHAR *name, ULONG numargs, RXSTRING args[],
  20.                CHAR *queuename, RXSTRING *retstr )
  21.   {
  22.     PSZ tmp;
  23.  
  24.     place_holder( queuename );
  25.  
  26.     /* Make sure we have only one argument, and that it's not a
  27.        null string... */
  28.  
  29.     if( numargs != 1 ) goto error;
  30.     if( args[0].strptr == NULL || args[0].strlength == 0 ) goto error;
  31.  
  32.     /* Get some buffer space.... */
  33.  
  34.     tmp = malloc( strlen( name ) + args[0].strlength + 100 );
  35.     if( !tmp ) goto error;
  36.  
  37.     /* Return the name of the func and the argument */
  38.  
  39.     sprintf( tmp, "EZFunc2 (called as '%s') called with argument '%s'",
  40.              name, args[0].strptr );
  41.  
  42.     CopyResult( tmp, strlen( tmp ), retstr );
  43.  
  44.     free( tmp );
  45.  
  46.     return( VALID_ROUTINE );
  47.  
  48.   error:
  49.     return( INVALID_ROUTINE );
  50. }
  51.  
  52.