This repository has been archived by the owner on Jun 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathplugin.h
158 lines (119 loc) · 2.96 KB
/
plugin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include "config.h"
#ifndef _PLUGINS_H
#define _PLUGINS_H
#include <pthread.h>
#include "utils.h"
#include "core.h"
typedef enum __supported_plugins_t {
#ifdef _C_PLUGIN
_C_,
#endif
#ifdef _PYTHON_PLUGIN
_PYTHON_,
#endif
#ifdef _RUBY_PLUGIN
_RUBY_,
#endif
#ifdef _PERL_PLUGIN
_PERL_,
#endif
#ifdef _LUA_PLUGIN
_LUA_,
#endif
#ifdef _TCL_PLUGIN
_TCL_,
#endif
#ifdef _JAVA_PLUGIN
_JAVA_,
#endif
END_VALUE
} supported_plugins_t;
static const UNUSED char* supported_plugins_str[] = {
#ifdef _C_PLUGIN
"C",
#endif
#ifdef _PYTHON_PLUGIN
_PYTHON_VERSION_,
#endif
#ifdef _RUBY_PLUGIN
_RUBY_VERSION_,
#endif
#ifdef _PERL_PLUGIN
_PERL_VERSION_,
#endif
#ifdef _LUA_PLUGIN
_LUA_VERSION_,
#endif
#ifdef _TCL_PLUGIN
_TCL_VERSION_,
#endif
#ifdef _JAVA_PLUGIN
_JAVA_VERSION_,
#endif
NULL
};
static const UNUSED char* plugins_extensions_str[] = {
#ifdef _C_PLUGIN
".so",
#endif
#ifdef _PYTHON_PLUGIN
".py",
#endif
#ifdef _RUBY_PLUGIN
".rb",
#endif
#ifdef _PERL_PLUGIN
".pl",
#endif
#ifdef _LUA_PLUGIN
".lua",
#endif
#ifdef _TCL_PLUGIN
".tcl",
#endif
#ifdef _JAVA_PLUGIN
".class",
#endif
NULL
};
#define MAX_VMS 10
typedef struct _interpreter_type {
unsigned short id;
supported_plugins_t type;
pthread_mutex_t mutex;
void *vm;
bool ready;
} interpreter_t;
interpreter_t vms[MAX_VMS];
typedef struct _plugin_type {
unsigned short id;
char fullpath[PATH_MAX]; // full absolute path (ex. /path/to/MyPlugin.py)
char filename[PATH_MAX]; // full file name (ex. MyPlugin.py)
char name[PATH_MAX]; // name as seen by VM (ex. MyPlugin)
supported_plugins_t type;
unsigned short priority;
struct _plugin_type* next;
proxenet_state state;
interpreter_t *interpreter; // points to the type of interpreter
void *onload_function;
void *onleave_function;
void *pre_function;
void *post_function;
void *internal; // internal is a free field that can freely used by plugin
} plugin_t;
#include "http.h"
unsigned int proxenet_plugin_list_size();
bool proxenet_is_plugin_loaded(char*);
int proxenet_get_plugin_type(char*);
unsigned int count_plugins_by_type(supported_plugins_t);
unsigned int count_initialized_plugins_by_type(supported_plugins_t);
int proxenet_add_new_plugins(char*, char*);
void proxenet_free_plugin(plugin_t*);
void proxenet_free_all_plugins();
void proxenet_print_plugins_list();
plugin_t* proxenet_get_plugin_by_id(unsigned short);
int proxenet_get_plugin_type(char*);
int proxenet_plugin_set_state_by_id(unsigned short, proxenet_state);
int proxenet_plugin_set_state(plugin_t*, proxenet_state);
int proxenet_plugin_set_prority(unsigned short, unsigned short);
#endif /* _PLUGINS_H */