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

  1. /*
  2.  * Source generated with ARexxBox 1.12 (May 18 1993)
  3.  * which is Copyright (c) 1992,1993 Michael Balzer
  4.  */
  5.  
  6. #include <exec/types.h>
  7. #include <exec/memory.h>
  8. #include <dos/dos.h>
  9. #include <rexx/storage.h>
  10. #include <rexx/rxslib.h>
  11.  
  12. #ifdef __GNUC__
  13. /* GCC needs all struct defs */
  14. #include <dos/exall.h>
  15. #include <graphics/graphint.h>
  16. #include <intuition/classes.h>
  17. #include <devices/keymap.h>
  18. #include <exec/semaphores.h>
  19. #endif
  20.  
  21. #include <clib/alib_protos.h>
  22. #include <clib/exec_protos.h>
  23. #include <clib/dos_protos.h>
  24. #include <clib/rexxsyslib_protos.h>
  25.  
  26. #ifndef __NO_PRAGMAS
  27.  
  28. #ifdef AZTEC_C
  29. #include <pragmas/exec_lib.h>
  30. #include <pragmas/dos_lib.h>
  31. #include <pragmas/rexxsyslib_lib.h>
  32. #endif
  33.  
  34. #ifdef LATTICE
  35. #include <pragmas/exec_pragmas.h>
  36. #include <pragmas/dos_pragmas.h>
  37. #include <pragmas/rexxsyslib_pragmas.h>
  38. #endif
  39.  
  40. #endif /* __NO_PRAGMAS */
  41.  
  42. #include <stdlib.h>
  43. #include <stdio.h>
  44. #include <string.h>
  45. #include <ctype.h>
  46.  
  47. #ifdef LATTICE
  48. #undef toupper
  49. #define inline __inline
  50. #endif
  51.  
  52. #ifdef __GNUC__
  53. #undef toupper
  54. static inline char toupper( char c )
  55. {
  56.     return( islower(c) ? c - 'a' + 'A' : c );
  57. }
  58. #endif
  59.  
  60. #ifdef AZTEC_C
  61. #define inline
  62. #endif
  63.  
  64. #include <dos/rdargs.h>
  65.  
  66. #include "drawrexx.h"
  67. #include "drawrexx_aux.h"
  68.  
  69.  
  70.  
  71. extern struct ExecBase *SysBase;
  72. extern struct DosLibrary *DOSBase;
  73. extern struct RxsLib *RexxSysBase;
  74. extern struct timerequest *TimerIO;
  75.  
  76. void (*ARexxResultHook)( struct RexxHost *, struct RexxMsg * ) = NULL;
  77.  
  78.  
  79.  
  80. void ReplyRexxCommand(
  81.     struct RexxMsg    *rexxmessage,
  82.     long            primary,
  83.     long            secondary,
  84.     char            *result )
  85. {
  86.  
  87.     /* If the timeout counter is still going, abort it */
  88.     if (!(CheckIO((struct IORequest *)TimerIO))) 
  89.     {
  90.         AbortIO((struct IORequest *)TimerIO);
  91.         WaitIO((struct IORequest *)TimerIO);
  92.     }
  93.         
  94.     if( rexxmessage->rm_Action & RXFF_RESULT )
  95.     {
  96.         if( primary == 0 )
  97.         {
  98.             secondary = result
  99.                 ? (long) CreateArgstring( result, strlen(result) )
  100.                 : (long) NULL;
  101.         }
  102.         else
  103.         {
  104.             char buf[16];
  105.             
  106.             if( primary > 0 )
  107.             {
  108.                 sprintf( buf, "%ld", secondary );
  109.                 result = buf;
  110.             }
  111.             else
  112.             {
  113.                 primary = -primary;
  114.                 result = (char *) secondary;
  115.             }
  116.             
  117.             SetRexxVar( (struct Message *) rexxmessage,
  118.                 "RC2", result, strlen(result) );
  119.             
  120.             secondary = 0;
  121.         }
  122.     }
  123.     else if( primary < 0 )
  124.         primary = -primary;
  125.     
  126.     rexxmessage->rm_Result1 = primary;
  127.     rexxmessage->rm_Result2 = secondary;
  128.     ReplyMsg( (struct Message *) rexxmessage );
  129. }
  130.  
  131.  
  132. void FreeRexxCommand( struct RexxMsg *rexxmessage )
  133. {
  134.     if( !rexxmessage->rm_Result1 && rexxmessage->rm_Result2 )
  135.         DeleteArgstring( (char *) rexxmessage->rm_Result2 );
  136.  
  137.     if( rexxmessage->rm_Stdin &&
  138.         rexxmessage->rm_Stdin != Input() )
  139.         Close( rexxmessage->rm_Stdin );
  140.  
  141.     if( rexxmessage->rm_Stdout &&
  142.         rexxmessage->rm_Stdout != rexxmessage->rm_Stdin &&
  143.         rexxmessage->rm_Stdout != Output() )
  144.         Close( rexxmessage->rm_Stdout );
  145.  
  146.     DeleteArgstring( (char *) ARG0(rexxmessage) );
  147.     DeleteRexxMsg( rexxmessage );
  148. }
  149.  
  150.  
  151. struct RexxMsg *CreateRexxCommand( struct RexxHost *host, char *buff, BPTR fh )
  152. {
  153.     struct RexxMsg *rexx_command_message;
  154.  
  155.     if( (rexx_command_message = CreateRexxMsg( host->port,
  156.         rexx_extension, host->port->mp_Node.ln_Name)) == NULL )
  157.     {
  158.         return( NULL );
  159.     }
  160.  
  161.     if( (rexx_command_message->rm_Args[0] =
  162.         CreateArgstring(buff,strlen(buff))) == NULL )
  163.     {
  164.         DeleteRexxMsg(rexx_command_message);
  165.         return( NULL );
  166.     }
  167.  
  168.     rexx_command_message->rm_Action = RXCOMM | RXFF_RESULT;
  169.     rexx_command_message->rm_Stdin  = fh;
  170.     rexx_command_message->rm_Stdout = fh;
  171.     
  172.     return( rexx_command_message );
  173. }
  174.  
  175.  
  176. struct RexxMsg *CommandToRexx( struct RexxHost *host, struct RexxMsg *rexx_command_message )
  177. {
  178.     struct MsgPort *rexxport;
  179.     
  180.     Forbid();
  181.  
  182.     if( (rexxport = FindPort(RXSDIR)) == NULL )
  183.     {
  184.         Permit();
  185.         return( NULL );
  186.     }
  187.  
  188.     PutMsg( rexxport, &rexx_command_message->rm_Node );
  189.     
  190.     Permit();
  191.     
  192.     ++host->replies;
  193.     return( rexx_command_message );
  194. }
  195.  
  196.  
  197. struct RexxMsg *SendRexxCommand( struct RexxHost *host, char *buff, BPTR fh )
  198. {
  199.     struct RexxMsg *rcm;
  200.     
  201.     if( rcm = CreateRexxCommand(host, buff, fh) )
  202.         return CommandToRexx( host, rcm );
  203.     else
  204.         return NULL;
  205. }
  206.  
  207.  
  208. void CloseDownARexxHost( struct RexxHost *host )
  209. {
  210.     struct RexxMsg *rexxmsg;
  211.  
  212.     if( host->port )
  213.     {
  214.         /* Port abmelden */
  215.         RemPort( host->port );
  216.         
  217.         /* Auf noch ausstehende Replies warten */
  218.         while( host->replies > 0 )
  219.         {
  220.             WaitPort( host->port );
  221.             
  222.             while( rexxmsg = (struct RexxMsg *) GetMsg(host->port) )
  223.             {
  224.                 if( rexxmsg->rm_Node.mn_Node.ln_Type == NT_REPLYMSG )
  225.                 {
  226.                     if( !rexxmsg->rm_Args[15] )
  227.                     {
  228.                         /* Reply zu einem SendRexxCommand()-Call */
  229.                         if( ARexxResultHook )
  230.                             ARexxResultHook( host, rexxmsg );
  231.                     }
  232.                     
  233.                     FreeRexxCommand( rexxmsg );
  234.                     --host->replies;
  235.                 }
  236.                 else
  237.                     ReplyRexxCommand( rexxmsg, -20, (long) "Host closing down", NULL );
  238.             }
  239.         }
  240.         
  241.         /* MsgPort leeren */
  242.         Forbid();      /* Forbit/Permit added by Jeremy to hopefully reduce Enforcer hitting! */
  243.         while( rexxmsg = (struct RexxMsg *) GetMsg(host->port) )
  244.             ReplyRexxCommand( rexxmsg, -20, (long) "Host closing down", NULL );
  245.         
  246.         if( !(host->flags & ARB_HF_USRMSGPORT) )
  247.             DeleteMsgPort( host->port );
  248.         Permit();  
  249.     }
  250.     
  251.     if( host->rdargs ) FreeDosObject( DOS_RDARGS, host->rdargs );
  252.     FreeVec( host );
  253. }
  254.  
  255.  
  256. struct RexxHost *SetupARexxHost( char *basename, struct MsgPort *usrport )
  257. {
  258.     struct RexxHost *host;
  259.     int ext = 0;
  260.     
  261.     if( !basename )
  262.         basename = RexxPortBaseName;
  263.     else if( !*basename )
  264.         basename = RexxPortBaseName;
  265.     
  266.     if( !(host = AllocVec(sizeof *host, MEMF_CLEAR)) )
  267.         return NULL;
  268.     
  269.     strcpy( host->portname, basename );
  270.     
  271.     if( usrport )
  272.     {
  273.         host->port   = usrport;
  274.         host->flags |= ARB_HF_USRMSGPORT;
  275.     }
  276.     else if( !(host->port = CreateMsgPort()) )
  277.     {
  278.         FreeVec( host );
  279.         return NULL;
  280.     }
  281.     else
  282.     {
  283.         host->port->mp_Node.ln_Pri = 0;
  284.     }
  285.     
  286.     Forbid();
  287.     
  288.     while( FindPort(host->portname) )
  289.         sprintf( host->portname, "%s.%d", basename, ++ext );
  290.     
  291.     host->port->mp_Node.ln_Name = host->portname;
  292.     AddPort( host->port );
  293.     
  294.     Permit();
  295.     
  296.     if( !(host->rdargs = AllocDosObject(DOS_RDARGS, NULL)) )
  297.     {
  298.         RemPort( host->port );
  299.         if( !usrport ) DeleteMsgPort( host->port );
  300.         FreeVec( host );
  301.         return NULL;
  302.     }
  303.     
  304.     host->rdargs->RDA_Flags = RDAF_NOPROMPT;
  305.     
  306.     return( host );
  307. }
  308.  
  309.  
  310. /* StateMachine für FindRXCommand() */
  311.  
  312. static char *scmp( char *inp, char *str )
  313. {
  314.     while( *str && *inp )
  315.         if( *inp++ != *str++ )
  316.             return NULL;
  317.     
  318.     /* Reststring zurückgeben */
  319.     return inp;
  320. }
  321.  
  322. static int find( char *input )
  323. {
  324.     struct arb_p_state *st = arb_p_state;
  325.     struct arb_p_link *ad;
  326.     char *ni, tmp[36], *s;
  327.     
  328.     ni = tmp;
  329.     while( *input && ni-tmp < 32 )
  330.         *ni++ = toupper( *input++ );
  331.     *ni = 0;
  332.     input = tmp;
  333.     
  334.     while( *input )
  335.     {
  336.         /* Terminalzustand erreicht? */
  337.         if( !st->pa )
  338.         {
  339.             if( *input )
  340.                 return -1;
  341.             else
  342.                 return st->cmd;
  343.         }
  344.         
  345.         /* Wo geht's weiter? */
  346.         ni = 0;
  347.         for( ad = st->pa; s = ad->str; ad++ )
  348.         {
  349.             /* die Links sind absteigend sortiert */
  350.             if( *input > *s )
  351.                 break;
  352.             
  353.             if( *input == *s )
  354.                 if( ni = scmp(input+1, s+1) )
  355.                     break;
  356.         }
  357.         
  358.         /* Nirgends... */
  359.         if( !ni )
  360.             return -1;
  361.         
  362.         /* Zustandsüberführung */
  363.         st = arb_p_state + ad->dst;
  364.         input = ni;
  365.     }
  366.     
  367.     return st->cmd;
  368. }
  369.  
  370. struct rxs_command *FindRXCommand( char *com )
  371. {
  372.     int cmd;
  373.     
  374.     cmd = find( com );
  375.     
  376.     if( cmd == -1 )
  377.         return NULL;
  378.     else
  379.         return( rxs_commandlist + cmd );
  380. }
  381.  
  382.  
  383. static struct rxs_command *ParseRXCommand( char **arg )
  384. {
  385.     char com[256], *s, *t;
  386.     
  387.     s = *arg;
  388.     t = com;
  389.     
  390.     while( *s && *s != ' ' && *s != '\n' )
  391.         *t++ = *s++;
  392.     
  393.     *t = '\0';
  394.     while( *s == ' ' ) ++s;
  395.     *arg = s;
  396.     
  397.     return( FindRXCommand( com ) );
  398. }
  399.  
  400.  
  401. char *CreateVAR( struct rxs_stemnode *stem )
  402. {
  403.     char *var;
  404.     struct rxs_stemnode *s;
  405.     long size = 0;
  406.     
  407.     if( !stem || stem == (struct rxs_stemnode *) -1L )
  408.         return( (char *) stem );
  409.     
  410.     for( s = stem; s; s = s->succ )
  411.         size += strlen( s->value ) + 1;
  412.     
  413.     if( !(var = AllocVec( size + 1, MEMF_ANY )) )
  414.         return( (char *) -1 );
  415.     
  416.     *var = '\0';
  417.     
  418.     for( s = stem; s; s = s->succ )
  419.     {
  420.         strcat( var, s->value );
  421.         if( s->succ )
  422.             strcat( var, " " );
  423.     }
  424.     
  425.     return( var );
  426. }
  427.  
  428.  
  429. static struct rxs_stemnode *new_stemnode( struct rxs_stemnode **first, struct rxs_stemnode **old )
  430. {
  431.     struct rxs_stemnode *new;
  432.     
  433.     if( !(new = AllocVec(sizeof(struct rxs_stemnode), MEMF_CLEAR)) )
  434.     {
  435.         return( NULL );
  436.     }
  437.     else
  438.     {
  439.         if( *old )
  440.         {
  441.             (*old)->succ = new;
  442.             (*old) = new;
  443.         }
  444.         else
  445.         {
  446.             *first = *old = new;
  447.         }
  448.     }
  449.     
  450.     return( new );
  451. }
  452.  
  453.  
  454. void free_stemlist( struct rxs_stemnode *first )
  455. {
  456.     struct rxs_stemnode *next;
  457.     
  458.     if( (long) first == -1 )
  459.         return;
  460.     
  461.     for( ; first; first = next )
  462.     {
  463.         next = first->succ;
  464.         if( first->name  ) FreeVec( first->name );
  465.         if( first->value ) FreeVec( first->value );
  466.         FreeVec( first );
  467.     }
  468. }
  469.  
  470.  
  471. char *StrDup( char *s )
  472. {
  473.     char *t = AllocVec( strlen(s)+1, MEMF_ANY );
  474.     if( t ) strcpy( t, s );
  475.     return t;
  476. }
  477.  
  478.  
  479. struct rxs_stemnode *CreateSTEM( struct rxs_command *rxc, LONG *resarray, char *stembase )
  480. {
  481.     struct rxs_stemnode *first = NULL, *old = NULL, *new;
  482.     char resb[512], *rs, *rb;
  483.     char longbuff[16];
  484.     
  485.     rb = resb;
  486.     if( stembase )
  487.     {
  488.         while( *stembase )
  489.             *rb++ = toupper( *stembase++ );
  490.     }
  491.     *rb = '\0';
  492.     
  493.     rb = resb + strlen(resb);
  494.     rs = rxc->results;
  495.     
  496.     while( *rs )
  497.     {
  498.         char *t = rb;
  499.         BOOL optn = FALSE, optm = FALSE;
  500.         
  501.         while( *rs && *rs != ',' )
  502.         {
  503.             if( *rs == '/' )
  504.             {
  505.                 ++rs;
  506.                 if( *rs == 'N' ) optn = TRUE;
  507.                 else if( *rs == 'M' ) optm = TRUE;
  508.             }
  509.             else
  510.                 *t++ = *rs;
  511.             
  512.             ++rs;
  513.         }
  514.         
  515.         if( *rs == ',' ) ++rs;
  516.         *t = '\0';
  517.         
  518.         /*
  519.          * Resultat(e) erzeugen
  520.          */
  521.         
  522.         if( !*resarray )
  523.         {
  524.             ++resarray;
  525.             continue;
  526.         }
  527.         
  528.         if( optm )
  529.         {
  530.             long *r, index = 0;
  531.             LONG **subarray = (LONG **) *resarray++;
  532.             struct rxs_stemnode *countnd;
  533.             
  534.             /* Anzahl der Elemente */
  535.             
  536.             if( !(new = new_stemnode(&first, &old)) )
  537.             {
  538.                 free_stemlist( first );
  539.                 return( (struct rxs_stemnode *) -1L );
  540.             }
  541.             countnd = new;
  542.             
  543.             /* Die Elemente selbst */
  544.             
  545.             while( r = *subarray++ )
  546.             {
  547.                 if( !(new = new_stemnode(&first, &old)) )
  548.                 {
  549.                     free_stemlist( first );
  550.                     return( (struct rxs_stemnode *) -1L );
  551.                 }
  552.                 
  553.                 sprintf( t, ".%ld", index++ );
  554.                 new->name = StrDup( resb );
  555.                 
  556.                 if( optn )
  557.                 {
  558.                     sprintf( longbuff, "%ld", *r );
  559.                     new->value = StrDup( longbuff );
  560.                 }
  561.                 else
  562.                 {
  563.                     new->value = StrDup( (char *) r );
  564.                 }
  565.             }
  566.             
  567.             /* Die Count-Node */
  568.             
  569.             strcpy( t, ".COUNT" );
  570.             countnd->name = StrDup( resb );
  571.             
  572.             sprintf( longbuff, "%ld", index );
  573.             countnd->value = StrDup( longbuff );
  574.         }
  575.         else
  576.         {
  577.             /* Neue Node anlegen */
  578.             if( !(new = new_stemnode(&first, &old)) )
  579.             {
  580.                 free_stemlist( first );
  581.                 return( (struct rxs_stemnode *) -1L );
  582.             }
  583.             
  584.             new->name = StrDup( resb );
  585.             
  586.             if( optn )
  587.             {
  588.                 sprintf( longbuff, "%ld", *((long *) *resarray) );
  589.                 new->value = StrDup( longbuff );
  590.                 ++resarray;
  591.             }
  592.             else
  593.             {
  594.                 new->value = StrDup( (char *) (*resarray++) );
  595.             }
  596.         }
  597.     }
  598.     
  599.     return( first );
  600. }
  601.  
  602.  
  603. static void DoRXCommand( struct RexxHost *host, struct RexxMsg *rexxmsg )
  604. {
  605.     struct rxs_command *rxc;
  606.     char *argb = NULL, *arg;
  607.     BOOL BProcessResults = FALSE;
  608.     
  609.     LONG *array = NULL;
  610.     LONG *argarray;
  611.     LONG *resarray;
  612.     
  613.     char *cargstr = NULL;
  614.     long rc=20, rc2=0;
  615.     char *result = NULL;
  616.  
  617.     if( !(argb = AllocVec(strlen((char *) ARG0(rexxmsg)) + 2, MEMF_ANY)) )
  618.     {
  619.         rc2 = ERROR_NO_FREE_STORE;
  620.         goto drc_cleanup;
  621.     }
  622.     
  623.     /* welches Kommando? */    
  624.     strcpy( argb, (char *) ARG0(rexxmsg) );
  625.     strcat( argb, "\n" );
  626.     arg = argb;
  627.     
  628.     if( !( rxc = ParseRXCommand( &arg ) ) )
  629.     {
  630.         if( arg = ExpandRXCommand( host, (char *) ARG0(rexxmsg) ) )
  631.         {
  632.             FreeVec( argb );
  633.             if( !(argb = AllocVec( strlen(arg) + 2, MEMF_ANY )) )
  634.             {
  635.                 rc2 = ERROR_NO_FREE_STORE;
  636.                 goto drc_cleanup;
  637.             }
  638.             
  639.             strcpy( argb, arg );
  640.             strcat( argb, "\n" );
  641.             FreeVec( arg );
  642.             arg = argb;
  643.             
  644.             rxc = ParseRXCommand( &arg );
  645.         }
  646.     }
  647.     
  648.     
  649.     if( !rxc )
  650.     {
  651.         /* Msg an ARexx schicken, vielleicht existiert ein Skript */
  652.         struct RexxMsg *rm;
  653.         
  654.         if( rm = CreateRexxCommand(host, (char *) ARG0(rexxmsg), NULL) )
  655.         {
  656.             /* Original-Msg merken */
  657.             rm->rm_Args[15] = (STRPTR) rexxmsg;
  658.             
  659.             if( CommandToRexx(host, rm) )
  660.             {
  661.                 /* Reply wird später vom Dispatcher gemacht */
  662.                 if( argb ) FreeVec( argb );
  663.                 return;
  664.             }
  665.             else
  666.                 rc2 = ERROR_NOT_IMPLEMENTED;
  667.         }
  668.         else
  669.             rc2 = ERROR_NO_FREE_STORE;
  670.         
  671.         goto drc_cleanup;
  672.     }
  673.  
  674.     if( !(rxc->flags & ARB_CF_ENABLED) )
  675.     {
  676.         rc = -10;
  677.         rc2 = (long) "Command disabled";
  678.         goto drc_cleanup;
  679.     }
  680.     
  681.     /* Speicher für Argumente etc. holen */
  682.     
  683.     (rxc->function)( host, (void **) &array, RXIF_INIT, rexxmsg );
  684.     cargstr = AllocVec( rxc->args ? 15+strlen(rxc->args) : 15, MEMF_ANY );
  685.     
  686.     if( !array || !cargstr )
  687.     {
  688.         rc2 = ERROR_NO_FREE_STORE;
  689.         goto drc_cleanup;
  690.     }
  691.     
  692.     argarray = array + 2;
  693.     resarray = array + rxc->resindex;
  694.     
  695.     /* Argumente parsen */
  696.  
  697.  
  698.     if( rxc->results )
  699.         strcpy( cargstr, "VAR/K,STEM/K" );
  700.     else
  701.         *cargstr = '\0';
  702.     
  703.     if( rxc->args )
  704.     {
  705.         if( *cargstr )
  706.             strcat( cargstr, "," );
  707.         strcat( cargstr, rxc->args );
  708.     }
  709.  
  710.     if( *cargstr )
  711.     {
  712.         host->rdargs->RDA_Source.CS_Buffer = arg;
  713.         host->rdargs->RDA_Source.CS_Length = strlen(arg);
  714.         host->rdargs->RDA_Source.CS_CurChr = 0;
  715.         host->rdargs->RDA_DAList = NULL;
  716.         host->rdargs->RDA_Buffer = NULL;
  717.     
  718.         if( !ReadArgs(cargstr, argarray, host->rdargs) )
  719.         {
  720.             rc = 10;
  721.             rc2 = IoErr();
  722.             goto drc_cleanup;
  723.         }    
  724.     }
  725.     
  726.     /* Funktion aufrufen */
  727.  
  728.     (rxc->function)( host, (void **) &array, RXIF_ACTION, rexxmsg );
  729.     rc = array[0];
  730.     rc2 = array[1];
  731.  
  732.     BProcessResults    = TRUE;    /* signal to check args */
  733.         
  734. drc_cleanup:
  735.     /* Save all info into global state struct */
  736.     RexxState.rexxmsg  = rexxmsg;
  737.     RexxState.rc       = rc;
  738.     RexxState.rc2       = rc2;
  739.     RexxState.result   = result;
  740.     RexxState.host     = host;
  741.     RexxState.cargstr  = cargstr;
  742.     RexxState.array    = array;
  743.     RexxState.argb     = argb;
  744.     RexxState.rxc      = rxc;    
  745.     RexxState.resarray = resarray;
  746.     RexxState.argarray = argarray;
  747.  
  748.     /* Nur RESULT, wenn weder VAR noch STEM */
  749.     if (PState.uwRexxWaitMask == 0)    ReplyAndFreeRexxMsg(BProcessResults);
  750.     return;    
  751. }
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758. void ARexxDispatch( struct RexxHost *host )
  759. {
  760.     struct RexxMsg *rexxmsg;
  761.     
  762.     /* MODIFICATION BY JAF */
  763.     int nCount = 0;
  764.     
  765.     while(((nCount++) < 2)&&( rexxmsg = (struct RexxMsg *) GetMsg(host->port) ))
  766.     {    
  767.         if( (rexxmsg->rm_Action & RXCODEMASK) != RXCOMM )
  768.         {
  769.             /* Keine Rexx-Message */
  770.             ReplyMsg( (struct Message *) rexxmsg );
  771.         }
  772.         else if( rexxmsg->rm_Node.mn_Node.ln_Type == NT_REPLYMSG )
  773.         {
  774.             struct RexxMsg *org = (struct RexxMsg *) rexxmsg->rm_Args[15];
  775.             
  776.             if( org )
  777.             {
  778.                 /* Reply zu durchgereichter Msg */
  779.                 if( rexxmsg->rm_Result1 != 0 )
  780.                 {
  781.                     /* Befehl unbekannt */
  782.                     ReplyRexxCommand( org, 20, ERROR_NOT_IMPLEMENTED, NULL );
  783.                 }
  784.                 else
  785.                 {
  786.                     ReplyRexxCommand( org, 0, 0, (char *) rexxmsg->rm_Result2 );
  787.                 }
  788.             }
  789.             else
  790.             {
  791.                 /* Reply zu einem SendRexxCommand()-Call */
  792.                 if( ARexxResultHook )
  793.                     ARexxResultHook( host, rexxmsg );
  794.             }
  795.             
  796.             FreeRexxCommand( rexxmsg );
  797.             --host->replies;
  798.         }
  799.         else if( ARG0(rexxmsg) )
  800.         {
  801.             DoRXCommand( host, rexxmsg );
  802.         }
  803.         else
  804.         {
  805.             ReplyMsg( (struct Message *) rexxmsg );
  806.         }
  807.     }
  808. }
  809.  
  810.  
  811.