[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: parsing IP address.
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Wed, 17 Sep 2008 17:15:58 +0200
> In my project requirement there is a lua wrapper function which is
> function pointer and takes any C function name and its parameters as
> input and execute that C function.
> Ex:- vxDo("functionname","memStats","murthy",1,2)
> its works fine for strings,integers as function parameters as mentioned
> above.However if we pass IP address ie for example "169.254.0.4" as
> input then its takes as integer and reads only first element 169 and
> system hangs.ex:-vxDo("functionname","169.254.0.4","memStats",1,2)
> It will be gratefull if somebody throws some light on how to parse the
> whole IP address in lua.
Do you want to pass the ip address as an int ? If so you can use the
local num = 0
for elem in str:gmatch("%d+") do
num = num * 256 + assert(tonumber(elem))