home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / cdrom / cd32goodies / launcher.c < prev    next >
C/C++ Source or Header  |  1977-12-31  |  2KB  |  80 lines

  1. /*
  2. **  launcher.c
  3. **
  4. **  this is a simple notification program
  5. **
  6. **  launch it on the CD³² and have twin running!
  7. **
  8. **  for example:
  9. **
  10. **  run <>NIL: launcher RAM:remote
  11. **  twin SER 300000
  12. **
  13. **  after that copy from the other computer somthing
  14. **  executable to ~RAM:remote - it will be started ;-)
  15. **
  16. **  written by Daniel Balster
  17. */
  18.  
  19. #include <exec/exec.h>
  20. #include <dos/dos.h>
  21. #include <dos/notify.h>
  22. #include <proto/exec.h>
  23. #include <proto/dos.h>
  24.  
  25. char *version = "$VER: launcher v1.0.0";
  26.  
  27. #define TEMPLATE "NAME/A"
  28.  
  29. struct {
  30.     STRPTR name;
  31.     ULONG pad[15];
  32. } args;
  33.  
  34. int main(void)
  35. {
  36.     struct RDArgs *rdargs;
  37.     struct NotifyRequest *nr;
  38.     ULONG signals, signal;
  39.     BOOL quit = FALSE;
  40.     
  41.     if (rdargs = ReadArgs(TEMPLATE,(LONG*)&args,NULL))
  42.     {
  43.         if (nr = (struct NotifyRequest*) AllocVec (sizeof(struct NotifyRequest),MEMF_PUBLIC|MEMF_CLEAR))
  44.         {
  45.             if (signal = AllocSignal(-1))
  46.             {
  47.                 nr->nr_Name                 = args.name;
  48.                 nr->nr_Flags                = NRF_SEND_SIGNAL;
  49.                 nr->nr_stuff.nr_Signal.nr_Task        = FindTask( NULL );
  50.                 nr->nr_stuff.nr_Signal.nr_SignalNum    = signal;
  51.  
  52.                 StartNotify (nr);
  53.  
  54.                 while (!quit)
  55.                 {
  56.                     signals = Wait ((1L<<signal)|SIGBREAKF_CTRL_C);
  57.  
  58.                     if( signals & SIGBREAKF_CTRL_C ) quit = TRUE;
  59.  
  60.                     if( signals & (1L<<signal) )
  61.                     {
  62.                         Execute (args.name,0,0);
  63.                         DeleteFile (args.name);
  64.                     }
  65.                 }
  66.  
  67.                 EndNotify( nr );
  68.                 FreeSignal( signal );
  69.             }
  70.             FreeVec (nr);
  71.         }
  72.         else PrintFault( ERROR_NO_FREE_STORE, 0 );
  73.         
  74.     FreeArgs( rdargs );
  75.     }
  76.     else PrintFault( IoErr(), NULL );
  77.  
  78.     return RETURN_OK;
  79. }
  80.