Esempio n. 1
0
static void registerPlugin(const char* type, void* plugin, void* private_data) {
    PluginPrivateData* priv_data= (PluginPrivateData*)private_data;

    const char* filename = priv_data->name;

    for (int i = 0; i < PRODBG_PLUGIN_COUNT; ++i) {
        if (strstr(type, s_pluginTypes[i])) {
            if (findPlugin(s_plugins[i], filename, ((PDPluginBase*)plugin)->name))
                return;

            // TODO: Verify that we don't add a plugin with the same plugin name in the same plugin

            PluginData* pluginData = (PluginData*)alloc_zero(sizeof(PluginData));
            pluginData->plugin = plugin;
            pluginData->type = type;
            pluginData->filename = filename;
            pluginData->fullFilename = priv_data->fullFilename;
            pluginData->lib = priv_data->lib;

            return (void)array_push(s_plugins[i], pluginData);
        }
    }

    pd_error("Unknown pluginType %s - %s", type, ((PDPluginBase*)plugin)->name);
}
Esempio n. 2
0
static PluginData* findPluginAll(const char* pluginFile, const char* pluginName) {
    PluginData* plugin = 0;

    for (int i = 0; i < PRODBG_PLUGIN_COUNT; ++i) {
        if ((plugin = findPlugin(s_plugins[i], pluginFile, pluginName)))
            return plugin;
    }

    return 0;
}
Esempio n. 3
0
void PluginInfoStore::getPluginInfo(WTF::String url, WTF::String /*pageUrl*/, WTF::String mimeType, bool& found, PepperPluginInfo& pluginInfo, WTF::String& actualMimeType)
{
    found = false;
    PluginModuleInfo info = findPlugin(mimeType, KURL(KURL(), url));

    pluginInfo = info;
    found = isPepperPlugin(info);
    if (info.info.mimes.size())
        actualMimeType = info.info.mimes[0].type;
    else
        actualMimeType = WTF::String();
}
Esempio n. 4
0
PluginLoadReturn load1Plugin ( std::string plugin, std::string config )
{
	int (*lpProc)(const char*,void*);

	std::string realPluginName = findPlugin(plugin);

	if (pluginExists(realPluginName))
	{
		printf("LoadPlugin fialed:%s is already loaded\n",realPluginName.c_str());
		return eLoadFailedDupe;
	}

	void *hLib = dlopen(realPluginName.c_str(), RTLD_LAZY | RTLD_GLOBAL);
	if (hLib)
	{
		if (dlsym(hLib, "bzwb_Load") == NULL) {
			printf("Plugin:%s found but does not contain bzwb_Load method, error %s\n",plugin.c_str(),dlerror());
			dlclose(hLib);
			return eLoadFailedError;
		}

		int version = getPluginVersion(hLib);
		if (version < BZWB_API_VERSION)
		{
			printf("Plugin:%s found but expects an older API version (%d), upgrade it\n", plugin.c_str(), version);
			dlclose(hLib);
			return eLoadFailedError;
		}
		else
		{
			lpProc = reinterpret_cast<int (*)(const char*,void*)>(dlsym(hLib,"bzwb_Load"));
			if (lpProc)
			{
				(*lpProc)(config.c_str(),hLib);
				printf("Plugin:%s loaded\n",plugin.c_str());
				trPluginRecord pluginRecord;
				pluginRecord.handle = hLib;
				pluginRecord.plugin = plugin;
				vPluginList.push_back(pluginRecord);
				return eLoadComplete;
			}
		}
	}
	else
	{
		printf("Plugin:%s not found, error %s\n",plugin.c_str(), dlerror());
		return eLoadFailedError;
	}

	printf("If you see this, there is something terribly wrong.\n");
	return eLoadFailedError;
}
Esempio n. 5
0
PluginLoadReturn load1Plugin ( std::string plugin, std::string config )
{
	int (*lpProc)(const char*,void*);

	std::string realPluginName = findPlugin(plugin);
	if (pluginExists(realPluginName))
	{
		printf("LoadPlugin fialed:%s is already loaded\n",realPluginName.c_str());
		return eLoadFailedDupe;
	}

	HINSTANCE	hLib = LoadLibraryA(realPluginName.c_str());
	if (hLib)
	{
		if (getPluginVersion(hLib) > BZWB_API_VERSION)
		{
			printf("Plugin:%s found but expects an newer API version (%d), upgrade your application\n",plugin.c_str(),getPluginVersion(hLib));
			FreeLibrary(hLib);
			return eLoadFailedError;
		}
		else
		{
			lpProc = (int (__cdecl *)(const char*, void*))GetProcAddress(hLib, "bzwb_Load");
			if (lpProc)
			{
				lpProc(config.c_str(),hLib);
				printf("Plugin:%s loaded\n",plugin.c_str());

				trPluginRecord pluginRecord;
				pluginRecord.foundPath = realPluginName;
				pluginRecord.handle = hLib;
				pluginRecord.plugin = plugin;
				vPluginList.push_back(pluginRecord);
			}
			else
			{
				printf("Plugin:%s found but does not contain bzwb_Load method\n",plugin.c_str());
				FreeLibrary(hLib);
				return eLoadFailedError;
			}
		}
	}
	else
	{
		printf("Plugin:%s not found\n",plugin.c_str());
		return eLoadFailedError;
	}

	return eLoadComplete;
}
Esempio n. 6
0
static void ensureLoaded()
{
    if(!g_loaded)
    {
#ifndef GSTPROVIDER_STATIC
        QString pluginFile;
        QString resourcePath;

        pluginFile = qgetenv("PSI_MEDIA_PLUGIN");
        if(pluginFile.isEmpty())
        {
#if defined(Q_OS_WIN)
            pluginFile = findPlugin(".", "gstprovider" DEBUG_POSTFIX);
            resourcePath = QCoreApplication::applicationDirPath() + "/gstreamer-0.10";
#elif defined(Q_OS_MAC)
            pluginFile = findPlugin("../Plugins", "gstprovider" DEBUG_POSTFIX);
            resourcePath = QCoreApplication::applicationDirPath() + "/../Frameworks/gstreamer-0.10";
#else
            foreach(const QString& path, ApplicationInfo::pluginDirs()) {
                pluginFile = findPlugin(path, "gstprovider" DEBUG_POSTFIX);
                if(!pluginFile.isEmpty())
                    break;
            }
/*
    Searches for plugin, that implements the indicator of type \a indicatorType.
    Creates and stores the indicator.
    Does nothing, if indicator is already added.
    Returns true on success and false on failure.
*/
HbIndicatorInterface *HbIndicatorPluginManager::addIndicator(const QString &indicatorType,
    const QVariantMap &securityCredentials, int *errorCode)
{
    TRACE_ENTRY
    int error = HbDeviceDialogNoError;
    if (!errorCode) {
        errorCode = &error;
    }
    HbIndicatorInterface *indicator = 0;
    bool loaded = false;
    bool added = false;
    *errorCode = HbDeviceDialogNoError;

    //search indicator 1. among already loaded plugins.
    int index = findPlugin(indicatorType);
    if (index < 0) {
        //2. search and load the correct plugin.
        index = loadPlugin(indicatorType);
        loaded = true;
    }
    // Allow plugin to do access control
    if (index >= 0) {
        if (!checkAccess(index, indicatorType, securityCredentials)) {
            if (loaded) {
                mPlugins.removeAt(index);
            }
            *errorCode = HbDeviceDialogAccessDeniedError;
            index = -1;
        }
    }
    if (index >= 0) {
        PluginInfo &pluginInfo = mPlugins[index];
        if (!loaded) {
            //check is the indicator is already created.
            foreach(const IndicatorInfo &indicatorInfo,
                     pluginInfo.mAddedIndicators) {
                if (indicatorInfo.indicator->indicatorType() ==
                        indicatorType) {
                    indicator = indicatorInfo.indicator;
                    added = true;
                    break;
                }
            }
        }
Esempio n. 8
0
int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
{
	char file[PLATFORM_MAX_PATH];
	FILE *fp = fopen(build_pathname_r(file, sizeof(file), "%s", filename), "rt");

	if (!fp)
	{
		if (warn)
		{
			AMXXLOG_Error("[AMXX] Plugins list not found (file \"%s\")", filename);
		}
		return 1;
	}

	// Find now folder
	char pluginName[256], error[256], debug[256];
	int debugFlag = 0;
	const char *pluginsDir = get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins");

	char line[512];

	List<ke::AString *>::iterator block_iter;

	while (!feof(fp))
	{
		pluginName[0] = '\0';

		debug[0] = '\0';
		debugFlag = 0;

		line[0] = '\0';
		fgets(line, sizeof(line), fp);

		/** quick hack */
		char *ptr = line;
		while (*ptr)
		{
			if (*ptr == ';')
			{
				*ptr = '\0';
			} else {
				ptr++;
			}
		}
		sscanf(line, "%s %s", pluginName, debug);

		if (!isalnum(*pluginName))
		{
			continue;
		}

		if (isalnum(*debug) && !strcmp(debug, "debug"))
		{
			debugFlag = 1;
		}

		bool skip = false;
		for (block_iter = m_BlockList.begin();
			 block_iter != m_BlockList.end();
			 block_iter++)
		{
			if ((*block_iter)->compare(pluginName) == 0)
			{
				skip = true;
				break;
			}
		}

		if (skip || !strcmp(debug, "disabled"))
		{
			continue;
		}

		if (findPlugin(pluginName) != NULL)
		{
			continue;
		}

		CPlugin* plugin = loadPlugin(pluginsDir, pluginName, error, sizeof(error), debugFlag);

		if (plugin->getStatusCode() == ps_bad_load)
		{
			char errorMsg[255];
			sprintf(errorMsg, "%s (plugin \"%s\")", error, pluginName);
			plugin->setError(errorMsg);
			AMXXLOG_Error("[AMXX] %s", plugin->getError());
		}
		else
		{
			cell addr;
			if (amx_FindPubVar(plugin->getAMX(), "MaxClients", &addr) != AMX_ERR_NOTFOUND)
			{
				*get_amxaddr(plugin->getAMX(), addr) = gpGlobals->maxClients;
			}

			if (amx_FindPubVar(plugin->getAMX(), "MapName", &addr) != AMX_ERR_NOTFOUND)
			{
				set_amxstring(plugin->getAMX(), addr, STRING(gpGlobals->mapname), MAX_MAPNAME_LENGTH - 1);
			}

			if (amx_FindPubVar(plugin->getAMX(), "NULL_STRING", &addr) != AMX_ERR_NOTFOUND)
			{
				plugin->m_pNullStringOfs = get_amxaddr(plugin->getAMX(), addr);
			}

			if (amx_FindPubVar(plugin->getAMX(), "NULL_VECTOR", &addr) != AMX_ERR_NOTFOUND)
			{
				plugin->m_pNullVectorOfs = get_amxaddr(plugin->getAMX(), addr);
			}
		}
	}

	fclose(fp);

	return pCounter;
}
Esempio n. 9
0
int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
{
	char file[256];
	FILE *fp = fopen(build_pathname_r(file, sizeof(file) - 1, "%s", filename), "rt");

	if (!fp) 
	{
		if (warn)
		{
			AMXXLOG_Error("[AMXX] Plugins list not found (file \"%s\")", filename);
		}
		return 1;
	}
	
	// Find now folder
	char pluginName[256], error[256], debug[256];
	int debugFlag = 0;
	const char *pluginsDir = get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins");
	
	String line;

	List<String *>::iterator block_iter;

	while (!feof(fp)) 
	{
		pluginName[0] = '\0';
		
		debug[0] = '\0';
		debugFlag = 0;
		
		line.clear();
		line._fread(fp);
		/** quick hack */
		char *ptr = const_cast<char *>(line.c_str());
		while (*ptr)
		{
			if (*ptr == ';')
			{
				*ptr = '\0';
			} else {
				ptr++;
			}
		}
		sscanf(line.c_str(), "%s %s", pluginName, debug);
		
		if (!isalnum(*pluginName))
		{
			continue;
		}

		if (isalnum(*debug) && !strcmp(debug, "debug"))
		{
			debugFlag = 1;
		}

		bool skip = false;
		for (block_iter = m_BlockList.begin();
			 block_iter != m_BlockList.end();
			 block_iter++)
		{
			if ((*block_iter)->compare(pluginName) == 0)
			{
				skip = true;
				break;
			}
		}

		if (skip || !strcmp(debug, "disabled"))
		{
			continue;
		}

		if (findPlugin(pluginName) != NULL)
		{
			continue;
		}

		CPlugin* plugin = loadPlugin(pluginsDir, pluginName, error, debugFlag);
		
		if (plugin->getStatusCode() == ps_bad_load)
		{
			char errorMsg[255];
			sprintf(errorMsg, "%s (plugin \"%s\")", error, pluginName);
			plugin->setError(errorMsg);
			AMXXLOG_Error("[AMXX] %s", plugin->getError());
		}
	}

	fclose(fp);

	return pCounter;
}
Esempio n. 10
0
int CPluginMngr::loadPluginsFromDir(const char* dir, bool debug ){
	char pluginName[ 256 ],
		error[ 256 ],
		dirFull[ 256 ];

	char * ext = 0;

	#if defined WIN32
	build_pathname_r( dirFull , sizeof( dirFull ) , "%s\\*" , dir );

	_finddata_t fd;
	intptr_t handle = _findfirst( dirFull , &fd);

	if (handle < 0){
		return 0;
	}

	while (!_findnext(handle, &fd)){
		if ( !strcmp ( fd.name , ".") || !strcmp ( fd.name , "..") ){
		  continue;
		}

       	ext = strrchr( fd.name, '.' );

       	if( !ext || strcmp( ext , ".amxx" ) ){
       		continue;
       	}

       	*ext = '\0';

       	strncpy( pluginName , fd.name , ext - ( fd.name ) );

       	pluginName[ ext - ( fd.name ) ] = '\0';

		if ( findPlugin( pluginName ) != NULL ){
			continue;
		}

		CPlugin* plugin = loadPlugin( dir, fd.name, error, debug , pluginName );
		
		if (plugin->getStatusCode() == ps_bad_load){
			char errorMsg[255];
			sprintf(errorMsg, "%s (plugin \"%s\")", error, pluginName);
			plugin->setError(errorMsg);
			AMXXLOG_Error("[AMXX] %s", plugin->getError());
		}
	}

	_findclose(handle);
#elif defined(__linux__) || defined(__APPLE__)
	build_pathname_r( dirFull , sizeof( dirFull ) , "%s" , dir );
	struct dirent *ep;
	DIR *dp;

	if (( dp = opendir( dirFull ) ) == NULL ){
		return 0;
	}

	while ( ( ep = readdir( dp )) != NULL ){

		if ( !strcmp ( ep -> d_name , ".") || !strcmp ( ep -> d_name , "..") ){
            continue;
		}

       	ext = strrchr( ep -> d_name, '.' );

       	if( !ext || strcmp( ext , ".amxx" ) ){
       		continue;
       	}
       	strncpy( pluginName , ep -> d_name , ext - ( ep -> d_name ) );

       	pluginName[ ext - ( ep -> d_name ) ] = '\0';

		if ( findPlugin( pluginName ) != NULL ){
			continue;
		}

		CPlugin* plugin = loadPlugin( dir, ep -> d_name, error, debug , pluginName );
		
		if (plugin->getStatusCode() == ps_bad_load){
			char errorMsg[255];
			sprintf(errorMsg, "%s (plugin \"%s\")", error, pluginName);
			plugin->setError(errorMsg);
			AMXXLOG_Error("[AMXX] %s", plugin->getError());
		}
	}

	closedir (dp);
#endif

	return pCounter;
}
Esempio n. 11
0
 void PluginLoader::loadPlugins()
 {
   QDir libdir(QLatin1String(PLUGINS_DIR));
   if (!libdir.exists() || !findPlugin(libdir))
     qWarning() << "Plugins not found in " << libdir.absolutePath();
 }