home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / AACD / Programming / AmiSlate-Source / AmiSource-c / drawrexx_aux.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-05  |  3.1 KB  |  132 lines

  1. /* Code I added to drawrexx.c. */
  2. #ifndef DRAWREXX_AUX_C
  3. #define DRAWREXX_AUX_C
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <exec/types.h>
  8. #include <exec/memory.h>
  9. #include <dos/dos.h>
  10. #include <rexx/storage.h>
  11. #include <rexx/rxslib.h>
  12.  
  13. #include <clib/alib_protos.h>
  14. #include <clib/exec_protos.h>
  15. #include <clib/dos_protos.h>
  16. #include <clib/rexxsyslib_protos.h>
  17.  
  18. #include "drawrexx.h"
  19. #include "drawrexx_aux.h"
  20.  
  21. struct RexxState RexxState;
  22.  
  23. /* This code was under drc_cleanup.  Moved to its own function so that
  24.    I can call it when *I* want! */
  25. void ReplyAndFreeRexxMsg(BOOL BProcessResults)
  26. {
  27.     /* Generate all return values */
  28.     if (BProcessResults == TRUE) ProcessResults();
  29.     
  30.     /* Release reply; this causes client script to resume execution */
  31.     ReplyRexxCommand(RexxState.rexxmsg, RexxState.rc,  RexxState.rc2,  RexxState.result );
  32.     
  33.     /* benutzten Speicher freigeben */
  34.     if(  RexxState.result ) FreeVec(  RexxState.result );
  35.     FreeArgs(  RexxState.host->rdargs );
  36.     if( RexxState.cargstr ) FreeVec( RexxState.cargstr );
  37.     if( RexxState.array ) 
  38.         (RexxState.rxc->function) (RexxState.host, 
  39.             (void **) &RexxState.array, 
  40.             RXIF_FREE,  RexxState.rexxmsg );
  41.     if( RexxState.argb ) FreeVec( RexxState.argb );
  42.     
  43.     return;
  44. }
  45.  
  46.  
  47.  
  48. void ProcessResults(void)
  49. {    
  50.     /* Resultat(e) auswerten */
  51.     if( RexxState.rxc->results && RexxState.rc==0 &&
  52.         (RexxState.rexxmsg->rm_Action & RXFF_RESULT) )
  53.     {
  54.         struct rxs_stemnode *stem, *s;
  55.         
  56.         stem = CreateSTEM( RexxState.rxc, RexxState.resarray, (char *)RexxState.argarray[1] );
  57.         RexxState.result = CreateVAR( stem );
  58.         
  59.         if( RexxState.result )
  60.         {
  61.             if( RexxState.argarray[0] )
  62.             {
  63.                 /* VAR */
  64.                 if( (long) RexxState.result == -1 )
  65.                 {
  66.                     RexxState.rc = 20;
  67.                     RexxState.rc2 = ERROR_NO_FREE_STORE;
  68.                 }
  69.                 else
  70.                 {
  71.                     char *rb;
  72.                     
  73.                     for( rb = (char *) RexxState.argarray[0]; *rb; ++rb )
  74.                         *rb = toupper( *rb );
  75.                     
  76.                     if( SetRexxVar( (struct Message *) RexxState.rexxmsg,
  77.                         *((char *)RexxState.argarray[0]) ? (char *)RexxState.argarray[0] : "RESULT",
  78.                         RexxState.result, strlen(RexxState.result) ) )
  79.                     {
  80.                         RexxState.rc = -10;
  81.                         RexxState.rc2 = (long) "Unable to set Rexx variable";
  82.                     }
  83.                     
  84.                     FreeVec( RexxState.result );
  85.                 }
  86.                 
  87.                 RexxState.result = NULL;
  88.             }
  89.             
  90.             if( !RexxState.rc && RexxState.argarray[1] )
  91.             {
  92.                 /* STEM */
  93.                 if( (long) stem == -1 )
  94.                 {
  95.                     RexxState.rc = 20;
  96.                     RexxState.rc2 = ERROR_NO_FREE_STORE;
  97.                 }
  98.                 else
  99.                 {
  100.                     for( s = stem; s; s = s->succ )
  101.                         RexxState.rc |= SetRexxVar( (struct Message *) RexxState.rexxmsg, s->name, s->value, strlen(s->value) );
  102.                     
  103.                     if( RexxState.rc )
  104.                     {
  105.                         RexxState.rc = -10;
  106.                         RexxState.rc2 = (long) "Unable to set Rexx variable";
  107.                     }
  108.                     
  109.                     if( RexxState.result && (long) RexxState.result != -1 )
  110.                         FreeVec( RexxState.result );
  111.                 }
  112.                 
  113.                 RexxState.result = NULL;
  114.             }
  115.             
  116.             /* Normales Resultat: Möglich? */
  117.             
  118.             if( (long) RexxState.result == -1 )
  119.             {
  120.                 /* Nein */
  121.                 RexxState.rc = 20;
  122.                 RexxState.rc2 = ERROR_NO_FREE_STORE;
  123.                 RexxState.result = NULL;
  124.             }
  125.         }        
  126.         free_stemlist( stem );
  127.     }
  128.     return;
  129. }
  130.  
  131. #endif
  132.