source: golgotha/src/i4/dll/linux_dll.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.1 KB
RevLine 
[80]1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "dll/dll.hh"
10#include <dlfcn.h>
11
12class i4_linux_dll_file : public i4_dll_file
13{
14  void *handle;
15public:
16  i4_linux_dll_file(void *handle) : handle(handle) {}
17
18  virtual ~i4_linux_dll_file()
19  {
20    dlclose(handle);
21  }
22
23  virtual void *find_function(const char *name)
24  {
25    return dlsym(handle, name);
26  } 
27};
28
29i4_dll_file *i4_open_dll(const i4_const_str &filename)
30{
31  char buf[1024];
32  i4_os_string(filename, buf, 1024);
33 
34  void *handle=dlopen(buf,  RTLD_NOW);
35  if (handle)
36    return new i4_linux_dll_file(handle);   
37  else
38  {
39    i4_warning("DLL load %s failed : %s", buf, dlerror());
40    return 0;
41  }
42 
43}
44
Note: See TracBrowser for help on using the repository browser.