Software /
code /
prosody
Comparison
core/xmlhandlers.lua @ 2464:0b5f0ae7a6b1
xmlhandlers: More refactoring, split up stream_ns and stream_tag, add stream_error_tag so that callers don't need to be so worried about the separator we use
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 19 Jan 2010 03:52:41 +0000 |
parent | 2463:d9ff0190eb4a |
child | 2468:68bb1cc1a8b0 |
comparison
equal
deleted
inserted
replaced
2463:d9ff0190eb4a | 2464:0b5f0ae7a6b1 |
---|---|
24 module "xmlhandlers" | 24 module "xmlhandlers" |
25 | 25 |
26 local ns_prefixes = { | 26 local ns_prefixes = { |
27 ["http://www.w3.org/XML/1998/namespace"] = "xml"; | 27 ["http://www.w3.org/XML/1998/namespace"] = "xml"; |
28 } | 28 } |
29 | |
30 local xmlns_streams = "http://etherx.jabber.org/streams"; | |
31 | |
29 local ns_separator = "\1"; | 32 local ns_separator = "\1"; |
30 local ns_pattern = "^([^"..ns_separator.."]*)"..ns_separator.."?(.*)$"; | 33 local ns_pattern = "^([^"..ns_separator.."]*)"..ns_separator.."?(.*)$"; |
31 | 34 |
32 function init_xmlhandlers(session, stream_callbacks) | 35 function init_xmlhandlers(session, stream_callbacks) |
33 local ns_stack = { "" }; | 36 local ns_stack = { "" }; |
39 local cb_streamopened = stream_callbacks.streamopened; | 42 local cb_streamopened = stream_callbacks.streamopened; |
40 local cb_streamclosed = stream_callbacks.streamclosed; | 43 local cb_streamclosed = stream_callbacks.streamclosed; |
41 local cb_error = stream_callbacks.error or function (session, e) error("XML stream error: "..tostring(e)); end; | 44 local cb_error = stream_callbacks.error or function (session, e) error("XML stream error: "..tostring(e)); end; |
42 local cb_handlestanza = stream_callbacks.handlestanza; | 45 local cb_handlestanza = stream_callbacks.handlestanza; |
43 | 46 |
44 local stream_tag = stream_callbacks.stream_tag; | 47 local stream_ns = stream_callbacks.stream_ns or xmlns_streams; |
48 local stream_tag = stream_ns..ns_separator..(stream_callbacks.stream_tag or "stream"); | |
49 local stream_error_tag = stream_ns..ns_separator..(stream_callbacks.error_tag or "error"); | |
50 | |
45 local stream_default_ns = stream_callbacks.default_ns; | 51 local stream_default_ns = stream_callbacks.default_ns; |
46 | 52 |
47 local stanza | 53 local stanza |
48 function xml_handlers:StartElement(tagname, attr) | 54 function xml_handlers:StartElement(tagname, attr) |
49 if stanza and #chardata > 0 then | 55 if stanza and #chardata > 0 then |