aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-05 14:26:20 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-05 14:26:20 +0100
commitdedb8506630e0de3f384d19c781993dedd73a2d5 (patch)
tree4855da0433bd019a03c727ad53175bd77745d228
parenta4c9f20fa7f30124253bbcc807eaec9cce65ee48 (diff)
downloadrspamd-dedb8506630e0de3f384d19c781993dedd73a2d5.tar.gz
rspamd-dedb8506630e0de3f384d19c781993dedd73a2d5.zip
[Feature] Use rspamd specific type checks for userdata
-rw-r--r--src/lua/lua_buffer.c4
-rw-r--r--src/lua/lua_cdb.c2
-rw-r--r--src/lua/lua_classifier.c6
-rw-r--r--src/lua/lua_config.c2
-rw-r--r--src/lua/lua_cryptobox.c8
-rw-r--r--src/lua/lua_dns.c14
-rw-r--r--src/lua/lua_expression.c2
-rw-r--r--src/lua/lua_fann.c2
-rw-r--r--src/lua/lua_html.c4
-rw-r--r--src/lua/lua_http.c12
-rw-r--r--src/lua/lua_ip.c2
-rw-r--r--src/lua/lua_map.c4
-rw-r--r--src/lua/lua_mempool.c2
-rw-r--r--src/lua/lua_mimepart.c4
-rw-r--r--src/lua/lua_regexp.c2
-rw-r--r--src/lua/lua_rsa.c6
-rw-r--r--src/lua/lua_session.c4
-rw-r--r--src/lua/lua_sqlite3.c4
-rw-r--r--src/lua/lua_task.c8
-rw-r--r--src/lua/lua_tcp.c8
-rw-r--r--src/lua/lua_trie.c2
-rw-r--r--src/lua/lua_upstream.c4
-rw-r--r--src/lua/lua_url.c2
23 files changed, 54 insertions, 54 deletions
diff --git a/src/lua/lua_buffer.c b/src/lua/lua_buffer.c
index c644eae7d..3605a0eb5 100644
--- a/src/lua/lua_buffer.c
+++ b/src/lua/lua_buffer.c
@@ -57,7 +57,7 @@ struct lua_dispatcher_cbdata {
struct rspamd_io_dispatcher_s *
lua_check_io_dispatcher (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{io_dispatcher}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{io_dispatcher}");
luaL_argcheck (L, ud != NULL, 1, "'io_dispatcher' expected");
return ud ? *((struct rspamd_io_dispatcher_s **)ud) : NULL;
}
@@ -65,7 +65,7 @@ lua_check_io_dispatcher (lua_State * L)
struct event_base *
lua_check_event_base (lua_State *L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{ev_base}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{ev_base}");
luaL_argcheck (L, ud != NULL, 1, "'ev_base' expected");
return ud ? *((struct event_base **)ud) : NULL;
}
diff --git a/src/lua/lua_cdb.c b/src/lua/lua_cdb.c
index b0e6df32e..a7292da03 100644
--- a/src/lua/lua_cdb.c
+++ b/src/lua/lua_cdb.c
@@ -38,7 +38,7 @@ static const struct luaL_reg cdblib_f[] = {
static struct cdb *
lua_check_cdb (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{cdb}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{cdb}");
luaL_argcheck (L, ud != NULL, 1, "'cdb' expected");
return ud ? *((struct cdb **)ud) : NULL;
diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c
index f777ba8aa..aaf3888df 100644
--- a/src/lua/lua_classifier.c
+++ b/src/lua/lua_classifier.c
@@ -59,7 +59,7 @@ static struct rspamd_statfile_config * lua_check_statfile (lua_State * L);
static struct rspamd_classifier_config *
lua_check_classifier (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{classifier}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{classifier}");
luaL_argcheck (L, ud != NULL, 1, "'classifier' expected");
return ud ? *((struct rspamd_classifier_config **)ud) : NULL;
}
@@ -96,7 +96,7 @@ call_classifier_pre_callback (struct rspamd_classifier_config *ccf,
if (lua_istable (L, -1)) {
lua_pushnil (L);
while (lua_next (L, -2)) {
- pst = luaL_checkudata (L, -1, "rspamd{statfile}");
+ pst = rspamd_lua_check_udata (L, -1, "rspamd{statfile}");
if (pst) {
res = g_list_prepend (res, *pst);
}
@@ -378,7 +378,7 @@ lua_statfile_get_param (lua_State *L)
static struct rspamd_statfile_config *
lua_check_statfile (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{statfile}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{statfile}");
luaL_argcheck (L, ud != NULL, 1, "'statfile' expected");
return ud ? *((struct rspamd_statfile_config **)ud) : NULL;
}
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 191a66126..c3834759c 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -484,7 +484,7 @@ static const guint64 rspamd_lua_callback_magic = 0x32c118af1e3263c7ULL;
struct rspamd_config *
lua_check_config (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{config}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{config}");
luaL_argcheck (L, ud != NULL, pos, "'config' expected");
return ud ? *((struct rspamd_config **)ud) : NULL;
}
diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c
index 9e699c2df..65cb04174 100644
--- a/src/lua/lua_cryptobox.c
+++ b/src/lua/lua_cryptobox.c
@@ -120,7 +120,7 @@ static const struct luaL_reg cryptoboxhashlib_m[] = {
static struct rspamd_cryptobox_pubkey *
lua_check_cryptobox_pubkey (lua_State * L, int pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{cryptobox_pubkey}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{cryptobox_pubkey}");
luaL_argcheck (L, ud != NULL, 1, "'cryptobox_pubkey' expected");
return ud ? *((struct rspamd_cryptobox_pubkey **)ud) : NULL;
@@ -129,7 +129,7 @@ lua_check_cryptobox_pubkey (lua_State * L, int pos)
static struct rspamd_cryptobox_keypair *
lua_check_cryptobox_keypair (lua_State * L, int pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{cryptobox_keypair}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{cryptobox_keypair}");
luaL_argcheck (L, ud != NULL, 1, "'cryptobox_keypair' expected");
return ud ? *((struct rspamd_cryptobox_keypair **)ud) : NULL;
@@ -138,7 +138,7 @@ lua_check_cryptobox_keypair (lua_State * L, int pos)
static rspamd_fstring_t *
lua_check_cryptobox_sign (lua_State * L, int pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{cryptobox_signature}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{cryptobox_signature}");
luaL_argcheck (L, ud != NULL, 1, "'cryptobox_signature' expected");
return ud ? *((rspamd_fstring_t **)ud) : NULL;
@@ -147,7 +147,7 @@ lua_check_cryptobox_sign (lua_State * L, int pos)
static rspamd_cryptobox_hash_state_t *
lua_check_cryptobox_hash (lua_State * L, int pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{cryptobox_hash}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{cryptobox_hash}");
luaL_argcheck (L, ud != NULL, 1, "'cryptobox_hash' expected");
return ud ? *((rspamd_cryptobox_hash_state_t **)ud) : NULL;
diff --git a/src/lua/lua_dns.c b/src/lua/lua_dns.c
index c52569225..1a778c53d 100644
--- a/src/lua/lua_dns.c
+++ b/src/lua/lua_dns.c
@@ -70,7 +70,7 @@ static const struct luaL_reg dns_resolverlib_m[] = {
struct rspamd_dns_resolver *
lua_check_dns_resolver (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{resolver}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{resolver}");
luaL_argcheck (L, ud != NULL, 1, "'resolver' expected");
return ud ? *((struct rspamd_dns_resolver **)ud) : NULL;
}
@@ -225,10 +225,10 @@ lua_dns_resolver_init (lua_State *L)
struct event_base *base, **pbase;
/* Check args */
- pbase = luaL_checkudata (L, 1, "rspamd{ev_base}");
+ pbase = rspamd_lua_check_udata (L, 1, "rspamd{ev_base}");
luaL_argcheck (L, pbase != NULL, 1, "'ev_base' expected");
base = pbase ? *(pbase) : NULL;
- pcfg = luaL_checkudata (L, 2, "rspamd{config}");
+ pcfg = rspamd_lua_check_udata (L, 2, "rspamd{config}");
luaL_argcheck (L, pcfg != NULL, 2, "'config' expected");
cfg = pcfg ? *(pcfg) : NULL;
@@ -266,10 +266,10 @@ lua_dns_resolver_resolve_common (lua_State *L,
/* Check arguments */
if (lua_type (L, first) == LUA_TUSERDATA) {
/* Legacy version */
- psession = luaL_checkudata (L, first, "rspamd{session}");
+ psession = rspamd_lua_check_udata (L, first, "rspamd{session}");
luaL_argcheck (L, psession != NULL, first, "'session' expected");
session = psession ? *(psession) : NULL;
- ppool = luaL_checkudata (L, first + 1, "rspamd{mempool}");
+ ppool = rspamd_lua_check_udata (L, first + 1, "rspamd{mempool}");
luaL_argcheck (L, ppool != NULL, first + 1, "'mempool' expected");
pool = ppool ? *(ppool) : NULL;
to_resolve = luaL_checkstring (L, first + 2);
@@ -315,7 +315,7 @@ lua_dns_resolver_resolve_common (lua_State *L,
if (task == NULL) {
lua_pushstring (L, "session");
lua_gettable (L, -2);
- if (luaL_checkudata (L, -1, "rspamd{session}")) {
+ if (rspamd_lua_check_udata (L, -1, "rspamd{session}")) {
session = *(struct rspamd_async_session **)lua_touserdata (L, -1);
}
else {
@@ -325,7 +325,7 @@ lua_dns_resolver_resolve_common (lua_State *L,
lua_pushstring (L, "pool");
lua_gettable (L, -2);
- if (luaL_checkudata (L, -1, "rspamd{mempool}")) {
+ if (rspamd_lua_check_udata (L, -1, "rspamd{mempool}")) {
pool = *(rspamd_mempool_t **)lua_touserdata (L, -1);
}
else {
diff --git a/src/lua/lua_expression.c b/src/lua/lua_expression.c
index ac5933993..7bacf5a75 100644
--- a/src/lua/lua_expression.c
+++ b/src/lua/lua_expression.c
@@ -124,7 +124,7 @@ lua_expr_quark (void)
struct lua_expression *
rspamd_lua_expression (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{expr}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{expr}");
luaL_argcheck (L, ud != NULL, pos, "'expr' expected");
return ud ? *((struct lua_expression **)ud) : NULL;
}
diff --git a/src/lua/lua_fann.c b/src/lua/lua_fann.c
index af6d0b590..0f20983e0 100644
--- a/src/lua/lua_fann.c
+++ b/src/lua/lua_fann.c
@@ -65,7 +65,7 @@ static const struct luaL_reg fannlib_m[] = {
struct fann *
rspamd_lua_check_fann (lua_State *L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{fann}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{fann}");
luaL_argcheck (L, ud != NULL, pos, "'fann' expected");
return ud ? *((struct fann **) ud) : NULL;
}
diff --git a/src/lua/lua_html.c b/src/lua/lua_html.c
index 7c5ca3cb9..b23530d6e 100644
--- a/src/lua/lua_html.c
+++ b/src/lua/lua_html.c
@@ -134,7 +134,7 @@ static const struct luaL_reg taglib_m[] = {
static struct html_content *
lua_check_html (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{html}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{html}");
luaL_argcheck (L, ud != NULL, pos, "'html' expected");
return ud ? *((struct html_content **)ud) : NULL;
}
@@ -142,7 +142,7 @@ lua_check_html (lua_State * L, gint pos)
static struct html_tag *
lua_check_html_tag (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{html_tag}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{html_tag}");
luaL_argcheck (L, ud != NULL, pos, "'html_tag' expected");
return ud ? *((struct html_tag **)ud) : NULL;
}
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c
index 816565869..84ab2de16 100644
--- a/src/lua/lua_http.c
+++ b/src/lua/lua_http.c
@@ -290,19 +290,19 @@ lua_http_request (lua_State *L)
}
lua_pushvalue (L, 2);
cbref = luaL_ref (L, LUA_REGISTRYINDEX);
- if (lua_gettop (L) >= 3 && luaL_checkudata (L, 3, "rspamd{ev_base}")) {
+ if (lua_gettop (L) >= 3 && rspamd_lua_check_udata (L, 3, "rspamd{ev_base}")) {
ev_base = *(struct event_base **)lua_touserdata (L, 3);
}
else {
ev_base = NULL;
}
- if (lua_gettop (L) >= 4 && luaL_checkudata (L, 4, "rspamd{resolver}")) {
+ if (lua_gettop (L) >= 4 && rspamd_lua_check_udata (L, 4, "rspamd{resolver}")) {
resolver = *(struct rspamd_dns_resolver **)lua_touserdata (L, 4);
}
else {
resolver = lua_http_global_resolver (ev_base);
}
- if (lua_gettop (L) >= 5 && luaL_checkudata (L, 5, "rspamd{session}")) {
+ if (lua_gettop (L) >= 5 && rspamd_lua_check_udata (L, 5, "rspamd{session}")) {
session = *(struct rspamd_async_session **)lua_touserdata (L, 5);
}
else {
@@ -343,7 +343,7 @@ lua_http_request (lua_State *L)
if (task == NULL) {
lua_pushstring (L, "ev_base");
lua_gettable (L, -2);
- if (luaL_checkudata (L, -1, "rspamd{ev_base}")) {
+ if (rspamd_lua_check_udata (L, -1, "rspamd{ev_base}")) {
ev_base = *(struct event_base **)lua_touserdata (L, -1);
}
else {
@@ -353,7 +353,7 @@ lua_http_request (lua_State *L)
lua_pushstring (L, "resolver");
lua_gettable (L, -2);
- if (luaL_checkudata (L, -1, "rspamd{resolver}")) {
+ if (rspamd_lua_check_udata (L, -1, "rspamd{resolver}")) {
resolver = *(struct rspamd_dns_resolver **)lua_touserdata (L, -1);
}
else {
@@ -363,7 +363,7 @@ lua_http_request (lua_State *L)
lua_pushstring (L, "session");
lua_gettable (L, -2);
- if (luaL_checkudata (L, -1, "rspamd{session}")) {
+ if (rspamd_lua_check_udata (L, -1, "rspamd{session}")) {
session = *(struct rspamd_async_session **)lua_touserdata (L, -1);
}
else {
diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c
index d82de9af9..5dd85f4a8 100644
--- a/src/lua/lua_ip.c
+++ b/src/lua/lua_ip.c
@@ -209,7 +209,7 @@ lua_ip_new (lua_State *L, struct rspamd_lua_ip *old)
struct rspamd_lua_ip *
lua_check_ip (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{ip}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{ip}");
luaL_argcheck (L, ud != NULL, pos, "'ip' expected");
return ud ? *((struct rspamd_lua_ip **)ud) : NULL;
diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c
index 439ea2941..c01088343 100644
--- a/src/lua/lua_map.c
+++ b/src/lua/lua_map.c
@@ -108,7 +108,7 @@ struct lua_map_callback_data {
struct rspamd_lua_map *
lua_check_map (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{map}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{map}");
luaL_argcheck (L, ud != NULL, pos, "'map' expected");
return ud ? *((struct rspamd_lua_map **)ud) : NULL;
}
@@ -542,7 +542,7 @@ lua_map_get_key (lua_State * L)
key_num = htonl (key_num);
}
else if (lua_type (L, 2) == LUA_TUSERDATA) {
- ud = luaL_checkudata (L, 2, "rspamd{ip}");
+ ud = rspamd_lua_check_udata (L, 2, "rspamd{ip}");
if (ud != NULL) {
addr = *((struct rspamd_lua_ip **)ud);
diff --git a/src/lua/lua_mempool.c b/src/lua/lua_mempool.c
index 00c2c24e0..15d0e6897 100644
--- a/src/lua/lua_mempool.c
+++ b/src/lua/lua_mempool.c
@@ -132,7 +132,7 @@ struct lua_mempool_udata {
struct memory_pool_s *
rspamd_lua_check_mempool (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{mempool}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{mempool}");
luaL_argcheck (L, ud != NULL, pos, "'mempool' expected");
return ud ? *((struct memory_pool_s **)ud) : NULL;
}
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index 2eedeeabe..b0bbce85f 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -226,7 +226,7 @@ static const struct luaL_reg mimepartlib_m[] = {
static struct mime_text_part *
lua_check_textpart (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{textpart}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{textpart}");
luaL_argcheck (L, ud != NULL, 1, "'textpart' expected");
return ud ? *((struct mime_text_part **)ud) : NULL;
}
@@ -234,7 +234,7 @@ lua_check_textpart (lua_State * L)
static struct mime_part *
lua_check_mimepart (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{mimepart}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{mimepart}");
luaL_argcheck (L, ud != NULL, 1, "'mimepart' expected");
return ud ? *((struct mime_part **)ud) : NULL;
}
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c
index e751fac86..e92c8530b 100644
--- a/src/lua/lua_regexp.c
+++ b/src/lua/lua_regexp.c
@@ -72,7 +72,7 @@ rspamd_mempool_t *regexp_static_pool = NULL;
static struct rspamd_lua_regexp *
lua_check_regexp (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{regexp}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{regexp}");
luaL_argcheck (L, ud != NULL, 1, "'regexp' expected");
return ud ? *((struct rspamd_lua_regexp **)ud) : NULL;
diff --git a/src/lua/lua_rsa.c b/src/lua/lua_rsa.c
index aa61d6069..659eaecd2 100644
--- a/src/lua/lua_rsa.c
+++ b/src/lua/lua_rsa.c
@@ -91,7 +91,7 @@ static const struct luaL_reg rsasignlib_m[] = {
static RSA *
lua_check_rsa_pubkey (lua_State * L, int pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{rsa_pubkey}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{rsa_pubkey}");
luaL_argcheck (L, ud != NULL, 1, "'rsa_pubkey' expected");
return ud ? *((RSA **)ud) : NULL;
@@ -100,7 +100,7 @@ lua_check_rsa_pubkey (lua_State * L, int pos)
static RSA *
lua_check_rsa_privkey (lua_State * L, int pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{rsa_privkey}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{rsa_privkey}");
luaL_argcheck (L, ud != NULL, 1, "'rsa_privkey' expected");
return ud ? *((RSA **)ud) : NULL;
@@ -109,7 +109,7 @@ lua_check_rsa_privkey (lua_State * L, int pos)
static rspamd_fstring_t *
lua_check_rsa_sign (lua_State * L, int pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{rsa_signature}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{rsa_signature}");
luaL_argcheck (L, ud != NULL, 1, "'rsa_signature' expected");
return ud ? *((rspamd_fstring_t **)ud) : NULL;
diff --git a/src/lua/lua_session.c b/src/lua/lua_session.c
index c2248336a..f4bd49c7e 100644
--- a/src/lua/lua_session.c
+++ b/src/lua/lua_session.c
@@ -63,7 +63,7 @@ static const struct luaL_reg eventlib_m[] = {
struct lua_session_udata *
lua_check_session (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{session}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{session}");
luaL_argcheck (L, ud != NULL, 1, "'session' expected");
return ud ? *((struct lua_session_udata **)ud) : NULL;
}
@@ -71,7 +71,7 @@ lua_check_session (lua_State * L)
struct rspamd_async_event *
lua_check_event (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{event}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{event}");
luaL_argcheck (L, ud != NULL, 1, "'event' expected");
return ud ? *((struct rspamd_async_event **)ud) : NULL;
}
diff --git a/src/lua/lua_sqlite3.c b/src/lua/lua_sqlite3.c
index 28c96446f..ca8481117 100644
--- a/src/lua/lua_sqlite3.c
+++ b/src/lua/lua_sqlite3.c
@@ -66,7 +66,7 @@ static const struct luaL_reg sqlitestmtlib_m[] = {
static sqlite3 *
lua_check_sqlite3 (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{sqlite3}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{sqlite3}");
luaL_argcheck (L, ud != NULL, pos, "'sqlite3' expected");
return ud ? *((sqlite3 **)ud) : NULL;
}
@@ -74,7 +74,7 @@ lua_check_sqlite3 (lua_State * L, gint pos)
static sqlite3_stmt *
lua_check_sqlite3_stmt (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{sqlite3_stmt}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{sqlite3_stmt}");
luaL_argcheck (L, ud != NULL, pos, "'sqlite3_stmt' expected");
return ud ? *((sqlite3_stmt **)ud) : NULL;
}
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index c53833d85..31b0aac76 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -714,7 +714,7 @@ static const struct luaL_reg textlib_m[] = {
struct rspamd_task *
lua_check_task (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{task}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{task}");
luaL_argcheck (L, ud != NULL, pos, "'task' expected");
return ud ? *((struct rspamd_task **)ud) : NULL;
}
@@ -722,7 +722,7 @@ lua_check_task (lua_State * L, gint pos)
static struct rspamd_image *
lua_check_image (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{image}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{image}");
luaL_argcheck (L, ud != NULL, 1, "'image' expected");
return ud ? *((struct rspamd_image **)ud) : NULL;
}
@@ -730,7 +730,7 @@ lua_check_image (lua_State * L)
struct rspamd_lua_text *
lua_check_text (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{text}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{text}");
luaL_argcheck (L, ud != NULL, pos, "'text' expected");
return ud ? (struct rspamd_lua_text *)ud : NULL;
}
@@ -783,7 +783,7 @@ static int
lua_task_set_cfg (lua_State *L)
{
struct rspamd_task *task = lua_check_task (L, 1);
- void *ud = luaL_checkudata (L, 2, "rspamd{config}");
+ void *ud = rspamd_lua_check_udata (L, 2, "rspamd{config}");
if (task) {
luaL_argcheck (L, ud != NULL, 1, "'config' expected");
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c
index ad093cbe4..e6ccd85ee 100644
--- a/src/lua/lua_tcp.c
+++ b/src/lua/lua_tcp.c
@@ -486,7 +486,7 @@ lua_tcp_request (lua_State *L)
if (task == NULL) {
lua_pushstring (L, "ev_base");
lua_gettable (L, -2);
- if (luaL_checkudata (L, -1, "rspamd{ev_base}")) {
+ if (rspamd_lua_check_udata (L, -1, "rspamd{ev_base}")) {
ev_base = *(struct event_base **)lua_touserdata (L, -1);
}
else {
@@ -496,7 +496,7 @@ lua_tcp_request (lua_State *L)
lua_pushstring (L, "pool");
lua_gettable (L, -2);
- if (luaL_checkudata (L, -1, "rspamd{mempool}")) {
+ if (rspamd_lua_check_udata (L, -1, "rspamd{mempool}")) {
pool = *(rspamd_mempool_t **)lua_touserdata (L, -1);
}
else {
@@ -506,7 +506,7 @@ lua_tcp_request (lua_State *L)
lua_pushstring (L, "resolver");
lua_gettable (L, -2);
- if (luaL_checkudata (L, -1, "rspamd{resolver}")) {
+ if (rspamd_lua_check_udata (L, -1, "rspamd{resolver}")) {
resolver = *(struct rspamd_dns_resolver **)lua_touserdata (L, -1);
}
else {
@@ -516,7 +516,7 @@ lua_tcp_request (lua_State *L)
lua_pushstring (L, "session");
lua_gettable (L, -2);
- if (luaL_checkudata (L, -1, "rspamd{session}")) {
+ if (rspamd_lua_check_udata (L, -1, "rspamd{session}")) {
session = *(struct rspamd_async_session **)lua_touserdata (L, -1);
}
else {
diff --git a/src/lua/lua_trie.c b/src/lua/lua_trie.c
index befb956e4..ac6ebb559 100644
--- a/src/lua/lua_trie.c
+++ b/src/lua/lua_trie.c
@@ -60,7 +60,7 @@ static const struct luaL_reg trielib_f[] = {
static struct rspamd_multipattern *
lua_check_trie (lua_State * L, gint idx)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{trie}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{trie}");
luaL_argcheck (L, ud != NULL, 1, "'trie' expected");
return ud ? *((struct rspamd_multipattern **)ud) : NULL;
diff --git a/src/lua/lua_upstream.c b/src/lua/lua_upstream.c
index be745206f..fe4697758 100644
--- a/src/lua/lua_upstream.c
+++ b/src/lua/lua_upstream.c
@@ -90,7 +90,7 @@ static const struct luaL_reg upstream_m[] = {
static struct upstream *
lua_check_upstream (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{upstream}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{upstream}");
luaL_argcheck (L, ud != NULL, 1, "'upstream' expected");
return ud ? *((struct upstream **)ud) : NULL;
@@ -153,7 +153,7 @@ lua_upstream_ok (lua_State *L)
static struct upstream_list *
lua_check_upstream_list (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{upstream_list}");
+ void *ud = rspamd_lua_check_udata (L, 1, "rspamd{upstream_list}");
luaL_argcheck (L, ud != NULL, 1, "'upstream_list' expected");
return ud ? *((struct upstream_list **)ud) : NULL;
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c
index 24c3f9a70..af49624b9 100644
--- a/src/lua/lua_url.c
+++ b/src/lua/lua_url.c
@@ -84,7 +84,7 @@ static const struct luaL_reg urllib_f[] = {
static struct rspamd_lua_url *
lua_check_url (lua_State * L, gint pos)
{
- void *ud = luaL_checkudata (L, pos, "rspamd{url}");
+ void *ud = rspamd_lua_check_udata (L, pos, "rspamd{url}");
luaL_argcheck (L, ud != NULL, pos, "'url' expected");
return ud ? ((struct rspamd_lua_url *)ud) : NULL;
}