projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c287c8c
)
Optimized uvl.datatypes
author
Steven Barth
<steven@midlink.org>
Tue, 9 Sep 2008 15:39:17 +0000
(15:39 +0000)
committer
Steven Barth
<steven@midlink.org>
Tue, 9 Sep 2008 15:39:17 +0000
(15:39 +0000)
libs/uvl/luasrc/uvl/datatypes.lua
patch
|
blob
|
history
diff --git
a/libs/uvl/luasrc/uvl/datatypes.lua
b/libs/uvl/luasrc/uvl/datatypes.lua
index
e6a4c16
..
971bb9d
100644
(file)
--- a/
libs/uvl/luasrc/uvl/datatypes.lua
+++ b/
libs/uvl/luasrc/uvl/datatypes.lua
@@
-14,11
+14,14
@@
$Id$
]]--
]]--
-module( "luci.uvl.datatypes", package.seeall )
+local fs = require "luci.fs"
+local ip = require "luci.ip"
+local math = require "math"
+local util = require "luci.util"
-require("luci.fs")
-require("luci.ip")
-require("luci.util")
+local tonumber = tonumber
+
+module "luci.uvl.datatypes"
function boolean( val )
function boolean( val )
@@
-59,7
+62,7
@@
end
function ip4addr( val )
if val then
function ip4addr( val )
if val then
- return
luci.
ip.IPv4(val) and true or false
+ return ip.IPv4(val) and true or false
end
return false
end
return false
@@
-72,7
+75,7
@@
end
function ip6addr( val )
if val then
function ip6addr( val )
if val then
- return
luci.
ip.IPv6(val) and true or false
+ return ip.IPv6(val) and true or false
end
return false
end
return false
@@
-102,7
+105,7
@@
function macaddr( val )
"^[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+:" ..
"[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+$"
) then
"^[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+:" ..
"[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+$"
) then
- local parts =
luci.
util.split( val, ":" )
+ local parts = util.split( val, ":" )
for i = 1,6 do
parts[i] = tonumber( parts[i], 16 )
for i = 1,6 do
parts[i] = tonumber( parts[i], 16 )
@@
-134,7
+137,7
@@
function string( val )
end
function directory( val, seen )
end
function directory( val, seen )
- local s =
luci.
fs.stat( val )
+ local s = fs.stat( val )
seen = seen or { }
if s and not seen[s.ino] then
seen = seen or { }
if s and not seen[s.ino] then
@@
-142,7
+145,7
@@
function directory( val, seen )
if s.type == "directory" then
return true
elseif s.type == "link" then
if s.type == "directory" then
return true
elseif s.type == "link" then
- return directory(
luci.
fs.readlink(val), seen )
+ return directory( fs.readlink(val), seen )
end
end
end
end
@@
-150,7
+153,7
@@
function directory( val, seen )
end
function file( val, seen )
end
function file( val, seen )
- local s =
luci.
fs.stat( val )
+ local s = fs.stat( val )
seen = seen or { }
if s and not seen[s.ino] then
seen = seen or { }
if s and not seen[s.ino] then
@@
-158,7
+161,7
@@
function file( val, seen )
if s.type == "regular" then
return true
elseif s.type == "link" then
if s.type == "regular" then
return true
elseif s.type == "link" then
- return file(
luci.
fs.readlink(val), seen )
+ return file( fs.readlink(val), seen )
end
end
end
end