From: Josef 'Jeff' Sipek Date: Thu, 17 Dec 2020 18:00:00 +0000 (-0500) Subject: lib-lua: Make dlua_push_event() take lua_State * directly X-Git-Tag: 2.3.14.rc1~128 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=072e385983df85998715ce69c67f6d228aceb9fb;p=thirdparty%2Fdovecot%2Fcore.git lib-lua: Make dlua_push_event() take lua_State * directly --- diff --git a/src/auth/db-lua.c b/src/auth/db-lua.c index dc2e4e2caf..c01bce15cc 100644 --- a/src/auth/db-lua.c +++ b/src/auth/db-lua.c @@ -238,7 +238,7 @@ static int auth_request_lua_event(lua_State *L) struct auth_request *request = auth_lua_check_auth_request(script, 1); struct event *event = event_create(authdb_event(request)); - dlua_push_event(script, event); + dlua_push_event(L, event); return 1; } diff --git a/src/lib-lua/dlua-dovecot.c b/src/lib-lua/dlua-dovecot.c index 494fe0a8ba..a2b7937afa 100644 --- a/src/lib-lua/dlua-dovecot.c +++ b/src/lib-lua/dlua-dovecot.c @@ -262,20 +262,20 @@ dlua_check_event(struct dlua_script *script, int arg) return *bp; } -void dlua_push_event(struct dlua_script *script, struct event *event) +void dlua_push_event(lua_State *L, struct event *event) { - luaL_checkstack(script->L, 3, "out of memory"); - lua_createtable(script->L, 0, 1); - luaL_setmetatable(script->L, DLUA_EVENT); + luaL_checkstack(L, 3, "out of memory"); + lua_createtable(L, 0, 1); + luaL_setmetatable(L, DLUA_EVENT); /* we need to attach gc to userdata to support older lua*/ - struct event **ptr = lua_newuserdata(script->L, sizeof(struct event*)); + struct event **ptr = lua_newuserdata(L, sizeof(struct event*)); *ptr = event; - lua_createtable(script->L, 0, 1); - lua_pushcfunction(script->L, dlua_event_gc); - lua_setfield(script->L, -2, "__gc"); - lua_setmetatable(script->L, -2); - lua_setfield(script->L, -2, "item"); + lua_createtable(L, 0, 1); + lua_pushcfunction(L, dlua_event_gc); + lua_setfield(L, -2, "__gc"); + lua_setmetatable(L, -2); + lua_setfield(L, -2, "item"); } static int dlua_event_append_log_prefix(lua_State *L) @@ -484,7 +484,7 @@ static int dlua_event_new(lua_State *L) parent = dlua_check_event(script, 1); dlua_get_file_line(L, 1, &file, &line); event = event_create(parent, file, line); - dlua_push_event(script, event); + dlua_push_event(L, event); return 1; } diff --git a/src/lib-lua/dlua-script-private.h b/src/lib-lua/dlua-script-private.h index 18d6b0aa21..a95f464c79 100644 --- a/src/lib-lua/dlua-script-private.h +++ b/src/lib-lua/dlua-script-private.h @@ -99,7 +99,7 @@ void dlua_getdovecot(lua_State *L); void dlua_setmembers(lua_State *L, const struct dlua_table_values *values, int idx); /* push event to top of stack */ -void dlua_push_event(struct dlua_script *script, struct event *event); +void dlua_push_event(lua_State *L, struct event *event); /* get event from given stack position */ struct event *dlua_check_event(struct dlua_script *script, int arg);