Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/configure.erl2
-rw-r--r--tools/ejabberdctl.bc99
-rw-r--r--tools/p1_prof.erl2
-rw-r--r--tools/xmpp_codec.erl10
-rw-r--r--tools/xmpp_codec.spec4
5 files changed, 108 insertions, 9 deletions
diff --git a/tools/configure.erl b/tools/configure.erl
index aa7feee31..bc0f87eb7 100644
--- a/tools/configure.erl
+++ b/tools/configure.erl
@@ -5,7 +5,7 @@
%%% Created : 27 Jan 2003 by Alexey Shchepin <alexey@process-one.net>
%%%
%%%
-%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
+%%% ejabberd, Copyright (C) 2002-2014 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
diff --git a/tools/ejabberdctl.bc b/tools/ejabberdctl.bc
new file mode 100644
index 000000000..72a5356f2
--- /dev/null
+++ b/tools/ejabberdctl.bc
@@ -0,0 +1,99 @@
+#
+# bash completion for ejabberdctl
+#
+get_help()
+{
+ local COMMANDCACHE=/var/log/ejabberd/bash_completion_$RANDOM
+ ejabberdctl $CTLARGS help >$COMMANDCACHE
+ if [[ $? == 2 ]] ; then
+ ISRUNNING=1
+ runningcommands=`cat $COMMANDCACHE | grep "^ [a-z]" | awk '{print $1}' | xargs`
+ fi
+ rm $COMMANDCACHE
+}
+
+_ejabberdctl()
+{
+ local cur prev
+ local ISRUNNING=0
+ local runningcommands
+
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ local startcoms="start debug live"
+ local startpars="--config-dir --config --ctl-config --logs --spool"
+
+ local i=1
+ local CTLARGS=""
+ while [ $i -lt $COMP_CWORD ] ; do
+ local PARAM="${COMP_WORDS[i]}"
+ i=$((i+1))
+ case $PARAM in
+ --*)
+ CTLARGS="--node ${COMP_WORDS[i]}"
+ i=$((i+1)) ;;
+ *) break ;;
+ esac
+ done
+
+ case "${prev##*/}" in
+ ejabberdctl)
+ # This clause matches even when calling `/sbin/ejabberdctl` thanks to the ##*/ in the case
+ get_help
+ COMPREPLY=($(compgen -W "--node --auth ${startpars} ${startcoms} ${runningcommands}" -- $cur))
+ return 0
+ ;;
+ start|live)
+ COMPREPLY=($(compgen -W "--node ${startpars}" -- $cur))
+ return 0
+ ;;
+ debug)
+ COMPREPLY=($(compgen -W "--node" -- $cur))
+ return 0
+ ;;
+ help)
+ get_help
+ COMPREPLY=($(compgen -W "${runningcommands}" -- $cur))
+ return 0
+ ;;
+ --node)
+ RUNNINGNODES=`epmd -names | grep name | awk '{print $2"@localhost"}' | xargs`
+ COMPREPLY=($(compgen -W "$RUNNINGNODES" -- $cur))
+ return 0
+ ;;
+ --config|--ctl-config)
+ _filedir '?(u)cfg'
+ return 0
+ ;;
+ --config-dir|--logs|--spool)
+ _filedir
+ return 0
+ ;;
+ *)
+ prev2="${COMP_WORDS[COMP_CWORD-2]}"
+ get_help
+ if [[ "$prev2" == --* ]]; then
+ COMPREPLY=($(compgen -W "--node --auth ${startpars} ${startcoms} ${runningcommands}" -- $cur))
+ else
+ if [[ $ISRUNNING == 1 ]]; then
+ echo ""
+ ejabberdctl $CTLARGS help ${PARAM}
+ echo -n "${COMP_LINE}"
+ fi
+ fi
+ return 0
+ ;;
+ esac
+}
+
+complete -F _ejabberdctl ejabberdctl
+
+# Local variables:
+# mode: shell-script
+# sh-basic-offset: 4
+# sh-indent-comment: t
+# indent-tabs-mode: nil
+# End:
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/tools/p1_prof.erl b/tools/p1_prof.erl
index 44fb9f766..c085f64fc 100644
--- a/tools/p1_prof.erl
+++ b/tools/p1_prof.erl
@@ -6,7 +6,7 @@
%%% Created : 23 Jan 2010 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
-%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
+%%% ejabberd, Copyright (C) 2002-2014 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
diff --git a/tools/xmpp_codec.erl b/tools/xmpp_codec.erl
index ff73f4259..6cfcc7a22 100644
--- a/tools/xmpp_codec.erl
+++ b/tools/xmpp_codec.erl
@@ -5,7 +5,7 @@
-compile({nowarn_unused_function,
[{dec_int, 3}, {dec_int, 1}, {dec_enum, 2},
- {enc_int, 1}, {enc_enum, 1}]}).
+ {enc_int, 1}, {get_attr, 2}, {enc_enum, 1}]}).
-export([pp/1, format_error/1, decode/1, is_known_tag/1,
encode/1]).
@@ -1580,12 +1580,12 @@ encode({last, _, _} = Query) ->
dec_int(Val) -> dec_int(Val, infinity, infinity).
dec_int(Val, Min, Max) ->
- case erlang:binary_to_integer(Val) of
+ case list_to_integer(binary_to_list(Val)) of
Int when Int =< Max, Min == infinity -> Int;
Int when Int =< Max, Int >= Min -> Int
end.
-enc_int(Int) -> erlang:integer_to_binary(Int).
+enc_int(Int) -> list_to_binary(integer_to_list(Int)).
dec_enum(Val, Enums) ->
AtomVal = erlang:binary_to_existing_atom(Val, utf8),
@@ -1787,8 +1787,8 @@ enc_tzo({H, M}) ->
dec_tzo(Val) ->
[H1, M1] = str:tokens(Val, <<":">>),
- H = erlang:binary_to_integer(H1),
- M = erlang:binary_to_integer(M1),
+ H = jlib:binary_to_integer(H1),
+ M = jlib:binary_to_integer(M1),
if H >= -12, H =< 12, M >= 0, M < 60 -> {H, M} end.
decode_muc({xmlel, <<"x">>, _attrs, _els}) ->
diff --git a/tools/xmpp_codec.spec b/tools/xmpp_codec.spec
index 86cc03088..02e28a1f9 100644
--- a/tools/xmpp_codec.spec
+++ b/tools/xmpp_codec.spec
@@ -1986,8 +1986,8 @@
dec_tzo(Val) ->
[H1, M1] = str:tokens(Val, <<":">>),
- H = erlang:binary_to_integer(H1),
- M = erlang:binary_to_integer(M1),
+ H = jlib:binary_to_integer(H1),
+ M = jlib:binary_to_integer(M1),
if H >= -12, H =< 12, M >= 0, M < 60 ->
{H, M}
end.