⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plugin.h

📁 linux集群服务器软件代码包
💻 H
📖 第 1 页 / 共 2 页
字号:
#define IS_PILPLUGINTYPE(s)	((s)->MagicNum == PIL_MAGIC_PLUGINTYPE)#define IS_PILPLUGINUNIV(s)	((s)->MagicNum == PIL_MAGIC_PLUGINUNIV)#define IS_PILINTERFACE(s)	((s)->MagicNum == PIL_MAGIC_INTERFACE)#define IS_PILINTERFACETYPE(s)	((s)->MagicNum == PIL_MAGIC_INTERFACETYPE)#define IS_PILINTERFACEUNIV(s)	((s)->MagicNum == PIL_MAGIC_INTERFACEUNIV)/* This is the place where PILS installs its own plugins */#define	PILS_BASE_PLUGINDIR	"/usr/lib/pils/plugins"/* The type of a Plugin Initialization Function */typedef PIL_rc (*PILPluginInitFun) (PILPlugin*us,		PILPluginImports* imports,		void*	plugin_user_data);/* * struct PILPluginOps_s (typedef PILPluginOps) defines the set of functions * exported by all plugins... */struct PILPluginOps_s {	const char*	(*pluginversion) (void);	int		(*getdebuglevel) (void);	void		(*setdebuglevel) (int);	const char*	(*license) (void);	const char*	(*licenseurl) (void);	void		(*close) (PILPlugin*);};/* *	Logging levels for the "standard" log interface. */typedef enum {	PIL_FATAL= 1,	/* BOOM! Causes program to stop */	PIL_CRIT	= 2,	/* Critical -- serious error */	PIL_WARN	= 3,	/* Warning */	PIL_INFO	= 4,	/* Informative message */	PIL_DEBUG= 5	/* Debug message */}PILLogLevel;typedef void (*PILLogFun)(PILLogLevel priority, const char * fmt, ...);/* * struct PILPluginImports_s (typedef PILPluginImports) defines * the functions and capabilities that every plugin imports when it is loaded. */struct PILPluginImports_s {	PIL_rc	(*register_plugin)(PILPlugin* piinfo	,	const PILPluginOps* commonops);	PIL_rc	(*unregister_plugin)(PILPlugin* piinfo);/* *	A little explanation of the close_func parameter to register_interface *	is in order. * *	It is an exported operation function, just like the Ops structure. *	However, the Ops vector is exported to applications that *	are using the interface. Unlike the Ops structure, close_func is *	exported only to the interface system, since applications shouldn't *	call it directly, but should manage the reference counts for the *	interfaces instead. *	The generic interface system doesn't have any idea how to call *	any functions in the operations vector.  So, it's a separate *	parameter for two good reasons. */	PIL_rc	(*register_interface)(PILPlugin* piinfo	,	const char *	interfacetype	/* Type of interface	*/	,	const char *	interfacename	/* Name of interface	*/	,	void*		Ops		/* Info (functions) exported						   by this interface	*/		/* Function to call to shut down this interface */	,	PILInterfaceFun	close_func	,	PILInterface**	interfaceid /* Interface id 	(OP)	*/	,	void**		Imports	,	void*		ud_interface);	/* interface user data */	PIL_rc	(*unregister_interface)(PILInterface* interfaceid);	PIL_rc	(*load_plugin)(PILPluginUniv* universe	,	const char * plugintype, const char * pluginname	,	void*	plugin_private);	void	(*log)	(PILLogLevel priority, const char * fmt, ...);	void*	(*alloc)(unsigned long size);	void*	(*mrealloc)(void * ptr, unsigned long size);	void	(*mfree)(void* space);	char*	(*mstrdup)(const char *s);};/* * Function for logging with the given logging function * The reason why it's here is so we can get printf arg checking * You can't get that when you call a function pointer directly. */void PILCallLog(PILLogFun logfun, PILLogLevel priority, const char * fmt, ...)	G_GNUC_PRINTF(3,4);/* * EXPORTED INTERFACES... *//* Create a new plugin universe - start the plugin loading system up */PILPluginUniv*	NewPILPluginUniv(const char * baseplugindirectory);/* Change memory allocation functions right after creating universe */void PilPluginUnivSetMemalloc(PILPluginUniv*,	void*	(*alloc)(unsigned long size),	void*	(*mrealloc)(void *, unsigned long size),	void	(*mfree)(void* space),	char*	(*mstrdup)(const char *s));void PilPluginUnivSetLog(PILPluginUniv*,	void	(*log)	(PILLogLevel priority, const char * fmt, ...));/* Delete a plugin universe - shut the plugin loading system down *//*	Best if used carefully ;-) */void		DelPILPluginUniv(PILPluginUniv*);/* Set the debug level for the plugin system itself */void		PILpisysSetDebugLevel (int level);/* Return a list of plugins of the given type */char **		PILListPlugins(PILPluginUniv* u, const char *plugintype,		int* plugincount /*can be NULL*/);/* Free the plugin list returned by PILFreeListPlugins */void		PILFreePluginList(char ** pluginlist);/* Load the requested plugin */PIL_rc		PILLoadPlugin(PILPluginUniv* piuniv,		const char *	plugintype,		const char *	pluginname,		void *		pi_private);/* Return  PIL_OK if the given  plugin exists */PIL_rc		PILPluginExists(PILPluginUniv* piuniv,		const char *	plugintype,		const char *	pluginname);/* Either or both of pitype and piname may be NULL */void		PILSetDebugLevel(PILPluginUniv*u, const char * pitype,		const char * piname,		int level);/* Neither pitype nor piname may be NULL */int		PILGetDebugLevel(PILPluginUniv* u, const char * pitype,		const char * piname);PIL_rc		PILIncrIFRefCount(PILPluginUniv* piuniv,		const char *	interfacetype,		const char *	interfacename,		int	plusminus);int		PILGetIFRefCount(PILPluginUniv* piuniv,		const char *	interfacetype,		const char *	interfacename);void PILLogMemStats(void);/* The plugin/interface type of a interface manager */#define	PI_IFMANAGER		"InterfaceMgr"#define	PI_IFMANAGER_TYPE	InterfaceMgr/* *      These functions are standard exported functions for all plugins. */#define PIL_PLUGIN_BOILERPLATE_PROTOTYPES_GENERIC(PluginVersion, DebugName) \/*								\ * Prototypes for boilerplate functions				\ */								\static const char*      Ourpluginversion(void);			\static int              GetOurDebugLevel(void);			\static void             SetOurDebugLevel(int);			\static const char *	ReturnOurLicense(void);			\static const char *	ReturnOurLicenseURL(void);#define	PIL_PLUGIN_BOILERPLATE_FUNCS(PluginVersion, DebugName)	\/*								\ * Definitions of boilerplate functions				\ */								\static const char*						\Ourpluginversion(void)						\{ return PluginVersion; }					\								\static int DebugName = 0;					\								\static int							\GetOurDebugLevel(void)						\{ return DebugName; }						\								\static void							\SetOurDebugLevel(int level)					\{ DebugName = level; }						\								\static const char *						\ReturnOurLicense(void)						\{ return PIL_PLUGINLICENSE; }					\								\static const char *						\ReturnOurLicenseURL(void)					\{ return PIL_PLUGINLICENSEURL; }#define PIL_PLUGIN_BOILERPLATE(PluginVersion, DebugName, CloseName) \PIL_PLUGIN_BOILERPLATE_PROTOTYPES_GENERIC(PluginVersion, DebugName) \static void             CloseName(PILPlugin*);			\/*								\ * Initialize Plugin Exports structure				\ */								\static PILPluginOps OurPIExports =				\{	Ourpluginversion					\,	GetOurDebugLevel					\,	SetOurDebugLevel					\,	ReturnOurLicense					\,	ReturnOurLicenseURL					\,	CloseName						\};								\PIL_PLUGIN_BOILERPLATE_FUNCS(PluginVersion, DebugName)#define PIL_PLUGIN_BOILERPLATE2(PluginVersion, DebugName)	\PIL_PLUGIN_BOILERPLATE_PROTOTYPES_GENERIC(PluginVersion, DebugName) \/*								\ * Initialize Plugin Exports structure				\ */								\static PILPluginOps OurPIExports =				\{	Ourpluginversion					\,	GetOurDebugLevel					\,	SetOurDebugLevel					\,	ReturnOurLicense					\,	ReturnOurLicenseURL					\,	NULL							\};								\PIL_PLUGIN_BOILERPLATE_FUNCS(PluginVersion, DebugName)/* A few sample licenses and URLs.  We can easily add to this */#define	LICENSE_GPL	 "gpl"#define	URL_GPL		"http://www.fsf.org/licenses/gpl.html"#define	LICENSE_LGPL	"lgpl"#define	URL_LGPL	"http://www.fsf.org/licenses/lgpl.html"#define	LICENSE_X11	"x11"#define	URL_X11		"http://www.x.org/terms.htm"#define	LICENSE_PUBDOM	"publicdomain"#define	URL_PUBDOM	"file:///dev/null"#define	LICENSE_MODBSD	"modbsd"#define	URL_MODBSD	"http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5"#define	LICENSE_OLDBSD	"origbsd"#define	URL_OLDBSD	"http://www.xfree86.org/3.3.6/COPYRIGHT2.html#6"#define	LICENSE_EXPAT	"expat"#define	URL_EXPAT	"http://www.jclark.com/xml/copying.txt"#define LICENSE_ZLIB	"zlib"#define URL_ZLIB	"http://www.gzip.org/zlib/zlib_license.html"#define	LICENSE_APACHE_10 "apache1_0"#define	URL_APACHE_10	"http://www.apache.org/LICENSE-1.0"#define	LICENSE_APACHE_11 "apache1_1"#define	URL_APACHE_11	"http://www.apache.org/LICENSE-1.1"#define	LICENSE_MPL	"mpl"#define	URL_MPL		"http://www.mozilla.org/MPL/MPL-1.1.html"#define	LICENSE_PROP	"proprietary"#define	URL_PROP	""#define	LICENSE_IBMPL	"ibmpl"#define	URL_IBMPL	"http://oss.software.ibm.com/developerworks/opensource/license10.html"#ifdef ENABLE_PIL_DEFS_PRIVATE/* Perhaps these should be moved to a different header file *//* * PILPluginType is the "class" for the basic plugin loading mechanism. * * To enable loading of plugins from a particular plugin type * one calls NewPILPluginType with the plugin type name, the plugin * base directory, and the set of functions to be imported to the plugin. * * * The general idea of these structures is as follows: * * The PILPluginUniv object contains information about all plugins of * all types. * * The PILPluginType object contains information about all the plugins of a * specific type. * * Note: for plugins which implement a single interface, the plugin type name * should be the same as the interface type name. * * For other plugins that implement more than one interface, one of * the interface names should normally match the plugin name. *//* * struct PILPlugin_s (typedef PILPlugin) is the structure which * represents/defines a plugin, and is used to identify which plugin is * being referred to in various function calls. * * NOTE: It may be the case that this definition should be moved to * another header file - since no one ought to be messing with them anyway ;-) * * I'm not sure that we're putting the right stuff in here, either... */struct PILPlugin_s {	unsigned long	MagicNum;		char*		plugin_name;	PILPluginType*	plugintype;	/* Parent structure */	int		refcnt;		/* Reference count for this plugin */	lt_dlhandle	dlhandle;	/* Reference to D.L. object */	PILPluginInitFun dlinitfun;	/* Initialization function */	const PILPluginOps* pluginops;	/* Exported plugin operations */	void*		ud_plugin;	/* Plugin-Private data */	/* Other stuff goes here ...  (?) */};/* *	PILPluginType		Information about all plugins of a given type. *					(i.e.,  in a given directory) *				(AKA struct PILPluginType_s) */struct PILPluginType_s {	unsigned long		MagicNum;		char *			plugintype;	PILPluginUniv*		piuniv; /* The universe to which we belong */	GHashTable*		Plugins;				/* Key is plugin type, value is PILPlugin */	char**	(*listplugins)(PILPluginType*, int* listlen);};/* *	PILPluginUniv (aka struct PILPluginUniv_s) is the structure which *	represents the universe of all PILPluginType objects. *	There is one PILPluginType object for each Plugin type. */struct PILPluginUniv_s {	unsigned long		MagicNum;		char **			rootdirlist;			/* key is plugin type, data is PILPluginType* */	GHashTable*		PluginTypes;	struct PILInterfaceUniv_s*ifuniv; /* Universe of interfaces */	PILPluginImports*	imports;};#  endif /* ENABLE_PIL_DEFS_PRIVATE */#endif /*PILS_PLUGIN_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -