dosboot.resource: add small hint about boot device page
[AROS.git] / workbench / libs / datatypes / launchtoola.c
blob228939abc59ef067b73ed78d4e06c4964aa4c2a4
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "datatypes_intern.h"
7 #include <datatypes/datatypesclass.h>
8 #include <utility/tagitem.h>
9 #include <dos/dostags.h>
10 #include <proto/alib.h>
11 #include <proto/dos.h>
12 #include <proto/exec.h>
13 #include <proto/utility.h>
14 #include <proto/workbench.h>
16 /* Putchar procedure needed by RawDoFmt() */
18 AROS_UFH2(void, dt_putchr,
19 AROS_UFHA(UBYTE, chr, D0),
20 AROS_UFHA(STRPTR *, p, A3))
22 AROS_USERFUNC_INIT
23 *(*p)++ = chr;
24 AROS_USERFUNC_EXIT
27 void dt__sprintf(struct Library *DataTypesBase, UBYTE *buffer,
28 UBYTE *format, ...)
30 RawDoFmt(format, &format+1, (VOID_FUNC)dt_putchr, &buffer);
34 /*****************************************************************************
36 NAME */
37 #include <proto/datatypes.h>
39 AROS_LH3(ULONG, LaunchToolA,
41 /* SYNOPSIS */
42 AROS_LHA(struct Tool * , tool, A0),
43 AROS_LHA(STRPTR , project, A1),
44 AROS_LHA(struct TagItem *, attrs, A2),
46 /* LOCATION */
47 struct Library *, DataTypesBase, 42, DataTypes)
49 /* FUNCTION
51 Launch an application with a particular project.
53 INPUTS
55 tool -- tool to use (may be NULL in which case this function
56 returns 0)
57 project -- name of the project to execute or NULL
58 attrs -- additional attributes
60 TAGS
62 NP_Priority (BYTE) -- priority of the launched tool (default is the
63 priority of the currect process except for
64 Workbench applications where the default priority
65 is 0 if not overridden by the TOOLPRI tooltype).
67 NP_Synchronous (BOOL) -- don't return until lauched application process
68 finishes (defaults to FALSE).
70 RESULT
72 Zero for failure, non-zero otherwise.
74 NOTES
76 EXAMPLE
78 BUGS
80 SEE ALSO
82 NewDTObjectA()
84 INTERNALS
86 *****************************************************************************/
88 AROS_LIBFUNC_INIT
90 BOOL isSynchronous;
91 BPTR output;
93 if (tool == NULL)
95 SetIoErr(ERROR_REQUIRED_ARG_MISSING);
97 return 0;
100 isSynchronous = (BOOL)GetTagData(NP_Synchronous, (IPTR)FALSE, attrs);
102 switch (tool->tn_Flags & TF_LAUNCH_MASK)
104 case TF_SHELL:
106 char tBuffer[512];
107 LONG ret;
109 dt__sprintf
111 DataTypesBase, tBuffer,
112 "\"%s\" \"%s\"", tool->tn_Program, project
115 output = Open("CON:////Output window/AUTO/WAIT/CLOSE/INACTIVE",
116 MODE_NEWFILE);
118 if (output != BNULL)
120 struct TagItem tags[] = { { SYS_Asynch, !isSynchronous },
121 { SYS_Input , (IPTR)NULL },
122 { SYS_Output, (IPTR)output },
123 { TAG_DONE, } };
126 ret = SystemTagList(tBuffer, tags);
128 /* Error? */
129 if (ret == -1)
131 return 0;
134 Close(output);
136 else
138 return 0;
142 break;
144 case TF_WORKBENCH:
146 BOOL success = FALSE;
147 struct Library *WorkbenchBase = OpenLibrary("workbench.library", 39L);
149 if (WorkbenchBase != NULL)
151 BPTR lock = Lock(project, ACCESS_READ);
153 if (lock != BNULL)
155 BPTR parent = ParentDir(lock);
157 success = OpenWorkbenchObject
159 tool->tn_Program,
160 WBOPENA_ArgLock, (IPTR) parent,
161 WBOPENA_ArgName, (IPTR) FilePart(project),
162 TAG_DONE
165 UnLock(lock);
168 CloseLibrary(WorkbenchBase);
171 if (!success) return 0;
173 break;
175 case TF_RX:
176 /* Sorry, no Arexx in AROS yet. */
177 /* FIXME: No Arexx compatibility yet */
179 /* Do some "RX command" here */
180 return 0;
181 break;
183 default:
184 return 0;
185 break;
188 return 1;
190 AROS_LIBFUNC_EXIT
191 } /* LaunchToolA */