00001
00002
00032 #ifndef _LUAINSTANCE_H
00033 #define _LUAINSTANCE_H 1
00034
00035
00036 #include <string>
00037
00038
00042 extern "C"
00043 {
00044 #include <lua.h>
00045 #include <lauxlib.h>
00046 #include <lualib.h>
00047 }
00048
00049
00050
00051
00075 class CLUAInstance
00076 {
00077
00078 public:
00085 static CLUAInstance *getInstance();
00086
00087
00091 ~CLUAInstance( );
00092
00093
00098 void runScript( std::string fileName );
00099
00100
00118 void callFunction(const char *func, const char *sig, ...);
00119
00120
00126 void callFunctionError( const char *fmt, ...);
00127
00128
00129 protected:
00130
00131
00136 CLUAInstance( );
00137
00138
00139 private:
00140
00141
00147 void registerFunctions();
00148
00149
00154 static CLUAInstance *m_instance;
00155
00156
00160 lua_State* m_lua;
00161
00162
00166 static int LUAGetURI( lua_State *L );
00167
00171 static int LUAServiceByPort( lua_State *L );
00172
00176 static int LUAServiceByName( lua_State *L );
00177
00178
00182 static int LUADetectService( lua_State *L );
00183
00187 static int LUAMD5Sum( lua_State *L );
00188
00192 static int LUAMD5SumFile( lua_State *L );
00193
00197 static int LUASHA1Sum( lua_State *L );
00198
00199
00203 static int LUASHA1SumFile( lua_State *L );
00204
00205
00209 static int LUAOpenPorts( lua_State *L );
00210
00214 static int CLUAInstance::LUAToHost( lua_State *L );
00215
00219 static int CLUAInstance::LUAToIP( lua_State *L );
00220
00221
00225 static int GetFileSize( const char *fileName );
00226
00230 static const char *readCompleteFile( const char *fileName );
00231
00232 };
00233
00234
00235 #endif