libcollection  0.6.0
collection_tools.h
1 /*
2  COLLECTION LIBRARY
3 
4  Header file for supplementary functions that provide
5  printing and debugging of collections.
6 
7  Copyright (C) Dmitri Pal <dpal@redhat.com> 2009
8 
9  Collection Library is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  Collection Library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with Collection Library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #ifndef COLLECTION_TOOLS_H
24 #define COLLECTION_TOOLS_H
25 
26 #include "collection.h"
27 
41 #ifdef HAVE_TRACE
42 #define COL_DEBUG_COLLECTION(collection) col_debug_collection(collection,COL_TRAVERSE_DEFAULT);
43 #else
44 #define COL_DEBUG_COLLECTION(collection) ;
45 #endif
46 
48 #define COL_TYPE_NAME_STRING "string"
49 
50 #define COL_TYPE_NAME_BINARY "bin"
51 
52 #define COL_TYPE_NAME_INTEGER "int"
53 
54 #define COL_TYPE_NAME_UNSIGNED "uint"
55 
56 #define COL_TYPE_NAME_LONG "long"
57 
58 #define COL_TYPE_NAME_ULONG "ulong"
59 
60 #define COL_TYPE_NAME_DOUBLE "double"
61 
62 #define COL_TYPE_NAME_BOOL "bool"
63 
64 #define COL_TYPE_NAME_UNKNOWN "unknown"
65 
67 #define TEXT_COLLECTION "SET"
68 
69 #define TEXT_COLLEN 3
70 
75 #define BLOCK_SIZE 1024
76 
82  char *buffer;
83  int size;
84  int length;
85  int nest_level;
86 };
87 
88 
97 int col_get_data_len(int type, int length);
98 
109 int col_grow_buffer(struct col_serial_data *buf_data, int len);
110 
121 int col_put_marker(struct col_serial_data *buf_data,
122  const void *data, int len);
123 
141 int col_serialize(const char *property_in,
142  int property_len_in,
143  int type,
144  void *data_in,
145  int length_in,
146  void *custom_data,
147  int *dummy);
148 
165 int col_debug_handle(const char *property,
166  int property_len,
167  int type,
168  void *data,
169  int length,
170  void *custom_data,
171  int *dummy);
172 
183 int col_debug_item(struct collection_item *item);
184 
196 int col_debug_collection(struct collection_item *handle,
197  int flag);
198 
211 int col_print_collection(struct collection_item *handle);
212 
224 int col_print_collection2(struct collection_item *handle);
225 
237 int col_print_item(struct collection_item *handle, const char *name);
238 
257 char **col_collection_to_list(struct collection_item *handle,
258  int *size,
259  int *error);
260 
266 void col_free_property_list(char **str_list);
267 
272 #endif
int col_put_marker(struct col_serial_data *buf_data, const void *data, int len)
Add special data to the serialization output.
Definition: collection_tools.c:335
char ** col_collection_to_list(struct collection_item *handle, int *size, int *error)
Convert collection to the array of properties.
Definition: collection_tools.c:684
int col_print_collection2(struct collection_item *handle)
Print collection data.
Definition: collection_tools.c:569
int col_print_collection(struct collection_item *handle)
Print collection data.
Definition: collection_tools.c:539
int col_debug_item(struct collection_item *item)
Convenience function to debug an item.
Definition: collection_tools.c:165
Structure is used to incrementaly serialize collection.
Definition: collection_tools.h:81
int col_debug_handle(const char *property, int property_len, int type, void *data, int length, void *custom_data, int *dummy)
Debug property callback.
Definition: collection_tools.c:33
int col_serialize(const char *property_in, int property_len_in, int type, void *data_in, int length_in, void *custom_data, int *dummy)
Serialization of data callback.
Definition: collection_tools.c:356
int col_grow_buffer(struct col_serial_data *buf_data, int len)
Grow serialization buffer.
Definition: collection_tools.c:306
Opaque structure that holds one property.
void col_free_property_list(char **str_list)
Free list of properties.
Definition: collection_tools.c:665
int col_get_data_len(int type, int length)
Calculate the potential size of the item.
Definition: collection_tools.c:239
int col_print_item(struct collection_item *handle, const char *name)
Find and print one property.
Definition: collection_tools.c:629
int col_debug_collection(struct collection_item *handle, int flag)
Print collection for debugging purposes.
Definition: collection_tools.c:180