| 933 | } |
| 934 | |
| 935 | LUALIB_API int luaopen_cmsgpack_safe(lua_State *L) { |
| 936 | int i; |
| 937 | |
| 938 | luaopen_cmsgpack(L); |
| 939 | |
| 940 | /* Wrap all functions in the safe handler */ |
| 941 | for (i = 0; i < (sizeof(cmds)/sizeof(*cmds) - 1); i++) { |
| 942 | lua_getfield(L, -1, cmds[i].name); |
| 943 | lua_pushcclosure(L, mp_safe, 1); |
| 944 | lua_setfield(L, -2, cmds[i].name); |
| 945 | } |
| 946 | |
| 947 | #if LUA_VERSION_NUM < 502 |
| 948 | /* Register name globally for 5.1 */ |
| 949 | lua_pushvalue(L, -1); |
| 950 | lua_setglobal(L, LUACMSGPACK_SAFE_NAME); |
| 951 | #endif |
| 952 | |
| 953 | return 1; |
| 954 | } |
| 955 | |
| 956 | /****************************************************************************** |
| 957 | * Copyright (C) 2012 Salvatore Sanfilippo. All rights reserved. |
nothing calls this directly
no test coverage detected