📄 plugin.h
字号:
#ifndef __PLUGIN_HEADER_INCLUDED__#define __PLUGIN_HEADER_INCLUDED__/* requires: sys/types.h *//* requires: firestorm.h */#define PLUGIN_ERR_OK 0 /* success */#define PLUGIN_ERR_FAIL 1 /* some internal failure */#define PLUGIN_ERR_PARAM 2 /* bad parameter */#define PLUGIN_ERR_NOMEM 3 /* ran out of memory during initialisation */#define PLUGIN_ERR_SIZE 4 /* wrong sized object */#define PLUGIN_ERR_OBJECT 5 /* couldn't load an object *//* TODO: If anyone knows the pre-processor wizardry to make this nicer * then please please email me. I can't quite get the stringification * working right... */#define PLUGIN_INIT firestorm_plugin_init2#define plugin_init "firestorm_plugin_init2"#define PLUGIN_UNLOAD firestorm_plugin_unload2#define plugin_unload "firestorm_plugin_unload2"#define PLUGIN_DECODE firestorm_plugin_decode#define plugin_decode "firestorm_plugin_decode"#define PLUGIN_CAPDEV firestorm_plugin_capdev#define plugin_capdev "firestorm_plugin_capdev"#define PLUGIN_PREPROC firestorm_plugin_preproc#define plugin_preproc "firestorm_plugin_preproc"#define PLUGIN_MATCHER firestorm_plugin_matcher#define plugin_matcher "firestorm_plugin_matcher"#define PLUGIN_PARSER firestorm_plugin_parser#define plugin_parser "firestorm_plugin_parser"#define PLUGIN_TARGET firestorm_plugin_target#define plugin_target "firestorm_plugin_target"typedef void *(*proc_plugin_import)(const char *);/* Host sends this to plugin */struct plugin_in { size_t size; proc_plugin_import import;};/* Plugin sends this to host */struct plugin_out { size_t size; const char *name; const char *desc; unsigned int ver_major; unsigned int ver_minor; const char *author_name; const char *author_email; const char *license;};typedef int (*proc_plugin_init)(struct plugin_in *, struct plugin_out *);typedef int (*proc_plugin_unload)(int);/* Plugin helper macros */#ifdef __PLUGIN__/* Standard definitions for plugins */#define PLUGIN_STD_DEFS() \ proc_mesg mesg;/* And the declarations */extern proc_mesg mesg;/* check parameters in init() function */#define plugin_check(x, y) \ do { \ if ( !x || !y ) \ return PLUGIN_ERR_PARAM; \ if ( x->size != sizeof(struct plugin_in) ) \ return PLUGIN_ERR_SIZE; \ if ( y->size != sizeof(struct plugin_out) ) \ return PLUGIN_ERR_SIZE; \ if ( !x->import ) return PLUGIN_ERR_PARAM; \ if ( !(mesg=in->import("mesg")) ) return PLUGIN_ERR_OBJECT; \ } while (0);/* Check any generic API object that is passed back and forth. The * object must have a field named 'size' preferably of type size_t. */#define object_check(x) do { \ if ( !x ) return PLUGIN_ERR_PARAM; \ if ( x->size != sizeof(*x) ) return PLUGIN_ERR_SIZE; \ } while(0);#define PLUGIN_ID(x, y) do { out->name=x; out->desc=y; } while(0);#define PLUGIN_VERSION(x, y) do { out->ver_major=x; out->ver_minor=y; } while(0);#define PLUGIN_AUTHOR(x, y) do { out->author_name=x; out->author_email=y; } while(0);/* This is redundant because plugins can only * be GPL since they are a derived work of firestorm * however it may be useful if you have proprietary * plugins that YOU DO NOT DISTRIBUTE (in accordance * with the GPL). *//* *** CONSULT A LAWYER BEFORE WRITING PROPRIETARY PLUGINS *** *//* *** YOU HAVE BEEN WARNED. I WILL SUE LICENSE VIOLATORS *** */#define PLUGIN_LICENSE(x) out->license=x;#endif#endif /* __PLUGIN_HEADER_INCLUDED__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -