gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r25527 - in gnunet-update/src: ext gnunet_update


From: gnunet
Subject: [GNUnet-SVN] r25527 - in gnunet-update/src: ext gnunet_update
Date: Tue, 18 Dec 2012 17:35:24 +0100

Author: harsha
Date: 2012-12-18 17:35:24 +0100 (Tue, 18 Dec 2012)
New Revision: 25527

Added:
   gnunet-update/src/ext/test_file_hash.c
Modified:
   gnunet-update/src/ext/Makefile.am
   gnunet-update/src/gnunet_update/package.py
Log:
- added a simple test

Modified: gnunet-update/src/ext/Makefile.am
===================================================================
--- gnunet-update/src/ext/Makefile.am   2012-12-18 13:16:45 UTC (rev 25526)
+++ gnunet-update/src/ext/Makefile.am   2012-12-18 16:35:24 UTC (rev 25527)
@@ -36,7 +36,8 @@
 
 
 check_PROGRAMS = \
- test_ext_api 
+ test_ext_api \
+ test_file_hash
 
 TESTS = $(check_PROGRAMS)
 
@@ -46,4 +47,9 @@
   $(top_builddir)/src/ext/libgnunetext.la \
   -lgnunetutil
 test_ext_api_LDFLAGS = \
- $(GNUNET_LIBS)  $(WINFLAGS) -export-dynamic 
\ No newline at end of file
+ $(GNUNET_LIBS)  $(WINFLAGS) -export-dynamic
+
+test_file_hash_SOURCES = \
+  test_file_hash.c
+test_file_hash_LDADD = \
+  -lgnunetutil
\ No newline at end of file

Added: gnunet-update/src/ext/test_file_hash.c
===================================================================
--- gnunet-update/src/ext/test_file_hash.c                              (rev 0)
+++ gnunet-update/src/ext/test_file_hash.c      2012-12-18 16:35:24 UTC (rev 
25527)
@@ -0,0 +1,60 @@
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_util_lib.h>
+
+/**
+ * Blocksize to use when hashing files for indexing (blocksize for IO,
+ * not for the DBlocks).  Larger blocksizes can be more efficient but
+ * will be more disruptive as far as the scheduler is concerned.
+ */
+#define HASHING_BLOCKSIZE (1024 * 128)
+
+struct GNUNET_CRYPTO_FileHashContext *hc;
+
+
+
+/**
+ * Function called once the hash computation over the
+ * specified file has completed.
+ *
+ * @param cls closure
+ * @param res resulting hash, NULL on error
+ */
+static void 
+hash_comp_cb (void *cls,
+              const struct GNUNET_HashCode *res)
+{
+  PRINTF ("Hash: %s\n", GNUNET_h2s_full (res));
+}
+
+
+static void
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  if ((NULL == args) || (NULL == args[0]))
+    return;
+  PRINTF ("Hashing file `%s'\n", args[0]);
+  hc = 
+      GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
+                               args[0],
+                               HASHING_BLOCKSIZE,
+                               hash_comp_cb,
+                               NULL);
+  GNUNET_break (NULL != hc);
+}
+
+
+int main (int argc, char *argv[])
+{
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
+  if (argc != 2)
+    return 1;
+  return GNUNET_PROGRAM_run (argc, argv, "test_file_hash", NULL,
+                            options, &run, NULL);
+  
+}

Modified: gnunet-update/src/gnunet_update/package.py
===================================================================
--- gnunet-update/src/gnunet_update/package.py  2012-12-18 13:16:45 UTC (rev 
25526)
+++ gnunet-update/src/gnunet_update/package.py  2012-12-18 16:35:24 UTC (rev 
25527)
@@ -241,10 +241,10 @@
             release = int(release_counter_file_content)
     except IOError as (errno, strerr):
         if errno == 2:
-            print ("IO Error while trying to open counter file" +
+            print ("IO Error while trying to open counter file: " +
                    release_counter_file_path)
         elif errno == 13:
-             print release_counter_file_path + "is not readable"
+             print release_counter_file_path + " is not readable."
              print "Check permissions"
         else:
             raise




reply via email to

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