Mercurial > prosody-hg
comparison util/caps.lua @ 6777:5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 21 Feb 2015 10:36:37 +0100 |
| parents | bd0ff8ae98a8 |
| children | 4f0f5b49bb03 |
comparison
equal
deleted
inserted
replaced
| 6774:3965662ae091 | 6777:5de6b93d0190 |
|---|---|
| 10 local sha1 = require "util.hashes".sha1; | 10 local sha1 = require "util.hashes".sha1; |
| 11 | 11 |
| 12 local t_insert, t_sort, t_concat = table.insert, table.sort, table.concat; | 12 local t_insert, t_sort, t_concat = table.insert, table.sort, table.concat; |
| 13 local ipairs = ipairs; | 13 local ipairs = ipairs; |
| 14 | 14 |
| 15 module "caps" | 15 local _ENV = nil; |
| 16 | 16 |
| 17 function calculate_hash(disco_info) | 17 local function calculate_hash(disco_info) |
| 18 local identities, features, extensions = {}, {}, {}; | 18 local identities, features, extensions = {}, {}, {}; |
| 19 for _, tag in ipairs(disco_info) do | 19 for _, tag in ipairs(disco_info) do |
| 20 if tag.name == "identity" then | 20 if tag.name == "identity" then |
| 21 t_insert(identities, (tag.attr.category or "").."\0"..(tag.attr.type or "").."\0"..(tag.attr["xml:lang"] or "").."\0"..(tag.attr.name or "")); | 21 t_insert(identities, (tag.attr.category or "").."\0"..(tag.attr.type or "").."\0"..(tag.attr["xml:lang"] or "").."\0"..(tag.attr.name or "")); |
| 22 elseif tag.name == "feature" then | 22 elseif tag.name == "feature" then |
| 56 local S = identities..features..extensions; | 56 local S = identities..features..extensions; |
| 57 local ver = base64(sha1(S)); | 57 local ver = base64(sha1(S)); |
| 58 return ver, S; | 58 return ver, S; |
| 59 end | 59 end |
| 60 | 60 |
| 61 return _M; | 61 return { |
| 62 calculate_hash = calculate_hash; | |
| 63 }; |
