#include #include #include #include #include #include #include "config.h" #include "_whelk.h" int whelk_perror(lua_State *L,const char *s) { lua_pushnil(L); if (s) lua_pushfstring(L,"%s: %s",s,strerror(errno)); else lua_pushstring(L,strerror(errno)); lua_pushinteger(L,errno); return 3; } static int whelk_unsupported(lua_State *L) { errno=ENOSYS; return whelk_perror(L,NULL); } #ifdef __WIN32__ #define WIN32_ONLY(func) func #else #define WIN32_ONLY(func) whelk_unsupported #endif static const luaL_reg whelk_functions[]={ { "GetFolderPath",WIN32_ONLY(whelk_get_folder_path) }, { "CreateShortCut",WIN32_ONLY(whelk_create_short_cut) }, { "Spawn",WIN32_ONLY(whelk_spawn) }, { "CryptCATAdmin",WIN32_ONLY(whelk_crypt_cat_admin_new) }, { "SetupCopyOEMInf",WIN32_ONLY(whelk_setup_copy_oem_inf) }, { "SetupUninstallOEMInf",WIN32_ONLY(whelk_setup_uninstall_oem_inf) }, { NULL } }; LUALIB_API int luaopen_whelk(lua_State *L) { luaL_register(L,"whelk",whelk_functions); lua_pushliteral(L,"version"); lua_pushliteral(L,PACKAGE_STRING); lua_settable(L,-3); #ifdef __WIN32__ whelk_open_get_folder_path(L); whelk_open_reg_keys(L); whelk_open_setup(L); #endif return 1; }