]> granicus.if.org Git - ejabberd/commitdiff
Support for "> ." in YAML configuration files
authorBadlop <badlop@process-one.net>
Wed, 28 Jan 2015 16:16:10 +0000 (17:16 +0100)
committerBadlop <badlop@process-one.net>
Wed, 28 Jan 2015 16:16:10 +0000 (17:16 +0100)
doc/guide.tex
src/ejabberd_config.erl

index b21e3a03d74412a843c4a4218acfa665618d8c1e..62e7fc8e27caca455ee0a434d2dbd0bcd0f086f6 100644 (file)
@@ -693,6 +693,29 @@ in Erlang terms. The format is still supported, but it is highly recommended
 to convert it to the new YAML format using \term{convert\_to\_yaml} command
 from \term{ejabberdctl} (see~\ref{ejabberdctl} and \ref{list-eja-commands} for details).
 
+If you want to specify some options using the old Erlang format,
+you can set them in an additional cfg file, and include it using
+the \option{include\_config\_file} option, see \ref{includeconfigfile}
+for the option description and a related example in \ref{accesscommands}.
+
+If you just want to provide an erlang term inside an option,
+you can use the \term{"> erlangterm."} syntax for embedding erlang terms in a YAML file, for example:
+\begin{verbatim}
+modules:
+  mod_cron:
+    tasks:
+      - time: 10
+        units: seconds
+        module: mnesia
+        function: info
+        arguments: "> []."
+      - time: 3
+        units: seconds
+        module: ejabberd_auth
+        function: try_register
+        arguments: "> [\"user1\", \"localhost\", \"pass\"]."
+\end{verbatim}
+
 \makesubsection{hostnames}{Host Names}
 \ind{options!hosts}\ind{host names}
 
index 0d25224b9eea55763bdc1a391e65721bbe7ae44f..53936744ec39a90501bf471f324286f407d4530d 100644 (file)
@@ -190,7 +190,7 @@ consult(File) ->
                 {ok, []} ->
                     {ok, []};
                 {ok, [Document|_]} ->
-                    {ok, Document};
+                    {ok, parserl(Document)};
                 {error, Err} ->
                     Msg1 = "Cannot load " ++ File ++ ": ",
                     Msg2 = p1_yaml:format_error(Err),
@@ -207,6 +207,19 @@ consult(File) ->
             end
     end.
 
+parserl([$>, $\s | String]) ->
+    {ok, A2, _} = erl_scan:string(String),
+    {ok, A3} = erl_parse:parse_term(A2),
+    A3;
+parserl(B) when is_binary(B) ->
+    parserl(binary_to_list(B));
+parserl({A, B}) ->
+    {parserl(A), parserl(B)};
+parserl([El|Tail]) ->
+    [parserl(El) | parserl(Tail)];
+parserl(Other) ->
+    Other.
+
 %% @doc Convert configuration filename to absolute path.
 %% Input is an absolute or relative path to an ejabberd configuration file.
 %% And returns an absolute path to the configuration file.