home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 206.lha / Flist_v1.2 / Sources / arpdos.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-12-28  |  2.5 KB  |  98 lines

  1. /* 
  2.         This module is the workhorse of Flist.
  3.         It is here that the commands typed in by the user are:
  4.   
  5.         a: Scanned for special commands
  6.         b: replaced for filename expansion
  7.         c: prepped for ASyncRun
  8.         d: Run as a Task.
  9.   
  10. */
  11.  
  12. #include <stdio.h>
  13. #include "flist.h"
  14.  
  15. /* Some external variables here */
  16.  
  17. extern struct Window *winptr;
  18. extern int errno;
  19. extern struct FileLock *lock;
  20. extern long mousey;
  21.  
  22. #define PCB_SETS PRF_SAVEIO|PRF_INTERACTIVE
  23.  
  24. long DoDOS(str)
  25. char *str;
  26. {
  27.     long ret;
  28.  
  29.     if (str[0] != 0) {
  30.             ret = spawnproc(str);
  31.             if (!ret)
  32.                     DisplayBeep(NULL);
  33.     }
  34.     return ret;
  35. }
  36.  
  37. long spawnproc(str)
  38. char *str;
  39. {
  40.         long i, j, ret, ret1, pnt;
  41.         char command[90], args[90], buf[1000], path[1000];
  42.         struct FileHandle *fh;
  43.  
  44.     /*  In case your wondering, I'm trying to put the window under the 
  45.         mouse. Why? Because I want to make it easy to kill it later! */
  46.  
  47.         i = (mousey > 119) ? 120: mousey;
  48.  
  49.         sprintf(buf,"CON:0/%d/640/80/Flist at Work", i);
  50.         fh = Open(buf,MODE_NEWFILE);
  51.         if (fh == NULL) {
  52.                 auto_req(" I can't seem to Open CON:");
  53.                 return FALSE;
  54.         }
  55.  
  56. /*  Here be the LARGEST Kluge I have ever run across in AmigaDOS...
  57.     Execute() must be fed the command 'cd current.directory' as part
  58.     of the string, if you expect to be executing out of the current
  59.     directory that is! */
  60.  
  61.         PathName(lock, path);
  62.         strcpy(buf, "cd \"");
  63.         strcat(buf, path);
  64.         pnt = strlen(buf);
  65.         strcat(buf, "\"\n");
  66.         strcat(buf, str); 
  67.  
  68. #ifdef DEBUG
  69.         sprintf(path,"Sending -%s- to Execute.",buf);
  70.         SetWindowTitles(winptr,-1L,path);
  71. #endif
  72.  
  73.         ret = Execute(buf,NULL,fh);
  74.         
  75.         if (!ret){
  76. #ifdef DEBUG 
  77.                 sprintf(&buf[0],"*** ERROR *** Execute returns - %ld", IoErr());
  78.                 SetWindowTitles(winptr,-1L,buf);
  79. #endif
  80.                 DisplayBeep(NULL);
  81.                 Close(fh);
  82.                 return FALSE;
  83.         } else {
  84.  
  85.         /* Wait for the user to terminate the window */
  86.  
  87.                 buf[0] = 0x9b;  buf[1] = 0x34;
  88.                 buf[2] = 0x30;  buf[3] = 0x3b;
  89.                 buf[4] = 0x33;  buf[5] = 0x33;
  90.                 buf[6] = 0x6d;  buf[7] = 0x0;
  91.                 strcat(buf, " Hit return to continue"); 
  92.                 Write(fh, buf, strlen(buf));
  93.                 ret1 = Read(fh, buf, 1L);
  94.                 Close(fh);
  95.         }
  96.         return TRUE;
  97. }
  98.