00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _PLUGIN_H_
00027 #define _PLUGIN_H_
00028
00029 #include "msint.h"
00030 #include "stmt/simplelist.h"
00031 #include "stmt/statement.h"
00032
00033
00034 #if defined(_WIN32) || defined(__declspec)
00035
00036 #define PLUGIN_STORAGE_TYPE __declspec(dllexport)
00037 #else
00038 #define PLUGIN_STORAGE_TYPE extern
00039 #endif
00040
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044
00045
00049 typedef struct _MSPlugin MSPlugin;
00050 typedef struct _MSInstance MSInstance;
00051 typedef struct _MSInterface MSInterface;
00052 typedef struct _StmtList StmtList;
00053 typedef struct _PluginFunc PluginFunc;
00054
00057 typedef enum {
00061 PLUGIN_TYPE_SETRULE,
00066 PLUGIN_TYPE_GETRULE,
00072 PLUGIN_TYPE_GETGENRULE,
00077 PLUGIN_TYPE_GETFILRULE,
00079 PLUGIN_TYPE_IFUNCTION,
00081 PLUGIN_TYPE_BEFORESETRULE,
00083 PLUGIN_TYPE_AFTERSETRULE,
00085 PLUGIN_TYPE_GETPOSTRULE,
00087 PLUGIN_TYPE_AFTERRESTORERULE,
00088
00089 } PluginFuncType;
00090
00091
00093 typedef enum {
00095 PLUGIN_RESP_CONTINUE,
00097 PLUGIN_RESP_STOP,
00099 PLUGIN_RESP_BLOCK,
00100
00101 } PluginResp;
00102
00105 typedef struct _PluginArg {
00106
00108 ModelStorage *msi;
00113 MSTxn *txn;
00116 const Statement *mask;
00119 Statement *stmt;
00122 Statement *result;
00127 void *private_data;
00128
00131 void *data;
00132
00133 } PluginArg;
00134
00135
00137 struct _PluginFunc {
00139 MSPlugin *plugin;
00140 PluginFuncType type;
00141 union {
00142 int (*BeforeSet) (PluginArg * arg, PluginResp *resp);
00143 int (*AfterSet) (PluginArg * arg, PluginResp *resp);
00144 int (*GetGenerate) (PluginArg * arg, PluginResp *resp);
00145 int (*GetFilter) (PluginArg * arg, PluginResp *resp);
00146 int (*GetPost) (PluginArg * arg, PluginResp *resp);
00147 int (*AfterRestore) (Statement *stmt, void *private_data);
00148 };
00149 int prio;
00150 int enabled;
00151 };
00152
00153
00156 struct _MSInterface {
00157 int (*ms_set_statement) (MSInstance *msi, Statement *s);
00158 int (*ms_get_statements) (MSInstance *msi, Statement *mask, StmtList *result);
00159 int (*ms_get_statements_ex)(MSInstance *msi, Statement *mask, StmtList *result, struct _PluginFunc *exclude);
00160 int (*ms_set_statement_ex) (MSInstance *msi, Statement *mask, StmtList *result, struct _PluginFunc *exclude);
00161 int (*ms_txn_begin) (MSInstance *msi);
00162 int (*ms_txn_commit) (MSInstance *msi);
00163 int (*ms_txn_rollback) (MSInstance *msi);
00164
00165 };
00166
00167
00173 struct _MSPlugin {
00174
00179 int (*axioms)(Statement **axioms, void *private_data);
00180
00182 int (*post_init)(ModelStorageEnv *env, void *private_data);
00183
00185 int (*get_functions)(PluginFunc **funcs, int *count);
00186
00190 int (*cleanup)( void **private_data );
00191
00193 int (*dump)(FILE *stream, void *private_data);
00194
00200 int (*restore)(unsigned int magic, FILE *stream, void **private_data);
00201
00202
00207 int prio;
00208 unsigned int magic;
00210 const char *name;
00212 const char *description;
00214 const char *vendor;
00216 const char *version;
00218 const char *id;
00219 void *private_data;
00220 int vital;
00221 int _enabled;
00222
00223
00224 };
00225
00226
00229 PLUGIN_STORAGE_TYPE MSPlugin plug_initialize(void);
00230
00231
00232 #ifdef __cplusplus
00233 }
00234 #endif
00235
00236 #endif //_PLUGIN_H_
00237