gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r7478 - GNUnet/src/util/containers


From: gnunet
Subject: [GNUnet-SVN] r7478 - GNUnet/src/util/containers
Date: Sat, 19 Jul 2008 22:45:17 -0600 (MDT)

Author: grothoff
Date: 2008-07-19 22:45:17 -0600 (Sat, 19 Jul 2008)
New Revision: 7478

Modified:
   GNUnet/src/util/containers/meta.c
Log:
removing code duplicated from LE

Modified: GNUnet/src/util/containers/meta.c
===================================================================
--- GNUnet/src/util/containers/meta.c   2008-07-20 04:38:41 UTC (rev 7477)
+++ GNUnet/src/util/containers/meta.c   2008-07-20 04:45:17 UTC (rev 7478)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2003, 2004, 2005, 2006 Christian Grothoff (and other contributing 
authors)
+     (C) 2003, 2004, 2005, 2006, 2008 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
@@ -26,6 +26,7 @@
 
 #include "platform.h"
 #include "gnunet_util.h"
+#include <extractor.h>
 #include <zlib.h>
 
 #define EXTRA_CHECKS ALLOW_EXTRA_CHECKS
@@ -231,53 +232,7 @@
   return ret;
 }
 
-
 /**
- * This function can be used to decode the binary data
- * stream produced by the thumbnailextractor.
- *
- * @param in 0-terminated string from the meta-data
- * @return 1 on error, 0 on success
- */
-static int
-decodeThumbnail (const char *in, unsigned char **out, size_t * outSize)
-{
-  unsigned char *buf;
-  size_t pos;
-  size_t wpos;
-  unsigned char marker;
-  size_t i;
-  size_t end;
-  size_t inSize;
-
-  inSize = strlen (in);
-  if (inSize == 0)
-    {
-      *out = NULL;
-      *outSize = 0;
-      return 1;
-    }
-
-  buf = GNUNET_malloc (inSize);        /* slightly more than needed ;-) */
-  *out = buf;
-
-  pos = 0;
-  wpos = 0;
-  while (pos < inSize)
-    {
-      end = pos + 255;          /* 255 here: count the marker! */
-      if (end > inSize)
-        end = inSize;
-      marker = in[pos++];
-      for (i = pos; i < end; i++)
-        buf[wpos++] = (in[i] == marker) ? 0 : in[i];
-      pos = end;
-    }
-  *outSize = wpos;
-  return 0;
-}
-
-/**
  * Get a thumbnail from the meta-data (if present).
  *
  * @param thumb will be set to the thumbnail data.  Must be
@@ -301,12 +256,11 @@
       return 0;                 /* invalid */
     }
   *thumb = NULL;
-  ret = decodeThumbnail (encoded, thumb, &size);
+  ret = EXTRACTOR_binaryDecode (encoded, thumb, &size);
   GNUNET_free (encoded);
-  if (ret == 0)
-    return size;
-  else
+  if (ret != 0)
     return 0;
+  return size;
 }
 
 /**





reply via email to

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