summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-09-09 15:39:17 +0000
committerSteven Barth <steven@midlink.org>2008-09-09 15:39:17 +0000
commit9a8cd55c36602a56ed782a4e6b8d740d0d02b22e (patch)
tree140bce8bbe33a7a0a32273b241db1d6c33f4364d
parentc287c8ca7e8abc9026c079cc9e00028a3ae6cb97 (diff)
Optimized uvl.datatypes
-rw-r--r--libs/uvl/luasrc/uvl/datatypes.lua25
1 files changed, 14 insertions, 11 deletions
diff --git a/libs/uvl/luasrc/uvl/datatypes.lua b/libs/uvl/luasrc/uvl/datatypes.lua
index e6a4c1688..971bb9d75 100644
--- 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 )
@@ -59,7 +62,7 @@ end
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
@@ -72,7 +75,7 @@ end
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
@@ -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
- local parts = luci.util.split( val, ":" )
+ local parts = util.split( val, ":" )
for i = 1,6 do
parts[i] = tonumber( parts[i], 16 )
@@ -134,7 +137,7 @@ function string( val )
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
@@ -142,7 +145,7 @@ function directory( val, seen )
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
@@ -150,7 +153,7 @@ function directory( 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
@@ -158,7 +161,7 @@ function file( val, seen )
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