2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
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
))
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
;
48 csm
->csm_ReturnCode
= DOSBase
? RETURN_OK
: RETURN_FAIL
;
49 ReplyMsg((struct Message
*)csm
);
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
;
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
;
83 iofs
.IOFS
.io_Device
= fhout
->fh_Device
;
84 iofs
.IOFS
.io_Unit
= fhout
->fh_Unit
;
89 rc
= RunCommand(ShellSeg
, cli
->cli_DefaultStack
* CLI_DEFAULTSTACK_UNIT
, argstr
, argsize
);
91 CloseLibrary((struct Library
*)DOSBase
);
96 csm
->csm_ReturnCode
= Cli()->cli_ReturnCode
;
97 ReplyMsg((struct Message
*)csm
);