1 /* 2 * Copyright 2001-2005, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Ingo Weinhold (bonefish@users.sf.net) 7 */ 8 9 //! Global library initialization/termination routines. 10 11 12 #include <stdio.h> 13 #include <stdlib.h> 14 15 #include <ClipboardPrivate.h> 16 #include <MessagePrivate.h> 17 #include <RosterPrivate.h> 18 19 20 // debugging 21 //#define DBG(x) x 22 #define DBG(x) 23 #define OUT printf 24 25 26 static void 27 initialize_forked_child() 28 { 29 DBG(OUT("initialize_forked_child()\n")); 30 31 BMessage::Private::StaticReInitForkedChild(); 32 33 DBG(OUT("initialize_forked_child() done\n")); 34 } 35 36 37 extern "C" void 38 initialize_before() 39 { 40 DBG(OUT("initialize_before()\n")); 41 42 BMessage::Private::StaticInit(); 43 BRoster::Private::InitBeRoster(); 44 45 atfork(initialize_forked_child); 46 47 DBG(OUT("initialize_before() done\n")); 48 } 49 50 51 extern "C" void 52 initialize_after() 53 { 54 DBG(OUT("initialize_after()\n")); 55 56 BPrivate::init_clipboard(); 57 // needs to send a message, and that requires gDefaultTokens to be initialized 58 59 DBG(OUT("initialize_after() done\n")); 60 } 61 62 63 extern "C" void 64 terminate_after() 65 { 66 DBG(OUT("terminate_after()\n")); 67 68 BRoster::Private::DeleteBeRoster(); 69 BMessage::Private::StaticCleanup(); 70 BMessage::Private::StaticCacheCleanup(); 71 72 DBG(OUT("terminate_after() done\n")); 73 } 74 75