| 1 | /* |
| 2 | COLLECTION LIBRARY |
| 3 | |
| 4 | Header file for internal structures used by the collection interface. |
| 5 | |
| 6 | Copyright (C) Dmitri Pal <[email protected]> 2009 |
| 7 | |
| 8 | Collection Library is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU Lesser General Public License as published by |
| 10 | the Free Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | Collection Library is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU Lesser General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU Lesser General Public License |
| 19 | along with Collection Library. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | #ifndef COLLECTION_PRIV_H |
| 23 | #define COLLECTION_PRIV_H |
| 24 | |
| 25 | #include <stdint.h> |
| 26 | |
| 27 | /* Define real strcutures */ |
| 28 | /* Structure that holds one property. |
| 29 | * This structure should never be assumed and used directly other than |
| 30 | * inside the collection.c that contains actual implementation or |
| 31 | * collection_tools.c or collection_utils.c. |
| 32 | */ |
| 33 | struct collection_item { |
| 34 | /* Member that contains element linking information. |
| 35 | * This member should never be directly accessed by an application. |
| 36 | */ |
| 37 | struct collection_item *next; |
| 38 | |
| 39 | /* Your implementation can assume that these members |
| 40 | * will always be members of the collection_item. |
| 41 | * but you should use get_item_xxx functions to get them. |
| 42 | */ |
| 43 | char *property; |
| 44 | int property_len; |
| 45 | int type; |
| 46 | int length; |
| 47 | void *data; |
| 48 | uint64_t phash; |
| 49 | }; |
| 50 | |
| 51 | |
| 52 | /* Internal iterator structure - exposed for reference. |
| 53 | * Never access internals of this structure in your application. |
| 54 | */ |
| 55 | struct collection_iterator { |
| 56 | struct collection_item *top; |
| 57 | struct collection_item **stack; |
| 58 | unsigned stack_size; |
| 59 | unsigned stack_depth; |
| 60 | unsigned item_level; |
| 61 | int flags; |
| 62 | struct collection_item *end_item; |
| 63 | struct collection_item *pin; |
| 64 | unsigned pin_level; |
| 65 | unsigned can_break; |
| 66 | }; |
| 67 | |
| 68 | |
| 69 | /* Special type of data that stores collection header information. */ |
| 70 | struct collection_header { |
| 71 | struct collection_item *last; |
| 72 | unsigned reference_count; |
| 73 | unsigned count; |
| 74 | unsigned cclass; |
| 75 | }; |
| 76 | |
| 77 | /* Internal function to allocate item */ |
| 78 | int col_allocate_item(struct collection_item **ci, |
| 79 | const char *property, |
| 80 | const void *item_data, |
| 81 | int length, |
| 82 | int type); |
| 83 | |
| 84 | #endif |