00001
00012 #ifndef OPDIS_INSNTREE_H
00013 #define OPDIS_INSNTREE_H
00014
00015 #include <sys/types.h>
00016
00017 #include <opdis/model.h>
00018 #include <opdis/types.h>
00019
00020 #ifdef WIN32
00021 #define LIBCALL _stdcall
00022 #else
00023 #define LIBCALL
00024 #endif
00025
00030 typedef struct opdis_tree_node {
00031 struct opdis_tree_node * parent;
00032 struct opdis_tree_node * left;
00033 struct opdis_tree_node * right;
00034 void * data;
00035 int level;
00036 } opdis_tree_node_t;
00037
00048 typedef void * (*OPDIS_TREE_KEY_FN) (void * item);
00049
00061 typedef int (*OPDIS_TREE_CMP_FN) (void * a, void *b);
00062
00070 typedef void (*OPDIS_TREE_FREE_FN) (void * item);
00071
00076 typedef struct std_tree {
00077 OPDIS_TREE_KEY_FN key_fn;
00078 OPDIS_TREE_CMP_FN cmp_fn;
00079 OPDIS_TREE_FREE_FN free_fn;
00080 opdis_tree_node_t * root;
00081 int num;
00082 } opdis_tree_base_t;
00083
00088 typedef opdis_tree_base_t * opdis_tree_t;
00089
00094 typedef opdis_tree_base_t * opdis_vma_tree_t;
00095
00100 typedef opdis_tree_base_t * opdis_insn_tree_t;
00101
00102
00103
00104 #ifdef __cplusplus
00105 extern "C"
00106 {
00107 #endif
00108
00109
00110
00125 opdis_tree_t LIBCALL opdis_tree_init( OPDIS_TREE_KEY_FN key_fn,
00126 OPDIS_TREE_CMP_FN cmp_fn,
00127 OPDIS_TREE_FREE_FN free_fn );
00128
00142 int LIBCALL opdis_tree_add( opdis_tree_t tree, void * data );
00143
00157 int LIBCALL opdis_tree_update( opdis_tree_t tree, void * data );
00158
00171 int LIBCALL opdis_tree_delete( opdis_tree_t tree, void * key );
00172
00189 int LIBCALL opdis_tree_contains( opdis_tree_t tree, void * key );
00190
00201 void * LIBCALL opdis_tree_find( opdis_tree_t tree, void * key );
00202
00214 void * LIBCALL opdis_tree_closest( opdis_tree_t tree, void * key );
00215
00227 void * LIBCALL opdis_tree_next( opdis_tree_t tree, void * key );
00228
00238 typedef int (*OPDIS_TREE_FOREACH_FN) (void * item, void * arg);
00239
00249 void LIBCALL opdis_tree_foreach( opdis_tree_t tree, OPDIS_TREE_FOREACH_FN fn,
00250 void * arg );
00251
00260 size_t LIBCALL opdis_tree_count( opdis_tree_t tree );
00261
00273 void LIBCALL opdis_tree_free( opdis_tree_t tree );
00274
00275
00276
00277
00289 opdis_vma_tree_t LIBCALL opdis_vma_tree_init( void );
00290
00301 int LIBCALL opdis_vma_tree_add( opdis_vma_tree_t tree, opdis_vma_t addr );
00302
00313 int LIBCALL opdis_vma_tree_delete( opdis_vma_tree_t tree, opdis_vma_t addr );
00314
00325 int LIBCALL opdis_vma_tree_contains( opdis_vma_tree_t tree, opdis_vma_t addr );
00326
00337 opdis_vma_t LIBCALL opdis_vma_tree_find( opdis_vma_tree_t tree,
00338 opdis_vma_t addr );
00339
00349 typedef int (*OPDIS_ADDR_TREE_FOREACH_FN) (opdis_vma_t addr, void * arg);
00350
00361 void LIBCALL opdis_vma_tree_foreach( opdis_vma_tree_t tree,
00362 OPDIS_ADDR_TREE_FOREACH_FN fn, void * arg );
00363
00372 void LIBCALL opdis_vma_tree_free( opdis_vma_tree_t tree );
00373
00374
00375
00376
00388 opdis_insn_tree_t LIBCALL opdis_insn_tree_init( int manage );
00389
00400 int LIBCALL opdis_insn_tree_add( opdis_insn_tree_t tree,
00401 opdis_insn_t * insn );
00402
00415 int LIBCALL opdis_insn_tree_delete( opdis_insn_tree_t tree, opdis_vma_t addr );
00416
00427 int LIBCALL opdis_insn_tree_contains(opdis_insn_tree_t tree, opdis_vma_t addr);
00428
00439 opdis_insn_t * LIBCALL opdis_insn_tree_find( opdis_insn_tree_t tree,
00440 opdis_vma_t addr );
00441
00451 typedef int (*OPDIS_INSN_TREE_FOREACH_FN) (opdis_insn_t * insn, void * arg);
00452
00463 void LIBCALL opdis_insn_tree_foreach( opdis_insn_tree_t tree,
00464 OPDIS_INSN_TREE_FOREACH_FN fn, void * arg );
00465
00476 void LIBCALL opdis_insn_tree_free( opdis_insn_tree_t tree );
00477
00478 #ifdef __cplusplus
00479 }
00480 #endif
00481
00482 #endif
00483