summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2001-12-17 11:51:05 +0000
committerPhilipp Lohmann <pl@openoffice.org>2001-12-17 11:51:05 +0000
commit36043bc4e0fa7626f1b41ff5681e32db63074e96 (patch)
tree08040e8af614a471f3e6295812d38b573a849366
parent044d168e2352749b58b82ad61a232b1978448ca4 (diff)
#95340# check plugins in same environment as they run in
-rw-r--r--extensions/source/plugin/unx/npwrap.cxx34
-rw-r--r--extensions/source/plugin/unx/unxmgr.cxx30
2 files changed, 48 insertions, 16 deletions
diff --git a/extensions/source/plugin/unx/npwrap.cxx b/extensions/source/plugin/unx/npwrap.cxx
index 6b8b56c66019..92bdf0caec75 100644
--- a/extensions/source/plugin/unx/npwrap.cxx
+++ b/extensions/source/plugin/unx/npwrap.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: npwrap.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: pl $ $Date: 2001-10-23 17:31:20 $
+ * last change: $Author: pl $ $Date: 2001-12-17 12:51:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -167,8 +167,38 @@ void* CreateNewShell( void** pShellReturn )
return newWidget;
}
+// Unix specific implementation
+static void CheckPlugin( const char* pPath )
+{
+ rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
+
+ void *pLib = dlopen( pPath, RTLD_LAZY );
+ if( ! pLib )
+ {
+#ifdef DEBUG
+ fprintf( stderr, "could not dlopen( %s ) (%s)\n", pPath, dlerror() );
+#endif
+ return;
+ }
+
+ char*(*pNP_GetMIMEDescription)() = (char*(*)())
+ dlsym( pLib, "NP_GetMIMEDescription" );
+ if( pNP_GetMIMEDescription )
+ printf( "%s\n", pNP_GetMIMEDescription() );
+#ifdef DEBUG
+ else
+ fprintf( stderr, "could not dlsym NP_GetMIMEDescription (%s)\n", dlerror() );
+#endif
+ dlclose( pLib );
+}
+
main( int argc, char **argv)
{
+ if( argc < 3 )
+ {
+ CheckPlugin(argv[1]);
+ exit(0);
+ }
#if ! ( defined DEBUG || defined DBG_UTIL )
fclose( stdout );
fclose( stderr );
diff --git a/extensions/source/plugin/unx/unxmgr.cxx b/extensions/source/plugin/unx/unxmgr.cxx
index 3178c1922b75..e34b6ec2fe30 100644
--- a/extensions/source/plugin/unx/unxmgr.cxx
+++ b/extensions/source/plugin/unx/unxmgr.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unxmgr.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: pl $ $Date: 2001-10-23 17:31:20 $
+ * last change: $Author: pl $ $Date: 2001-12-17 12:51:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,7 +62,6 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
-#include <dlfcn.h>
#include <osl/thread.h>
#include <vcl/svapp.hxx>
@@ -78,15 +77,22 @@ static PluginDescription** CheckPlugin( const ByteString& rPath, int& rDescripti
PluginDescription** pRet = NULL;
rDescriptions = 0;
- void *pLib = dlopen( rPath.GetBuffer(), RTLD_LAZY );
- if( ! pLib )
- return NULL;
+ ByteString aCommand( "pluginapp.bin \"" );
+ aCommand.Append( rPath );
+ aCommand.Append( '"' );
- char*(*pNP_GetMIMEDescription)() = (char*(*)())
- dlsym( pLib, "NP_GetMIMEDescription" );
- if( pNP_GetMIMEDescription )
+ FILE* pResult = popen( aCommand.GetBuffer(), "r" );
+ if( pResult )
{
- ByteString aMIME = pNP_GetMIMEDescription();
+ ByteString aMIME;
+ char buf[256];
+ while( fgets( buf, sizeof( buf ), pResult ) )
+ aMIME += buf;
+ pclose( pResult );
+ if( aMIME.GetChar( aMIME.Len()-1 ) == '\n' )
+ aMIME.Erase( aMIME.Len()-1 );
+
+
char cTok = ';';
if( aMIME.GetTokenCount( ';' ) > 2 )
cTok = ';';
@@ -107,10 +113,6 @@ static PluginDescription** CheckPlugin( const ByteString& rPath, int& rDescripti
}
rDescriptions = nExtensions;
}
- // some libraries register atexit handlers when loaded
- // (e.g. g++ made libraries register global destructors)
- // not closing them does prevent this
-// dlclose( pLib );
return pRet;
}