]> git.e2factory.org Git - e2factory.git/commitdiff
Change hash module to a more protected type
authorTobias Ulmer <tu@emlix.com>
Fri, 3 Aug 2012 14:45:27 +0000 (16:45 +0200)
committerTobias Ulmer <tu@emlix.com>
Mon, 6 Aug 2012 09:23:55 +0000 (11:23 +0200)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/hash.lua
local/e2tool.lua
local/files.lua
local/git.lua
local/svn.lua

index 95e8f15d9021ce3ea539a244a4aa1d261006b794..7201dc352963181a34cc72bb20d8e0120398bcb2 100644 (file)
@@ -1,6 +1,7 @@
 --[[
    e2factory, the emlix embedded build system
 
+   Copyright (C) 2012 Tobias Ulmer <tu@emlix.com>, emlix GmbH
    Copyright (C) 2007-2009 Gordon Hecker <gh@emlix.com>, emlix GmbH
    Copyright (C) 2007-2009 Oskar Schirmer <os@emlix.com>, emlix GmbH
    Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ]]
 
-module("hash", package.seeall)
+local hash = {}
 require("sha1")
 
 --- create a hash context
 -- @return a hash context object, or nil on error
 -- @return nil, an error string on error
-function hash_start()
+function hash.hash_start()
        local hc = {}
 
        for k,v in pairs(hash) do
@@ -48,7 +49,7 @@ end
 --- add hash data
 -- @param hc the hash context
 -- @param data string: data
-function hash_append(hc, data)
+function hash.hash_append(hc, data)
        assert(type(hc) == "table" and type(hc.ctx) == "userdata")
        assert(type(data) == "string")
 
@@ -66,8 +67,8 @@ end
 --- hash a line
 -- @param hc the hash context
 -- @param data string: data to hash, a newline is appended
-function hash_line(hc, data)
-       hash_append(hc, data .. "\n")
+function hash.hash_line(hc, data)
+       hash.hash_append(hc, data .. "\n")
 end
 
 --- hash a file
@@ -75,7 +76,7 @@ end
 -- @param path string: the full path to the file
 -- @return true on success, nil on error
 -- @return nil, error object on failure
-function hash_file(hc, path)
+function hash.hash_file(hc, path)
        assert(type(hc) == "table" and type(hc.ctx) == "userdata")
        assert(type(path) == "string")
 
@@ -91,7 +92,7 @@ function hash_file(hc, path)
                        break
                end
 
-               hash_append(hc, buf)
+               hash.hash_append(hc, buf)
        end
 
        fd:close()
@@ -103,7 +104,7 @@ end
 -- @param hc the hash context
 -- @return the hash value, or nil on error
 -- @return an error string on error
-function hash_finish(hc)
+function hash.hash_finish(hc)
        assert(type(hc) == "table" and type(hc.ctx) == "userdata")
 
        hc.ctx:update(hc.data)
@@ -118,3 +119,5 @@ function hash_finish(hc)
 
        return cs
 end
+
+return hash
index 70b79e4a9e8de44434157608f75b36ca5ece6c23..51320fb46a08469aed4d22a8321a36522e15ba70 100644 (file)
@@ -45,7 +45,7 @@ require("tools")
 require("environment")
 require("plugin")
 require("url")
-require("hash")
+local hash = require("hash")
 require("lock")
 require("e2util")
 require("e2option")
index f2323658cf5afe5c10a5edefacef06b1f8bef5a4..edede203b15f0da766b5913b17659708c691721b 100644 (file)
@@ -31,6 +31,7 @@
 
 module("files", package.seeall)
 require("scm")
+local hash = require("hash")
 
 --- validate source configuration, log errors to the debug log
 -- @param info the info table
index f8b5a1894134c147e99ffb282a245159caddf630..dda7c239ec692460644b090440e95acd48490692 100644 (file)
@@ -31,6 +31,7 @@
 
 module("git", package.seeall)
 require("scm")
+local hash = require("hash")
 
 --- git branch wrapper
 -- get the current branch
index 78baf831b0b06a2bd563e8a1451b0fd3ee0b81e6..31bd3f34ef116480ab1a53fe2c5ebb108ce1bfba 100644 (file)
@@ -29,6 +29,7 @@
 
 module("svn", package.seeall)
 require("scm")
+local hash = require("hash")
 
 --- translate url into subversion url
 -- @param u table: url table