1
%% ``The contents of this file are subject to the Erlang Public License,
4
%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
2
7
%% Version 1.1, (the "License"); you may not use this file except in
3
8
%% compliance with the License. You should have received a copy of the
4
9
%% Erlang Public License along with this software. If not, it can be
5
%% retrieved via the world wide web at http://www.erlang.org/.
10
%% retrieved online at http://www.erlang.org/.
7
12
%% Software distributed under the License is distributed on an "AS IS"
8
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
%% the License for the specific language governing rights and limitations
10
15
%% under the License.
12
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
%% AB. All Rights Reserved.''
19
20
-behaviour(gen_server).
44
45
-include("../include/file.hrl").
47
%%----------------------------------------------------------------------
48
%% Contract specifications
49
%%----------------------------------------------------------------------
51
-type(node() :: atom()).
53
47
%%----------------------------------------------------------------------
54
48
%% Exported functions
55
49
%%----------------------------------------------------------------------
70
-spec(cookie/0 :: () -> atom()).
64
-spec cookie() -> atom().
75
-spec(cookie/1 :: (Cookies :: [atom(),...] | atom()) -> 'true').
69
-spec cookie(Cookies :: [atom(),...] | atom()) -> 'true'.
77
71
cookie([Cookie]) ->
78
72
set_cookie(Cookie);
80
74
set_cookie(Cookie).
82
-spec(node_cookie/1 :: (Cookies :: [atom(),...]) -> 'yes' | 'no').
76
-spec node_cookie(Cookies :: [atom(),...]) -> 'yes' | 'no'.
84
78
node_cookie([Node, Cookie]) ->
85
79
node_cookie(Node, Cookie).
87
-spec(node_cookie/2 :: (Node :: node(), Cookie :: atom()) -> 'yes' | 'no').
81
-spec node_cookie(Node :: node(), Cookie :: atom()) -> 'yes' | 'no'.
89
83
node_cookie(Node, Cookie) ->
90
84
set_cookie(Node, Cookie),
93
87
%%--"New" interface-----------------------------------------------------
95
-spec(get_cookie/0 :: () -> atom()).
89
-spec get_cookie() -> atom().
98
92
get_cookie(node()).
100
-spec(get_cookie/1 :: (Node :: node()) -> atom()).
94
-spec get_cookie(Node :: node()) -> atom().
102
96
get_cookie(_Node) when node() =:= nonode@nohost ->
104
98
get_cookie(Node) ->
105
99
gen_server:call(auth, {get_cookie, Node}).
107
-spec(set_cookie/1 :: (Cookie :: atom()) -> 'true').
101
-spec set_cookie(Cookie :: atom()) -> 'true'.
109
103
set_cookie(Cookie) ->
110
104
set_cookie(node(), Cookie).
112
-spec(set_cookie/2 :: (Node :: node(), Cookie :: atom()) -> 'true').
106
-spec set_cookie(Node :: node(), Cookie :: atom()) -> 'true'.
114
108
set_cookie(_Node, _Cookie) when node() =:= nonode@nohost ->
115
109
erlang:error(distribution_not_started);
116
110
set_cookie(Node, Cookie) ->
117
111
gen_server:call(auth, {set_cookie, Node, Cookie}).
119
-spec(sync_cookie/0 :: () -> any()).
113
-spec sync_cookie() -> any().
122
116
gen_server:call(auth, sync_cookie).
124
-spec(print/3 :: (Node :: node(), Format :: string(), Args :: [_]) -> 'ok').
118
-spec print(Node :: node(), Format :: string(), Args :: [_]) -> 'ok'.
126
120
print(Node,Format,Args) ->
127
121
(catch gen_server:cast({auth,Node},{print,Format,Args})).