From bf2bab9b2856546bcf47261f8708da6bd7dd7c45 Mon Sep 17 00:00:00 2001 From: Sourena Date: Sun, 15 Sep 2024 09:05:21 +0000 Subject: [PATCH] add nil to create last call --- src/scanner.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/scanner.c b/src/scanner.c index cd8c50f..5482416 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -788,6 +788,10 @@ void * scan_lua_worker_routine(void * ptr){ } if (strcmp((char*) item, tp->quit_data) == 0){ //fprintf(stderr, "We have received a quit message in thread#%ld\n", pthread_self()); + // let's call the lua script for the last time but pass nil instead + // this is very usefull for the lua file to know the last call + lua_settop (L, 0); + lua_dns_routine_scan(NULL, si, L); lua_close(L); return NULL; } @@ -808,7 +812,11 @@ void lua_dns_routine_scan(void * item, struct scanner_input * si, lua_State * L) fprintf(stdout, "No 'main' function detected in Lua script\n"); return; } - lua_pushstring(L, (char*)item); + if (NULL == item){ + lua_pushnil(L); + }else{ + lua_pushstring(L, (char*)item); + } size_t str_len; int res = lua_pcall(L, 1, 1, 0); if (res != 0){