Merge 0.10->trunk
[prosody.git] / tools / xep227toprosody.lua
index b5156f45f8193085b4ff5334ea747c1d18e4e510..521851e93f3ac8bcc54850fb9d619e7f4ada345d 100755 (executable)
@@ -3,7 +3,7 @@
 -- Copyright (C) 2008-2009 Matthew Wild
 -- Copyright (C) 2008-2009 Waqas Hussain
 -- Copyright (C) 2010      Stefan Gehn
--- 
+--
 -- This project is MIT/X11 licensed. Please see the
 -- COPYING file in the source package for more information.
 --
 package.path = package.path..";../?.lua";
 package.cpath = package.cpath..";../?.so"; -- needed for util.pposix used in datamanager
 
+local my_name = arg[0];
+if my_name:match("[/\\]") then
+       package.path = package.path..";"..my_name:gsub("[^/\\]+$", "../?.lua");
+       package.cpath = package.cpath..";"..my_name:gsub("[^/\\]+$", "../?.so");
+end
+
 -- ugly workaround for getting datamanager to work outside of prosody :(
 prosody = { };
 prosody.platform = "unknown";
@@ -196,7 +202,7 @@ function lxp_handlers.StartElement(parser, elementname, attributes)
        --count = count + 1;
        if curr_host ~= "" then
                -- forward to xmlhandlers
-               user_handlers:StartElement(elementname, attributes);
+               user_handlers.StartElement(parser, elementname, attributes);
        elseif (curr_ns == xmlns_xep227) and (name == "host") then
                curr_host = attributes["jid"]; -- start of host element
                print("Begin parsing host "..curr_host);
@@ -220,7 +226,7 @@ function lxp_handlers.EndElement(parser, elementname)
                        curr_host = "" -- end of host element
                else
                        -- forward to xmlhandlers
-                       user_handlers:EndElement(elementname);
+                       user_handlers.EndElement(parser, elementname);
                end
        elseif (curr_ns ~= xmlns_xep227) or (name ~= "server-data") then
                io.stderr:write("Unhandled XML element: ", name, "\n");
@@ -231,7 +237,7 @@ end
 function lxp_handlers.CharacterData(parser, string)
        if curr_host ~= "" then
                -- forward to xmlhandlers
-               user_handlers:CharacterData(string);
+               user_handlers.CharacterData(parser, string);
        end
 end