//gm_zip by Hexxeh#include <windows.h>#include "common/GMLuaModule.h"// This is a macro to make life easier.// When the dll is loaded it will call the function (Init)GMOD_MODULE( Init, Shutdown );LUA_FUNCTION( version ){ // Push a string onto the Lua stack g_Lua->Push( "gm_zip version 0.1" ); // Return 1 because we're returning 1 string return 1;}LUA_FUNCTION( unzip ){ const char* filename = g_Lua->GetString(1); const char* extractdir = g_Lua->GetString(2); ZipFile zip = ZipFile.Read(filename); foreach (ZipEntry e in zip) { e.Extract(extractdir); }}// When the DLL is initialized it will call this function to set itself up.// It should be used to set up your library so it's all ready to go.int Init( void ){ // Msg is defined in GMLuaModule.h // It's actually calling the Lua function, Msg Msg("gm_zip by Hexxeh loaded\n"); // Lets make a global table filled with functions (a module) g_Lua->NewGlobalTable( "zip" ); ILuaObject* zip = g_Lua->GetGlobal( "zip" ); zip->SetMember( "version", version ); // We're not deleting the table here - we're deleting the reference to it. // If you don't do this you're leaking memory. SAFE_UNREF( zip ); return 0;}// When the DLL is shutdown it calls this function.// g_Lua should be assumed to have been released hereint Shutdown( void ){ return 0;}