emqttd_internal.hrl 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. %%--------------------------------------------------------------------
  2. %% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
  3. %%
  4. %% Licensed under the Apache License, Version 2.0 (the "License");
  5. %% you may not use this file except in compliance with the License.
  6. %% You may obtain a copy of the License at
  7. %%
  8. %% http://www.apache.org/licenses/LICENSE-2.0
  9. %%
  10. %% Unless required by applicable law or agreed to in writing, software
  11. %% distributed under the License is distributed on an "AS IS" BASIS,
  12. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. %% See the License for the specific language governing permissions and
  14. %% limitations under the License.
  15. %%--------------------------------------------------------------------
  16. %% Internal Header File
  17. -define(GPROC_POOL(JoinOrLeave, Pool, Id),
  18. (begin
  19. case JoinOrLeave of
  20. join -> gproc_pool:connect_worker(Pool, {Pool, Id});
  21. leave -> gproc_pool:disconnect_worker(Pool, {Pool, Id})
  22. end
  23. end)).
  24. -define(PROC_NAME(M, I), (list_to_atom(lists:concat([M, "_", I])))).
  25. -define(record_to_proplist(Def, Rec),
  26. lists:zip(record_info(fields, Def), tl(tuple_to_list(Rec)))).
  27. -define(record_to_proplist(Def, Rec, Fields),
  28. [{K, V} || {K, V} <- ?record_to_proplist(Def, Rec),
  29. lists:member(K, Fields)]).
  30. -define(UNEXPECTED_REQ(Req, State),
  31. (begin
  32. lager:error("Unexpected Request: ~p", [Req]),
  33. {reply, {error, unexpected_request}, State}
  34. end)).
  35. -define(UNEXPECTED_MSG(Msg, State),
  36. (begin
  37. lager:error("Unexpected Message: ~p", [Msg]),
  38. {noreply, State}
  39. end)).
  40. -define(UNEXPECTED_INFO(Info, State),
  41. (begin
  42. lager:error("Unexpected Info: ~p", [Info]),
  43. {noreply, State}
  44. end)).
  45. -define(IF(Cond, TrueFun, FalseFun),
  46. (case (Cond) of
  47. true -> (TrueFun);
  48. false-> (FalseFun)
  49. end)).
  50. -define(FULLSWEEP_OPTS, [{fullsweep_after, 10}]).
  51. -define(SUCCESS, 0). %% Success
  52. -define(ERROR1, 101). %% badrpc
  53. -define(ERROR2, 102). %% Unknown error
  54. -define(ERROR3, 103). %% Username or password error
  55. -define(ERROR4, 104). %% Empty username or password
  56. -define(ERROR5, 105). %% User does not exist
  57. -define(ERROR6, 106). %% Admin can not be deleted
  58. -define(ERROR7, 107). %% Missing request parameter
  59. -define(ERROR8, 108). %% Request parameter type error
  60. -define(ERROR9, 109). %% Request parameter is not a json
  61. -define(ERROR10, 110). %% Plugin has been loaded
  62. -define(ERROR11, 111). %% Plugin has been loaded
  63. -define(ERROR12, 112). %% Client not online
  64. -define(ERROR13, 113). %% User already exist
  65. -define(ERROR14, 114). %% OldPassword error