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;
}
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;
}
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;
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;
}
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);
}
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;
}
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;
}
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;
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;
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;
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;
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;
}
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;
/* 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);
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 {
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 {
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;
}
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;
}
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;
}
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;
}
}
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 {
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 {
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 {
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 {
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;
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;
}
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);
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;
}
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;
}
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;
}
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;
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;
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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");
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 {
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 {
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 {
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 {
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;
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;
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;
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;
}