Software /
code /
prosody
Comparison
util/xmppstream.lua @ 2921:f0ddfd7739ea
util.xmppstream: new() now returns a parser object
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 22 Mar 2010 16:55:10 +0000 |
parent | 2920:f3335285b20d |
child | 2926:fc96d439453b |
comparison
equal
deleted
inserted
replaced
2920:f3335285b20d | 2921:f0ddfd7739ea |
---|---|
5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 | 9 |
10 local lxp = require "lxp"; | |
11 local st = require "util.stanza"; | |
10 | 12 |
11 require "util.stanza" | |
12 | |
13 local st = stanza; | |
14 local tostring = tostring; | 13 local tostring = tostring; |
15 local t_insert = table.insert; | 14 local t_insert = table.insert; |
16 local t_concat = table.concat; | 15 local t_concat = table.concat; |
17 | 16 |
18 local default_log = require "util.logger".init("xmlhandlers"); | 17 local default_log = require "util.logger".init("xmlhandlers"); |
19 | 18 |
20 local error = error; | 19 local error = error; |
21 | 20 |
22 module "xmppstream" | 21 module "xmppstream" |
23 | 22 |
23 local new_parser = lxp.new; | |
24 | |
24 local ns_prefixes = { | 25 local ns_prefixes = { |
25 ["http://www.w3.org/XML/1998/namespace"] = "xml"; | 26 ["http://www.w3.org/XML/1998/namespace"] = "xml"; |
26 }; | 27 }; |
27 | 28 |
28 local xmlns_streams = "http://etherx.jabber.org/streams"; | 29 local xmlns_streams = "http://etherx.jabber.org/streams"; |
29 | 30 |
30 local ns_separator = "\1"; | 31 local ns_separator = "\1"; |
31 local ns_pattern = "^([^"..ns_separator.."]*)"..ns_separator.."?(.*)$"; | 32 local ns_pattern = "^([^"..ns_separator.."]*)"..ns_separator.."?(.*)$"; |
32 | 33 |
33 function new(session, stream_callbacks) | 34 function new_sax_handlers(session, stream_callbacks) |
34 local chardata = {}; | 35 local chardata = {}; |
35 local xml_handlers = {}; | 36 local xml_handlers = {}; |
36 local log = session.log or default_log; | 37 local log = session.log or default_log; |
37 | 38 |
38 local cb_streamopened = stream_callbacks.streamopened; | 39 local cb_streamopened = stream_callbacks.streamopened; |
140 end | 141 end |
141 end | 142 end |
142 return xml_handlers; | 143 return xml_handlers; |
143 end | 144 end |
144 | 145 |
146 function new(session, stream_callbacks) | |
147 return new_parser(new_sax_handlers(session, stream_callbacks), ns_separator); | |
148 end | |
149 | |
145 return _M; | 150 return _M; |