gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r318 - in GNUnet/src: applications/fs/ecrs util


From: grothoff
Subject: [GNUnet-SVN] r318 - in GNUnet/src: applications/fs/ecrs util
Date: Fri, 25 Feb 2005 21:08:47 -0800 (PST)

Author: grothoff
Date: 2005-02-25 21:08:45 -0800 (Fri, 25 Feb 2005)
New Revision: 318

Modified:
   GNUnet/src/applications/fs/ecrs/ecrstest.c
   GNUnet/src/applications/fs/ecrs/upload.c
   GNUnet/src/util/kblockkey.c
   GNUnet/src/util/kblockkey_test.c
Log:
upload fix

Modified: GNUnet/src/applications/fs/ecrs/ecrstest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrstest.c  2005-02-26 04:41:42 UTC (rev 
317)
+++ GNUnet/src/applications/fs/ecrs/ecrstest.c  2005-02-26 05:08:45 UTC (rev 
318)
@@ -113,12 +113,14 @@
                    const HashCode160 * key,
                    void * closure) {
   struct ECRS_URI ** my = closure;
+  char * tmp;
   
-  // GNUNET_ASSERT(NULL == *my);
-  if (NULL != *my) {
-    BREAK();
-    return SYSERR;
-  }
+  tmp = ECRS_uriToString(fi->uri);
+  LOG(LOG_DEBUG,
+      "Search found URI '%s'\n",
+      tmp);
+  FREE(tmp);    
+  GNUNET_ASSERT(NULL == *my);
   *my = ECRS_dupUri(fi->uri);
   return SYSERR; /* abort search */
 }
@@ -149,11 +151,51 @@
 }
 
 static int downloadFile(unsigned int size,
-                       struct ECRS_URI * uri) {
-  /* FIXME: initiate download,
-     verify file */
-  ECRS_freeUri(uri);
-  return OK;
+                       const struct ECRS_URI * uri) {
+  int ret;
+  char * tmpName;
+  int fd;
+  char * buf;
+  char * in;
+  int i;
+  char * tmp;
+  
+  tmp = ECRS_uriToString(uri);
+  LOG(LOG_DEBUG,
+      "Starting download of '%s'\n",
+      tmp);
+  FREE(tmp);
+  tmpName = makeName(0);
+  ret = SYSERR;
+  if (OK == ECRS_downloadFile(uri,
+                             tmpName,
+                             0,
+                             NULL,
+                             NULL,
+                             &testTerminate,
+                             NULL)) {
+    
+    fd = OPEN(tmpName, O_RDONLY);
+    buf = MALLOC(size);
+    in = MALLOC(size);
+    memset(buf, size + size / 253, size);
+    for (i=0;i<(int) (size - 42 - sizeof(HashCode160));i+=sizeof(HashCode160)) 
+      hash(&buf[i+sizeof(HashCode160)],
+          42,
+          (HashCode160*) &buf[i]);
+    if (size != read(fd, in, size))
+      ret = SYSERR;
+    else if (0 == memcmp(buf,
+                        in,
+                        size))
+      ret = OK;
+    FREE(buf);
+    FREE(in);
+    CLOSE(fd); 
+  }
+  UNLINK(tmpName);
+  FREE(tmpName);
+  return ret;
 }
 
 
@@ -175,11 +217,11 @@
 
 int main(int argc, char * argv[]){
   static unsigned int filesizes[] = {
-    /*    1,
+    1,
     2,
     4,
     16,
-    32, */
+    32, 
     1024,
     DBLOCK_SIZE - 1,
     DBLOCK_SIZE,
@@ -237,6 +279,7 @@
     CHECK(NULL != uri);
     CHECK(OK == searchFile(&uri));
     CHECK(OK == downloadFile(filesizes[i], uri));
+    ECRS_freeUri(uri);
     CHECK(OK == unindexFile(filesizes[i]));
     fprintf(stderr,
            " Ok.\n");

Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c    2005-02-26 04:41:42 UTC (rev 
317)
+++ GNUnet/src/applications/fs/ecrs/upload.c    2005-02-26 05:08:45 UTC (rev 
318)
@@ -356,8 +356,6 @@
       }
       FREE(value);
     }
-    if (treedepth == 0)
-      goto NOTREE;
     pos += size;
     cronTime(&now);
     if (pos > 0) {
@@ -424,7 +422,6 @@
     FREE(iblocks[i]);
     iblocks[i] = NULL;
   }
- NOTREE:
   if (doIndex) {
     trySymlinking(filename,
                  &fileId,
@@ -438,7 +435,9 @@
       &enc);  
   /* build URI */
   fid.file_length = htonll(filesize);
-  fid.chk = *(CHK*)&((DBlock*) &iblocks[treedepth][1])[1];
+  db = (DBlock*) &iblocks[treedepth][1];
+
+  fid.chk = *(CHK*)&(db[1]);
   uris = createFileURI(&fid);
   *uri = ECRS_stringToUri(uris);
   FREE(uris);

Modified: GNUnet/src/util/kblockkey.c
===================================================================
--- GNUnet/src/util/kblockkey.c 2005-02-26 04:41:42 UTC (rev 317)
+++ GNUnet/src/util/kblockkey.c 2005-02-26 05:08:45 UTC (rev 318)
@@ -232,7 +232,7 @@
       
       /* Make sure that the number is smaller than the prime and
         keep the randomness of the high bit. */
-      if ( mpz_tstbit(x, nbits-2) ) {
+      if (mpz_tstbit(x, nbits-2) ) {
        set_highbit(x, nbits-2); /* Clear all higher bits. */
       } else {
        set_highbit(x, nbits-2 );

Modified: GNUnet/src/util/kblockkey_test.c
===================================================================
--- GNUnet/src/util/kblockkey_test.c    2005-02-26 04:41:42 UTC (rev 317)
+++ GNUnet/src/util/kblockkey_test.c    2005-02-26 05:08:45 UTC (rev 318)
@@ -30,6 +30,10 @@
     return SYSERR;
   }
   getPublicKey(hostkey, &pkey);
+  /*
+  for (i=0;i<sizeof(PublicKey);i++)
+    printf("%02x", ((unsigned char*) &pkey)[i]);
+    printf("\n"); */
   freePrivateKey(hostkey);
   for (i=0;i<6;i++) {
     fprintf(stderr, ".");





reply via email to

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