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  */
00027 
00028 /*!
00029  * \file 
00030  * \brief MI :: Tree
00031  * \ingroup mi
00032  */
00033 
00034 
00035 
00036 
00037 #ifndef _MI_TREE_H
00038 #define _MI_TREE_H
00039 
00040 #include <stdarg.h>
00041 #include "../str.h"
00042 
00043 struct mi_node;
00044 struct mi_handler;
00045 
00046 #include "attr.h"
00047 
00048 #define MI_DUP_NAME   (1<<0)
00049 #define MI_DUP_VALUE  (1<<1)
00050 
00051 #define MI_OK_S              "OK"
00052 #define MI_OK_LEN            (sizeof(MI_OK_S)-1)
00053 #define MI_INTERNAL_ERR_S    "Server Internal Error"
00054 #define MI_INTERNAL_ERR_LEN  (sizeof(MI_INTERNAL_ERR_S)-1)
00055 #define MI_MISSING_PARM_S    "Too few or too many arguments"
00056 #define MI_MISSING_PARM_LEN  (sizeof(MI_MISSING_PARM_S)-1)
00057 #define MI_BAD_PARM_S        "Bad parameter"
00058 #define MI_BAD_PARM_LEN      (sizeof(MI_BAD_PARM_S)-1)
00059 
00060 #define MI_SSTR(_s)           _s,(sizeof(_s)-1)
00061 #define MI_OK                 MI_OK_S
00062 #define MI_INTERNAL_ERR       MI_INTERNAL_ERR_S
00063 #define MI_MISSING_PARM       MI_MISSING_PARM_S
00064 #define MI_BAD_PARM           MI_BAD_PARM_S
00065 
00066 struct mi_node {
00067    str value;
00068    str name;
00069    struct mi_node *kids;
00070    struct mi_node *next;
00071    struct mi_node *last;
00072    struct mi_attr *attributes;
00073 };
00074 
00075 struct mi_root {
00076    unsigned int       code;
00077    str                reason;
00078    struct mi_handler  *async_hdl;
00079    struct mi_node     node;
00080 };
00081 
00082 struct mi_root *init_mi_tree(unsigned int code, char *reason, int reason_len);
00083 
00084 void free_mi_tree(struct mi_root *parent);
00085 
00086 struct mi_node *add_mi_node_sibling(struct mi_node *brother, int flags,
00087    char *name, int name_len, char *value, int value_len);
00088 
00089 struct mi_node *addf_mi_node_sibling(struct mi_node *brother, int flags,
00090    char *name, int name_len, char *fmt_val, ...);
00091 
00092 struct mi_node *add_mi_node_child(struct mi_node *parent, int flags,
00093    char *name, int name_len, char *value, int value_len);
00094 
00095 struct mi_node *addf_mi_node_child(struct mi_node *parent, int flags,
00096    char *name, int name_len, char *fmt_val, ...);
00097 
00098 struct mi_root* clone_mi_tree(struct mi_root *org, int shm);
00099 
00100 void free_shm_mi_tree(struct mi_root *parent);
00101 
00102 #endif
00103 

Generated on Thu May 24 20:00:33 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6