lib/kmi/tree.h

Go to the documentation of this file.
00001 /*
00002  * $Id: tree.h 4518 2008-07-28 15:39:28Z henningw $
00003  *
00004  * Copyright (C) 2006 Voice Sistem SRL
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021  *
00022  *
00023  * History:
00024  * ---------
00025  *  2006-09-08  first version (bogdan)
00026  *  2010-08-18  use mi types from ../../mi/mi_types.h (andrei)
00027  */
00028 
00038 #ifndef _MI_TREE_H
00039 #define _MI_TREE_H
00040 
00041 #include <stdarg.h>
00042 #include "../../str.h"
00043 #include "../../mi/mi_types.h"
00044 
00045 struct mi_node;
00046 struct mi_handler;
00047 
00048 #include "attr.h"
00049 
00050 #define MI_DUP_NAME   (1<<0)
00051 #define MI_DUP_VALUE  (1<<1)
00052 
00053 #define MI_OK_S              "OK"
00054 #define MI_OK_LEN            (sizeof(MI_OK_S)-1)
00055 #define MI_INTERNAL_ERR_S    "Server Internal Error"
00056 #define MI_INTERNAL_ERR_LEN  (sizeof(MI_INTERNAL_ERR_S)-1)
00057 #define MI_MISSING_PARM_S    "Too few or too many arguments"
00058 #define MI_MISSING_PARM_LEN  (sizeof(MI_MISSING_PARM_S)-1)
00059 #define MI_BAD_PARM_S        "Bad parameter"
00060 #define MI_BAD_PARM_LEN      (sizeof(MI_BAD_PARM_S)-1)
00061 
00062 #define MI_SSTR(_s)           _s,(sizeof(_s)-1)
00063 #define MI_OK                 MI_OK_S
00064 #define MI_INTERNAL_ERR       MI_INTERNAL_ERR_S
00065 #define MI_MISSING_PARM       MI_MISSING_PARM_S
00066 #define MI_BAD_PARM           MI_BAD_PARM_S
00067 
00068 
00069 
00070 struct mi_root *init_mi_tree(unsigned int code, char *reason, int reason_len);
00071 
00072 void free_mi_tree(struct mi_root *parent);
00073 
00074 struct mi_node *add_mi_node_sibling(struct mi_node *brother, int flags,
00075         char *name, int name_len, char *value, int value_len);
00076 
00077 struct mi_node *addf_mi_node_sibling(struct mi_node *brother, int flags,
00078         char *name, int name_len, char *fmt_val, ...);
00079 
00080 struct mi_node *add_mi_node_child(struct mi_node *parent, int flags,
00081         char *name, int name_len, char *value, int value_len);
00082 
00083 struct mi_node *addf_mi_node_child(struct mi_node *parent, int flags,
00084         char *name, int name_len, char *fmt_val, ...);
00085 
00086 struct mi_root* clone_mi_tree(struct mi_root *org, int shm);
00087 
00088 void free_shm_mi_tree(struct mi_root *parent);
00089 
00090 #endif
00091