mail-user-lua.c (dovecot-2.3.16) | : | mail-user-lua.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
mail_user_ref(user); | mail_user_ref(user); | |||
struct mail_user **ptr = lua_newuserdata(L, sizeof(struct mail_user*)); | struct mail_user **ptr = lua_newuserdata(L, sizeof(struct mail_user*)); | |||
*ptr = user; | *ptr = user; | |||
lua_createtable(L, 0, 1); | lua_createtable(L, 0, 1); | |||
lua_pushcfunction(L, lua_storage_mail_user_unref); | lua_pushcfunction(L, lua_storage_mail_user_unref); | |||
lua_setfield(L, -2, "__gc"); | lua_setfield(L, -2, "__gc"); | |||
lua_setmetatable(L, -2); | lua_setmetatable(L, -2); | |||
lua_setfield(L, -2, "item"); | lua_setfield(L, -2, "item"); | |||
#undef LUA_TABLE_SETNUMBER | #undef LUA_TABLE_SET_NUMBER | |||
#define LUA_TABLE_SETNUMBER(field) \ | #define LUA_TABLE_SET_NUMBER(field) \ | |||
lua_pushnumber(L, user->field); \ | lua_pushnumber(L, user->field); \ | |||
lua_setfield(L, -2, #field); | lua_setfield(L, -2, #field); | |||
#undef LUA_TABLE_SETBOOL | #undef LUA_TABLE_SET_BOOL | |||
#define LUA_TABLE_SETBOOL(field) \ | #define LUA_TABLE_SET_BOOL(field) \ | |||
lua_pushboolean(L, user->field); \ | lua_pushboolean(L, user->field); \ | |||
lua_setfield(L, -2, #field); | lua_setfield(L, -2, #field); | |||
#undef LUA_TABLE_SETSTRING | #undef LUA_TABLE_SET_STRING | |||
#define LUA_TABLE_SETSTRING(field) \ | #define LUA_TABLE_SET_STRING(field) \ | |||
lua_pushstring(L, user->field); \ | lua_pushstring(L, user->field); \ | |||
lua_setfield(L, -2, #field); | lua_setfield(L, -2, #field); | |||
const char *home = NULL; | const char *home = NULL; | |||
(void)mail_user_get_home(user, &home); | (void)mail_user_get_home(user, &home); | |||
lua_pushstring(L, home); | lua_pushstring(L, home); | |||
lua_setfield(L, -2, "home"); | lua_setfield(L, -2, "home"); | |||
LUA_TABLE_SETSTRING(username); | LUA_TABLE_SET_STRING(username); | |||
LUA_TABLE_SETNUMBER(uid); | LUA_TABLE_SET_NUMBER(uid); | |||
LUA_TABLE_SETNUMBER(gid); | LUA_TABLE_SET_NUMBER(gid); | |||
LUA_TABLE_SETSTRING(service); | LUA_TABLE_SET_STRING(service); | |||
LUA_TABLE_SETSTRING(session_id); | LUA_TABLE_SET_STRING(session_id); | |||
LUA_TABLE_SETNUMBER(session_create_time); | LUA_TABLE_SET_NUMBER(session_create_time); | |||
LUA_TABLE_SETBOOL(nonexistent); | LUA_TABLE_SET_BOOL(nonexistent); | |||
LUA_TABLE_SETBOOL(anonymous); | LUA_TABLE_SET_BOOL(anonymous); | |||
LUA_TABLE_SETBOOL(autocreated); | LUA_TABLE_SET_BOOL(autocreated); | |||
LUA_TABLE_SETBOOL(mail_debug); | LUA_TABLE_SET_BOOL(mail_debug); | |||
LUA_TABLE_SETBOOL(fuzzy_search); | LUA_TABLE_SET_BOOL(fuzzy_search); | |||
LUA_TABLE_SETBOOL(dsyncing); | LUA_TABLE_SET_BOOL(dsyncing); | |||
LUA_TABLE_SETBOOL(admin); | LUA_TABLE_SET_BOOL(admin); | |||
LUA_TABLE_SETBOOL(session_restored); | LUA_TABLE_SET_BOOL(session_restored); | |||
} | } | |||
static struct mail_user * | static struct mail_user * | |||
lua_check_storage_mail_user(lua_State *L, int arg) | lua_check_storage_mail_user(lua_State *L, int arg) | |||
{ | { | |||
if (!lua_istable(L, arg)) { | if (!lua_istable(L, arg)) { | |||
(void)luaL_error(L, "Bad argument #%d, expected %s got %s", | (void)luaL_error(L, "Bad argument #%d, expected %s got %s", | |||
arg, LUA_STORAGE_MAIL_USER, | arg, LUA_STORAGE_MAIL_USER, | |||
lua_typename(L, lua_type(L, arg))); | lua_typename(L, lua_type(L, arg))); | |||
} | } | |||
End of changes. 4 change blocks. | ||||
21 lines changed or deleted | 21 lines changed or added |