2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
10 #include <exec/types.h>
13 #include <proto/dos.h>
14 #include <proto/workbench.h>
15 #include <proto/utility.h>
18 #include <aros/debug.h>
20 #define SH_GLOBAL_DOSBASE TRUE
21 #include <aros/shcommands.h>
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")
33 struct Library
*WorkbenchBase
= OpenLibrary("workbench.library", 44L);
34 struct Library
*UtilityBase
= OpenLibrary("utility.library", 41L);
35 struct TagItem
*argsTagList
= NULL
;
37 int nbArgs
= 0, i
= 0;
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
);
64 PutStr("ERROR: Could not open utility.library v41+.\n");
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
);
78 PutStr("ERROR: Could not open workbench.library v44+.\n");
81 return success
? RETURN_OK
: RETURN_FAIL
;