diff options
author | Dmitri Pal <dpal@redhat.com> | 2009-04-06 09:30:01 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-04-06 15:59:21 -0400 |
commit | de6d6fb21bf367a94c7d292f2c3decd24cf42868 (patch) | |
tree | 3eb3a5347eb9b39ede80984a3b2caade1cfa40c4 /common/collection/collection_tools.h | |
parent | 2ec952c6db27db1d5a21154e2683d1e862643ac8 (diff) | |
download | sssd-de6d6fb21bf367a94c7d292f2c3decd24cf42868.tar.gz sssd-de6d6fb21bf367a94c7d292f2c3decd24cf42868.tar.xz sssd-de6d6fb21bf367a94c7d292f2c3decd24cf42868.zip |
First commit of basic collection API.
Diffstat (limited to 'common/collection/collection_tools.h')
-rw-r--r-- | common/collection/collection_tools.h | 98 |
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 |