mi/mi.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 #ifndef _MI_MI_H_
00036 #define _MI_MI_H_
00037
00038 #include "../str.h"
00039 #include "tree.h"
00040
00041 #define MI_ASYNC_RPL_FLAG (1<<0)
00042 #define MI_NO_INPUT_FLAG (1<<1)
00043
00044 #define MI_ROOT_ASYNC_RPL ((struct mi_root*)-1)
00045
00046 struct mi_handler;
00047
00048 typedef struct mi_root* (mi_cmd_f)(struct mi_root*, void *param);
00049 typedef int (mi_child_init_f)(void);
00050 typedef void (mi_handler_f)(struct mi_root *, struct mi_handler *, int);
00051
00052
00053 struct mi_handler {
00054 mi_handler_f *handler_f;
00055 void * param;
00056 };
00057
00058
00059 struct mi_cmd {
00060 int id;
00061 str name;
00062 mi_child_init_f *init_f;
00063 mi_cmd_f *f;
00064 unsigned int flags;
00065 void *param;
00066 };
00067
00068
00069 typedef struct mi_export_ {
00070 char *name;
00071 mi_cmd_f *cmd;
00072 unsigned int flags;
00073 void *param;
00074 mi_child_init_f *init_f;
00075 }mi_export_t;
00076
00077
00078 int register_mi_cmd( mi_cmd_f f, char *name, void *param,
00079 mi_child_init_f in, unsigned int flags);
00080
00081 int register_mi_mod( char *mod_name, mi_export_t *mis);
00082
00083 int init_mi_child(void);
00084
00085 struct mi_cmd* lookup_mi_cmd( char *name, int len);
00086
00087 static inline struct mi_root* run_mi_cmd(struct mi_cmd *cmd, struct mi_root *t)
00088 {
00089 return cmd->f( t, cmd->param);
00090 }
00091
00092 void get_mi_cmds( struct mi_cmd** cmds, int *size);
00093
00094 #endif
00095