summaryrefslogtreecommitdiff
path: root/libmodman/module_manager.cpp
diff options
context:
space:
mode:
authornpmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56>2010-02-05 20:29:19 +0000
committernpmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56>2010-02-05 20:29:19 +0000
commitfc3cdee5f5e52e2f069bdbe1625dafcb77fdfd15 (patch)
tree503baf348ad8beaf6793737a0c7cf31f5ceea50b /libmodman/module_manager.cpp
parent8fa9f746e25d3fc6f7c96a27e1dbddc33650178f (diff)
downloadlibproxy-fc3cdee5f5e52e2f069bdbe1625dafcb77fdfd15.tar.gz
make modman work on win32 (test suite still doesn't work, but at least the library does...)
git-svn-id: http://libproxy.googlecode.com/svn/trunk@516 c587cffe-e639-0410-9787-d7902ae8ed56
Diffstat (limited to 'libmodman/module_manager.cpp')
-rw-r--r--libmodman/module_manager.cpp37
1 files changed, 7 insertions, 30 deletions
diff --git a/libmodman/module_manager.cpp b/libmodman/module_manager.cpp
index e2c3cbb..c5d4ce2 100644
--- a/libmodman/module_manager.cpp
+++ b/libmodman/module_manager.cpp
@@ -17,9 +17,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/
-#include <algorithm>
-
+#include <algorithm> // For sort()
#include <sys/stat.h> // For stat()
+
#ifdef WIN32
#include <windows.h>
#else
@@ -28,13 +28,11 @@
#endif
#include "module_manager.hpp"
-
-#include <cstdio>
+using namespace com::googlecode::libmodman;
#ifdef WIN32
#define pdlmtype HMODULE
#define pdlopen(filename) LoadLibrary(filename)
-#define pdlopenl(filename) LoadLibraryEx(filename, NULL, DONT_RESOLVE_DLL_REFERENCES)
#define pdlsym GetProcAddress
#define pdlclose(module) FreeLibrary((pdlmtype) module)
/*static std::string pdlerror() {
@@ -49,32 +47,21 @@
(LPTSTR) &msg,
0,
NULL);
- e = std::string(msg);
+ e = std::string((const char*) msg);
LocalFree(msg);
return e;
}*/
-static pdlmtype pdlreopen(pdlmtype module) {
- char tmp[4096];
- if (!module) return NULL;
- DWORD i = GetModuleFileName(module, tmp, 4096);
- pdlclose(module);
- return (i == 0 || i == 4096) ? NULL : pdlopen(tmp);
-}
#else
#define pdlmtype void*
-#define pdlopen(filename) dlopen(filename, RTLD_NOW | RTLD_LOCAL)
-#define pdlopenl(filename) dlopen(filename, RTLD_LAZY | RTLD_LOCAL)
+#define pdlopen(filename) dlopen(filename, RTLD_LAZY | RTLD_LOCAL)
#define pdlsym dlsym
#define pdlclose(module) dlclose((pdlmtype) module)
//static std::string pdlerror() { return dlerror(); }
-static pdlmtype pdlreopen(pdlmtype module) { return module; }
#endif
#define _str(s) #s
#define __str(s) _str(s)
-using namespace com::googlecode::libmodman;
-
module_manager::~module_manager() {
// Free all extensions
for (map<string, vector<base_extension*> >::iterator i=this->extensions.begin() ; i != this->extensions.end() ; i++) {
@@ -96,10 +83,9 @@ bool module_manager::load_file(string filename, bool symbreq) {
if (stat(filename.c_str(), &st) != 0) return false;
if ((st.st_mode & S_IFMT) != S_IFREG) return false;
- // Open the module without doing any symbol resolution
- pdlmtype dlobj = pdlopenl(filename.c_str());
+ // Open the module
+ pdlmtype dlobj = pdlopen(filename.c_str());
if (!dlobj) return false;
- bool lazyload = true;
// If we have already loaded this module, return true
if (this->modules.find((void*) dlobj) != this->modules.end()) {
@@ -107,7 +93,6 @@ bool module_manager::load_file(string filename, bool symbreq) {
return true;
}
-on_reload:
// Get the module_info struct
module* mi = (module*) pdlsym(dlobj, __str(MM_MODULE_NAME));
if (!mi) {
@@ -150,14 +135,6 @@ on_reload:
}
#endif
- if (lazyload) {
- // Reload the module (not in lazy mode)
- dlobj = pdlreopen(dlobj);
- if (!dlobj) return false;
- lazyload = false;
- goto on_reload;
- }
-
// If our execution test succeeds, call init()
if (mi[i].test()) {
base_extension** extensions = mi[i].init();