summaryrefslogtreecommitdiffstats
path: root/common/collection/collection_tools.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/collection/collection_tools.h')
-rw-r--r--common/collection/collection_tools.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/common/collection/collection_tools.h b/common/collection/collection_tools.h
new file mode 100644
index 000000000..726f21c72
--- /dev/null
+++ b/common/collection/collection_tools.h
@@ -0,0 +1,98 @@
+/*
+ COLLECTION LIBRARY
+
+ Header file for supplementary functions that provide
+ printing and debugging of collections.
+
+ Copyright (C) Dmitri Pal <dpal@redhat.com> 2009
+
+ Collection Library is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Collection Library 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with Collection Library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef COLLECTION_TOOLS_H
+#define COLLECTION_TOOLS_H
+
+#include "trace.h"
+#include "collection.h"
+
+#ifdef HAVE_TRACE
+#define DEBUG_COLLECTION(collection) debug_collection(collection,COL_TRAVERSE_DEFAULT);
+#else
+#define DEBUG_COLLECTION(collection) ;
+#endif
+
+#define COL_TYPE_NAME_STRING "string"
+#define COL_TYPE_NAME_BINARY "bin"
+#define COL_TYPE_NAME_INTEGER "int"
+#define COL_TYPE_NAME_UNSIGNED "uint"
+#define COL_TYPE_NAME_LONG "long"
+#define COL_TYPE_NAME_ULONG "ulong"
+#define COL_TYPE_NAME_DOUBLE "double"
+#define COL_TYPE_NAME_BOOL "bool"
+#define COL_TYPE_NAME_UNKNOWN "unknown"
+
+#define TEXT_COLLECTION "SET"
+#define TEXT_COLLEN 3
+
+#define BLOCK_SIZE 1024
+
+struct serial_data {
+ char *buffer;
+ int size;
+ int length;
+ int nest_level;
+};
+
+
+/* Calculate the potential size of the item */
+int get_data_len(int type, int length);
+
+/* Grow buffer to accomodate more space */
+int grow_buffer(struct serial_data *buf_data, int len);
+
+/* Specail function to add different formatting symbols to the output */
+int put_marker(struct serial_data *buf_data, void *data, int len);
+
+/* Serialization of data user handler */
+int serialize(char *property_in,
+ int property_len_in,
+ int type,
+ void *data_in,
+ int length_in,
+ void *custom_data,
+ int *dummy);
+
+/* Debug handle */
+int debug_handle(char *property,
+ int property_len,
+ int type,
+ void *data,
+ int length,
+ void *custom_data,
+ int *dummy);
+
+/* Convenience function to debug an item */
+int debug_item(struct collection_item *item);
+
+/* Print collection for debugging purposes */
+int debug_collection(struct collection_item *handle,int flag);
+
+/* Print the collection using default serialization */
+int print_collection(struct collection_item *handle);
+
+
+/* Find and print one item using default serialization */
+int print_item(struct collection_item *handle, char *name);
+
+#endif