Gnash  0.8.10
sharedlib.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_SHAREDLIB_H
00020 #define GNASH_SHAREDLIB_H
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include "gnashconfig.h"
00024 #endif
00025 
00026 #include <boost/thread/mutex.hpp>
00027 #include <string>
00028 #include "dsodefs.h" // DSOEXPORT
00029 
00030 #ifdef _WIN32
00031 #undef DLL_EXPORT
00032 #define LIBLTDL_DLL_IMPORT 1
00033 #endif
00034 
00035 #include <ltdl.h>
00036 
00037 // Used on Darwin for basename
00038 #ifdef HAVE_LIBGEN_H
00039 #include <libgen.h>
00040 #endif
00041 
00042 namespace gnash {
00043     class as_object;
00044 }
00045 
00046 namespace gnash {
00047 
00049 class SharedLib
00050 {
00051     typedef boost::mutex::scoped_lock scoped_lock;
00052 
00053 public:
00054     // Typedefs for function pointers to keep the code readable
00055     typedef bool entrypoint (void *obj);
00056     typedef void initentry(as_object &obj);
00057     
00058     DSOEXPORT SharedLib(const std::string& filespec);
00059 
00060     DSOEXPORT bool openLib();
00061     bool openLib(const std::string &filespec);
00062     
00063     // Get a C symbol from the shared library based on the name
00064     entrypoint *getDllSymbol (const std::string& symbol);
00065     DSOEXPORT initentry *getInitEntry (const std::string& symbol);
00066     
00067 private:
00068 
00069     bool closeLib();
00070 
00071     lt_dlhandle _dlhandle;
00072     std::string _filespec;
00073     boost::mutex _libMutex;    
00074 };
00075 
00076 } // end of gnash namespace
00077 
00078 // GNASH_SHAREDLIB_H
00079 #endif
00080 
00081 // Local Variables:
00082 // mode: C++
00083 // indent-tabs-mode: t
00084 // End: