grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / c / shellcommands / NewShell.c
blob2fd35e85679c7a068d8c4337b1089115af42e0a0
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: NewShell CLI Command
6 Lang: English
7 */
9 /******************************************************************************
12 NAME
14 NewShell
16 SYNOPSIS
18 WINDOW,FROM
20 LOCATION
24 FUNCTION
26 Create a new shell in a new console window. This window will become
27 the active one. The new shell inherits most attributes of the parent
28 shell like the current directory, stack size, prompt and so on.
29 However, it is completely independent of the parent shell.
30 The window belonging to the new shell may be specified by
31 using the WINDOW keyword.
33 INPUTS
35 WINDOW -- Specification of the shell window
37 X -- number of pixels from the left edge of
38 the screen
39 Y -- number of pixels from the top edge of
40 the screen
41 WIDTH -- width of the shell window in pixels
42 HEIGHT -- height of the shell window in pixels
43 TITLE -- text to appear in the shell window's
44 title bar
45 AUTO -- the window automatically appears when the
46 program needs input or output
47 ALT -- the window appears in the specified size
48 and position when the zoom gadget is clicked
49 BACKDROP -- the window is a backdrop window
50 CLOSE -- include a close gadget
51 INACTIVE -- the window is not made active when opened
52 NOBORDER -- the window is borderless, only the size,
53 depth and zoom gadgets are available
54 NOCLOSE -- the window has no close gadget
55 NODEPTH -- the window has no depth gadget
56 NODRAG -- the window cannot be drag; implies NOCLOSE
57 NOSIZE -- the window has no size gadget
58 SCREEN -- name of a public screen to open the window on
59 SIMPLE -- if the window is enlarged the text expands to
60 fill the available space
61 SMART -- if the window is enlarged the text will not
62 expand
63 WAIT -- the window can only be closed by selecting
64 the close gadget or entering CTRL-\.
67 FROM -- File to execute before resorting to normal shell
68 operations. If nothing is specified S:Shell-Startup
69 is used.
71 RESULT
73 NOTES
75 EXAMPLE
77 NewShell "CON:10/10/640/480/My own shell/CLOSE"
79 BUGS
81 SEE ALSO
83 INTERNALS
85 HISTORY
87 ******************************************************************************/
89 #include <exec/memory.h>
90 #include <proto/exec.h>
91 #include <proto/dos.h>
92 #include <dos/dosextens.h>
93 #include <dos/dostags.h>
94 #include <aros/asmcall.h>
95 #include <string.h>
97 #include <aros/shcommands.h>
99 AROS_SH3(NewShell, 41.2,
100 AROS_SHA(STRPTR, ,WINDOW, ,"CON:10/50/640/480/AROS-Shell/CLOSE"),
101 AROS_SHA(STRPTR, ,FROM, ,"S:Shell-Startup"),
102 AROS_SHA(LONG *, ,STACK,/N,NULL))
104 AROS_SHCOMMAND_INIT
106 BPTR from = Open(SHArg(FROM), MODE_OLDFILE);
107 BPTR win = Open(SHArg(WINDOW), MODE_OLDFILE);
108 LONG *stackp = SHArg(STACK);
109 ULONG stack;
111 LONG rc = RETURN_FAIL;
113 if (stackp == NULL || *stackp < AROS_STACKSIZE)
114 stack = AROS_STACKSIZE;
115 else
116 stack = *stackp;
118 if (win)
120 struct TagItem tags[] =
122 { SYS_Asynch, TRUE },
123 { SYS_Background, FALSE },
124 { SYS_Input, (IPTR)win },
125 { SYS_Output, (IPTR)NULL },
126 { SYS_Error, (IPTR)NULL },
127 { SYS_ScriptInput, (IPTR)from },
128 { SYS_UserShell, TRUE },
129 { NP_StackSize, stack },
130 { TAG_DONE, 0 }
133 rc = SystemTagList("", tags);
134 if (rc != -1)
136 win = BNULL;
137 from = BNULL;
139 else
140 rc = RETURN_FAIL;
142 else
144 PrintFault(IoErr(), "NewShell");
147 Close(win);
148 Close(from);
150 return rc;
152 AROS_SHCOMMAND_EXIT