mod_Ranks.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * $Id$
  3. *
  4. * Copyright (C) 2012 Konstantin Mosesov
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * This file 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. *
  14. * This file is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. */
  24. // Python includes
  25. #include <Python.h>
  26. #include "structmember.h"
  27. // Other/system includes
  28. #include <libgen.h>
  29. // router includes
  30. #include "../../str.h"
  31. #include "../../sr_module.h"
  32. // local includes
  33. #include "python_exec.h"
  34. #include "python_mod.h"
  35. #include "python_iface.h"
  36. #include "python_msgobj.h"
  37. #include "python_support.h"
  38. #include "mod_Router.h"
  39. #include "mod_Ranks.h"
  40. PyMethodDef RanksMethods[] = {
  41. {NULL, NULL, 0, NULL}
  42. };
  43. void init_mod_Ranks(void)
  44. {
  45. ranks_module = Py_InitModule("Router.Ranks", RanksMethods);
  46. PyDict_SetItemString(main_module_dict, "Ranks", ranks_module);
  47. PyModule_AddObject(ranks_module, "PROC_MAIN", PyInt_FromLong((long)PROC_MAIN));
  48. PyModule_AddObject(ranks_module, "PROC_TIMER", PyInt_FromLong((long)PROC_TIMER));
  49. PyModule_AddObject(ranks_module, "PROC_RPC", PyInt_FromLong((long)PROC_RPC));
  50. PyModule_AddObject(ranks_module, "PROC_FIFO", PyInt_FromLong((long)PROC_FIFO));
  51. PyModule_AddObject(ranks_module, "PROC_TCP_MAIN", PyInt_FromLong((long)PROC_TCP_MAIN));
  52. PyModule_AddObject(ranks_module, "PROC_UNIXSOCK", PyInt_FromLong((long)PROC_UNIXSOCK));
  53. PyModule_AddObject(ranks_module, "PROC_ATTENDANT", PyInt_FromLong((long)PROC_ATTENDANT));
  54. PyModule_AddObject(ranks_module, "PROC_INIT", PyInt_FromLong((long)PROC_INIT));
  55. PyModule_AddObject(ranks_module, "PROC_NOCHLDINIT", PyInt_FromLong((long)PROC_NOCHLDINIT));
  56. PyModule_AddObject(ranks_module, "PROC_SIPINIT", PyInt_FromLong((long)PROC_SIPINIT));
  57. PyModule_AddObject(ranks_module, "PROC_SIPRPC", PyInt_FromLong((long)PROC_SIPRPC));
  58. PyModule_AddObject(ranks_module, "PROC_MIN", PyInt_FromLong((long)PROC_MIN));
  59. Py_INCREF(ranks_module);
  60. #ifdef WITH_EXTRA_DEBUG
  61. LM_ERR("Module 'Router.Ranks' has been initialized\n");
  62. #endif
  63. }
  64. void destroy_mod_Ranks(void)
  65. {
  66. Py_XDECREF(ranks_module);
  67. #ifdef WITH_EXTRA_DEBUG
  68. LM_ERR("Module 'Router.Ranks' has been destroyed\n");
  69. #endif
  70. }