- Define structure pointer to NULL to make the compiler happy
[AROS.git] / rom / dos / execute.c
blob042abd9017980875b134c7fdf3602dda4915e83f
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Execute a CLI command
6 Lang: English
7 */
9 #include <aros/debug.h>
10 #include <dos/dosextens.h>
11 #include <utility/tagitem.h>
13 #include "dos_intern.h"
15 /*****************************************************************************
17 NAME */
18 #include <proto/dos.h>
20 AROS_LH3(BOOL, Execute,
22 /* SYNOPSIS */
23 AROS_LHA(CONST_STRPTR, string, D1),
24 AROS_LHA(BPTR , input , D2),
25 AROS_LHA(BPTR , output, D3),
27 /* LOCATION */
28 struct DosLibrary *, DOSBase, 37, Dos)
30 /* FUNCTION
31 Execute a CLI command specified in 'string'. This string may contain
32 features you may use on the shell commandline like redirection using >,
33 < or >>. Execute() doesn't return until the command(s) that should be
34 executed are finished.
36 If 'input' is not NULL, more commands will be read from this stream
37 until end of file is reached. 'output' will be used as the output stream
38 of the commands (if output is not redirected). If 'output' is NULL the
39 current window is used for output -- note that programs run from the
40 Workbench doesn't normally have a current window.
42 INPUTS
43 string - pointer to a NULL-terminated string with commands
44 (may be NULL)
45 input - stream to use as input (may be NULL)
46 output - stream to use as output (may be NULL)
48 RESULT
49 Boolean telling whether Execute() could find and start the specified
50 command(s). (This is NOT the return code of the command(s).)
52 NOTES
54 EXAMPLE
56 BUGS
58 SEE ALSO
60 SystemTagList()
62 INTERNALS
63 To get the right result, the function ExecCommand() (used by both
64 Execute() and SystemTagList()) uses NP_Synchronous to wait for the
65 commands to finish. This is not the way AmigaOS does it as
66 NP_Synchronous is not implemented (but defined).
68 *****************************************************************************/
70 AROS_LIBFUNC_INIT
72 LONG result;
73 struct TagItem tags[] =
75 { SYS_Background, TRUE },
76 { SYS_Asynch, FALSE },
77 { SYS_Input, (IPTR)input },
78 { SYS_Output, (IPTR)output },
79 { SYS_Error, (IPTR)NULL },
80 { TAG_DONE, 0 }
83 D(bug("[Execute] input = %p, output = %p, cmd = \"%s\"\n", input, output, string));
85 /* Check for the special cases where we want a new
86 * interactive shell.
88 if ((!string || string[0] == 0) && IsInteractive(input) && output == BNULL)
89 tags[0].ti_Data = FALSE;
91 if ((!string || string[0] == 0) && input == BNULL && output == BNULL)
92 string = "Run NewShell";
94 result = SystemTagList(string, tags);
96 if(result == 0)
97 return DOSTRUE;
98 else
99 return DOSFALSE;
101 AROS_LIBFUNC_EXIT
102 } /* Execute */