1 /* === S I N F G =========================================================== */
5 ** $Id: module.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
24 #define SINFG_NO_ANGLE
36 #include <ETL/stringf>
39 /* === M A C R O S ========================================================= */
41 /* === G L O B A L S ======================================================= */
45 using namespace sinfg;
47 Module::Book *sinfg::Module::book_;
49 /* === P R O C E D U R E S ================================================= */
52 Module::subsys_init(const String &prefix)
54 #ifndef SINFG_LTDL_NO_STATIC
55 //LTDL_SET_PRELOADED_SYMBOLS();
60 error(_("Errors on lt_dlinit()"));
65 lt_dladdsearchdir(".");
66 lt_dladdsearchdir("~/.sinfg/modules");
67 lt_dladdsearchdir((prefix+"/lib/sinfg/modules").c_str());
69 lt_dladdsearchdir(LIBDIR"/sinfg/modules");
72 lt_dladdsearchdir("/Library/Frameworks/sinfg.framework/Resources/modules");
74 lt_dladdsearchdir("/usr/local/lib/sinfg/modules");
75 lt_dladdsearchdir(".");
91 register_default_modules()
103 sinfg::Module::Register(Module::Handle mod)
105 book()[mod->Name()]=mod;
109 sinfg::Module::Register(const String &module_name, ProgressCallback *callback)
113 if(callback)callback->task(strprintf(_("Attempting to register \"%s\""),module_name.c_str()));
115 module=lt_dlopenext((string("lib")+module_name).c_str());
116 if(!module)module=lt_dlopenext(module_name.c_str());
120 if(callback)callback->error(strprintf(_("Unable to find module \"%s\" (%s)"),module_name.c_str(),lt_dlerror()));
124 if(callback)callback->task(strprintf(_("Found module \"%s\""),module_name.c_str()));
126 Module::constructor_type constructor=NULL;
131 // if(callback)callback->task(string("looking for -> ")+module_name+"_LTX_new_instance()");
132 constructor=(Module::constructor_type )lt_dlsym(module,(module_name+"_LTX_new_instance").c_str());
137 // if(callback)callback->task(string("looking for -> lib")+module_name+"_LTX_new_instance()");
138 constructor=(Module::constructor_type )lt_dlsym(module,(string("lib")+module_name+"_LTX_new_instance").c_str());
142 // if(callback)callback->task(string("looking for -> lib")+module_name+"_LTX_new_instance()");
143 constructor=(Module::constructor_type )lt_dlsym(module,(string("_lib")+module_name+"_LTX_new_instance").c_str());
147 // if(callback)callback->task(string("looking for -> lib")+module_name+"_LTX_new_instance()");
148 constructor=(Module::constructor_type )lt_dlsym(module,(string("_")+module_name+"_LTX_new_instance").c_str());
153 // if(callback)callback->task(strprintf("Executing callback for \"%s\"",module_name.c_str()));
154 mod=handle<Module>((*constructor)(callback));
158 if(callback)callback->error(strprintf(_("Unable to find entrypoint in module \"%s\" (%s)"),module_name.c_str(),lt_dlerror()));
162 // if(callback)callback->task(strprintf("Done executing callback for \"%s\"",module_name.c_str()));
166 // if(callback)callback->task(strprintf("Registering \"%s\"",module_name.c_str()));
171 if(callback)callback->error(_("Entrypoint did not return a module."));
175 if(callback)callback->task(strprintf(_("Success for \"%s\""),module_name.c_str()));