summaryrefslogtreecommitdiff
path: root/lib/frrscript.h
diff options
context:
space:
mode:
authorDonald Lee <dlqs@gmx.com>2021-07-04 22:58:21 +0800
committerDonald Lee <dlqs@gmx.com>2021-07-18 06:32:03 +0800
commit105ba9af8f0bd9a116f2571625b2ea39c49c20c1 (patch)
treec7ae13ddec6cdca02d7d898e84ad39ce14ca186c /lib/frrscript.h
parent432bb280fb4fbe3ce35bd3f2aea3da1ce4e48a03 (diff)
lib: Change frrscript to hold many Lua states
Instead of 1 frrscript : 1 lua state, it is changed to 1 : N. The states are hashed with their function names. Signed-off-by: Donald Lee <dlqs@gmx.com>
Diffstat (limited to 'lib/frrscript.h')
-rw-r--r--lib/frrscript.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/frrscript.h b/lib/frrscript.h
index 8612c602f3..97e543eb00 100644
--- a/lib/frrscript.h
+++ b/lib/frrscript.h
@@ -40,14 +40,31 @@ struct frrscript_codec {
decoder_func decoder;
};
+struct lua_function_state {
+ const char *name;
+ lua_State *L;
+};
+
+
struct frrscript {
/* Script name */
char *name;
- /* Lua state */
- struct lua_State *L;
+ /* Hash of Lua function name to Lua function state */
+ struct hash *lua_function_hash;
};
+
+/*
+ * Hash related functions for lua_function_hash
+ */
+
+void *lua_function_alloc(void *arg);
+
+unsigned int lua_function_hash_key(const void *data);
+
+bool lua_function_hash_cmp(const void *d1, const void *d2);
+
struct frrscript_env {
/* Value type */
const char *typename;