2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 Initialization of workbench.library.
9 #include <aros/debug.h>
10 #include <aros/atomic.h>
11 #include <aros/symbolsets.h>
13 #include "workbench_intern.h"
14 #include LC_LIBDEFS_FILE
18 static int WBInit(LIBBASETYPEPTR LIBBASE
)
20 /* Make sure that the libraries are opened in L_OpenLib() --------------*/
21 WorkbenchBase
->wb_Initialized
= FALSE
;
23 /* Initialize our private lists ----------------------------------------*/
24 NEWLIST(&(WorkbenchBase
->wb_AppWindows
));
25 NEWLIST(&(WorkbenchBase
->wb_AppIcons
));
26 NEWLIST(&(WorkbenchBase
->wb_AppMenuItems
));
27 NEWLIST(&(WorkbenchBase
->wb_HiddenDevices
));
29 /* Initialize our semaphores -------------------------------------------*/
30 InitSemaphore(&(WorkbenchBase
->wb_WorkbenchPortSemaphore
));
31 InitSemaphore(&(WorkbenchBase
->wb_InitializationSemaphore
));
32 InitSemaphore(&(WorkbenchBase
->wb_BaseSemaphore
));
34 /* Initialize handler message port -------------------------------------*/
35 WorkbenchBase
->wb_HandlerPort
.mp_SigBit
= SIGBREAKB_CTRL_F
;
36 WorkbenchBase
->wb_HandlerPort
.mp_SigTask
= NULL
;
37 WorkbenchBase
->wb_HandlerPort
.mp_Flags
= PA_IGNORE
;
38 NEWLIST(&(WorkbenchBase
->wb_HandlerPort
.mp_MsgList
));
40 /* Initialize miscellanous variables -----------------------------------*/
41 WorkbenchBase
->wb_DefaultStackSize
= 1024 * 32; /* 32kiB */ // FIXME: also read from preferences */
46 static int WBOpen(LIBBASETYPEPTR LIBBASE
)
48 ObtainSemaphore(&(WorkbenchBase
->wb_InitializationSemaphore
));
50 if (!(WorkbenchBase
->wb_Initialized
))
52 struct CommandLineInterface
*cli
;
54 /* Duplicate the search path ---------------------------------------*/
55 if ((cli
= Cli()) != NULL
)
57 WorkbenchBase
->wb_SearchPath
= DuplicateSearchPath
63 /* Start workbench handler -----------------------------------------*/
69 NP_Entry
, (IPTR
) WorkbenchHandler
,
71 NP_Name
, (IPTR
) "Workbench Handler",
72 NP_UserData
, (IPTR
) WorkbenchBase
,
78 /* Prevent expunging while the handler is running */
79 AROS_ATOMIC_INC(WorkbenchBase
->LibNode
.lib_OpenCnt
);
83 // FIXME: free resources
87 WorkbenchBase
->wb_Initialized
= TRUE
;
90 ReleaseSemaphore(&(WorkbenchBase
->wb_InitializationSemaphore
));
95 ADD2INITLIB(WBInit
, 0);
96 ADD2OPENLIB(WBOpen
, 0);