Change lua-style function names to be consistent with dovecot's style.
lua_pushboolean(L, req->fields.skip_password_check);
lua_setfield(L, -2, "skip_password_check");
-#undef LUA_TABLE_SETBOOL
-#define LUA_TABLE_SETBOOL(field) \
+#undef LUA_TABLE_SET_BOOL
+#define LUA_TABLE_SET_BOOL(field) \
lua_pushboolean(L, req->field); \
lua_setfield(L, -2, #field);
- LUA_TABLE_SETBOOL(passdbs_seen_user_unknown);
- LUA_TABLE_SETBOOL(passdbs_seen_internal_failure);
- LUA_TABLE_SETBOOL(userdbs_seen_internal_failure);
+ LUA_TABLE_SET_BOOL(passdbs_seen_user_unknown);
+ LUA_TABLE_SET_BOOL(passdbs_seen_internal_failure);
+ LUA_TABLE_SET_BOOL(userdbs_seen_internal_failure);
}
static struct auth_request *
static void auth_lua_dovecot_auth_register(lua_State *L)
{
- dlua_getdovecot(L);
+ dlua_get_dovecot(L);
/* Create new table for holding values */
lua_newtable(L);
/* register constants */
- dlua_setmembers(L, auth_lua_dovecot_auth_values, -1);
+ dlua_set_members(L, auth_lua_dovecot_auth_values, -1);
/* push new metatable to stack */
luaL_newmetatable(L, AUTH_LUA_DOVECOT_AUTH);
{ NULL, NULL }
};
-void dlua_getdovecot(lua_State *L)
+void dlua_get_dovecot(lua_State *L)
{
lua_getglobal(L, LUA_SCRIPT_DOVECOT);
}
{
va_list argp;
va_start(argp, fmt);
- (void)dlua_pushvfstring(L, fmt, argp);
+ (void)dlua_push_vfstring(L, fmt, argp);
va_end(argp);
return lua_error(L);
}
#include "str.h"
#include "dlua-script-private.h"
-const char *dlua_pushvfstring(lua_State *L, const char *fmt, va_list argp)
+const char *dlua_push_vfstring(lua_State *L, const char *fmt, va_list argp)
{
const char *str;
T_BEGIN {
return str;
}
-const char *dlua_pushfstring(lua_State *L, const char *fmt, ...)
+const char *dlua_push_fstring(lua_State *L, const char *fmt, ...)
{
const char *str;
va_list argp;
va_start(argp, fmt);
- str = dlua_pushvfstring(L, fmt, argp);
+ str = dlua_push_vfstring(L, fmt, argp);
va_end(argp);
return str;
}
void dlua_dovecot_register(struct dlua_script *script);
/* push 'dovecot' global on top of stack */
-void dlua_getdovecot(lua_State *L);
+void dlua_get_dovecot(lua_State *L);
/* assign values to table on idx */
-void dlua_setmembers(lua_State *L, const struct dlua_table_values *values, int idx);
+void dlua_set_members(lua_State *L, const struct dlua_table_values *values, int idx);
/* push event to top of stack */
void dlua_push_event(lua_State *L, struct event *event);
struct event *dlua_check_event(lua_State *L, int arg);
/* improved lua_pushfstring, can handle full C format support */
-const char *dlua_pushvfstring(lua_State *L, const char *fmt, va_list argp) ATTR_FORMAT(2, 0);
-const char *dlua_pushfstring(lua_State *L, const char *fmt, ...) ATTR_FORMAT(2, 3);
+const char *dlua_push_vfstring(lua_State *L, const char *fmt, va_list argp) ATTR_FORMAT(2, 0);
+const char *dlua_push_fstring(lua_State *L, const char *fmt, ...) ATTR_FORMAT(2, 3);
/* improved luaL_error, can handle full C format support */
int dluaL_error(lua_State *L, const char *fmt, ...) ATTR_FORMAT(2, 3);
return ret;
}
-void dlua_setmembers(lua_State *L, const struct dlua_table_values *values,
+void dlua_set_members(lua_State *L, const struct dlua_table_values *values,
int idx)
{
i_assert(L != NULL);
lua_pushlightuserdata(L, mail);
lua_setfield(L, -2, "item");
-#undef LUA_TABLE_SETNUMBER
-#define LUA_TABLE_SETNUMBER(field) \
+#undef LUA_TABLE_SET_NUMBER
+#define LUA_TABLE_SET_NUMBER(field) \
lua_pushnumber(L, mail->field); \
lua_setfield(L, -2, #field);
-#undef LUA_TABLE_SETBOOL
-#define LUA_TABLE_SETBOOL(field) \
+#undef LUA_TABLE_SET_BOOL
+#define LUA_TABLE_SET_BOOL(field) \
lua_pushboolean(L, mail->field); \
lua_setfield(L, -2, #field);
- LUA_TABLE_SETNUMBER(seq);
- LUA_TABLE_SETNUMBER(uid);
- LUA_TABLE_SETBOOL(expunged);
+ LUA_TABLE_SET_NUMBER(seq);
+ LUA_TABLE_SET_NUMBER(uid);
+ LUA_TABLE_SET_BOOL(expunged);
dlua_push_mailbox(L, mail->box);
lua_setfield(L, -2, "mailbox");
void dlua_register_mail_storage(struct dlua_script *script)
{
/* get dlua_dovecot */
- dlua_getdovecot(script->L);
+ dlua_get_dovecot(script->L);
/* Create table for holding values */
lua_newtable(script->L);
- dlua_setmembers(script->L, lua_storage_mail_storage_flags, -1);
+ dlua_set_members(script->L, lua_storage_mail_storage_flags, -1);
/* push new metatable to stack */
luaL_newmetatable(script->L, LUA_SCRIPT_STORAGE);
lua_setmetatable(L, -2);
lua_setfield(L, -2, "item");
-#undef LUA_TABLE_SETNUMBER
-#define LUA_TABLE_SETNUMBER(field) \
+#undef LUA_TABLE_SET_NUMBER
+#define LUA_TABLE_SET_NUMBER(field) \
lua_pushnumber(L, user->field); \
lua_setfield(L, -2, #field);
-#undef LUA_TABLE_SETBOOL
-#define LUA_TABLE_SETBOOL(field) \
+#undef LUA_TABLE_SET_BOOL
+#define LUA_TABLE_SET_BOOL(field) \
lua_pushboolean(L, user->field); \
lua_setfield(L, -2, #field);
-#undef LUA_TABLE_SETSTRING
-#define LUA_TABLE_SETSTRING(field) \
+#undef LUA_TABLE_SET_STRING
+#define LUA_TABLE_SET_STRING(field) \
lua_pushstring(L, user->field); \
lua_setfield(L, -2, #field);
lua_pushstring(L, home);
lua_setfield(L, -2, "home");
- LUA_TABLE_SETSTRING(username);
- LUA_TABLE_SETNUMBER(uid);
- LUA_TABLE_SETNUMBER(gid);
- LUA_TABLE_SETSTRING(service);
- LUA_TABLE_SETSTRING(session_id);
- LUA_TABLE_SETNUMBER(session_create_time);
-
- LUA_TABLE_SETBOOL(nonexistent);
- LUA_TABLE_SETBOOL(anonymous);
- LUA_TABLE_SETBOOL(autocreated);
- LUA_TABLE_SETBOOL(mail_debug);
- LUA_TABLE_SETBOOL(fuzzy_search);
- LUA_TABLE_SETBOOL(dsyncing);
- LUA_TABLE_SETBOOL(admin);
- LUA_TABLE_SETBOOL(session_restored);
+ LUA_TABLE_SET_STRING(username);
+ LUA_TABLE_SET_NUMBER(uid);
+ LUA_TABLE_SET_NUMBER(gid);
+ LUA_TABLE_SET_STRING(service);
+ LUA_TABLE_SET_STRING(session_id);
+ LUA_TABLE_SET_NUMBER(session_create_time);
+
+ LUA_TABLE_SET_BOOL(nonexistent);
+ LUA_TABLE_SET_BOOL(anonymous);
+ LUA_TABLE_SET_BOOL(autocreated);
+ LUA_TABLE_SET_BOOL(mail_debug);
+ LUA_TABLE_SET_BOOL(fuzzy_search);
+ LUA_TABLE_SET_BOOL(dsyncing);
+ LUA_TABLE_SET_BOOL(admin);
+ LUA_TABLE_SET_BOOL(session_restored);
}
static struct mail_user *
lua_pushstring(L, mailbox_get_vname(mbox));
lua_setfield(L, -2, "mailbox");
-#undef LUA_TABLE_SETNUMBER
-#define LUA_TABLE_SETNUMBER(field) \
+#undef LUA_TABLE_SET_NUMBER
+#define LUA_TABLE_SET_NUMBER(field) \
lua_pushnumber(L, status.field); \
lua_setfield(L, -2, #field);
-#undef LUA_TABLE_SETBOOL
-#define LUA_TABLE_SETBOOL(field) \
+#undef LUA_TABLE_SET_BOOL
+#define LUA_TABLE_SET_BOOL(field) \
lua_pushboolean(L, status.field); \
lua_setfield(L, -2, #field);
- LUA_TABLE_SETNUMBER(messages);
- LUA_TABLE_SETNUMBER(recent);
- LUA_TABLE_SETNUMBER(unseen);
- LUA_TABLE_SETNUMBER(uidvalidity);
- LUA_TABLE_SETNUMBER(uidnext);
- LUA_TABLE_SETNUMBER(first_unseen_seq);
- LUA_TABLE_SETNUMBER(first_recent_uid);
- LUA_TABLE_SETNUMBER(highest_modseq);
- LUA_TABLE_SETNUMBER(highest_pvt_modseq);
-
- LUA_TABLE_SETNUMBER(permanent_flags);
- LUA_TABLE_SETNUMBER(flags);
-
- LUA_TABLE_SETBOOL(permanent_keywords);
- LUA_TABLE_SETBOOL(allow_new_keywords);
- LUA_TABLE_SETBOOL(nonpermanent_modseqs);
- LUA_TABLE_SETBOOL(no_modseq_tracking);
- LUA_TABLE_SETBOOL(have_guids);
- LUA_TABLE_SETBOOL(have_save_guids);
- LUA_TABLE_SETBOOL(have_only_guid128);
+ LUA_TABLE_SET_NUMBER(messages);
+ LUA_TABLE_SET_NUMBER(recent);
+ LUA_TABLE_SET_NUMBER(unseen);
+ LUA_TABLE_SET_NUMBER(uidvalidity);
+ LUA_TABLE_SET_NUMBER(uidnext);
+ LUA_TABLE_SET_NUMBER(first_unseen_seq);
+ LUA_TABLE_SET_NUMBER(first_recent_uid);
+ LUA_TABLE_SET_NUMBER(highest_modseq);
+ LUA_TABLE_SET_NUMBER(highest_pvt_modseq);
+
+ LUA_TABLE_SET_NUMBER(permanent_flags);
+ LUA_TABLE_SET_NUMBER(flags);
+
+ LUA_TABLE_SET_BOOL(permanent_keywords);
+ LUA_TABLE_SET_BOOL(allow_new_keywords);
+ LUA_TABLE_SET_BOOL(nonpermanent_modseqs);
+ LUA_TABLE_SET_BOOL(no_modseq_tracking);
+ LUA_TABLE_SET_BOOL(have_guids);
+ LUA_TABLE_SET_BOOL(have_save_guids);
+ LUA_TABLE_SET_BOOL(have_only_guid128);
if (status.keywords != NULL && array_is_created(status.keywords)) {
int i = 1;
}
/* Pushes lua list of flags */
-static void dlua_pushflags(struct dlua_script *script, enum mail_flags flags)
+static void dlua_push_flags(struct dlua_script *script, enum mail_flags flags)
{
lua_newtable(script->L);
int idx = 1;
}
static void
-dlua_pushkeywords(struct dlua_script *script, const char *const *keywords,
+dlua_push_keywords(struct dlua_script *script, const char *const *keywords,
unsigned int count)
{
lua_newtable(script->L);
unsigned int size = 0;
struct push_notification_event_flagsclear_data *data = event->data;
- dlua_pushflags(script, data->flags_clear);
+ dlua_push_flags(script, data->flags_clear);
lua_setfield(script->L, -2, "flags");
- dlua_pushflags(script, data->flags_old);
+ dlua_push_flags(script, data->flags_old);
lua_setfield(script->L, -2, "flags_old");
if (array_is_created(&data->keywords_clear)) {
const char *const *kw = array_get(&data->keywords_clear, &size);
- dlua_pushkeywords(script, kw, size);
+ dlua_push_keywords(script, kw, size);
lua_setfield(script->L, -2, "keywords");
}
if (array_is_created(&data->keywords_old)) {
const char *const *kw = array_get(&data->keywords_old, &size);
- dlua_pushkeywords(script, kw, size);
+ dlua_push_keywords(script, kw, size);
lua_setfield(script->L, -2, "keywords_old");
}
}
unsigned int size = 0;
struct push_notification_event_flagsset_data *data = event->data;
- dlua_pushflags(script, data->flags_set);
+ dlua_push_flags(script, data->flags_set);
lua_setfield(script->L, -2, "flags");
if (array_is_created(&data->keywords_set)) {
const char *const *kw = array_get(&data->keywords_set, &size);
- dlua_pushkeywords(script, kw, size);
+ dlua_push_keywords(script, kw, size);
lua_setfield(script->L, -2, "keywords");
}
}
lua_setfield(script->L, -2, "mailbox_old");
}
-#define push_notification_lua_pushstring(L, value) \
+#define push_notification_lua_push_string(L, value) \
lua_pushstring((L), (value) == NULL ? "" : (value))
static void
const struct push_notification_message_ext *ext,
struct dlua_script *script)
{
- push_notification_lua_pushstring(script->L, ext->from_address);
+ push_notification_lua_push_string(script->L, ext->from_address);
lua_setfield(script->L, -2, "from_address");
- push_notification_lua_pushstring(script->L, ext->from_display_name_utf8);
+ push_notification_lua_push_string(script->L, ext->from_display_name_utf8);
lua_setfield(script->L, -2, "from_display_name");
- push_notification_lua_pushstring(script->L, ext->to_address);
+ push_notification_lua_push_string(script->L, ext->to_address);
lua_setfield(script->L, -2, "to_address");
- push_notification_lua_pushstring(script->L, ext->to_display_name_utf8);
+ push_notification_lua_push_string(script->L, ext->to_display_name_utf8);
lua_setfield(script->L, -2, "to_display_name");
lua_pushstring(script->L, ext->subject_utf8);
lua_pushnumber(script->L, data->date_tz);
lua_setfield(script->L, -2, "tz");
- push_notification_lua_pushstring(script->L, data->from);
+ push_notification_lua_push_string(script->L, data->from);
lua_setfield(script->L, -2, "from");
- push_notification_lua_pushstring(script->L, data->to);
+ push_notification_lua_push_string(script->L, data->to);
lua_setfield(script->L, -2, "to");
lua_pushstring(script->L, data->snippet);
lua_setfield(script->L, -2, "snippet");
- dlua_pushflags(script, data->flags);
+ dlua_push_flags(script, data->flags);
lua_setfield(script->L, -2, "flags");
- dlua_pushkeywords(script, data->keywords,
+ dlua_push_keywords(script, data->keywords,
str_array_length(data->keywords));
lua_setfield(script->L, -2, "keywords");
lua_pushnumber(script->L, data->date_tz);
lua_setfield(script->L, -2, "tz");
- push_notification_lua_pushstring(script->L, data->from);
+ push_notification_lua_push_string(script->L, data->from);
lua_setfield(script->L, -2, "from");
- push_notification_lua_pushstring(script->L, data->to);
+ push_notification_lua_push_string(script->L, data->to);
lua_setfield(script->L, -2, "to");
lua_pushstring(script->L, data->snippet);
lua_setfield(script->L, -2, "snippet");
- dlua_pushflags(script, data->flags);
+ dlua_push_flags(script, data->flags);
lua_setfield(script->L, -2, "flags");
- dlua_pushkeywords(script, data->keywords,
+ dlua_push_keywords(script, data->keywords,
str_array_length(data->keywords));
lua_setfield(script->L, -2, "keywords");
};
static void
-push_notification_driver_lua_pushevent(
+push_notification_driver_lua_push_event(
const struct push_notification_txn_event *event,
struct dlua_push_notification_context *ctx)
{
lua_rawgeti(ctx->script->L, LUA_REGISTRYINDEX, tctx->tx_ref);
/* Push event + common fields */
- push_notification_driver_lua_pushevent(event, ctx);
+ push_notification_driver_lua_push_event(event, ctx);
if (mbox != NULL) {
lua_pushstring(ctx->script->L, mbox->mailbox);