[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7633 - in GNUnet/src: applications/fs/ecrs applications/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7633 - in GNUnet/src: applications/fs/ecrs applications/fs/fsui applications/fs/tools include |
Date: |
Tue, 26 Aug 2008 21:49:13 -0600 (MDT) |
Author: amatus
Date: 2008-08-26 21:49:13 -0600 (Tue, 26 Aug 2008)
New Revision: 7633
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:
Revert directory entry callback and change the offset parameter to a pointer.
Modified: GNUnet/src/applications/fs/ecrs/directory.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directory.c 2008-08-26 15:33:38 UTC (rev
7632)
+++ GNUnet/src/applications/fs/ecrs/directory.c 2008-08-27 03:49:13 UTC (rev
7633)
@@ -54,9 +54,9 @@
GNUNET_ECRS_directory_list_contents (struct GNUNET_GE_Context *ectx,
const char *data,
unsigned long long len,
- unsigned long long offset,
+ unsigned long long *offset,
struct GNUNET_MetaData **md,
- GNUNET_ECRS_DirectoryEntryCallback decb,
+ GNUNET_ECRS_SearchResultProcessor spcb,
void *spcbClosure)
{
unsigned long long pos;
@@ -68,16 +68,19 @@
count = 0;
*md = NULL;
- pos = offset;
- if ((len - pos >= 8 + sizeof (unsigned int)) &&
- (0 == memcmp (&data[pos], GNUNET_DIRECTORY_MAGIC, 8)))
+ if (offset != NULL)
+ pos = *offset;
+ else
+ pos = 0;
+ if ((pos == 0) && (len >= 8 + sizeof (unsigned int)) &&
+ (0 == memcmp (data, GNUNET_DIRECTORY_MAGIC, 8)))
{
- memcpy (&mdSize, &data[pos + 8], sizeof (unsigned int));
+ memcpy (&mdSize, &data[8], sizeof (unsigned int));
mdSize = ntohl (mdSize);
- if (mdSize > len - pos - 8 - sizeof (unsigned int))
+ if (mdSize > len - 8 - sizeof (unsigned int))
return GNUNET_SYSERR; /* invalid size */
*md = GNUNET_meta_data_deserialize (ectx,
- &data[pos + 8 +
+ &data[8 +
sizeof (unsigned int)],
mdSize);
if (*md == NULL)
@@ -85,7 +88,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)
{
@@ -147,8 +150,11 @@
}
pos += mdSize;
count++;
- if (decb != NULL)
- decb (&fi, pos, spcbClosure);
+ if (offset != NULL)
+ *offset = pos;
+ if ((spcb != NULL) &&
+ (GNUNET_SYSERR == spcb (&fi, NULL, GNUNET_NO, spcbClosure)))
+ pos = len; /* break out of loop */
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 15:33:38 UTC
(rev 7632)
+++ GNUnet/src/applications/fs/ecrs/directorytest.c 2008-08-27 03:49:13 UTC
(rev 7633)
@@ -41,7 +41,7 @@
static int
processor (const GNUNET_ECRS_FileInfo * fi,
- unsigned long long offset, void *cls)
+ const GNUNET_HashCode * key, int isRoot, 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, 0, &meta2,
+ GNUNET_ECRS_directory_list_contents (NULL, data, dlen, NULL, &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 15:33:38 UTC (rev
7632)
+++ GNUnet/src/applications/fs/fsui/download.c 2008-08-27 03:49:13 UTC (rev
7633)
@@ -40,10 +40,12 @@
*/
static int
listURIfoundDirectory (const GNUNET_ECRS_FileInfo * fi,
- unsigned long long offset, void *prnt)
+ const GNUNET_HashCode * key, int isRoot, 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);
@@ -76,7 +78,7 @@
*/
static int
triggerRecursiveDownload (const GNUNET_ECRS_FileInfo * fi,
- unsigned long long offset, void *prnt)
+ const GNUNET_HashCode * key, int isRoot, void *prnt)
{
GNUNET_FSUI_DownloadList *parent = prnt;
struct GNUNET_GE_Context *ectx;
@@ -87,6 +89,9 @@
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))
@@ -171,7 +176,7 @@
GNUNET_ECRS_directory_list_contents (dl->ctx->ectx,
dirBlock,
totalBytes,
- 0,
+ NULL,
&md,
&listURIfoundDirectory, dl);
if (md != NULL)
@@ -185,7 +190,7 @@
n = GNUNET_ECRS_directory_list_contents (dl->ctx->ectx,
dirBlock,
totalBytes,
- 0,
+ NULL,
&md,
&triggerRecursiveDownload,
dl);
Modified: GNUnet/src/applications/fs/tools/gnunet-directory.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-directory.c 2008-08-26 15:33:38 UTC
(rev 7632)
+++ GNUnet/src/applications/fs/tools/gnunet-directory.c 2008-08-27 03:49:13 UTC
(rev 7633)
@@ -59,7 +59,7 @@
static int
printNode (const GNUNET_ECRS_FileInfo * fi,
- unsigned long long offset, void *unused)
+ const GNUNET_HashCode * key, int isRoot, void *unused)
{
char *string;
@@ -108,7 +108,7 @@
else
{
ret =
- GNUNET_ECRS_directory_list_contents (ectx, data, len, 0, &md,
+ GNUNET_ECRS_directory_list_contents (ectx, data, len, NULL, &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 15:33:38 UTC
(rev 7632)
+++ GNUnet/src/applications/fs/tools/gnunet-download.c 2008-08-27 03:49:13 UTC
(rev 7633)
@@ -171,7 +171,7 @@
static int
directoryIterator (const GNUNET_ECRS_FileInfo * fi,
- unsigned long long offset, void *cls)
+ const GNUNET_HashCode * key, int isRoot, void *cls)
{
struct GNUNET_FSUI_Context *ctx = cls;
struct GNUNET_MetaData *meta;
@@ -350,7 +350,7 @@
count = GNUNET_ECRS_directory_list_contents (ectx,
data,
sbuf.st_size,
- 0,
+ NULL,
&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 15:33:38 UTC (rev
7632)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2008-08-27 03:49:13 UTC (rev
7633)
@@ -581,11 +581,10 @@
* The search has found another result. Callback to notify
* whoever is controlling the search.
*
- * @param uri the URI of the datum
+ * @param fi the URI and metadata of the result
* @param key under which the result was found (GNUNET_hash of keyword),
* NULL if no key is known
* @param isRoot is this a namespace root advertisement?
- * @param md a description for the URI
* @return GNUNET_OK, GNUNET_SYSERR to abort
*/
typedef int (*GNUNET_ECRS_SearchResultProcessor)
@@ -764,15 +763,6 @@
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
@@ -781,7 +771,8 @@
*
* @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 offset stores the number of bytes into directory to start listing
+ * on input and where the next element begins on output, can be NULL
* @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
@@ -790,10 +781,10 @@
int GNUNET_ECRS_directory_list_contents (struct GNUNET_GE_Context *ectx,
const char *data,
unsigned long long len,
- unsigned long long offset,
+ unsigned long long *offset,
struct GNUNET_MetaData **md,
- GNUNET_ECRS_DirectoryEntryCallback
- decb, void *spcbClosure);
+ GNUNET_ECRS_SearchResultProcessor
+ spcb, void *spcbClosure);
/**
* Create a directory.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7633 - in GNUnet/src: applications/fs/ecrs applications/fs/fsui applications/fs/tools include,
gnunet <=