Diff

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
line wrap: on
line diff
--- a/util/xmppstream.lua	Mon Mar 22 16:24:49 2010 +0000
+++ b/util/xmppstream.lua	Mon Mar 22 16:55:10 2010 +0000
@@ -7,10 +7,9 @@
 --
 
 
+local lxp = require "lxp";
+local st = require "util.stanza";
 
-require "util.stanza"
-
-local st = stanza;
 local tostring = tostring;
 local t_insert = table.insert;
 local t_concat = table.concat;
@@ -21,6 +20,8 @@
 
 module "xmppstream"
 
+local new_parser = lxp.new;
+
 local ns_prefixes = {
 	["http://www.w3.org/XML/1998/namespace"] = "xml";
 };
@@ -30,7 +31,7 @@
 local ns_separator = "\1";
 local ns_pattern = "^([^"..ns_separator.."]*)"..ns_separator.."?(.*)$";
 
-function new(session, stream_callbacks)
+function new_sax_handlers(session, stream_callbacks)
 	local chardata = {};
 	local xml_handlers = {};
 	local log = session.log or default_log;
@@ -142,4 +143,8 @@
 	return xml_handlers;
 end
 
+function new(session, stream_callbacks)
+	return new_parser(new_sax_handlers(session, stream_callbacks), ns_separator);
+end
+
 return _M;