gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r7630 - in GNUnet/src: applications/fs/ecrs applications/fs/fsui applications/fs/tools include
Date: Mon, 25 Aug 2008 22:54:51 -0600 (MDT)

Author: amatus
Date: 2008-08-25 22:54:50 -0600 (Mon, 25 Aug 2008)
New Revision: 7630

Modified:
   GNUnet/src/applications/fs/ecrs/directory.c
   GNUnet/src/applications/fs/ecrs/directorytest.c
   GNUnet/src/applications/fs/fsui/download.c
   GNUnet/src/applications/fs/tools/gnunet-directory.c
   GNUnet/src/applications/fs/tools/gnunet-download.c
   GNUnet/src/include/gnunet_ecrs_lib.h
Log:
Allow directory listing to be continued at a particular offset.


Modified: GNUnet/src/applications/fs/ecrs/directory.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directory.c 2008-08-26 02:44:35 UTC (rev 
7629)
+++ GNUnet/src/applications/fs/ecrs/directory.c 2008-08-26 04:54:50 UTC (rev 
7630)
@@ -54,8 +54,9 @@
 GNUNET_ECRS_directory_list_contents (struct GNUNET_GE_Context *ectx,
                                      const char *data,
                                      unsigned long long len,
+                                     unsigned long long offset,
                                      struct GNUNET_MetaData **md,
-                                     GNUNET_ECRS_SearchResultProcessor spcb,
+                                     GNUNET_ECRS_DirectoryEntryCallback decb,
                                      void *spcbClosure)
 {
   unsigned long long pos;
@@ -67,16 +68,16 @@
 
   count = 0;
   *md = NULL;
-  pos = 0;
-  if ((len >= 8 + sizeof (unsigned int)) &&
-      (0 == memcmp (data, GNUNET_DIRECTORY_MAGIC, 8)))
+  pos = offset;
+  if ((len - pos >= 8 + sizeof (unsigned int)) &&
+      (0 == memcmp (&data[pos], GNUNET_DIRECTORY_MAGIC, 8)))
     {
-      memcpy (&mdSize, &data[8], sizeof (unsigned int));
+      memcpy (&mdSize, &data[pos + 8], sizeof (unsigned int));
       mdSize = ntohl (mdSize);
-      if (mdSize > len - 8 - sizeof (unsigned int))
+      if (mdSize > len - pos - 8 - sizeof (unsigned int))
         return GNUNET_SYSERR;   /* invalid size */
       *md = GNUNET_meta_data_deserialize (ectx,
-                                          &data[8 +
+                                          &data[pos + 8 +
                                                 sizeof (unsigned int)],
                                           mdSize);
       if (*md == NULL)
@@ -84,7 +85,7 @@
           GNUNET_GE_BREAK (ectx, 0);
           return GNUNET_SYSERR; /* malformed ! */
         }
-      pos = 8 + sizeof (unsigned int) + mdSize;
+      pos += 8 + sizeof (unsigned int) + mdSize;
     }
   while (pos < len)
     {
@@ -146,8 +147,8 @@
         }
       pos += mdSize;
       count++;
-      if (spcb != NULL)
-        spcb (&fi, NULL, GNUNET_NO, spcbClosure);
+      if (decb != NULL)
+        decb (&fi, pos, spcbClosure);
       GNUNET_meta_data_destroy (fi.meta);
       GNUNET_ECRS_uri_destroy (fi.uri);
     }

Modified: GNUnet/src/applications/fs/ecrs/directorytest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directorytest.c     2008-08-26 02:44:35 UTC 
(rev 7629)
+++ GNUnet/src/applications/fs/ecrs/directorytest.c     2008-08-26 04:54:50 UTC 
(rev 7630)
@@ -41,7 +41,7 @@
 
 static int
 processor (const GNUNET_ECRS_FileInfo * fi,
-           const GNUNET_HashCode * key, int isRoot, void *cls)
+           unsigned long long offset, void *cls)
 {
   struct PCLS *p = cls;
   int i;
@@ -123,7 +123,7 @@
   cls.pos = 0;
   cls.fi = fis;
   if (i !=
-      GNUNET_ECRS_directory_list_contents (NULL, data, dlen, &meta2,
+      GNUNET_ECRS_directory_list_contents (NULL, data, dlen, 0, &meta2,
                                            &processor, &cls))
     {
       printf ("expected %u\n", i);

Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c  2008-08-26 02:44:35 UTC (rev 
7629)
+++ GNUnet/src/applications/fs/fsui/download.c  2008-08-26 04:54:50 UTC (rev 
7630)
@@ -40,12 +40,10 @@
  */
 static int
 listURIfoundDirectory (const GNUNET_ECRS_FileInfo * fi,
-                       const GNUNET_HashCode * key, int isRoot, void *prnt)
+                       unsigned long long offset, void *prnt)
 {
   GNUNET_FSUI_DownloadList *dl = prnt;
 
-  if (isRoot == GNUNET_YES)
-    return GNUNET_OK;           /* namespace ad, ignore */
   GNUNET_URITRACK_add_state (dl->ctx->ectx,
                              dl->ctx->cfg, fi->uri,
                              GNUNET_URITRACK_DIRECTORY_FOUND);
@@ -78,7 +76,7 @@
  */
 static int
 triggerRecursiveDownload (const GNUNET_ECRS_FileInfo * fi,
-                          const GNUNET_HashCode * key, int isRoot, void *prnt)
+                          unsigned long long offset, void *prnt)
 {
   GNUNET_FSUI_DownloadList *parent = prnt;
   struct GNUNET_GE_Context *ectx;
@@ -89,9 +87,6 @@
   char *dotdot;
 
   ectx = parent->ctx->ectx;
-  if (isRoot == GNUNET_YES)
-    return GNUNET_OK;           /* namespace ad, ignore */
-
   GNUNET_URITRACK_track (ectx, parent->ctx->cfg, fi);
   for (i = 0; i < parent->completedDownloadsCount; i++)
     if (GNUNET_ECRS_uri_test_equal (parent->completedDownloads[i], fi->uri))
@@ -176,6 +171,7 @@
           GNUNET_ECRS_directory_list_contents (dl->ctx->ectx,
                                                dirBlock,
                                                totalBytes,
+                                               0,
                                                &md,
                                                &listURIfoundDirectory, dl);
           if (md != NULL)
@@ -189,6 +185,7 @@
               n = GNUNET_ECRS_directory_list_contents (dl->ctx->ectx,
                                                        dirBlock,
                                                        totalBytes,
+                                                       0,
                                                        &md,
                                                        
&triggerRecursiveDownload,
                                                        dl);

Modified: GNUnet/src/applications/fs/tools/gnunet-directory.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-directory.c 2008-08-26 02:44:35 UTC 
(rev 7629)
+++ GNUnet/src/applications/fs/tools/gnunet-directory.c 2008-08-26 04:54:50 UTC 
(rev 7630)
@@ -59,7 +59,7 @@
 
 static int
 printNode (const GNUNET_ECRS_FileInfo * fi,
-           const GNUNET_HashCode * key, int isRoot, void *unused)
+           unsigned long long offset, void *unused)
 {
   char *string;
 
@@ -108,7 +108,7 @@
       else
         {
           ret =
-            GNUNET_ECRS_directory_list_contents (ectx, data, len, &md,
+            GNUNET_ECRS_directory_list_contents (ectx, data, len, 0, &md,
                                                  &printNode, NULL);
           MUNMAP (data, len);
         }

Modified: GNUnet/src/applications/fs/tools/gnunet-download.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-download.c  2008-08-26 02:44:35 UTC 
(rev 7629)
+++ GNUnet/src/applications/fs/tools/gnunet-download.c  2008-08-26 04:54:50 UTC 
(rev 7630)
@@ -171,7 +171,7 @@
 
 static int
 directoryIterator (const GNUNET_ECRS_FileInfo * fi,
-                   const GNUNET_HashCode * key, int isRoot, void *cls)
+                   unsigned long long offset, void *cls)
 {
   struct GNUNET_FSUI_Context *ctx = cls;
   struct GNUNET_MetaData *meta;
@@ -350,6 +350,7 @@
       count = GNUNET_ECRS_directory_list_contents (ectx,
                                                    data,
                                                    sbuf.st_size,
+                                                   0,
                                                    &meta, &directoryIterator,
                                                    ctx);
       GNUNET_meta_data_destroy (meta);

Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h        2008-08-26 02:44:35 UTC (rev 
7629)
+++ GNUnet/src/include/gnunet_ecrs_lib.h        2008-08-26 04:54:50 UTC (rev 
7630)
@@ -764,6 +764,15 @@
                                        void *ttClosure);
 
 /**
+ * Directory entry callback
+ *
+ * @param fi URI and metadata of entry
+ * @param offset number of bytes into directory of next entry
+ */
+typedef int (*GNUNET_ECRS_DirectoryEntryCallback)
+  (const GNUNET_ECRS_FileInfo * fi, unsigned long long offset, void *closure);
+
+/**
  * Iterate over all entries in a directory.  Note that directories
  * are structured such that it is possible to iterate over the
  * individual blocks as well as over the entire directory.  Thus
@@ -772,6 +781,7 @@
  *
  * @param data pointer to the beginning of the directory
  * @param len number of bytes in data
+ * @param offset number of bytes into directory to start listing
  * @param md set to the MD for the directory if the first
  *   block is part of data
  * @return number of entries on success, GNUNET_SYSERR if the
@@ -780,9 +790,10 @@
 int GNUNET_ECRS_directory_list_contents (struct GNUNET_GE_Context *ectx,
                                          const char *data,
                                          unsigned long long len,
+                                         unsigned long long offset,
                                          struct GNUNET_MetaData **md,
-                                         GNUNET_ECRS_SearchResultProcessor
-                                         spcb, void *spcbClosure);
+                                         GNUNET_ECRS_DirectoryEntryCallback
+                                         decb, void *spcbClosure);
 
 /**
  * Create a directory.





reply via email to

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