mod_Ranks.c 2.7 KB

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