From: Siavash Tavakoli Date: Fri, 13 Aug 2021 10:08:30 +0000 (+0100) Subject: global: Use consistent lua function names X-Git-Tag: 2.3.17~195 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f28482afb825004073bf3550610fefc3ab882efb;p=thirdparty%2Fdovecot%2Fcore.git global: Use consistent lua function names Change lua-style function names to be consistent with dovecot's style. --- diff --git a/src/auth/db-lua.c b/src/auth/db-lua.c index d2b48e454e..dd4e77b25f 100644 --- a/src/auth/db-lua.c +++ b/src/auth/db-lua.c @@ -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); diff --git a/src/lib-lua/dlua-dovecot.c b/src/lib-lua/dlua-dovecot.c index 9dce09cfad..991ce25975 100644 --- a/src/lib-lua/dlua-dovecot.c +++ b/src/lib-lua/dlua-dovecot.c @@ -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); } diff --git a/src/lib-lua/dlua-error.c b/src/lib-lua/dlua-error.c index 6ecb5d2f41..90011ed1d7 100644 --- a/src/lib-lua/dlua-error.c +++ b/src/lib-lua/dlua-error.c @@ -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); } diff --git a/src/lib-lua/dlua-pushstring.c b/src/lib-lua/dlua-pushstring.c index d985e177c2..436fd29cfc 100644 --- a/src/lib-lua/dlua-pushstring.c +++ b/src/lib-lua/dlua-pushstring.c @@ -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; } diff --git a/src/lib-lua/dlua-script-private.h b/src/lib-lua/dlua-script-private.h index 32c9ab6e29..5abe5086d9 100644 --- a/src/lib-lua/dlua-script-private.h +++ b/src/lib-lua/dlua-script-private.h @@ -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); diff --git a/src/lib-lua/dlua-script.c b/src/lib-lua/dlua-script.c index db5a39143d..31fa69793a 100644 --- a/src/lib-lua/dlua-script.c +++ b/src/lib-lua/dlua-script.c @@ -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); diff --git a/src/lib-storage/mail-lua.c b/src/lib-storage/mail-lua.c index 018d46d884..a559f98ab8 100644 --- a/src/lib-storage/mail-lua.c +++ b/src/lib-storage/mail-lua.c @@ -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"); diff --git a/src/lib-storage/mail-storage-lua.c b/src/lib-storage/mail-storage-lua.c index 6b57d3eb88..02808bd785 100644 --- a/src/lib-storage/mail-storage-lua.c +++ b/src/lib-storage/mail-storage-lua.c @@ -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); diff --git a/src/lib-storage/mail-user-lua.c b/src/lib-storage/mail-user-lua.c index 55577f1db1..529bd75443 100644 --- a/src/lib-storage/mail-user-lua.c +++ b/src/lib-storage/mail-user-lua.c @@ -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 * diff --git a/src/lib-storage/mailbox-lua.c b/src/lib-storage/mailbox-lua.c index 18e5c1f9db..19327ba0a4 100644 --- a/src/lib-storage/mailbox-lua.c +++ b/src/lib-storage/mailbox-lua.c @@ -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; diff --git a/src/plugins/push-notification/push-notification-driver-lua.c b/src/plugins/push-notification/push-notification-driver-lua.c index 629a581e77..e1178fa774 100644 --- a/src/plugins/push-notification/push-notification-driver-lua.c +++ b/src/plugins/push-notification/push-notification-driver-lua.c @@ -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);