You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rspamadm.h 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*-
  2. * Copyright 2016 Vsevolod Stakhov
  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. #ifndef RSPAMD_RSPAMDADM_H
  17. #define RSPAMD_RSPAMDADM_H
  18. #include "config.h"
  19. #include "ucl.h"
  20. #include <lua.h>
  21. #include <lauxlib.h>
  22. #include <lualib.h>
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. extern GHashTable *ucl_vars;
  27. extern char **lua_env;
  28. extern struct rspamd_main *rspamd_main;
  29. GQuark rspamadm_error(void);
  30. struct rspamadm_command;
  31. typedef const char *(*rspamadm_help_func)(gboolean full_help,
  32. const struct rspamadm_command *cmd);
  33. typedef void (*rspamadm_run_func)(int argc, char **argv,
  34. const struct rspamadm_command *cmd);
  35. typedef void (*rspamadm_lua_exports_func)(gpointer lua_state);
  36. #define RSPAMADM_FLAG_NOHELP (1u << 0u)
  37. #define RSPAMADM_FLAG_LUA (1u << 1u)
  38. #define RSPAMADM_FLAG_DYNAMIC (1u << 2u)
  39. struct rspamadm_command {
  40. const char *name;
  41. unsigned int flags;
  42. rspamadm_help_func help;
  43. rspamadm_run_func run;
  44. rspamadm_lua_exports_func lua_subrs;
  45. GPtrArray *aliases;
  46. gpointer command_data; /* Opaque data */
  47. };
  48. extern const struct rspamadm_command *commands[];
  49. extern struct rspamadm_command help_command;
  50. const struct rspamadm_command *rspamadm_search_command(const char *name,
  51. GPtrArray *all_commands);
  52. void rspamadm_fill_internal_commands(GPtrArray *dest);
  53. void rspamadm_fill_lua_commands(lua_State *L, GPtrArray *dest);
  54. gboolean rspamadm_execute_lua_ucl_subr(int argc, char **argv,
  55. const ucl_object_t *res,
  56. const char *script_name,
  57. gboolean rspamadm_subcommand);
  58. struct thread_entry;
  59. typedef void (*lua_thread_error_t)(struct thread_entry *thread, int ret, const char *msg);
  60. struct lua_call_data {
  61. int top;
  62. int ret;
  63. gpointer ud;
  64. };
  65. int lua_repl_thread_call(struct thread_entry *thread, int narg,
  66. gpointer ud, lua_thread_error_t error_func);
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif