util.x509: Only collect commonNames that pass idna
[prosody.git] / util-src / compat.c
blob34b35c35bf0a63a0a086cd7af210a04c77f17f36
2 #include <lua.h>
3 #include <lauxlib.h>
6 static int lc_xpcall (lua_State *L) {
7 int ret;
8 int n_arg = lua_gettop(L);
9 /* f, msgh, p1, p2... */
10 luaL_argcheck(L, n_arg >= 2, 2, "value expected");
11 lua_pushvalue(L, 1); /* f to top */
12 lua_pushvalue(L, 2); /* msgh to top */
13 lua_replace(L, 1); /* msgh to 1 */
14 lua_replace(L, 2); /* f to 2 */
15 /* msgh, f, p1, p2... */
16 ret = lua_pcall(L, n_arg - 2, LUA_MULTRET, 1);
17 lua_pushboolean(L, ret == 0);
18 lua_replace(L, 1);
19 return lua_gettop(L);
22 int luaopen_util_compat(lua_State *L) {
23 lua_createtable(L, 0, 2);
25 lua_pushcfunction(L, lc_xpcall);
26 lua_setfield(L, -2, "xpcall");
28 return 1;