]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Use consistent lua function names
authorSiavash Tavakoli <siavash.tavakoli@open-xchange.com>
Fri, 13 Aug 2021 10:08:30 +0000 (11:08 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 17 Aug 2021 07:49:37 +0000 (07:49 +0000)
Change lua-style function names to be consistent with dovecot's style.

src/auth/db-lua.c
src/lib-lua/dlua-dovecot.c
src/lib-lua/dlua-error.c
src/lib-lua/dlua-pushstring.c
src/lib-lua/dlua-script-private.h
src/lib-lua/dlua-script.c
src/lib-storage/mail-lua.c
src/lib-storage/mail-storage-lua.c
src/lib-storage/mail-user-lua.c
src/lib-storage/mailbox-lua.c
src/plugins/push-notification/push-notification-driver-lua.c

index d2b48e454e871d29641e9b10c51e92609332e5db..dd4e77b25f0a060914c0115728813a297e38c82f 100644 (file)
@@ -303,14 +303,14 @@ static void auth_lua_push_auth_request(lua_State *L, struct auth_request *req)
        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 *
@@ -370,12 +370,12 @@ static luaL_Reg auth_lua_dovecot_auth_methods[] = {
 
 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);
index 9dce09cfad70df15dc8e2c0bf38ca739ee8a206d..991ce259757087c9f1b985aa4e442e17f1fb75b6 100644 (file)
@@ -585,7 +585,7 @@ static luaL_Reg lua_dovecot_methods[] = {
        { NULL, NULL }
 };
 
-void dlua_getdovecot(lua_State *L)
+void dlua_get_dovecot(lua_State *L)
 {
        lua_getglobal(L, LUA_SCRIPT_DOVECOT);
 }
index 6ecb5d2f41ba87a74cc5dcad7b56cf7c47aa7878..90011ed1d7c0b9405f501f93c4606738f712e93e 100644 (file)
@@ -7,7 +7,7 @@ int dluaL_error(lua_State *L, const char *fmt, ...)
 {
        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);
 }
index d985e177c2df52fe22fc4dbe33037c24acabcb28..436fd29cfc484bc75a4840eb5a3139fcf8c275e2 100644 (file)
@@ -4,7 +4,7 @@
 #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 {
@@ -15,12 +15,12 @@ const char *dlua_pushvfstring(lua_State *L, const char *fmt, va_list argp)
        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;
 }
index 32c9ab6e29df619a3f371ecfb9ca48c2341faa32..5abe5086d98405791d9d29d90a5991e596735c8d 100644 (file)
@@ -91,10 +91,10 @@ struct dlua_script *dlua_script_from_state(lua_State *L);
 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);
@@ -103,8 +103,8 @@ 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);
index db5a39143d4124fe3a1683e4c1d89c06a68540e6..31fa69793a272cecdd5dcc82c4918dae6b0373e4 100644 (file)
@@ -387,7 +387,7 @@ bool dlua_script_has_function(struct dlua_script *script, const char *fn)
        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);
index 018d46d884e64d44e5a293684c846770ddba47ce..a559f98ab82a3c41969c860cb34a4a94b72005a5 100644 (file)
@@ -25,18 +25,18 @@ void dlua_push_mail(lua_State *L, struct mail *mail)
        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");
index 6b57d3eb886bfc11ec68930d88996b167cd90398..02808bd7854c983613cc0730d5c5c6722b208096 100644 (file)
@@ -62,12 +62,12 @@ static luaL_Reg lua_storage_methods[] = {
 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);
index 55577f1db12375a6b923b759ba7d76d29521e655..529bd754431dfedfee16e14128e1febff3707710 100644 (file)
@@ -33,16 +33,16 @@ void dlua_push_mail_user(lua_State *L, struct mail_user *user)
        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);
 
@@ -52,21 +52,21 @@ void dlua_push_mail_user(lua_State *L, struct mail_user *user)
        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 *
index 18e5c1f9db603502e34ebe2760f30498338d2710..19327ba0a475964ca3e1a82c817143832b11bdb3 100644 (file)
@@ -182,35 +182,35 @@ static int lua_storage_mailbox_status(lua_State *L)
        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;
index 629a581e77cc9f03fff5450c83c4093684b3b652..e1178fa774fef36942956ba0e34bd53be85b5688 100644 (file)
@@ -252,7 +252,7 @@ static const char *push_notification_driver_lua_to_fn(const char *evname)
 }
 
 /* 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;
@@ -284,7 +284,7 @@ static void dlua_pushflags(struct dlua_script *script, enum mail_flags flags)
 }
 
 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);
@@ -305,20 +305,20 @@ push_notification_lua_push_flagsclear(
        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");
        }
 }
@@ -332,12 +332,12 @@ push_notification_lua_push_flagsset(
        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");
        }
 }
@@ -353,7 +353,7 @@ push_notification_lua_push_mailboxrename(
        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
@@ -361,14 +361,14 @@ push_notification_lua_push_message_ext(
        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);
@@ -388,19 +388,19 @@ push_notification_lua_push_messageappend(
        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");
 
@@ -423,19 +423,19 @@ push_notification_lua_push_messagenew(
        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");
 
@@ -474,7 +474,7 @@ static struct push_notification_event_to_lua {
 };
 
 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)
 {
@@ -513,7 +513,7 @@ push_notification_driver_lua_call(
        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);