Listtree.mcc: add information about SetDropMark
[AROS.git] / compiler / autoinit / fromwb.c
blobe21080da3b278020368a95aaedd6cfcb2807d60a
1 /*
2 Copyright © 2009, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: autoinit library - handle program started from workbench.
6 */
7 #include <dos/dos.h>
8 #include <dos/dosextens.h>
9 #include <aros/startup.h>
10 #include <aros/symbolsets.h>
11 #include <proto/dos.h>
12 #include <workbench/startup.h>
14 #define DEBUG 0
15 #include <aros/debug.h>
17 struct WBStartup *WBenchMsg;
19 int __nowbsupport __attribute__((weak)) = 0;
21 static void __startup_fromwb(struct ExecBase *SysBase)
23 struct Process *myproc;
24 BPTR curdir = BNULL;
26 D(bug("Entering __startup_fromwb()\n"));
28 myproc = (struct Process *)FindTask(NULL);
30 /* Do we have a CLI structure? */
31 if (!myproc->pr_CLI)
33 /* Workbench startup. Get WBenchMsg and pass it to main() */
35 WaitPort(&myproc->pr_MsgPort);
36 WBenchMsg = (struct WBStartup *)GetMsg(&myproc->pr_MsgPort);
37 __argv = (char **) WBenchMsg;
38 __argc = 0;
40 /* WB started processes' pr_CurrentDir = BNULL */
41 curdir = DupLock(WBenchMsg->sm_ArgList->wa_Lock);
42 CurrentDir(curdir);
44 D(bug("[startup] Started from Workbench\n"));
47 __startup_entries_next();
49 /* Reply startup message to Workbench */
50 if (WBenchMsg)
52 /* Close original lock */
53 CurrentDir(BNULL);
54 UnLock(curdir);
56 Forbid(); /* make sure we're not UnLoadseg()ed before we're really done */
57 ReplyMsg((struct Message *) WBenchMsg);
60 D(bug("Leaving __startup_fromwb\n"));
63 ADD2SET(__startup_fromwb, PROGRAM_ENTRIES, -50);