tree.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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