home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / c / execute.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  1.3 KB  |  72 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: execute.c,v 1.4 1996/09/17 16:43:00 digulla Exp $
  4.     $Log: execute.c,v $
  5.     Revision 1.4  1996/09/17 16:43:00  digulla
  6.     Use general startup code
  7.  
  8.     Revision 1.3  1996/09/13 17:52:10  digulla
  9.     Use IPTR
  10.  
  11.     Revision 1.2  1996/08/01 17:40:44  digulla
  12.     Added standard header for all files
  13.  
  14.     Desc:
  15.     Lang:
  16. */
  17. #include <exec/memory.h>
  18. #include <clib/exec_protos.h>
  19. #include <dos/dosextens.h>
  20. #include <dos/dostags.h>
  21. #include <clib/dos_protos.h>
  22. #include <utility/tagitem.h>
  23.  
  24. int main (int argc, char ** argv)
  25. {
  26.     STRPTR args[1]={ 0 };
  27.     struct RDArgs *rda;
  28.     BPTR shell;
  29.     STRPTR s1, s2, s3, buf;
  30.     LONG error=0;
  31.  
  32.     rda=ReadArgs("FILE/A",(IPTR *)args,NULL);
  33.     if(rda!=NULL)
  34.     {
  35.     s1=s2=(STRPTR)args[0];
  36.     while(*s2++)
  37.         ;
  38.     buf=(STRPTR)AllocVec(9+2*(s2-s1),MEMF_ANY);
  39.     if(buf!=NULL)
  40.     {
  41.         CopyMem("COMMAND ",buf,8);
  42.         s3=buf+8;
  43.         s2=s1;
  44.         *s3++='\"';
  45.         while(*s1)
  46.         {
  47.         if(*s1=='*'||*s1=='\"'||*s1=='\n')
  48.             *s3++='*';
  49.         if(*s1=='\n')
  50.             *s3++='n';
  51.         else
  52.             *s3++=*s1;
  53.         s1++;
  54.         }
  55.         *s3++='\"';
  56.         *s3=0;
  57.         shell=LoadSeg("c:shell");
  58.         if(shell)
  59.         {
  60.         RunCommand(shell,4096,buf,s3-buf);
  61.         UnLoadSeg(shell);
  62.         }
  63.         FreeVec(buf);
  64.     }
  65.     FreeArgs(rda);
  66.     }else
  67.     error=RETURN_FAIL;
  68.     if(error)
  69.     PrintFault(IoErr(),"Run");
  70.     return error;
  71. }
  72.