diff options
Diffstat (limited to 'util/rsm.lua')
-rw-r--r-- | util/rsm.lua | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/util/rsm.lua b/util/rsm.lua index 40a78fb5..e6060af8 100644 --- a/util/rsm.lua +++ b/util/rsm.lua @@ -10,10 +10,15 @@ -- local stanza = require"util.stanza".stanza; -local tostring, tonumber = tostring, tonumber; +local tonumber = tonumber; +local s_format = string.format; local type = type; local pairs = pairs; +local function inttostr(n) + return s_format("%d", n); +end + local xmlns_rsm = 'http://jabber.org/protocol/rsm'; local element_parsers = {}; @@ -45,22 +50,31 @@ end local element_generators = setmetatable({ first = function(st, data) if type(data) == "table" then - st:tag("first", { index = data.index }):text(data[1]):up(); + st:tag("first", { index = inttostr(data.index) }):text(data[1]):up(); else - st:tag("first"):text(tostring(data)):up(); + st:text_tag("first", data); end end; before = function(st, data) if data == true then st:tag("before"):up(); else - st:tag("before"):text(tostring(data)):up(); + st:text_tag("before", data); end - end + end; + max = function (st, data) + st:text_tag("max", inttostr(data)); + end; + index = function (st, data) + st:text_tag("index", inttostr(data)); + end; + count = function (st, data) + st:text_tag("count", inttostr(data)); + end; }, { __index = function(_, name) return function(st, data) - st:tag(name):text(tostring(data)):up(); + st:text_tag(name, data); end end; }); |