home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / dos / runcommand.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  3.1 KB  |  134 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: runcommand.c,v 1.10 1997/01/27 00:36:29 ldp Exp $
  4.     $Log: runcommand.c,v $
  5.     Revision 1.10  1997/01/27 00:36:29  ldp
  6.     Polish
  7.  
  8.     Revision 1.9  1996/12/09 13:53:40  aros
  9.     Added empty templates for all missing functions
  10.  
  11.     Moved #include's into first column
  12.  
  13.     Revision 1.8  1996/10/24 15:50:35  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.7  1996/10/10 13:22:20  digulla
  17.     Wrong cast (Fleischer)
  18.  
  19.     Revision 1.6  1996/09/13 17:50:09  digulla
  20.     Use IPTR
  21.  
  22.     Revision 1.5  1996/09/11 16:54:23  digulla
  23.     Always use AROS_SLIB_ENTRY() to access shared external symbols, because
  24.     some systems name an external symbol "x" as "_x" and others as "x".
  25.     (The problem arises with assembler symbols which might differ)
  26.  
  27.     Revision 1.4  1996/08/13 13:52:51  digulla
  28.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  29.     Replaced AROS_LA by AROS_LHA
  30.  
  31.     Revision 1.3  1996/08/01 17:40:57  digulla
  32.     Added standard header for all files
  33.  
  34.     Desc:
  35.     Lang: english
  36. */
  37. #include <exec/memory.h>
  38. #include <proto/exec.h>
  39. #include <utility/tagitem.h>
  40. #include <dos/filesystem.h>
  41. #include <proto/dos.h>
  42. #include "dos_intern.h"
  43.  
  44. LONG AROS_SLIB_ENTRY(RunProcess,Dos)(struct Process *proc,
  45.     struct StackSwapStruct *sss, STRPTR argptr, ULONG argsize,
  46.     LONG_FUNC entry, struct DosLibrary *DOSBase);
  47.  
  48. /*****************************************************************************
  49.  
  50.     NAME */
  51. #include <proto/dos.h>
  52.  
  53.     AROS_LH4(LONG, RunCommand,
  54.  
  55. /*  SYNOPSIS */
  56.     AROS_LHA(BPTR,   segList,   D1),
  57.     AROS_LHA(ULONG,  stacksize, D2),
  58.     AROS_LHA(STRPTR, argptr,    D3),
  59.     AROS_LHA(ULONG,  argsize,   D4),
  60.  
  61. /*  LOCATION */
  62.     struct DosLibrary *, DOSBase, 84, Dos)
  63.  
  64. /*  FUNCTION
  65.  
  66.     INPUTS
  67.  
  68.     RESULT
  69.  
  70.     NOTES
  71.  
  72.     EXAMPLE
  73.  
  74.     BUGS
  75.  
  76.     SEE ALSO
  77.  
  78.     INTERNALS
  79.  
  80.     HISTORY
  81.     29-10-95    digulla automatically created from
  82.                 dos_lib.fd and clib/dos_protos.h
  83.  
  84. *****************************************************************************/
  85. {
  86.     AROS_LIBFUNC_INIT
  87.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  88.  
  89.     STRPTR oldargs;
  90.     LONG oldresult;
  91.  
  92.     /* Get pointer to process structure */
  93.     struct Process *me=(struct Process *)FindTask(NULL);
  94.  
  95.     UBYTE *stack;
  96.     LONG ret;
  97.     struct StackSwapStruct sss;
  98.  
  99.     stack=(UBYTE *)AllocMem(stacksize,MEMF_ANY);
  100.     if(stack==NULL)
  101.     return -1;
  102.  
  103.     sss.stk_Lower=stack;
  104.     sss.stk_Upper=(IPTR)stack+stacksize;
  105.  
  106.     oldresult=me->pr_Result2;
  107.     if(me->pr_CIS)
  108.     Flush(me->pr_CIS);
  109.     if(me->pr_COS)
  110.     Flush(me->pr_COS);
  111.     if(me->pr_CES)
  112.     Flush(me->pr_CES);
  113.     me->pr_Result2=oldresult;
  114.  
  115.     oldargs=me->pr_Arguments;
  116.     me->pr_Arguments=argptr;
  117.     ret=AROS_SLIB_ENTRY(RunProcess,Dos)(me,&sss,argptr,argsize,
  118.         (LONG_FUNC)((BPTR *)BADDR(segList)+1),DOSBase);
  119.     me->pr_Arguments=oldargs;
  120.  
  121.     oldresult=me->pr_Result2;
  122.     if(me->pr_CIS)
  123.     Flush(me->pr_CIS);
  124.     if(me->pr_COS)
  125.     Flush(me->pr_COS);
  126.     if(me->pr_CES)
  127.     Flush(me->pr_CES);
  128.     me->pr_Result2=oldresult;
  129.  
  130.     FreeMem(stack,stacksize);
  131.     return ret;
  132.     AROS_LIBFUNC_EXIT
  133. } /* RunCommand */
  134.