#include <stdio.h>
#include <dlfcn.h>
#include <string>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include "plugin.h"
#include "pluginhandling.h"
#include "../common/config.h"
#include "../common/options.h"
Go to the source code of this file.
Functions | |
bool | add_plugin (char* filename) |
void | get_plugins ( char *dirname ) |
void | LoadAllPlugins ( void ) |
Loads all available plugins. More... | |
Variables | |
FEPList* | FEPhead |
APList* | APhead |
|
Loads all available plugins.
Definition at line 156 of file pluginhandling.cpp.
00157 { 00158 get_plugins (SERVER_PLUGIN_DIR); 00159 }
|
Definition at line 39 of file pluginhandling.cpp.
00040 { 00041 typedef void *(*pfnPlugIn)(void); 00042 pfnPlugIn getPlugIn; 00043 void *handler; 00044 00045 00046 #ifdef DEBUG 00047 fprintf ( stderr, "\nloading shared library" ); 00048 #endif 00049 if ( ( handler = dlopen (filename, RTLD_NOW ) ) != NULL ) // dynamic loading of the plugin 00050 { 00051 if ( ( getPlugIn = (pfnPlugIn)dlsym ( handler, "GetFrontEndPlugin" ) ) != NULL ) // search for the function 00052 { 00053 FEPList* tmp; 00054 00055 if (FEPhead == NULL) 00056 { 00057 FEPhead = new FEPList; 00058 tmp = FEPhead; 00059 } 00060 else 00061 { 00062 tmp = FEPhead; 00063 00064 while (tmp->next != NULL) tmp = tmp->next; 00065 00066 tmp->next = new FEPList; 00067 tmp = tmp->next; 00068 } 00069 00070 tmp->plug = (FrontEndPlugin *) getPlugIn (); 00071 tmp->id = tmp->plug->id; 00072 tmp->active = true; //this _has_ to be false in near future, when the plugins can be 00073 //selected using a frontend. Then the default _has_ to be false, and 00074 //LoadAllPlugins() looks into the config file to decide which plugins 00075 //will be turned on., xandi 00076 tmp->next = NULL; 00077 } 00078 00079 else if ( ( getPlugIn = (pfnPlugIn)dlsym ( handler, "GetAuthenticationPlugin" ) ) != NULL ) 00080 { 00081 00082 00083 } 00084 else 00085 { 00086 dlclose ( handler ); 00087 return false; 00088 } 00089 00090 return true; 00091 } 00092 else 00093 { 00094 #ifdef DEBUG 00095 fprintf ( stderr, "- failed!\n"); 00096 fprintf ( stderr, "Error: %s\n", dlerror() ); 00097 #endif 00098 return false; 00099 } 00100 }
|
Definition at line 112 of file pluginhandling.cpp.
00113 { 00114 string filename; 00115 00116 DIR *dir; 00117 00118 struct dirent *dent; 00119 struct stat statbuf; 00120 00121 dir = opendir(dirname); 00122 00123 if (dir) 00124 { 00125 while ( ( dent = readdir ( dir ) ) != NULL ) 00126 { 00127 filename = dirname; 00128 filename += "/"; 00129 filename += dent->d_name; 00130 00131 if ( !stat ( filename.c_str (), &statbuf ) ) 00132 { 00133 if ( S_ISREG ( statbuf.st_mode ) ) { 00134 if (filename.rfind (".so") != string::npos ) 00135 add_plugin (const_cast<char*>(filename.c_str())); 00136 } 00137 } 00138 } 00139 } 00140 }
|
Definition at line 26 of file pluginhandling.cpp.
|
Definition at line 25 of file pluginhandling.cpp.