level 1
zhulu323
楼主
func.lua
require("LuaXml")
function get_result(msg,name,oper,arg)
local xfile = xml.eval(msg)
local body = xfile:find("body")
if body ~= nil then
local request = body:find("Request")
if request ~= nil then
local results = request:find("Results")
if results ~= nil then
print (results[1])
local Result = results[1]:find("Result")
if Result ~= nil then
if Result:find("displayName")[1] == "360杀毒" then
if oper == ">=" then
if Result:find("versionNumber")[1] >= arg then
return 1
end
elseif oper == "<=" then
if Result:find("versionNumber")[1] <= arg then
return 1
end
elseif oper == "=" then
if Result:find("versionNumber")[1] == arg then
return 1
end
end
end
end
end
end
end
return 0
end
c程序:
#include <stdio.h>#
include
#include <string.h>#
include
#include <lua.h>#
include #include
char msg[]=" ""id00000x""tdsvc.agentservice""tdsvc.wmimgr""WmiQuery""2012/1/10 10:20:30""""""""SELECT * FROM AntiVirusProduct""""""360.cn""360杀毒""""""{D737F2DE-FA43-4036-AF5B-911612E2D674}""TRUE""""""TRUE""""""3.1.0.3074""""""""""";
int main(int argc,char** argv){ lua_State * l = luaL_newstate() ; if ( l == NULL ) { printf("luaL_newstat() failed"); } int ret = 0 ; ret = luaL_loadfile(l,"func.lua") ; if ( ret != 0 ) { printf("luaL_loadfile failed") ; } ret = lua_pcall(l,0,0,0) ; if ( ret != 0 ) { printf("lua_pcall failed:%s",lua_tostring(l,-1)) ;}
lua_getglobal(l,"get_result"); lua_pushstring(l,msg);lua_pushstring(l,">=");lua_pushstring(l,"3.1"); ret = lua_pcall(l,3,1,0) ; if ( ret != 0 ) { printf("lua_pcall failed:%s",lua_tostring(l,-1)) ; exit; } printf("result\n",(int)lua_tonumber(l,-1)) ; lua_pop(l,1);
lua_close(l) ; return 0 ;}
2012年07月31日 07点07分
1
require("LuaXml")
function get_result(msg,name,oper,arg)
local xfile = xml.eval(msg)
local body = xfile:find("body")
if body ~= nil then
local request = body:find("Request")
if request ~= nil then
local results = request:find("Results")
if results ~= nil then
print (results[1])
local Result = results[1]:find("Result")
if Result ~= nil then
if Result:find("displayName")[1] == "360杀毒" then
if oper == ">=" then
if Result:find("versionNumber")[1] >= arg then
return 1
end
elseif oper == "<=" then
if Result:find("versionNumber")[1] <= arg then
return 1
end
elseif oper == "=" then
if Result:find("versionNumber")[1] == arg then
return 1
end
end
end
end
end
end
end
return 0
end
c程序:
#include <stdio.h>#
include
#include <string.h>#
include
#include <lua.h>#
include #include
char msg[]=" ""id00000x""tdsvc.agentservice""tdsvc.wmimgr""WmiQuery""2012/1/10 10:20:30""""""""SELECT * FROM AntiVirusProduct""""""360.cn""360杀毒""""""{D737F2DE-FA43-4036-AF5B-911612E2D674}""TRUE""""""TRUE""""""3.1.0.3074""""""""""";
int main(int argc,char** argv){ lua_State * l = luaL_newstate() ; if ( l == NULL ) { printf("luaL_newstat() failed"); } int ret = 0 ; ret = luaL_loadfile(l,"func.lua") ; if ( ret != 0 ) { printf("luaL_loadfile failed") ; } ret = lua_pcall(l,0,0,0) ; if ( ret != 0 ) { printf("lua_pcall failed:%s",lua_tostring(l,-1)) ;}
lua_getglobal(l,"get_result"); lua_pushstring(l,msg);lua_pushstring(l,">=");lua_pushstring(l,"3.1"); ret = lua_pcall(l,3,1,0) ; if ( ret != 0 ) { printf("lua_pcall failed:%s",lua_tostring(l,-1)) ; exit; } printf("result\n",(int)lua_tonumber(l,-1)) ; lua_pop(l,1);
lua_close(l) ; return 0 ;}