1 |
|
%%%---------------------------------------------------------------------- |
2 |
|
%%% File : ejabberd.erl |
3 |
|
%%% Author : Alexey Shchepin <alexey@process-one.net> |
4 |
|
%%% Purpose : ejabberd wrapper: start / stop |
5 |
|
%%% Created : 16 Nov 2002 by Alexey Shchepin <alexey@process-one.net> |
6 |
|
%%% |
7 |
|
%%% |
8 |
|
%%% ejabberd, Copyright (C) 2002-2011 ProcessOne |
9 |
|
%%% |
10 |
|
%%% This program is free software; you can redistribute it and/or |
11 |
|
%%% modify it under the terms of the GNU General Public License as |
12 |
|
%%% published by the Free Software Foundation; either version 2 of the |
13 |
|
%%% License, or (at your option) any later version. |
14 |
|
%%% |
15 |
|
%%% This program is distributed in the hope that it will be useful, |
16 |
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 |
|
%%% General Public License for more details. |
19 |
|
%%% |
20 |
|
%%% You should have received a copy of the GNU General Public License |
21 |
|
%%% along with this program; if not, write to the Free Software |
22 |
|
%%% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
23 |
|
%%% |
24 |
|
%%%---------------------------------------------------------------------- |
25 |
|
|
26 |
|
-module(ejabberd). |
27 |
|
-author('alexey@process-one.net'). |
28 |
|
-xep([{xep, 212}, {version, "1.0"}]). |
29 |
|
-export([start/0, |
30 |
|
stop/0, |
31 |
|
get_pid_file/0, |
32 |
|
get_status_file/0, |
33 |
|
get_so_path/0, |
34 |
|
get_bin_path/0]). |
35 |
|
|
36 |
|
-ignore_xref([get_bin_path/0, stop/0]). |
37 |
|
|
38 |
|
-type lang() :: binary(). |
39 |
|
|
40 |
|
-type sockmod() :: gen_tcp |
41 |
|
| ejabberd_socket |
42 |
|
| mod_bosh_socket |
43 |
|
| mod_websockets |
44 |
|
| mongoose_tls |
45 |
|
| ejabberd_zlib. |
46 |
|
|
47 |
|
%% Incoming event from XML stream. Used everywhere in xmlstream fsm modules |
48 |
|
-type xml_stream_item() :: 'closed' |
49 |
|
| 'timeout' |
50 |
|
| {'xmlstreamelement', exml:element()} |
51 |
|
| {'xmlstreamend', _} |
52 |
|
| {'xmlstreamerror', _} |
53 |
|
| {'xmlstreamstart', Name :: any(), Attrs :: list()}. |
54 |
|
|
55 |
|
-export_type([lang/0, |
56 |
|
sockmod/0, |
57 |
|
xml_stream_item/0 |
58 |
|
]). |
59 |
|
|
60 |
|
start() -> |
61 |
:-( |
application:ensure_all_started(mongooseim). |
62 |
|
|
63 |
|
stop() -> |
64 |
:-( |
application:stop(mongooseim). |
65 |
|
|
66 |
|
-spec get_so_path() -> binary() | string(). |
67 |
|
get_so_path() -> |
68 |
17 |
case os:getenv("EJABBERD_SO_PATH") of |
69 |
|
false -> |
70 |
1 |
case code:priv_dir(mongooseim) of |
71 |
|
{error, _} -> |
72 |
:-( |
"."; |
73 |
|
Path -> |
74 |
1 |
filename:join([Path, "lib"]) |
75 |
|
end; |
76 |
|
Path -> |
77 |
16 |
Path |
78 |
|
end. |
79 |
|
|
80 |
|
-spec get_bin_path() -> binary() | string(). |
81 |
|
get_bin_path() -> |
82 |
:-( |
case os:getenv("EJABBERD_BIN_PATH") of |
83 |
|
false -> |
84 |
:-( |
case code:priv_dir(ejabberd) of |
85 |
|
{error, _} -> |
86 |
:-( |
"."; |
87 |
|
Path -> |
88 |
:-( |
filename:join([Path, "bin"]) |
89 |
|
end; |
90 |
|
Path -> |
91 |
:-( |
Path |
92 |
|
end. |
93 |
|
|
94 |
|
-spec get_pid_file() -> 'false' | nonempty_string(). |
95 |
|
get_pid_file() -> |
96 |
166 |
case os:getenv("EJABBERD_PID_PATH") of |
97 |
|
false -> |
98 |
:-( |
false; |
99 |
|
"" -> |
100 |
:-( |
false; |
101 |
|
Path -> |
102 |
166 |
Path |
103 |
|
end. |
104 |
|
|
105 |
|
-spec get_status_file() -> 'false' | nonempty_string(). |
106 |
|
get_status_file() -> |
107 |
249 |
case os:getenv("EJABBERD_STATUS_PATH") of |
108 |
|
false -> |
109 |
:-( |
false; |
110 |
|
"" -> |
111 |
:-( |
false; |
112 |
|
Path -> |
113 |
249 |
Path |
114 |
|
end. |