/*
This file is part of GNUnet.
- Copyright (C) 2001-2015 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2001-2015 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
- * @file include/gnunet_container_lib.h
- * @brief container classes for GNUnet
* @author Christian Grothoff
* @author Nils Durner
- * @defgroup hashmap multi hash-map
- * @defgroup heap min- or max-heap with arbitrary element removal
- * @defgroup bloomfilter Bloom filter (probabilistic set tests)
- * @defgroup dll Doubly-linked list
- * @defgroup metadata Meta data (GNU libextractor key-value pairs)
+ *
+ * @file
+ * Container classes for GNUnet
+ *
+ * @defgroup hashmap Container library: MultiHashMap
+ * Hash map with multiple values per key.
+ *
+ * @see [Documentation](https://gnunet.org/util_multihashmap)
+ *
+ * @defgroup heap Container library: Heap
+ * Min- or max-heap with arbitrary element removal
+ *
+ * @defgroup bloomfilter Container library: Bloom filter
+ * Probabilistic set tests
+ *
+ * @defgroup dll Container library: Doubly-linked list
+ *
+ * @see [Documentation](https://gnunet.org/mdll-api)
+ *
+ * @defgroup metadata Container library: Metadata
+ * GNU libextractor key-value pairs
*/
#ifndef GNUNET_CONTAINER_LIB_H
/* add error and config prototypes */
#include "gnunet_crypto_lib.h"
+
+/**
+ * Try to compress the given block of data using libz. Only returns
+ * the compressed block if compression worked and the new block is
+ * actually smaller. Decompress using #GNUNET_decompress().
+ *
+ * @param data block to compress; if compression
+ * resulted in a smaller block, the first
+ * bytes of data are updated to the compressed
+ * data
+ * @param old_size number of bytes in data
+ * @param[out] result set to the compressed data, if compression worked
+ * @param[out] new_size set to size of result, if compression worked
+ * @return #GNUNET_YES if compression reduce the size,
+ * #GNUNET_NO if compression did not help
+ */
+int
+GNUNET_try_compression (const char *data,
+ size_t old_size,
+ char **result,
+ size_t *new_size);
+
+
+/**
+ * Decompress input, return the decompressed data as output. Dual to
+ * #GNUNET_try_compression(). Caller must set @a output_size to the
+ * number of bytes that were originally compressed.
+ *
+ * @param input compressed data
+ * @param input_size number of bytes in input
+ * @param output_size expected size of the output
+ * @return NULL on error, buffer of @a output_size decompressed bytes otherwise
+ */
+char *
+GNUNET_decompress (const char *input,
+ size_t input_size,
+ size_t output_size);
+
+
#if HAVE_EXTRACTOR_H
#include <extractor.h>
void *value);
+/**
+ * Hash map from peer identities to values.
+ */
struct GNUNET_CONTAINER_MultiPeerMap;
+
+
/**
* @ingroup hashmap
* Create a multi peer map (hash map for public keys of peers).