2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
9 /******************************************************************************
26 Create a new shell in a new console window. This window will become
29 The window belonging to the new shell may be specified by
30 using the WINDOW tooltype.
34 The attributes are read as tooltypes from the Shell icon.
36 WINDOW -- Specification of the shell window. It must be in the form
37 con:[X]/[Y]/[WIDTH]/[HEIGHT]...
39 X -- number of pixels from the left edge of
41 Y -- number of pixels from the top edge of
43 WIDTH -- width of the shell window in pixels
44 HEIGHT -- height of the shell window in pixels
45 TITLE -- text to appear in the shell window's
47 AUTO -- the window automatically appears when the
48 program needs input or output
49 ALT -- the window appears in the specified size
50 and position when the zoom gadget is clicked
51 BACKDROP -- the window is a backdrop window
52 CLOSE -- include a close gadget
53 INACTIVE -- the window is not made active when opened
54 NOBORDER -- the window is borderless, only the size,
55 depth and zoom gadgets are available
56 NOCLOSE -- the window has no close gadget
57 NODEPTH -- the window has no depth gadget
58 NODRAG -- the window cannot be drag; implies NOCLOSE
59 NOSIZE -- the window has no size gadget
60 SCREEN -- name of a public screen to open the window on
61 SIMPLE -- if the window is enlarged the text expands to
62 fill the available space
63 SMART -- if the window is enlarged the text will not
65 WAIT -- the window can only be closed by selecting
66 the close gadget or entering CTRL-\.
69 FROM -- File to execute before resorting to normal shell
70 operations. If nothing is specified S:Shell-Startup
73 STACK -- Stack size in Bytes.
78 As opposed to C:NewShell, this is a Workbench Tool.
90 ******************************************************************************/
92 #include <proto/dos.h>
93 #include <proto/icon.h>
94 #include <workbench/startup.h>
97 #include <aros/debug.h>
99 const TEXT ver
[] = "$VER:CLI 1.2 (07.02.2017) © AROS Dev Team";
100 static BPTR olddir
= (BPTR
)-1;
102 int main(int argc
, char **argv
)
104 struct DiskObject
*dobj
= NULL
;
107 STRPTR winspec
= NULL
;
108 STRPTR fromspec
= NULL
;
112 BPTR iconlock
= BNULL
;
113 STRPTR iconname
= NULL
;
115 // CLI is a special case, because it is
116 // a default tool of an icon with a different name,
117 // usually SYS:System/Shell.info.
119 // check the wbmessage for the icon name
120 // from which we were called
123 struct WBStartup
*wbmsg
= (struct WBStartup
*)argv
;
124 if (wbmsg
->sm_NumArgs
== 2)
126 iconlock
= wbmsg
->sm_ArgList
[1].wa_Lock
;
127 iconname
= wbmsg
->sm_ArgList
[1].wa_Name
;
128 olddir
= CurrentDir(iconlock
);
132 // if we don't have a valid name we try the standard name
133 if ((iconname
== NULL
) || (*iconname
== '\0'))
135 iconname
= "SYS:System/Shell";
138 // read the diskobject for the tooltypes
139 if ((dobj
= GetDiskObject(iconname
)) != NULL
)
142 STRPTR
*toolarray
= dobj
->do_ToolTypes
;
144 result
= FindToolType(toolarray
, "STACK");
146 StrToLong(result
, &stack
);
148 result
= FindToolType(toolarray
, "FROM");
152 result
= FindToolType(toolarray
, "WINDOW");
156 D(bug("[CLI] iconname %s diskobject %p\n", iconname
, dobj
));
158 // sanity checks; set default values
159 if (stack
< AROS_STACKSIZE
)
160 stack
= AROS_STACKSIZE
;
162 if (fromspec
== NULL
)
163 fromspec
= "S:Shell-Startup";
166 winspec
= "CON:0/50//130/AROS-Shell/CLOSE";
168 D(bug("[CLI] stack %d from %s window %s\n", stack
, fromspec
, winspec
));
170 // open the streams for SystemTagList
171 from
= Open(fromspec
, MODE_OLDFILE
);
172 win
= Open(winspec
, MODE_NEWFILE
);
177 struct TagItem tags
[] =
179 { SYS_Asynch
, TRUE
},
180 { SYS_Background
, FALSE
},
181 { SYS_Input
, (IPTR
)win
},
182 { SYS_Output
, (IPTR
)NULL
},
183 { SYS_Error
, (IPTR
)NULL
},
184 { SYS_ScriptInput
, (IPTR
)from
},
185 { SYS_UserShell
, TRUE
},
186 { NP_StackSize
, stack
},
189 rc
= SystemTagList("", tags
);
192 // SystemTagList closes the streams for us
193 // when run successfully asynch
202 FreeDiskObject(dobj
);
204 if (olddir
!= (BPTR
)-1)