Kaynağa Gözat

Adopt to lua 5.2.

tags/0.5.6
Vsevolod Stakhov 11 yıl önce
ebeveyn
işleme
7cc8754ad9

+ 53
- 9
CMakeLists.txt Dosyayı Görüntüle

@@ -373,10 +373,60 @@ ENDIF(NOT LOCALSTATES_PREFIX)

# Now find libraries and headers

INCLUDE(FindLua51)
# Find lua libraries
IF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR)
SET(LUA_VERSION_MAJOR "5")
SET(LUA_VERSION_MINOR "1")
ENDIF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR)

FIND_PATH(LUA_INCLUDE_DIR lua.h
HINTS
$ENV{LUA_DIR}
PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
"include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
include/lua include
PATHS
/usr/local
/usr
~/Library/Frameworks
/Library/Frameworks
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)

FIND_LIBRARY(LUA_LIBRARY
NAMES lua
"lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
"lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
"lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
HINTS
$ENV{LUA_DIR}
PATH_SUFFIXES lib64 lib
PATHS
/usr/local
/usr
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
DOC "Lua library"
)

IF(LUA_LIBRARY AND LUA_INCLUDE_DIR)
SET(LUA_FOUND 1)
ENDIF(LUA_LIBRARY AND LUA_INCLUDE_DIR)

# Check for luajit
IF(ENABLE_LUAJIT MATCHES "ON")
FIND_LIBRARY(LUAJIT_LIBRARY NAMES luajit51 luajit5.1 luajit-5.1 luajit
FIND_LIBRARY(LUAJIT_LIBRARY NAMES
"luajit${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
"luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
"luajit-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
luajit
HINTS
$ENV{LUA_DIR}
PATH_SUFFIXES lib64 lib
@@ -396,13 +446,7 @@ IF(ENABLE_LUAJIT MATCHES "ON")
ENDIF(ENABLE_LUAJIT MATCHES "ON")

IF(NOT LUA_FOUND)
# Automatic check failed, check passed variable
IF(LUA_INCLUDE_DIR)
INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}")
SET(WITH_LUA 1)
ELSE(LUA_INCLUDE_DIR)
MESSAGE(FATAL_ERROR "Lua not found, lua support is required for working")
ENDIF(LUA_INCLUDE_DIR)
MESSAGE(FATAL_ERROR "Lua not found, lua support is required for working")
ELSE(NOT LUA_FOUND)
SET(WITH_LUA 1)
INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}")

+ 3
- 3
src/lua/lua_buffer.c Dosyayı Görüntüle

@@ -329,14 +329,14 @@ luaopen_io_dispatcher (lua_State * L)
lua_pushstring (L, "rspamd{io_dispatcher}");
lua_rawset (L, -3);

luaL_openlib (L, NULL, io_dispatcherlib_m, 0);
luaL_openlib(L, "rspamd_io_dispatcher", io_dispatcherlib_f, 0);
luaL_register (L, NULL, io_dispatcherlib_m);
luaL_register (L, "rspamd_io_dispatcher", io_dispatcherlib_f);

lua_pop(L, 1); /* remove metatable from stack */

/* Simple event class */
lua_newclass (L, "rspamd{ev_base}", null_reg);
luaL_openlib (L, "rspamd_ev_base", null_reg, 0);
luaL_register (L, "rspamd_ev_base", null_reg);

lua_pop(L, 1); /* remove metatable from stack */


+ 2
- 2
src/lua/lua_cdb.c Dosyayı Görüntüle

@@ -158,8 +158,8 @@ luaopen_cdb (lua_State * L)
lua_pushstring (L, "rspamd{cdb}");
lua_rawset (L, -3);

luaL_openlib (L, NULL, cdblib_m, 0);
luaL_openlib (L, "cdb", cdblib_f, 0);
luaL_register (L, NULL, cdblib_m);
luaL_register (L, "cdb", cdblib_f);

lua_pop (L, 1); /* remove metatable from stack */


+ 2
- 2
src/lua/lua_classifier.c Dosyayı Görüntüle

@@ -412,7 +412,7 @@ gint
luaopen_classifier (lua_State * L)
{
lua_newclass (L, "rspamd{classifier}", classifierlib_m);
luaL_openlib (L, "rspamd_classifier", null_reg, 0);
luaL_register (L, "rspamd_classifier", null_reg);

lua_pop (L, 1); /* remove metatable from stack */

@@ -423,7 +423,7 @@ gint
luaopen_statfile (lua_State * L)
{
lua_newclass (L, "rspamd{statfile}", statfilelib_m);
luaL_openlib (L, "rspamd_statfile", null_reg, 0);
luaL_register (L, "rspamd_statfile", null_reg);

lua_pop (L, 1); /* remove metatable from stack */


+ 6
- 8
src/lua/lua_common.c Dosyayı Görüntüle

@@ -210,8 +210,7 @@ lua_newclass (lua_State * L, const gchar *classname, const struct luaL_reg *meth
lua_pushstring (L, "class"); /* mt,"__index",it,"class" */
lua_pushstring (L, classname); /* mt,"__index",it,"class",classname */
lua_rawset (L, -3); /* mt,"__index",it */

luaL_openlib (L, NULL, methods, 0);
luaL_register (L, NULL, methods);
}

/**
@@ -221,7 +220,7 @@ void
lua_newclass_full (lua_State *L, const gchar *classname, const gchar *static_name, const struct luaL_reg *methods, const struct luaL_reg *func)
{
lua_newclass (L, classname, methods);
luaL_openlib(L, static_name, func, 0);
luaL_register (L, static_name, func);
}

gint
@@ -358,7 +357,7 @@ lua_logger_debug (lua_State * L)
gint
luaopen_rspamd (lua_State * L)
{
luaL_openlib (L, "rspamd", null_reg, 0);
luaL_register (L, "rspamd", null_reg);
/* make version string available to scripts */
lua_pushstring (L, "_VERSION");
lua_pushstring (L, RVERSION);
@@ -371,8 +370,7 @@ static gint
luaopen_logger (lua_State * L)
{

luaL_openlib (L, "rspamd_logger", loggerlib_f, 0);

luaL_register (L, "rspamd_logger", loggerlib_f);
return 1;
}

@@ -380,7 +378,7 @@ luaopen_logger (lua_State * L)
static gint
luaopen_util (lua_State *L)
{
luaL_openlib (L, "rspamd_util", utillib_f, 0);
luaL_register (L, "rspamd_util", utillib_f);

return 1;
}
@@ -406,7 +404,7 @@ init_lua (struct config_file *cfg)
{
lua_State *L;

L = lua_open ();
L = luaL_newstate ();
luaL_openlibs (L);

(void)luaopen_rspamd (L);

+ 21
- 0
src/lua/lua_common.h Dosyayı Görüntüle

@@ -10,6 +10,27 @@
#include <lauxlib.h>
#include <lualib.h>

#ifndef lua_open
#define lua_open() luaL_newstate()
#endif

#ifndef luaL_reg
#define luaL_reg luaL_Reg
#endif

#if LUA_VERSION_NUM > 501
static inline void
luaL_register (lua_State *L, const gchar *name, const struct luaL_reg *methods)
{
lua_newtable (L);
luaL_setfuncs (L, methods, 0);
if (name != NULL) {
lua_pushvalue (L, -1);
lua_setglobal (L, name);
}
}
#endif

/* Interface definitions */
#define LUA_FUNCTION_DEF(class, name) static gint lua_##class##_##name(lua_State *L)
#define LUA_INTERFACE_DEF(class, name) { #name, lua_##class##_##name }

+ 5
- 5
src/lua/lua_config.c Dosyayı Görüntüle

@@ -960,7 +960,7 @@ gint
luaopen_config (lua_State * L)
{
lua_newclass (L, "rspamd{config}", configlib_m);
luaL_openlib (L, "rspamd_config", null_reg, 0);
luaL_register (L, "rspamd_config", null_reg);

lua_pop (L, 1); /* remove metatable from stack */

@@ -971,7 +971,7 @@ gint
luaopen_radix (lua_State * L)
{
lua_newclass (L, "rspamd{radix}", radixlib_m);
luaL_openlib (L, "rspamd_radix", null_reg, 0);
luaL_register (L, "rspamd_radix", null_reg);

lua_pop (L, 1); /* remove metatable from stack */

@@ -982,7 +982,7 @@ gint
luaopen_hash_table (lua_State * L)
{
lua_newclass (L, "rspamd{hash_table}", hashlib_m);
luaL_openlib (L, "rspamd_hash_table", null_reg, 0);
luaL_register (L, "rspamd_hash_table", null_reg);

lua_pop (L, 1); /* remove metatable from stack */

@@ -1001,8 +1001,8 @@ luaopen_trie (lua_State * L)
lua_pushstring (L, "rspamd{trie}");
lua_rawset (L, -3);

luaL_openlib (L, NULL, trielib_m, 0);
luaL_openlib(L, "rspamd_trie", trielib_f, 0);
luaL_register (L, NULL, trielib_m);
luaL_register (L, "rspamd_trie", trielib_f);

lua_pop (L, 1); /* remove metatable from stack */


+ 2
- 2
src/lua/lua_dns.c Dosyayı Görüntüle

@@ -275,8 +275,8 @@ luaopen_dns_resolver (lua_State * L)
lua_pushstring (L, "rspamd{resolver}");
lua_rawset (L, -3);

luaL_openlib (L, NULL, dns_resolverlib_m, 0);
luaL_openlib(L, "rspamd_resolver", dns_resolverlib_f, 0);
luaL_register (L, NULL, dns_resolverlib_m);
luaL_register (L, "rspamd_resolver", dns_resolverlib_f);

lua_pop (L, 1); /* remove metatable from stack */
return 1;

+ 1
- 1
src/lua/lua_http.c Dosyayı Görüntüle

@@ -622,7 +622,7 @@ gint
luaopen_http (lua_State * L)
{

luaL_openlib (L, "rspamd_http", httplib_m, 0);
luaL_register (L, "rspamd_http", httplib_m);

return 1;
}

+ 2
- 2
src/lua/lua_mempool.c Dosyayı Görüntüle

@@ -228,8 +228,8 @@ luaopen_mempool (lua_State * L)
lua_pushstring (L, "rspamd{mempool}");
lua_rawset (L, -3);

luaL_openlib (L, NULL, mempoollib_m, 0);
luaL_openlib(L, "rspamd_mempool", mempoollib_f, 0);
luaL_register (L, NULL, mempoollib_m);
luaL_register (L, "rspamd_mempool", mempoollib_f);

lua_pop (L, 1); /* remove metatable from stack */


+ 1
- 1
src/lua/lua_message.c Dosyayı Görüntüle

@@ -204,7 +204,7 @@ gint
luaopen_message (lua_State * L)
{
lua_newclass (L, "rspamd{message}", msglib_m);
luaL_openlib (L, "rspamd_message", null_reg, 0);
luaL_register (L, "rspamd_message", null_reg);

lua_pop (L, 1); /* remove metatable from stack */


+ 1
- 1
src/lua/lua_redis.c Dosyayı Görüntüle

@@ -343,7 +343,7 @@ gint
luaopen_redis (lua_State * L)
{

luaL_openlib (L, "rspamd_redis", redislib_m, 0);
luaL_register (L, "rspamd_redis", redislib_m);

return 1;
}

+ 2
- 2
src/lua/lua_regexp.c Dosyayı Görüntüle

@@ -266,8 +266,8 @@ luaopen_glib_regexp (lua_State * L)
lua_pushstring (L, "rspamd{regexp}");
lua_rawset (L, -3);

luaL_openlib (L, NULL, regexplib_m, 0);
luaL_openlib(L, "regexp", regexplib_f, 0);
luaL_register (L, NULL, regexplib_m);
luaL_register (L, "regexp", regexplib_f);

regexp_static_pool = memory_pool_new (memory_pool_get_size ());


+ 3
- 3
src/lua/lua_session.c Dosyayı Görüntüle

@@ -301,14 +301,14 @@ luaopen_session (lua_State * L)
lua_pushstring (L, "rspamd{session}");
lua_rawset (L, -3);

luaL_openlib (L, NULL, sessionlib_m, 0);
luaL_openlib(L, "rspamd_session", sessionlib_f, 0);
luaL_register (L, NULL, sessionlib_m);
luaL_register (L, "rspamd_session", sessionlib_f);

lua_pop (L, 1); /* remove metatable from stack */

/* Simple event class */
lua_newclass (L, "rspamd{event}", eventlib_m);
luaL_openlib (L, "rspamd_event", null_reg, 0);
luaL_register (L, "rspamd_event", null_reg);

lua_pop (L, 1); /* remove metatable from stack */


+ 4
- 4
src/lua/lua_task.c Dosyayı Görüntüle

@@ -2051,7 +2051,7 @@ gint
luaopen_textpart (lua_State * L)
{
lua_newclass (L, "rspamd{textpart}", textpartlib_m);
luaL_openlib (L, "rspamd_textpart", null_reg, 0);
luaL_register (L, "rspamd_textpart", null_reg);

lua_pop (L, 1); /* remove metatable from stack */

@@ -2062,7 +2062,7 @@ gint
luaopen_mimepart (lua_State * L)
{
lua_newclass (L, "rspamd{mimepart}", mimepartlib_m);
luaL_openlib (L, "rspamd_mimepart", null_reg, 0);
luaL_register (L, "rspamd_mimepart", null_reg);

lua_pop (L, 1); /* remove metatable from stack */

@@ -2073,7 +2073,7 @@ gint
luaopen_image (lua_State * L)
{
lua_newclass (L, "rspamd{image}", imagelib_m);
luaL_openlib (L, "rspamd_image", null_reg, 0);
luaL_register (L, "rspamd_image", null_reg);

lua_pop (L, 1); /* remove metatable from stack */

@@ -2084,7 +2084,7 @@ gint
luaopen_url (lua_State * L)
{
lua_newclass (L, "rspamd{url}", urllib_m);
luaL_openlib (L, "rspamd_url", null_reg, 0);
luaL_register (L, "rspamd_url", null_reg);

lua_pop (L, 1); /* remove metatable from stack */


+ 4
- 4
src/lua/lua_upstream.c Dosyayı Görüntüle

@@ -519,8 +519,8 @@ luaopen_upstream (lua_State * L)
lua_pushstring (L, "rspamd{upstream_list}");
lua_rawset (L, -3);

luaL_openlib (L, NULL, upstream_list_m, 0);
luaL_openlib (L, "upstream_list", upstream_list_f, 0);
luaL_register (L, NULL, upstream_list_m);
luaL_register (L, "upstream_list", upstream_list_f);

lua_pop (L, 1); /* remove metatable from stack */

@@ -533,8 +533,8 @@ luaopen_upstream (lua_State * L)
lua_pushstring (L, "rspamd{upstream}");
lua_rawset (L, -3);

luaL_openlib (L, NULL, upstream_m, 0);
luaL_openlib (L, "upstream", upstream_f, 0);
luaL_register (L, NULL, upstream_m);
luaL_register (L, "upstream", upstream_f);

lua_pop (L, 1); /* remove metatable from stack */


+ 1
- 1
src/lua/lua_xmlrpc.c Dosyayı Görüntüle

@@ -552,7 +552,7 @@ gint
luaopen_xmlrpc (lua_State * L)
{

luaL_openlib (L, "rspamd_xmlrpc", xmlrpclib_m, 0);
luaL_register (L, "rspamd_xmlrpc", xmlrpclib_m);

return 1;
}

+ 1
- 1
src/lua_worker.c Dosyayı Görüntüle

@@ -104,7 +104,7 @@ static gint
luaopen_lua_worker (lua_State * L)
{
lua_newclass (L, "rspamd{worker}", lua_workerlib_m);
luaL_openlib (L, "rspamd_worker", null_reg, 0);
luaL_register (L, "rspamd_worker", null_reg);

lua_pop (L, 1); /* remove metatable from stack */


+ 1
- 1
src/plugins/regexp.c Dosyayı Görüntüle

@@ -175,7 +175,7 @@ task_cache_check (struct worker_task *task, struct rspamd_regexp *re)
static gint
luaopen_regexp (lua_State * L)
{
luaL_openlib (L, "rspamd_regexp", regexplib_m, 0);
luaL_register (L, "rspamd_regexp", regexplib_m);

return 1;
}

Loading…
İptal
Kaydet