app_lua_api.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * $Id$
  3. *
  4. * Copyright (C) 2010 Daniel-Constantin Mierla (asipto.com)
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. */
  23. #ifndef _APP_LUA_API_H_
  24. #define _APP_LUA_API_H_
  25. #include <lua.h>
  26. #include <lauxlib.h>
  27. #include <lualib.h>
  28. #include "../../parser/msg_parser.h"
  29. /**
  30. * version variable stores a version counter for each script loaded.
  31. * This counter will be updated via RPC.
  32. */
  33. typedef struct _sr_lua_script_ver
  34. {
  35. unsigned int *version;
  36. unsigned int len; /* length of version array */
  37. } sr_lua_script_ver_t;
  38. typedef struct _sr_lua_env
  39. {
  40. lua_State *L;
  41. lua_State *LL;
  42. struct sip_msg *msg;
  43. unsigned int flags;
  44. unsigned int nload; /* number of scripts loaded */
  45. } sr_lua_env_t;
  46. typedef struct _sr_lua_load
  47. {
  48. char *script;
  49. int version; /* child loaded version */
  50. struct _sr_lua_load *next;
  51. } sr_lua_load_t;
  52. sr_lua_env_t *sr_lua_env_get(void);
  53. int lua_sr_initialized(void);
  54. int lua_sr_init_mod(void);
  55. int lua_sr_init_child(void);
  56. void lua_sr_destroy(void);
  57. int lua_sr_init_probe(void);
  58. int lua_sr_reload_script(int pos);
  59. int lua_sr_list_script(sr_lua_load_t **list);
  60. int sr_lua_load_script(char *script);
  61. int sr_lua_reload_script(void);
  62. int sr_lua_register_module(char *mname);
  63. int sr_lua_reload_module(unsigned int reload);
  64. int app_lua_dostring(struct sip_msg *msg, char *script);
  65. int app_lua_dofile(struct sip_msg *msg, char *script);
  66. int app_lua_runstring(struct sip_msg *msg, char *script);
  67. int app_lua_run(struct sip_msg *msg, char *func, char *p1, char *p2,
  68. char *p3);
  69. #define SRLUA_FALSE 0
  70. #define SRLUA_TRUE 1
  71. int app_lua_return_boolean(lua_State *L, int b);
  72. int app_lua_return_false(lua_State *L);
  73. int app_lua_return_true(lua_State *L);
  74. int app_lua_return_int(lua_State *L, int v);
  75. int app_lua_return_error(lua_State *L);
  76. void app_lua_dump_stack(lua_State *L);
  77. #endif