status_t TEncoderAddonManager::LoadAddons(const char *addondDir)
{
	fp_text_convert_t fp_text_convert;
	image_id id;
	BDirectory dir(addondDir);
	BEntry entry;
	
	// load encoders add-on
	while (dir.GetNextEntry(&entry) == B_OK) {
		BPath addonPath(&entry);
		if ((id = load_add_on(addonPath.Path())) < 0) continue;
		if (get_image_symbol(id, "fp_text_convert", B_SYMBOL_TYPE_TEXT, (void **)&fp_text_convert)) {
			unload_add_on(id);
			continue;
		}
		encoder_addon_t *addon = (encoder_addon_t *)malloc(sizeof(encoder_addon_t));
		if (!addon) {
			fprintf(stderr, "%s\n", strerror(ENOMEM));
			unload_add_on(id);
			return ENOMEM;
		}
		addon->id = id;
		addon->fp_text_convert = fp_text_convert;
		strncpy(addon->name, addonPath.Leaf(), sizeof(addon->name));
		fEncoderAddonList.AddItem(addon);
		fprintf(stderr, "load: %s\n", addon->name);
	}
	return B_OK;
}
Пример #2
0
void
CayaProtocolAddOn::_Init()
{
    const char* (*signature)();
    const char* (*friendly_signature)();

    fStatus = B_OK;

    if (get_image_symbol(fImage, "protocol", B_SYMBOL_TYPE_TEXT,
                         (void**)&fGetProtocol) != B_OK) {
        unload_add_on(fImage);
        fStatus = B_ERROR;
        return;
    }

    if (get_image_symbol(fImage, "signature", B_SYMBOL_TYPE_TEXT,
                         (void**)&signature) != B_OK) {
        unload_add_on(fImage);
        fStatus = B_ERROR;
        return;
    }

    if (get_image_symbol(fImage, "friendly_signature", B_SYMBOL_TYPE_TEXT,
                         (void**)&friendly_signature) != B_OK) {
        unload_add_on(fImage);
        fStatus = B_ERROR;
        return;
    }

    fSignature = signature();
    fFriendlySignature = friendly_signature();
}
PrinterDriverAddOn::~PrinterDriverAddOn()
{
	if (IsLoaded()) {
		unload_add_on(fAddOnID);
		fAddOnID = -1;
	}
}
Пример #4
0
bool
BTranslatorRoster::IsTranslator(entry_ref* ref)
{
	if (ref == NULL)
		return false;

	BPath path(ref);
	image_id image = load_add_on(path.Path());
	if (image < B_OK)
		return false;

	// Function pointer used to create post R4.5 style translators
	BTranslator* (*makeNthTranslator)(int32 n, image_id you, uint32 flags, ...);

	status_t status = get_image_symbol(image, "make_nth_translator",
		B_SYMBOL_TYPE_TEXT, (void**)&makeNthTranslator);
	if (status < B_OK) {
		// If this is a translator add-on, it is in the C format
		translator_data translatorData;
		status = fPrivate->GetTranslatorData(image, translatorData);
	}

	unload_add_on(image);
	return status == B_OK;
}
Пример #5
0
void
PluginManager::PutPlugin(MediaPlugin* plugin)
{
	TRACE("PluginManager::PutPlugin()\n");
	fLocker.Lock();
	
	plugin_info* pinfo;
	
	for (fPluginList.Rewind(); fPluginList.GetNext(&pinfo); ) {
		if (plugin == pinfo->plugin) {
			pinfo->usecount--;
			if (pinfo->usecount == 0) {
				TRACE("  deleting %p\n", pinfo->plugin);
				delete pinfo->plugin;
				TRACE("  unloading add-on: %ld\n\n", pinfo->image);
				unload_add_on(pinfo->image);
				fPluginList.RemoveCurrent();
			}
			fLocker.Unlock();
			return;
		}
	}
	
	printf("PluginManager: Error, can't put PlugIn %p\n", plugin);
	
	fLocker.Unlock();
}
Пример #6
0
static int beos_unload (DSO * dso)
{
    image_id id;

    if (dso == NULL)
    {
        DSOerr (DSO_F_BEOS_UNLOAD, ERR_R_PASSED_NULL_PARAMETER);
        return (0);
    }
    if (sk_num (dso->meth_data) < 1)
        return (1);
    id = (image_id) sk_pop (dso->meth_data);
    if (id < 1)
    {
        DSOerr (DSO_F_BEOS_UNLOAD, DSO_R_NULL_HANDLE);
        return (0);
    }
    if (unload_add_on (id) != B_OK)
    {
        DSOerr (DSO_F_BEOS_UNLOAD, DSO_R_UNLOAD_FAILED);
        /* We should push the value back onto the stack in
         * case of a retry. */
        sk_push (dso->meth_data, (char *) id);
        return (0);
    }
    return (1);
}
Пример #7
0
status_t
DecorManager::SetDecorator(BString path, Desktop* desktop)
{
	status_t error = B_OK;
	DecorAddOn* newDecor = _LoadDecor(path, error);
	if (newDecor == NULL)
		return error == B_OK ? B_ERROR : error;

	DecorAddOn* oldDecor = fCurrentDecor;
	BString oldPath = fCurrentDecorPath;
	image_id oldImage = fCurrentDecor->ImageID();

	fCurrentDecor = newDecor;
	fCurrentDecorPath = path.String();

	if (desktop->ReloadDecor()) {
		// now safe to unload all old decorator data
		// saves us from deleting oldDecor...
		unload_add_on(oldImage);
		_SaveSettingsToDisk();
		return B_OK;
	}

	// TODO: unloading the newDecor and its image
	// problem is we don't know how many windows failed... or why they failed...
	syslog(LOG_WARNING,
		"app_server:DecorManager:SetDecorator:\"%s\" *partly* failed\n",
		fCurrentDecorPath.String());

	fCurrentDecor = oldDecor;
	fCurrentDecorPath = oldPath;
	return B_ERROR;
}
Пример #8
0
bool BeHappy::CheckAddOn(const char *path,bool alert,BString *pName)
{
	image_id addOnImage = load_add_on(path);
	void *instFunc;
	const char **projName;
	const uint16 *BHVersion,*BHVLastCompatible;
	bool ok = false;
	BPath aoPath(path);
	
	BString alTxt(aoPath.Leaf());		// chaîne utilisée pour générer des alertes d'erreur

	if ((addOnImage>=0) &&
		(get_image_symbol(addOnImage,"InstantiateProject",B_SYMBOL_TYPE_ANY,&instFunc) == B_OK) &&
		(get_image_symbol(addOnImage,"projectName",B_SYMBOL_TYPE_ANY,(void**)&projName) == B_OK) &&
		(get_image_symbol(addOnImage,"BHVersion",B_SYMBOL_TYPE_ANY,(void**)&BHVersion) == B_OK) &&
		(get_image_symbol(addOnImage,"BHVLastCompatible",B_SYMBOL_TYPE_ANY,(void**)&BHVLastCompatible) == B_OK))
	{
		if ((*BHVLastCompatible) > bhv_application)
		{
			if (alert)
			{
				alTxt << " " << T("isn't compatible with this (old) version of BeHappy. Please download a more recent version of BeHappy.");
				BAlert *myAlert = new BAlert("BeHappy",alTxt.String(),"OK",
					NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT);
				myAlert->Go();
			}
		}
		else if ((*BHVersion) < bhv_last_addon)
		{
			if (alert)
			{
				alTxt << " " << T("is too old, and isn't compatible with this version of BeHappy. Please find a more recent version of the add-on.");
				BAlert *myAlert = new BAlert("BeHappy",alTxt.String(),"OK",
					NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT);
				myAlert->Go();
			}
		}
		else
		{
			ok = true;
			if (pName != NULL)
				*pName=*projName;
		}					
	}
	else	
	{
		if (alert)
		{
			alTxt << " " << T("is an invalid BeHappy add-on.");
			BAlert *myAlert = new BAlert("BeHappy",alTxt.String(),"OK",
				NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT);
			myAlert->Go();
		}
	}
	
	if (addOnImage>=0)
		unload_add_on(addOnImage);

	return ok;
}
Пример #9
0
static int beos_load (DSO * dso)
{
    image_id id;

    /* See applicable comments from dso_dl.c */
    char *filename = DSO_convert_filename (dso, NULL);

    if (filename == NULL)
    {
        DSOerr (DSO_F_BEOS_LOAD, DSO_R_NO_FILENAME);
        goto err;
    }
    id = load_add_on (filename);
    if (id < 1)
    {
        DSOerr (DSO_F_BEOS_LOAD, DSO_R_LOAD_FAILED);
        ERR_add_error_data (3, "filename(", filename, ")");
        goto err;
    }
    if (!sk_push (dso->meth_data, (char *) id))
    {
        DSOerr (DSO_F_BEOS_LOAD, DSO_R_STACK_ERROR);
        goto err;
    }
    /* Success */
    dso->loaded_filename = filename;
    return (1);
  err:
    /* Cleanup ! */
    if (filename != NULL)
        OPENSSL_free (filename);
    if (id > 0)
        unload_add_on (id);
    return (0);
}
Пример #10
0
// Unload
void
AddOnImage::Unload()
{
	if (fID >= 0) {
		unload_add_on(fID);
		fID = -1;
	}
}
Пример #11
0
void ArpAddonManager::BasicAddon::Close(void)
{
	if( --ref_count <= 0 ) {
		if( image >= 0 ) unload_add_on(image);
		image = B_ERROR;
		ref_count = 0;
	}
}
Пример #12
0
/*
=================
Sys_UnloadDll

=================
*/
void Sys_UnloadDll(void *dllHandle) {
	// bk001206 - verbose error reporting
	if (!dllHandle) {
		Com_Printf("Sys_UnloadDll(NULL)\n");
		return;
	}
	unload_add_on((long int)dllHandle);
}
Пример #13
0
int
main(int argc, char **argv)
{
	// Parse command line arguments

	bool ignorePunctuation = false;
	char *addon = NULL;
	BCollator *collator = NULL;

	while ((++argv)[0]) {
		if (argv[0][0] == '-') {
			if (!strcmp(argv[0], "-i"))
				ignorePunctuation = true;
			else if (!strcmp(argv[0], "--help"))
				usage();
		} else {
			// this will be the add-on to be loaded
			addon = argv[0];
		}
	}

	// load the collator add-on if necessary

	if (addon != NULL) {
		image_id image = load_add_on(addon);
		if (image < B_OK)
			fprintf(stderr, "could not load add-on at \"%s\": %s.\n", addon, strerror(image));

		BCollatorAddOn *(*instantiate)(void);
		if (get_image_symbol(image, "instantiate_collator",
				B_SYMBOL_TYPE_TEXT, (void **)&instantiate) == B_OK) {
			BCollatorAddOn *collatorAddOn = instantiate();
			if (collatorAddOn != NULL)
				collator = new BCollator(collatorAddOn, B_COLLATE_PRIMARY, true);
		} else if (image >= B_OK) {
			fprintf(stderr, "could not find instantiate_collator() function in add-on!\n");
			unload_add_on(image);
		}
	}

	if (collator == NULL) {
		collator = be_locale->Collator();
		addon = (char*)"default";
	}

	// test key creation speed

	collator->SetIgnorePunctuation(ignorePunctuation);

	printf("%s:\n", addon);
	test(collator, "primary:   ", B_COLLATE_PRIMARY);
	test(collator, "secondary: ", B_COLLATE_SECONDARY);
	test(collator, "tertiary:  ", B_COLLATE_TERTIARY);
	test(collator, "quaternary:", B_COLLATE_QUATERNARY);
	test(collator, "identical: ", B_COLLATE_IDENTICAL);

	return 0;
}
Пример #14
0
ServerSettingsView::~ServerSettingsView()
{
	// Remove manually, as their code may be located in an add-on
	RemoveChild(fInboundAuthMenu);
	RemoveChild(fInboundEncryptionMenu);
	delete fInboundAuthMenu;
	delete fInboundEncryptionMenu;
	unload_add_on(fImageID);
}
Пример #15
0
/*------------------------------------------------------------------------------*\
	UnloadAddons()
		-	unloads all loaded filter-addons
\*------------------------------------------------------------------------------*/
void BmFilterList::UnloadAddons() {
	mLearnAsSpamFilter = NULL;
	mLearnAsTofuFilter = NULL;
	BmFilterAddonMap::const_iterator iter;
	for( iter = FilterAddonMap.begin(); iter != FilterAddonMap.end(); ++iter) {
		unload_add_on( iter->second.image);
	}
	FilterAddonMap.clear();
}
Пример #16
0
void
SDL_UnloadObject(void *handle)
{
    image_id library_id;
    if (handle != NULL) {
        library_id = (image_id) handle;
        unload_add_on(library_id);
    }
}
void TEncoderAddonManager::UnloadAddons()
{
	for(int32 i = 0; i < fEncoderAddonList.CountItems(); i++) {
		encoder_addon_t *addon = (encoder_addon_t *)fEncoderAddonList.ItemAt(i);
		fprintf(stderr, "unload: %s\n", addon->name);
		unload_add_on(addon->id);
		free(addon);
	}
	fCurrentFunc = NULL;
}
Пример #18
0
/* Whack an item; the item is an image_id in disguise, so we'll call
 * unload_add_on() for it.
 */
static void beos_nuke_dyn( PyObject *item )
{
	status_t retval;

	if( item ) {
		image_id id = (image_id)PyInt_AsLong( item );
		
		retval = unload_add_on( id );
	}
}
Пример #19
0
void
DormantNodeManager::_UnloadAddOn(BMediaAddOn* addOn, image_id image)
{
	ASSERT(addOn != NULL);
	ASSERT(addOn->ImageID() == image);
		// if this fails, something bad happened to the add-on

	delete addOn;
	unload_add_on(image);
}
Пример #20
0
status_t
DormantNodeManager::_LoadAddOn(const char* path, media_addon_id id,
	BMediaAddOn** _newAddOn, image_id* _newImage)
{
	image_id image = load_add_on(path);
	if (image < 0) {
		ERROR("DormantNodeManager::LoadAddon: loading \"%s\" failed: %s\n",
			path, strerror(image));
		return image;
	}

	BMediaAddOn* (*makeAddOn)(image_id);
	status_t status = get_image_symbol(image, "make_media_addon",
		B_SYMBOL_TYPE_TEXT, (void**)&makeAddOn);
	if (status != B_OK) {
		ERROR("DormantNodeManager::LoadAddon: loading failed, function not "
			"found: %s\n", strerror(status));
		unload_add_on(image);
		return status;
	}

	BMediaAddOn* addOn = makeAddOn(image);
	if (addOn == NULL) {
		ERROR("DormantNodeManager::LoadAddon: creating BMediaAddOn failed\n");
		unload_add_on(image);
		return B_ERROR;
	}

	ASSERT(addOn->ImageID() == image);
		// this should be true for a well behaving add-ons

	// We are a friend class of BMediaAddOn and initialize these member
	// variables
	addOn->fAddon = id;
	addOn->fImage = image;

	// everything ok
	*_newAddOn = addOn;
	*_newImage = image;

	return B_OK;
}
void
CatalogAddOnInfo::UnloadIfPossible()
{
	if (!fIsEmbedded && fLoadedCatalogs.IsEmpty()) {
		unload_add_on(fAddOnImage);
		fAddOnImage = B_NO_INIT;
		fInstantiateFunc = NULL;
		fCreateFunc = NULL;
		fLanguagesFunc = NULL;
	}
}
void
ScreenSaverRunner::_CleanUp()
{
	delete fSaver;
	fSaver = NULL;

	if (fAddonImage >= 0) {
		unload_add_on(fAddonImage);
		fAddonImage = -1;
	}
}
static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
{
    image_id lib = load_add_on(fname);
    void *retval = NULL;
    if (lib >= 0) {
        if (get_image_symbol(lib, sym, B_SYMBOL_TYPE_TEXT, &retval) != B_NO_ERROR) {
            unload_add_on(lib);
            retval = NULL;
        }
    }
    return retval;
}
Пример #24
0
PluginManager::~PluginManager()
{
	CALLED();
	for (int i = fPluginList.CountItems() - 1; i >= 0; i--) {
		plugin_info* info = NULL;
		fPluginList.Get(i, &info);
		TRACE("PluginManager: Error, unloading PlugIn %s with usecount "
			"%d\n", info->name, info->usecount);
		delete info->plugin;
		unload_add_on(info->image);
	}
}
Пример #25
0
//------------------------------------------------------------------------------
void TInstantiateObjectTester::UnloadAddon()
{
	if (fAddonId > 0)
	{
		status_t err = unload_add_on(fAddonId);
		fAddonId = B_ERROR;
		if (err)
		{
			FORMAT_AND_THROW(" failed to unload addon: ", err);
		}
	}
}
Пример #26
0
static int
xmlModulePlatformClose(void *handle)
{
    status_t rc;

    rc = unload_add_on((image_id) handle);

    if (rc == B_OK)
        return 0;
    else
        return -1;
}
Пример #27
0
PrintTransport::~PrintTransport()
{
	if (fExitProc) {
		(*fExitProc)();
		fExitProc = NULL;
	}

	if (fAddOnID >= 0) {
		unload_add_on(fAddOnID);
		fAddOnID = -1;
	}
}
Пример #28
0
void
IndexServer::RegisterAddOn(entry_ref ref)
{
	STRACE("RegisterAddOn %s\n", ref.name);

	BPath path(&ref);
	image_id image = load_add_on(path.Path());
	if (image < 0)
		return;

	create_index_server_addon* createFunc;

	// Get the instantiation function
	status_t status = get_image_symbol(image, "instantiate_index_server_addon",
		B_SYMBOL_TYPE_TEXT, (void**)&createFunc);
	if (status != B_OK) {
		unload_add_on(image);
		return;
	}

	IndexServerAddOn* addon = createFunc(image, ref.name);
	if (!addon) {
		unload_add_on(image);
		return;
	}
	if (!fAddOnList.AddItem(addon)) {
		unload_add_on(image);
		return;
	}

	for (int i = 0; i < fVolumeWatcherList.CountItems(); i++) {
		VolumeWatcher* watcher = fVolumeWatcherList.ItemAt(i);
		FileAnalyser* analyser = _SetupFileAnalyser(addon, watcher->Volume());
		if (!analyser)
			continue;
		if (!watcher->AddAnalyser(analyser))
			delete analyser;
	}

}
Пример #29
0
DecorAddOn*
DecorManager::_LoadDecor(BString _path, status_t& error )
{
	if (_path == "Default") {
		error = B_OK;
		return &fDefaultDecor;
	}

	BEntry entry(_path.String(), true);
	if (!entry.Exists()) {
		error = B_ENTRY_NOT_FOUND;
		return NULL;
	}

	BPath path(&entry);
	image_id image = load_add_on(path.Path());
	if (image < 0) {
		error = B_BAD_IMAGE_ID;
		return NULL;
	}

	create_decor_addon*	createFunc;
	if (get_image_symbol(image, "instantiate_decor_addon", B_SYMBOL_TYPE_TEXT,
			(void**)&createFunc) != B_OK) {
		unload_add_on(image);
		error = B_MISSING_SYMBOL;
		return NULL;
	}

	char name[B_FILE_NAME_LENGTH];
	entry.GetName(name);
	DecorAddOn* newDecor = createFunc(image, name);
	if (newDecor == NULL || newDecor->InitCheck() != B_OK) {
		unload_add_on(image);
		error = B_ERROR;
		return NULL;
	}

	return newDecor;
}
Пример #30
0
status_t
PluginManager::_LoadPlugin(const entry_ref& ref, MediaPlugin** plugin,
	image_id* image)
{
	BPath p(&ref);

	TRACE("PluginManager: _LoadPlugin trying to load %s\n", p.Path());

	image_id id;
	id = load_add_on(p.Path());
	if (id < 0) {
		printf("PluginManager: Error, load_add_on(): %s\n", strerror(id));
		return B_ERROR;
	}
		
	MediaPlugin* (*instantiate_plugin_func)();
	
	if (get_image_symbol(id, "instantiate_plugin", B_SYMBOL_TYPE_TEXT,
			(void**)&instantiate_plugin_func) < B_OK) {
		printf("PluginManager: Error, _LoadPlugin can't find "
			"instantiate_plugin in %s\n", p.Path());
		unload_add_on(id);
		return B_ERROR;
	}
	
	MediaPlugin *pl;
	
	pl = (*instantiate_plugin_func)();
	if (pl == NULL) {
		printf("PluginManager: Error, _LoadPlugin instantiate_plugin in %s "
			"returned NULL\n", p.Path());
		unload_add_on(id);
		return B_ERROR;
	}
	
	*plugin = pl;
	*image = id;
	return B_OK;
}