From 715cc5ea3bf01ea99b2516c0d3d48e2a5ccb8174 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Thu, 1 Jul 2010 20:54:01 +1000 Subject: New configure option: --enable-nif --- src/xml.erl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/xml.erl') diff --git a/src/xml.erl b/src/xml.erl index 9a9a7f833..22746b10a 100644 --- a/src/xml.erl +++ b/src/xml.erl @@ -37,8 +37,11 @@ get_subtag/2, get_subtag_cdata/2, append_subtags/2, get_path_s/2, + start/0, replace_tag_attr/3]). +-include("ejabberd.hrl"). + %% Select at compile time how to escape characters in binary text %% nodes. %% Can be choosen with ./configure --enable-full-xml @@ -48,6 +51,22 @@ -define(ESCAPE_BINARY(CData), crypt(CData)). -endif. +%% Replace element_to_binary/1 with NIF +%% Can be choosen with ./configure --enable-nif +-ifdef(NIF). +start() -> + SOPath = filename:join(ejabberd:get_so_path(), "xml"), + case catch erlang:load_nif(SOPath, 0) of + ok -> + ok; + Err -> + ?WARNING_MSG("unable to load xml NIF: ~p", [Err]) + end. +-else. +start() -> + ok. +-endif. + element_to_binary(El) -> iolist_to_binary(element_to_string(El)). -- cgit v1.2.3