]> jfr.im git - irc/quakenet/newserv.git/blobdiff - lua/lua.c
Merge chanserv-live into default.
[irc/quakenet/newserv.git] / lua / lua.c
index 32d460cc7385503b07f6148c5c39fffed91c7ead..5263f26a02f504b39f4d24e687d421ad295982e7 100644 (file)
--- a/lua/lua.c
+++ b/lua/lua.c
@@ -57,8 +57,10 @@ void lua_deregisternicks(lua_list *l);
 void lua_registerlocalcommands(lua_State *ps);
 void lua_registerdebug(lua_State *ps);
 void lua_socket_closeall(lua_list *l);
+void lua_scheduler_freeall(lua_list *l);
 void lua_registersocketcommands(lua_State *ps);
 void lua_registercryptocommands(lua_State *ps);
+void lua_registerschedulercommands(lua_State *ps);
 
 #ifdef LUA_DEBUGSOCKET
 
@@ -190,6 +192,7 @@ lua_State *lua_loadscript(char *file) {
   lua_State *l;
   lua_list *n;
   char buf[1024];
+  void *args[2];
 
   if(!cpath || !suffix)
     return NULL;
@@ -229,6 +232,11 @@ lua_State *lua_loadscript(char *file) {
   lua_registerdbcommands(l);
   lua_registersocketcommands(l);
   lua_registercryptocommands(l);
+  lua_registerschedulercommands(l);
+
+  args[0] = file;
+  args[1] = l;
+  triggerhook(HOOK_LUA_LOADSCRIPT, args);
 
 #ifdef LUA_USEJIT
   lua_require(l, "lib/jit");
@@ -251,6 +259,7 @@ lua_State *lua_loadscript(char *file) {
   n->prev = lua_tail;
   n->nicks = NULL;
   n->sockets = NULL;
+  n->schedulers = NULL;
 
   if(!lua_head) { 
     lua_head = n;
@@ -287,9 +296,12 @@ lua_State *lua_loadscript(char *file) {
 }
 
 void lua_unloadscript(lua_list *l) {
+  triggerhook(HOOK_LUA_UNLOADSCRIPT, l->l);
+
   lua_onunload(l->l);
   lua_deregisternicks(l);
   lua_socket_closeall(l);
+  lua_scheduler_freeall(l);
   lua_close(l->l);
   freesstring(l->name);
 
@@ -438,7 +450,7 @@ int lua_lineok(const char *data) {
   return 1;
 }
 
-INLINE int lua_debugpcall(lua_State *l, char *message, int a, int b, int c) {
+int lua_debugpcall(lua_State *l, char *message, int a, int b, int c) {
   lua_list *l2 = lua_listfromstate(l);
   int ret;