diff options
Diffstat (limited to 'src/xml_stream.erl')
-rw-r--r-- | src/xml_stream.erl | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/src/xml_stream.erl b/src/xml_stream.erl index a513532a3..324796d8d 100644 --- a/src/xml_stream.erl +++ b/src/xml_stream.erl @@ -10,10 +10,7 @@ -author('alexey@sevcom.net'). -vsn('$Revision$ '). --export([start/1, start/2, - init/1, init/2, - send_text/2, - new/1, +-export([new/1, parse/2, close/1, parse_element/1]). @@ -28,37 +25,6 @@ -record(xml_stream_state, {callback_pid, port, stack}). -start(CallbackPid) -> - spawn(?MODULE, init, [CallbackPid]). - -start(Receiver, CallbackPid) -> - spawn(?MODULE, init, [Receiver, CallbackPid]). - -init(CallbackPid) -> - Port = open_port({spawn, expat_erl}, [binary]), - loop(CallbackPid, Port, []). - -init(Receiver, CallbackPid) -> - erlang:monitor(process, Receiver), - Port = open_port({spawn, expat_erl}, [binary]), - loop(CallbackPid, Port, []). - -loop(CallbackPid, Port, Stack) -> - receive - {Port, {data, Bin}} -> - Data = binary_to_term(Bin), - loop(CallbackPid, Port, process_data(CallbackPid, Stack, Data)); - {_From, {send, Str}} -> - Res = port_control(Port, ?PARSE_COMMAND, Str), - NewStack = lists:foldl( - fun(Data, St) -> - process_data(CallbackPid, St, Data) - end, Stack, binary_to_term(Res)), - loop(CallbackPid, Port, NewStack); - {'DOWN', _Ref, _Type, _Object, _Info} -> - ok - end. - process_data(CallbackPid, Stack, Data) -> case Data of {?XML_START, {Name, Attrs}} -> @@ -102,9 +68,6 @@ process_data(CallbackPid, Stack, Data) -> end. -send_text(Pid, Text) -> - Pid ! {self(), {send, Text}}. - new(CallbackPid) -> Port = open_port({spawn, expat_erl}, [binary]), |