home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 2: PC / frozenfish_august_1995.bin / bbs / d07xx / d0745.lha / ARexxBox / rxif / rx_cmdshell.c < prev    next >
C/C++ Source or Header  |  1992-10-12  |  2KB  |  86 lines

  1.  
  2. /*
  3.  * Dieses Kommando kann nur von ARexx aus eine CmdShell
  4.  * _╓FFNEN_, und nur von einer CmdShell aus diese _SCHLIE▀EN_.
  5.  *
  6.  * Mit etwas mehr Aufwand (Buchfⁿhrung ⁿber die Hosts) kann man
  7.  * auch eine andere (flexiblere) L÷sung finden.
  8.  *
  9.  * ACHTUNG: Buchfⁿhrung ⁿber offene CmdShells ist zwingend
  10.  * notwendig fⁿr den CloseDown! Sonst bleiben nach 'Quit' u.U.
  11.  * noch CmdShells offen!
  12.  *
  13.  */
  14.  
  15. #include <dos/dostags.h>
  16.  
  17.  
  18. extern struct Library *SysBase, *DOSBase;
  19.  
  20.  
  21. static void runCommandShell( void )
  22. {
  23.     BPTR fh;
  24.     struct RexxHost *rh;
  25.     
  26.     /* diese Funktion wird als eigener Proze▀ gestartet */
  27.     
  28.     geta4();
  29.     
  30.     if( rh = SetupARexxHost(NULL) )
  31.     {
  32.         if( fh = Open( "CON:////CommandShell/AUTO", MODE_NEWFILE ) )
  33.         {
  34.             CommandShell( rh, fh, fh, "> " );
  35.             Close( fh );
  36.         }
  37.         
  38.         CloseDownARexxHost( rh );
  39.     }
  40. }
  41.  
  42.  
  43. void rx_cmdshell( struct RexxHost *host, struct rxd_cmdshell **rxd, long action )
  44. {
  45.     struct rxd_cmdshell *rd = *rxd;
  46.  
  47.     switch( action )
  48.     {
  49.         case RXIF_INIT:
  50.             *rxd = calloc( sizeof *rd, 1 );
  51.             break;
  52.             
  53.         case RXIF_ACTION:
  54.             /* Insert your code HERE */
  55.             
  56.             if( rd->arg.close ) /* schlie▀en */
  57.             {
  58.                 if( host->flags & ARB_HF_CMDSHELL )
  59.                 {
  60.                     host->flags &= ~ARB_HF_CMDSHELL;
  61.                 }
  62.                 else
  63.                 {
  64.                     rd->rc = -10;
  65.                     rd->rc2 = (long) "Not a CommandShell";
  66.                 }
  67.             }
  68.             else /* ÷ffnen (OPEN ist unn÷tig) */
  69.             {
  70.                 CreateNewProcTags(
  71.                     NP_Entry, runCommandShell,
  72.                     NP_Name, "CommandShell",
  73.                     TAG_DONE );
  74.             }
  75.             
  76.             break;
  77.         
  78.         case RXIF_FREE:
  79.             /* FREE your local data HERE */
  80.             free( rd );
  81.             break;
  82.     }
  83.     return;
  84. }
  85.  
  86.