Workaround for includes conflict that stopped compilation with GCC 3.
[cake.git] / rom / dos / newcliproc.c
blobb67f9e052a85dd2d3b817a54d39a9952eb0ddf46
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <dos/dos.h>
10 #include <dos/filesystem.h>
11 #include <proto/dos.h>
12 #include <proto/exec.h>
14 #include "dos_newcliproc.h"
15 #include "dos_dosdoio.h"
17 AROS_UFH3(LONG, NewCliProc,
18 AROS_UFHA(char *,argstr,A0),
19 AROS_UFHA(ULONG,argsize,D0),
20 AROS_UFHA(struct ExecBase *,SysBase,A6))
22 AROS_USERFUNC_INIT
24 struct Process *me;
25 struct CliStartupMessage *csm;
26 LONG rc = RETURN_FAIL;
27 struct DosLibrary *DOSBase;
29 BPTR ShellSeg, CurrentInput;
30 BOOL Background, Asynch;
32 me = (struct Process *)FindTask(NULL);
33 WaitPort(&me->pr_MsgPort);
34 csm = (struct CliStartupMessage *)GetMsg(&me->pr_MsgPort);
37 DOSBase = (struct DosLibrary *)OpenLibrary(DOSNAME, 39);
39 ShellSeg = csm->csm_ShellSeg;
40 CurrentInput = csm->csm_CurrentInput;
41 Background = csm->csm_Background;
42 Asynch = csm->csm_Asynch;
44 csm->csm_CliNumber = me->pr_TaskNum;
46 if (Asynch)
48 csm->csm_ReturnCode = DOSBase ? RETURN_OK : RETURN_FAIL;
49 ReplyMsg((struct Message *)csm);
52 if (DOSBase)
54 struct CommandLineInterface *cli = Cli();
56 cli->cli_StandardInput = Input();
57 cli->cli_StandardOutput =
58 cli->cli_CurrentOutput = Output();
59 cli->cli_StandardError = Error();
60 cli->cli_CurrentInput = CurrentInput;
61 cli->cli_Interactive = cli->cli_CurrentInput == cli->cli_StandardInput ? DOSTRUE : DOSFALSE;
62 cli->cli_Background = Background;
64 if (!Background)
66 struct IOFileSys iofs;
67 struct FileHandle *fhin = BADDR(Input());
68 struct FileHandle *fhout = BADDR(Output());
70 iofs.IOFS.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
71 iofs.IOFS.io_Message.mn_ReplyPort = &me->pr_MsgPort;
72 iofs.IOFS.io_Message.mn_Length = sizeof(struct IOFileSys);
73 iofs.IOFS.io_Command = FSA_CHANGE_SIGNAL;
74 iofs.IOFS.io_Flags = 0;
76 iofs.io_Union.io_CHANGE_SIGNAL.io_Task = (struct Task *)me;
78 iofs.IOFS.io_Device = fhin->fh_Device;
79 iofs.IOFS.io_Unit = fhin->fh_Unit;
81 DoIO(&iofs.IOFS);
83 iofs.IOFS.io_Device = fhout->fh_Device;
84 iofs.IOFS.io_Unit = fhout->fh_Unit;
86 DoIO(&iofs.IOFS);
89 rc = RunCommand(ShellSeg, cli->cli_DefaultStack * CLI_DEFAULTSTACK_UNIT, argstr, argsize);
91 CloseLibrary((struct Library *)DOSBase);
94 if (!Asynch)
96 csm->csm_ReturnCode = Cli()->cli_ReturnCode;
97 ReplyMsg((struct Message *)csm);
100 UnLoadSeg(ShellSeg);
102 return rc;
104 AROS_USERFUNC_EXIT