X-Git-Url: http://git.silcnet.org/gitweb/?p=runtime.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilctree_i.h;fp=lib%2Fsilcutil%2Fsilctree_i.h;h=9f3a6aa36607fe21456081dd6e976f62613a7412;hp=0000000000000000000000000000000000000000;hb=a6428c51f8544ca92870eb573f8a7bc7d1e16d19;hpb=0ec0cbbedc2ec9ab76aa1073b30572288441e9c9 diff --git a/lib/silcutil/silctree_i.h b/lib/silcutil/silctree_i.h new file mode 100644 index 00000000..9f3a6aa3 --- /dev/null +++ b/lib/silcutil/silctree_i.h @@ -0,0 +1,64 @@ +/* + + silctree_i.h + + Author: Pekka Riikonen + + Copyright (C) 2008 Pekka Riikonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +*/ + +#ifndef SILCTREE_I_H +#define SILCTREE_I_H + +#ifndef SILCTREE_H +#error "Do not include this header directly" +#endif + +/* Tree operatins header */ +struct SilcTreeOpsStruct { + SilcBool (*add)(SilcTree *tree, void *entry); + SilcBool (*del)(SilcTree *tree, void *entry); + void *(*find)(SilcTree *tree, void *entry, SilcTreeCompare compare, + void *context); +}; + +/* Generic tree header, present in each entry in tree */ +struct SilcTreeHeaderStruct { + struct SilcTreeHeaderStruct *parent; + struct SilcTreeHeaderStruct *left; + struct SilcTreeHeaderStruct *right; + struct SilcTreeHeaderStruct *dup; + SilcInt16 t; + unsigned int duplicate : 1; +}; + +/* Tree context */ +struct SilcTreeStruct { + const struct SilcTreeOpsStruct *ops; + SilcTreeHeader *root; + SilcTreeCompare compare; + void *context; + SilcUInt32 count; + unsigned int offset : 31; + unsigned int duplicates : 1; +}; + +/* Get tree header from entry */ +#define SILC_TREE_GET_HEADER(tree, pos) \ + ((void *)((unsigned char *)(pos) + tree->offset)) + +/* Get entry from tree header */ +#define SILC_TREE_GET_ENTRY(tree, pos) \ + ((void *)((unsigned char *)(pos) - tree->offset)) + +#endif /* SILCTREE_I_H */