Fixed some autodocs
[AROS.git] / workbench / c / Open / main.c
blob86fd70d364c9abd3ffe85591a94c9adf9ddcf4b5
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Open CLI command
6 Lang: English
7 */
10 #include <exec/types.h>
11 #include <dos/dos.h>
13 #include <proto/dos.h>
14 #include <proto/workbench.h>
15 #include <proto/utility.h>
17 #define DEBUG 0
18 #include <aros/debug.h>
20 #define SH_GLOBAL_DOSBASE TRUE
21 #include <aros/shcommands.h>
23 AROS_SH2H
25 Open, 0.3, "Open/launch a workbench object as if its icon was double-clicked",
26 AROS_SHAH(STRPTR , , NAME , /A, "","\tName of the object to be opened"),
27 AROS_SHAH(STRPTR *, , ARGUMENTS, /M, NULL,"List of parameters (Workbench arguments)\n"
28 "\t\t\t\tto pass to the tool/project to be launched")
31 AROS_SHCOMMAND_INIT
33 struct Library *WorkbenchBase = OpenLibrary("workbench.library", 44L);
34 struct Library *UtilityBase = OpenLibrary("utility.library", 41L);
35 struct TagItem *argsTagList = NULL;
36 BOOL success = FALSE;
37 int nbArgs = 0, i = 0;
38 STRPTR *wbArg;
40 if (WorkbenchBase != NULL)
42 if (SHArg(ARGUMENTS) != NULL)
44 if (UtilityBase != NULL)
46 for ( wbArg = SHArg(ARGUMENTS) ; *wbArg ; wbArg++, nbArgs++ )
48 D(bug("[Open] wbArg[%d] %s\n", nbArgs, *wbArg));
50 argsTagList = AllocateTagItems(nbArgs + 1);
51 for ( wbArg = SHArg(ARGUMENTS) ; *wbArg ; wbArg++, i++ )
53 argsTagList[i].ti_Tag = WBOPENA_ArgName;
54 argsTagList[i].ti_Data = (IPTR) *wbArg;
55 D(bug("[Open] argsTagList[%d]: %s\n", i, argsTagList[i].ti_Data));
57 argsTagList[i].ti_Tag = TAG_DONE;
58 D(bug("[Open] i = %d, nbArgs = %d\n", i, nbArgs));
59 success = OpenWorkbenchObjectA(SHArg(NAME), argsTagList);
60 FreeTagItems(argsTagList);
62 else
64 PutStr("ERROR: Could not open utility.library v41+.\n");
67 else
69 D(bug("[Open] SHArg(ARGUMENTS) == NULL\n"));
70 success = OpenWorkbenchObject(SHArg(NAME), TAG_DONE);
72 if (UtilityBase != NULL)
73 CloseLibrary(UtilityBase);
74 CloseLibrary(WorkbenchBase);
76 else
78 PutStr("ERROR: Could not open workbench.library v44+.\n");
81 return success ? RETURN_OK : RETURN_FAIL;
83 AROS_SHCOMMAND_EXIT