tree.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * $Id: tree.h 4518 2008-07-28 15:39:28Z henningw $
  3. *
  4. * Copyright (C) 2006 Voice Sistem SRL
  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. * History:
  24. * ---------
  25. * 2006-09-08 first version (bogdan)
  26. * 2010-08-18 use mi types from ../../mi/mi_types.h (andrei)
  27. */
  28. /*!
  29. * \file
  30. * \brief MI :: Tree
  31. * \ingroup mi
  32. */
  33. #ifndef _MI_TREE_H
  34. #define _MI_TREE_H
  35. #include <stdarg.h>
  36. #include "../../str.h"
  37. #include "../../mi/mi_types.h"
  38. struct mi_node;
  39. struct mi_handler;
  40. #include "attr.h"
  41. #define MI_DUP_NAME (1<<0)
  42. #define MI_DUP_VALUE (1<<1)
  43. #define MI_OK_S "OK"
  44. #define MI_OK_LEN (sizeof(MI_OK_S)-1)
  45. #define MI_INTERNAL_ERR_S "Server Internal Error"
  46. #define MI_INTERNAL_ERR_LEN (sizeof(MI_INTERNAL_ERR_S)-1)
  47. #define MI_MISSING_PARM_S "Too few or too many arguments"
  48. #define MI_MISSING_PARM_LEN (sizeof(MI_MISSING_PARM_S)-1)
  49. #define MI_BAD_PARM_S "Bad parameter"
  50. #define MI_BAD_PARM_LEN (sizeof(MI_BAD_PARM_S)-1)
  51. #define MI_SSTR(_s) _s,(sizeof(_s)-1)
  52. #define MI_OK MI_OK_S
  53. #define MI_INTERNAL_ERR MI_INTERNAL_ERR_S
  54. #define MI_MISSING_PARM MI_MISSING_PARM_S
  55. #define MI_BAD_PARM MI_BAD_PARM_S
  56. struct mi_root *init_mi_tree(unsigned int code, char *reason, int reason_len);
  57. void free_mi_tree(struct mi_root *parent);
  58. struct mi_node *add_mi_node_sibling(struct mi_node *brother, int flags,
  59. char *name, int name_len, char *value, int value_len);
  60. struct mi_node *addf_mi_node_sibling(struct mi_node *brother, int flags,
  61. char *name, int name_len, char *fmt_val, ...);
  62. struct mi_node *add_mi_node_child(struct mi_node *parent, int flags,
  63. char *name, int name_len, char *value, int value_len);
  64. struct mi_node *addf_mi_node_child(struct mi_node *parent, int flags,
  65. char *name, int name_len, char *fmt_val, ...);
  66. struct mi_root* clone_mi_tree(struct mi_root *org, int shm);
  67. void free_shm_mi_tree(struct mi_root *parent);
  68. #endif