gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r28715 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r28715 - in gnunet/src: include util
Date: Mon, 19 Aug 2013 21:18:18 +0200

Author: grothoff
Date: 2013-08-19 21:18:17 +0200 (Mon, 19 Aug 2013)
New Revision: 28715

Modified:
   gnunet/src/include/gnunet_container_lib.h
   gnunet/src/include/gnunet_crypto_lib.h
   gnunet/src/util/common_logging.c
   gnunet/src/util/crypto_hash.c
Log:
-remove ShortHashCode from API, deprecate SList

Modified: gnunet/src/include/gnunet_container_lib.h
===================================================================
--- gnunet/src/include/gnunet_container_lib.h   2013-08-19 19:13:22 UTC (rev 
28714)
+++ gnunet/src/include/gnunet_container_lib.h   2013-08-19 19:18:17 UTC (rev 
28715)
@@ -1394,22 +1394,26 @@
 /**
  * Possible ways for how data stored in the linked list
  * might be allocated.
+ * @deprecated use DLL macros
  */
 enum GNUNET_CONTAINER_SListDisposition
 {
-    /**
-     * Single-linked list must copy the buffer.
-     */
+  /**
+   * Single-linked list must copy the buffer.
+   * @deprecated use DLL macros
+   */
   GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT = 0,
 
-    /**
-     * Data is static, no need to copy or free.
-     */
+  /**
+   * Data is static, no need to copy or free.
+   * @deprecated use DLL macros
+   */
   GNUNET_CONTAINER_SLIST_DISPOSITION_STATIC = 2,
 
-    /**
-     * Data is dynamic, do not copy but free when done.
-     */
+  /**
+   * Data is dynamic, do not copy but free when done.
+   * @deprecated use DLL macros
+   */
   GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC = 4
 };
 
@@ -1417,11 +1421,13 @@
 
 /**
  * Handle to a singly linked list
+ * @deprecated use DLL macros
  */
 struct GNUNET_CONTAINER_SList;
 
 /**
  * Handle to a singly linked list iterator
+ * @deprecated use DLL macros
  */
 struct GNUNET_CONTAINER_SList_Iterator
 {
@@ -1449,6 +1455,7 @@
  * @param disp memory disposition
  * @param buf payload buffer
  * @param len length of the buffer
+ * @deprecated use DLL macros
  */
 void
 GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l,
@@ -1462,6 +1469,7 @@
  * @param disp memory disposition
  * @param buf payload buffer
  * @param len length of the buffer
+ * @deprecated use DLL macros
  */
 void
 GNUNET_CONTAINER_slist_add_end (struct GNUNET_CONTAINER_SList *l,
@@ -1473,6 +1481,7 @@
  * Append a singly linked list to another
  * @param dst list to append to
  * @param src source
+ * @deprecated use DLL macros
  */
 void
 GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst,
@@ -1482,6 +1491,7 @@
 /**
  * Create a new singly linked list
  * @return the new list
+ * @deprecated use DLL macros
  */
 struct GNUNET_CONTAINER_SList *
 GNUNET_CONTAINER_slist_create (void);
@@ -1490,6 +1500,7 @@
 /**
  * Destroy a singly linked list
  * @param l the list to be destroyed
+ * @deprecated use DLL macros
  */
 void
 GNUNET_CONTAINER_slist_destroy (struct GNUNET_CONTAINER_SList *l);
@@ -1502,6 +1513,7 @@
  * @return iterator pointing to the beginning (by value! Either allocate the
  *   structure on the stack, or use GNUNET_malloc() yourself! All other
  *   functions do take pointer to this struct though)
+ * @deprecated use DLL macros
  */
 struct GNUNET_CONTAINER_SList_Iterator
 GNUNET_CONTAINER_slist_begin (struct GNUNET_CONTAINER_SList *l);
@@ -1511,6 +1523,7 @@
  * Clear a list
  *
  * @param l list
+ * @deprecated use DLL macros
  */
 void
 GNUNET_CONTAINER_slist_clear (struct GNUNET_CONTAINER_SList *l);
@@ -1521,8 +1534,8 @@
  * @param l list
  * @param buf payload buffer to find
  * @param len length of the payload (number of bytes in buf)
- *
  * @return GNUNET_YES if found, GNUNET_NO otherwise
+ * @deprecated use DLL macros
  */
 int
 GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l,
@@ -1538,6 +1551,7 @@
  *
  * @return NULL if the 'buf' could not be found, pointer to the
  *         list element, if found
+ * @deprecated use DLL macros
  */
 void *
 GNUNET_CONTAINER_slist_contains2 (const struct GNUNET_CONTAINER_SList *l,
@@ -1547,6 +1561,7 @@
  * Count the elements of a list
  * @param l list
  * @return number of elements in the list
+ * @deprecated use DLL macros
  */
 int
 GNUNET_CONTAINER_slist_count (const struct GNUNET_CONTAINER_SList *l);
@@ -1555,6 +1570,7 @@
 /**
  * Remove an element from the list
  * @param i iterator that points to the element to be removed
+ * @deprecated use DLL macros
  */
 void
 GNUNET_CONTAINER_slist_erase (struct GNUNET_CONTAINER_SList_Iterator *i);
@@ -1566,6 +1582,7 @@
  * @param disp memory disposition
  * @param buf payload buffer
  * @param len length of the payload
+ * @deprecated use DLL macros
  */
 void
 GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator *before,
@@ -1577,6 +1594,7 @@
  * Advance an iterator to the next element
  * @param i iterator
  * @return GNUNET_YES on success, GNUNET_NO if the end has been reached
+ * @deprecated use DLL macros
  */
 int
 GNUNET_CONTAINER_slist_next (struct GNUNET_CONTAINER_SList_Iterator *i);
@@ -1587,6 +1605,7 @@
  * @param i iterator
  * @return GNUNET_YES if the end has been reached, GNUNET_NO if the iterator
  *         points to a valid element
+ * @deprecated use DLL macros
  */
 int
 GNUNET_CONTAINER_slist_end (struct GNUNET_CONTAINER_SList_Iterator *i);
@@ -1598,6 +1617,7 @@
  * @param i iterator
  * @param len set to the payload length
  * @return payload
+ * @deprecated use DLL macros
  */
 void *
 GNUNET_CONTAINER_slist_get (const struct GNUNET_CONTAINER_SList_Iterator *i,
@@ -1607,6 +1627,7 @@
 /**
  * Release an iterator
  * @param i iterator
+ * @deprecated use DLL macros
  */
 void
 GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator 
*i);

Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h      2013-08-19 19:13:22 UTC (rev 
28714)
+++ gnunet/src/include/gnunet_crypto_lib.h      2013-08-19 19:18:17 UTC (rev 
28715)
@@ -96,15 +96,6 @@
 };
 
 
-/**
- * @brief 0-terminated ASCII encoding of a struct GNUNET_CRYPTO_ShortHashCode.
- */
-struct GNUNET_CRYPTO_ShortHashAsciiEncoded
-{
-  unsigned char short_encoding[53];
-};
-
-
 GNUNET_NETWORK_STRUCT_BEGIN
 
 
@@ -406,19 +397,6 @@
 
 /**
  * @ingroup hash
- * Convert short hash to ASCII encoding.
- *
- * @param block the hash code
- * @param result where to store the encoding (struct 
GNUNET_CRYPTO_ShortHashAsciiEncoded can be
- *  safely cast to char*, a '\\0' termination is set).
- */
-void
-GNUNET_CRYPTO_short_hash_to_enc (const struct GNUNET_CRYPTO_ShortHashCode * 
block,
-                                struct GNUNET_CRYPTO_ShortHashAsciiEncoded 
*result);
-
-
-/**
- * @ingroup hash
  * Convert ASCII encoding back to a 'struct GNUNET_HashCode'
  *
  * @param enc the encoding
@@ -433,20 +411,6 @@
 
 /**
  * @ingroup hash
- * Convert ASCII encoding back to a 'struct GNUNET_CRYPTO_ShortHash'
- *
- * @param enc the encoding
- * @param enclen number of characters in @a enc (without 0-terminator, which 
can be missing)
- * @param result where to store the hash code
- * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong 
encoding
- */
-int
-GNUNET_CRYPTO_short_hash_from_string2 (const char *enc, size_t enclen,
-                                      struct GNUNET_CRYPTO_ShortHashCode * 
result);
-
-
-/**
- * @ingroup hash
  * Convert ASCII encoding back to struct GNUNET_HashCode
  *
  * @param enc the encoding
@@ -459,31 +423,6 @@
 
 /**
  * @ingroup hash
- * Convert ASCII encoding back to a 'struct GNUNET_CRYPTO_ShortHash'
- *
- * @param enc the encoding
- * @param result where to store the GNUNET_CRYPTO_ShortHash 
- * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong 
encoding
- */
-#define GNUNET_CRYPTO_short_hash_from_string(enc, result) \
-  GNUNET_CRYPTO_short_hash_from_string2 (enc, strlen(enc), result)
-
-
-/**
- * @ingroup hash
- * Compare function for ShortHashCodes, producing a total ordering
- * of all hashcodes.
- *
- * @param h1 some hash code
- * @param h2 some hash code
- * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
- */
-int
-GNUNET_CRYPTO_short_hash_cmp (const struct GNUNET_CRYPTO_ShortHashCode * h1,
-                              const struct GNUNET_CRYPTO_ShortHashCode * h2);
-
-/**
- * @ingroup hash
  * Compute the distance between 2 hashcodes.
  * The computation must be fast, not involve
  * a.a or a.e (they're used elsewhere), and
@@ -513,45 +452,6 @@
 
 /**
  * @ingroup hash
- * Compute short (256-bit) hash of a given block.
- *
- * @param block the data to hash
- * @param size size of the @a block
- * @param ret pointer to where to write the hashcode
- */
-void
-GNUNET_CRYPTO_short_hash (const void *block, size_t size, 
-                         struct GNUNET_CRYPTO_ShortHashCode * ret);
-
-
-/**
- * @ingroup hash
- * Double short (256-bit) hash to create a long hash.
- *
- * @param sh short hash to double
- * @param dh where to store the (doubled) long hash (not really a hash)
- */
-void
-GNUNET_CRYPTO_short_hash_double (const struct GNUNET_CRYPTO_ShortHashCode *sh,
-                                struct GNUNET_HashCode *dh);
-
-
-/**
- * @ingroup hash
- * Truncate doubled short hash back to a short hash.
- *
- * @param dh doubled short hash to reduce again
- * @param sh where to store the short hash
- * @return GNUNET_OK on success, GNUNET_SYSERR if this was not a
- *         doubled short hash
- */
-int
-GNUNET_CRYPTO_short_hash_from_truncation (const struct GNUNET_HashCode *dh,
-                                         struct GNUNET_CRYPTO_ShortHashCode 
*sh);
-
-
-/**
- * @ingroup hash
  * Calculate HMAC of a message (RFC 2104)
  *
  * @param key secret key

Modified: gnunet/src/util/common_logging.c
===================================================================
--- gnunet/src/util/common_logging.c    2013-08-19 19:13:22 UTC (rev 28714)
+++ gnunet/src/util/common_logging.c    2013-08-19 19:18:17 UTC (rev 28715)
@@ -1038,43 +1038,6 @@
 
 
 /**
- * Convert a short hash to a string (for printing debug messages).
- * This is one of the very few calls in the entire API that is
- * NOT reentrant!
- *
- * @param hc the short hash code
- * @return string form; will be overwritten by next call to GNUNET_h2s.
- */
-const char *
-GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc)
-{
-  static struct GNUNET_CRYPTO_ShortHashAsciiEncoded ret;
-
-  GNUNET_CRYPTO_short_hash_to_enc (hc, &ret);
-  ret.short_encoding[8] = '\0';
-  return (const char *) ret.short_encoding;
-}
-
-
-/**
- * Convert a short hash to a string (for printing debug messages).
- * This is one of the very few calls in the entire API that is
- * NOT reentrant!
- *
- * @param hc the short hash code
- * @return string form; will be overwritten by next call to GNUNET_h2s_full.
- */
-const char *
-GNUNET_short_h2s_full (const struct GNUNET_CRYPTO_ShortHashCode * hc)
-{
-  static struct GNUNET_CRYPTO_ShortHashAsciiEncoded ret;
-
-  GNUNET_CRYPTO_short_hash_to_enc (hc, &ret);
-  ret.short_encoding[sizeof (ret) - 1] = '\0';
-  return (const char *) ret.short_encoding;
-}
-
-/**
  * Convert a hash to a string (for printing debug messages).
  * This is one of the very few calls in the entire API that is
  * NOT reentrant!

Modified: gnunet/src/util/crypto_hash.c
===================================================================
--- gnunet/src/util/crypto_hash.c       2013-08-19 19:13:22 UTC (rev 28714)
+++ gnunet/src/util/crypto_hash.c       2013-08-19 19:18:17 UTC (rev 28715)
@@ -1,10 +1,10 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2012 Christian Grothoff 
(and other contributing authors)
+     (C) 2001-2013 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -17,11 +17,6 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 
-     SHA-512 code by Jean-Luc Cooke <address@hidden>
-
-     Copyright (c) Jean-Luc Cooke <address@hidden>
-     Copyright (c) Andrew McDonald <address@hidden>
-     Copyright (c) 2003 Kyle McMartin <address@hidden>
 */
 
 /**
@@ -56,21 +51,6 @@
 
 
 /**
- * Compute short (256-bit) hash of a given block.
- *
- * @param block the data to GNUNET_CRYPTO_hash, length is given as a second 
argument
- * @param size the length of the data to GNUNET_CRYPTO_hash
- * @param ret pointer to where to write the hashcode
- */
-void
-GNUNET_CRYPTO_short_hash (const void *block, size_t size, 
-                         struct GNUNET_CRYPTO_ShortHashCode * ret)
-{
-  gcry_md_hash_buffer (GCRY_MD_SHA256, ret, block, size);
-}
-
-
-/**
  * Context used when hashing a file.
  */
 struct GNUNET_CRYPTO_FileHashContext
@@ -590,119 +570,4 @@
 }
 
 
-
-/**
- * Double short (256-bit) hash to create a long hash.
- *
- * @param sh short hash to double
- * @param dh where to store the (doubled) long hash (not really a hash)
- */
-void
-GNUNET_CRYPTO_short_hash_double (const struct GNUNET_CRYPTO_ShortHashCode *sh,
-                                struct GNUNET_HashCode *dh)
-{
-  char *ptr;
-
-  ptr = (char*) dh;
-  memcpy (ptr, sh, sizeof (struct GNUNET_CRYPTO_ShortHashCode));
-  memcpy (&ptr[sizeof (struct GNUNET_CRYPTO_ShortHashCode)], sh, sizeof 
(struct GNUNET_CRYPTO_ShortHashCode));
-}
-
-
-/**
- * Truncate doubled short hash back to a short hash.
- *
- * @param dh doubled short hash to reduce again
- * @param sh where to store the short hash
- * @return GNUNET_OK on success, GNUNET_SYSERR if this was not a
- *         doubled short hash
- */
-int
-GNUNET_CRYPTO_short_hash_from_truncation (const struct GNUNET_HashCode *dh,
-                                         struct GNUNET_CRYPTO_ShortHashCode 
*sh)
-{
-  const struct GNUNET_CRYPTO_ShortHashCode *s;
-
-  s = (const struct GNUNET_CRYPTO_ShortHashCode *) dh;
-  if (0 != memcmp (&s[0],
-                  &s[1],
-                  sizeof (struct GNUNET_CRYPTO_ShortHashCode)))
-    return GNUNET_SYSERR;
-  *sh = *s;
-  return GNUNET_OK;
-}
-
-
-/**
- * Convert ASCII encoding back to a 'struct GNUNET_CRYPTO_ShortHash'
- *
- * @param enc the encoding
- * @param enclen number of characters in 'enc' (without 0-terminator, which 
can be missing)
- * @param result where to store the GNUNET_CRYPTO_hash code
- * @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding
- */
-int
-GNUNET_CRYPTO_short_hash_from_string2 (const char *enc, size_t enclen,
-                                      struct GNUNET_CRYPTO_ShortHashCode * 
result)
-{
-
-  char upper_enc[enclen];
-  char* up_ptr = upper_enc;
-
-  GNUNET_STRINGS_utf8_toupper(enc, &up_ptr);
-  return GNUNET_STRINGS_string_to_data (upper_enc, enclen,
-                                       (unsigned char*) result,
-                                       sizeof (struct 
GNUNET_CRYPTO_ShortHashCode));
-}
-
-
-/**
- * Convert short hash to ASCII encoding.
- *
- * @param block the hash code
- * @param result where to store the encoding (struct 
GNUNET_CRYPTO_ShortHashAsciiEncoded can be
- *  safely cast to char*, a '\\0' termination is set).
- */
-void
-GNUNET_CRYPTO_short_hash_to_enc (const struct GNUNET_CRYPTO_ShortHashCode * 
block,
-                                struct GNUNET_CRYPTO_ShortHashAsciiEncoded 
*result)
-{
-  char *np;
-
-  np = GNUNET_STRINGS_data_to_string ((const unsigned char *) block,
-                                     sizeof (struct 
GNUNET_CRYPTO_ShortHashCode),
-                                     (char*) result,
-                                     sizeof (struct 
GNUNET_CRYPTO_ShortHashAsciiEncoded) - 1);
-  GNUNET_assert (NULL != np);
-  *np = '\0';
-}
-
-/**
- * Compare function for ShortHashCodes, producing a total ordering
- * of all hashcodes.
- *
- * @param h1 some hash code
- * @param h2 some hash code
- * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
- */
-int
-GNUNET_CRYPTO_short_hash_cmp (const struct GNUNET_CRYPTO_ShortHashCode * h1,
-                        const struct GNUNET_CRYPTO_ShortHashCode * h2)
-{
-  unsigned int *i1;
-  unsigned int *i2;
-  int i;
-
-  i1 = (unsigned int *) h1;
-  i2 = (unsigned int *) h2;
-  for (i = (sizeof (struct GNUNET_CRYPTO_ShortHashCode) / sizeof (unsigned 
int)) - 1; i >= 0; i--)
-  {
-    if (i1[i] > i2[i])
-      return 1;
-    if (i1[i] < i2[i])
-      return -1;
-  }
-  return 0;
-}
-
 /* end of crypto_hash.c */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]