gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r378 - in GNUnet: . src/applications/fs/ecrs src/applicatio


From: grothoff
Subject: [GNUnet-SVN] r378 - in GNUnet: . src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/tools src/include
Date: Sat, 5 Mar 2005 21:58:29 -0800 (PST)

Author: grothoff
Date: 2005-03-05 21:58:27 -0800 (Sat, 05 Mar 2005)
New Revision: 378

Added:
   GNUnet/src/applications/fs/ecrs/directorytest.c
Modified:
   GNUnet/src/applications/fs/ecrs/Makefile.am
   GNUnet/src/applications/fs/ecrs/directory.c
   GNUnet/src/applications/fs/ecrs/ecrs.h
   GNUnet/src/applications/fs/ecrs/meta.c
   GNUnet/src/applications/fs/ecrs/metatest.c
   GNUnet/src/applications/fs/ecrs/namespace.c
   GNUnet/src/applications/fs/ecrs/tree.h
   GNUnet/src/applications/fs/ecrs/uri.c
   GNUnet/src/applications/fs/fsui/namespace_info.c
   GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
   GNUnet/src/include/gnunet_ecrs_lib.h
   GNUnet/src/include/gnunet_fsui_lib.h
   GNUnet/todo
Log:
fixing bugs in ECRS directory handling -- and ecrs meta by chance.  also minor 
API changes

Modified: GNUnet/src/applications/fs/ecrs/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/ecrs/Makefile.am 2005-03-05 20:41:21 UTC (rev 
377)
+++ GNUnet/src/applications/fs/ecrs/Makefile.am 2005-03-06 05:58:27 UTC (rev 
378)
@@ -25,6 +25,7 @@
 
 
 check_PROGRAMS = \
+  directorytest \
   uritest \
   metatest \
   ecrstest 
@@ -46,5 +47,10 @@
 ecrstest_LDADD = \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
+directorytest_SOURCES = \
+  directorytest.c
+directorytest_LDADD = \
+  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
+
 EXTRA_DIST = \
   check.conf

Modified: GNUnet/src/applications/fs/ecrs/directory.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directory.c 2005-03-05 20:41:21 UTC (rev 
377)
+++ GNUnet/src/applications/fs/ecrs/directory.c 2005-03-06 05:58:27 UTC (rev 
378)
@@ -43,11 +43,11 @@
  *         directory is malformed
  */
 int ECRS_listDirectory(const char * data,
-                      unsigned int len,
+                      unsigned long long len,
                       struct ECRS_MetaData ** md,
                       ECRS_SearchProgressCallback spcb,
                       void * spcbClosure) {
-  unsigned int pos;
+  unsigned long long pos;
   unsigned long long align;
   unsigned int mdSize;
   unsigned long long epos;
@@ -94,6 +94,10 @@
     pos = epos+1;
     if (fi.uri == NULL) 
       return SYSERR; /* malformed! */
+    if (ECRS_isKeywordURI(fi.uri)) {
+      ECRS_freeUri(fi.uri);
+      return SYSERR; /* illegal in directory! */
+    }
 
     memcpy(&mdSize, &data[pos], sizeof(unsigned int)); 
     mdSize = ntohl(mdSize);
@@ -156,10 +160,16 @@
   char ** ucs;
   int ret;
 
+  for (i=0;i<count;i++) {
+    if (ECRS_isKeywordURI(fis[i].uri)) {
+      BREAK();
+      return SYSERR; /* illegal in directory! */
+    }
+  }
   ucs = MALLOC(sizeof(char*) * count);
-
   size = 8 + sizeof(unsigned int);
   size += ECRS_sizeofMetaData(meta);
+
   for (i=0;i<count;i++) {
     psize = size;
 
@@ -168,11 +178,10 @@
     size += strlen(ucs[i]) + 1;
     size += sizeof(unsigned int);
     size += ECRS_sizeofMetaData(fis[i].meta);
-    
     align = (size / BLOCK_ALIGN_SIZE) * BLOCK_ALIGN_SIZE;
     if ( (psize < align) &&
         (size > align) ) {
-      size = align + size - psize;
+       size = align + size - psize;
     }
   }
 
@@ -194,28 +203,27 @@
   memcpy(&(*data)[pos],
         &ret,
         sizeof(unsigned int));
-  pos += ret + sizeof(unsigned int);
+  pos += ntohl(ret) + sizeof(unsigned int);
 
   for (i=0;i<count;i++) {
     psize = pos;
 
     pos += strlen(ucs[i]) + 1 + 
-      ECRS_sizeofMetaData(fis[i].meta) + sizeof(unsigned int);
-    
+      ECRS_sizeofMetaData(fis[i].meta);
+    pos += sizeof(unsigned int);    
     align = (pos / BLOCK_ALIGN_SIZE) * BLOCK_ALIGN_SIZE;
     if ( (psize < align) &&
         (pos > align) ) {
       pos = align;
     } else
       pos = psize;
-    
     memcpy(&(*data)[pos],
           ucs[i],
           strlen(ucs[i]) + 1);
     pos += strlen(ucs[i]) + 1;
     FREE(ucs[i]);
-    
-    ret = ECRS_serializeMetaData(meta,
+
+    ret = ECRS_serializeMetaData(fis[i].meta,
                                 &(*data)[pos + sizeof(unsigned int)],
                                 size - pos - sizeof(unsigned int),
                                 NO);
@@ -224,7 +232,7 @@
     memcpy(&(*data)[pos],
           &ret,
           sizeof(unsigned int));
-    pos += ret + sizeof(unsigned int);   
+    pos += ntohl(ret) + sizeof(unsigned int);   
   }
   FREE(ucs);
   GNUNET_ASSERT(pos == size);

Added: GNUnet/src/applications/fs/ecrs/directorytest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directorytest.c     2005-03-05 20:41:21 UTC 
(rev 377)
+++ GNUnet/src/applications/fs/ecrs/directorytest.c     2005-03-06 05:58:27 UTC 
(rev 378)
@@ -0,0 +1,136 @@
+/*
+     This file is part of GNUnet.
+     (C) 2005 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
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file applications/fs/ecrs/directorytest.c
+ * @brief Test for directory.c
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include <extractor.h>
+#include "gnunet_util.h"
+#include "gnunet_ecrs_lib.h"
+#include "ecrs.h"
+
+#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); 
return 1; }
+
+struct PCLS {
+  ECRS_FileInfo * fi;
+  unsigned int pos;
+};
+
+static int processor(const ECRS_FileInfo * fi,
+                    const HashCode512 * key,
+                    void * cls) {
+  struct PCLS * p = cls;
+  
+  if (ECRS_equalsMetaData(p->fi[p->pos].meta,
+                         fi->meta) &&
+      ECRS_equalsUri(p->fi[p->pos].uri,
+                    fi->uri)) {
+    p->pos++;
+    return OK;
+  } else {
+    fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); 
+    return SYSERR;
+  }
+}
+
+static int testDirectory(unsigned int i) {
+  char * data;
+  unsigned long long dlen;
+  ECRS_FileInfo * fis;
+  struct ECRS_MetaData * meta;
+  struct ECRS_MetaData * meta2;
+  struct PCLS cls;
+  int p;
+  int q;
+  char uri[512];
+  char txt[128];
+
+  fis = MALLOC(sizeof(ECRS_FileInfo) * i);
+  for (p=0;p<i;p++) {
+    fis[p].meta = ECRS_createMetaData();
+    for (q=0;q<=p;q++) {
+      SNPRINTF(txt,
+              128,
+              "%u -- %u\n",
+              p, q);
+      ECRS_addToMetaData(fis[p].meta,
+                        q % EXTRACTOR_getHighestKeywordTypeNumber(),
+                        txt);
+    }
+    SNPRINTF(uri,
+            512,
+            
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
+            p);
+    fis[p].uri = ECRS_stringToUri(uri);
+    if (fis[p].uri == NULL)
+      ABORT(); /* error in testcase */
+  }
+  meta = ECRS_createMetaData();
+  ECRS_addToMetaData(meta,
+                    EXTRACTOR_TITLE,
+                    "A title");
+  ECRS_addToMetaData(meta,
+                    EXTRACTOR_AUTHOR,
+                    "An author");
+  if (OK != ECRS_createDirectory(&data,
+                                &dlen,
+                                i,
+                                fis,
+                                meta))
+    ABORT();
+  cls.pos = 0;
+  cls.fi = fis;
+  if (i != ECRS_listDirectory(data,
+                             dlen,
+                             &meta2,
+                             &processor,
+                             &cls))
+    ABORT();
+  if (! ECRS_equalsMetaData(meta,
+                           meta2))
+    ABORT();
+  ECRS_freeMetaData(meta);
+  ECRS_freeMetaData(meta2);
+  for (p=0;p<i;p++) {
+    ECRS_freeMetaData(fis[p].meta);
+    ECRS_freeUri(fis[p].uri);
+  }
+  FREE(fis);
+  return 0;
+}
+
+int main(int argc, char * argv[]) {
+  int failureCount = 0;
+  int i;
+  
+  for (i=17;i<18;i++) 
+    failureCount += testDirectory(i);  
+
+  if (failureCount == 0)
+    return 0;
+  else 
+    return 1;
+} 
+
+/* end of directorytest.c */

Modified: GNUnet/src/applications/fs/ecrs/ecrs.h
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrs.h      2005-03-05 20:41:21 UTC (rev 
377)
+++ GNUnet/src/applications/fs/ecrs/ecrs.h      2005-03-06 05:58:27 UTC (rev 
378)
@@ -28,6 +28,7 @@
 #define ECRS_H
 
 #include "ecrs_core.h"
+#include "tree.h"
 #include <extractor.h>
 
 
@@ -40,7 +41,7 @@
 #define SBLOCK_UPDATE_NONE       0
 
 
-#define BLOCK_ALIGN_SIZE (32 * 1024)
+#define BLOCK_ALIGN_SIZE (DBLOCK_SIZE)
 
 typedef struct Location {
   PeerIdentity peer;

Modified: GNUnet/src/applications/fs/ecrs/meta.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/meta.c      2005-03-05 20:41:21 UTC (rev 
377)
+++ GNUnet/src/applications/fs/ecrs/meta.c      2005-03-06 05:58:27 UTC (rev 
378)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2003, 2004 Christian Grothoff (and other contributing authors)
+     (C) 2003, 2004, 2005 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
@@ -399,9 +399,6 @@
       pos += len;
     }
     hdr->size = htonl(size);
-    if (size <= max)
-      break;
-
     pos = tryCompression((char*)&hdr[1],
                         size - sizeof(MetaDataHeader));
     if (pos < size - sizeof(MetaDataHeader)) {
@@ -413,8 +410,9 @@
     FREE(hdr);
     hdr = NULL;
 
-    if (! part) 
+    if (! part) {
       return SYSERR; /* does not fit! */
+    }
 
     /* partial serialization ok, try again with less meta-data */
     if (size > 2 * max) 
@@ -725,5 +723,13 @@
   return ret;
 }
 
+/**
+ * Test if two MDs are equal.
+ */
+int ECRS_equalsMetaData(const struct ECRS_MetaData * md1,
+                       const struct ECRS_MetaData * md2) {
+  return YES;
+}
 
+
 /* end of meta.c */

Modified: GNUnet/src/applications/fs/ecrs/metatest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/metatest.c  2005-03-05 20:41:21 UTC (rev 
377)
+++ GNUnet/src/applications/fs/ecrs/metatest.c  2005-03-06 05:58:27 UTC (rev 
378)
@@ -122,12 +122,42 @@
   return 0;
 }
 
+int testMetaMore(int i) {
+  struct ECRS_MetaData * meta;
+  int q;
+  char txt[128];
+  char * data;
+  unsigned long long size;
+
+  meta = ECRS_createMetaData();
+  for (q=0;q<=i;q++) {
+    SNPRINTF(txt,
+            128,
+            "%u -- %u\n",
+            i, q);
+    ECRS_addToMetaData(meta,
+                      q % EXTRACTOR_getHighestKeywordTypeNumber(),
+                      txt);
+  }
+  size = ECRS_sizeofMetaData(meta);
+  data = MALLOC(size * 4);
+  if (size != ECRS_serializeMetaData(meta,
+                                    data,
+                                    size * 4,
+                                    NO))
+    ABORT();
+  FREE(data);
+  return 0;
+}
+
 int main(int argc, char * argv[]) {
   int failureCount = 0;
   int i;
   
   for (i=0;i<255;i++) 
     failureCount += testMeta(i);  
+  for (i=1;i<255;i++) 
+    failureCount += testMetaMore(i);  
 
   if (failureCount == 0)
     return 0;

Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2005-03-05 20:41:21 UTC (rev 
377)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2005-03-06 05:58:27 UTC (rev 
378)
@@ -1,5 +1,6 @@
 /*
      This file is part of GNUnet
+     (C) 2004, 2005 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
@@ -346,7 +347,7 @@
   unsigned short len;
   HashCode512 hc;
 
-  /* FIRST: read and decrypt pseudonym! */
+  /* FIRST: read pseudonym! */
   fileName = getPseudonymFileName(name);
   len = getFileSize(fileName);
   if (len < 2) {
@@ -467,21 +468,71 @@
   return ret;
 }
 
-typedef struct {
-  int pos;
-  int size;
-  char ** list;
-} PList_;
+struct lNCLS {
+  ECRS_NamespaceInfoCallback cb;
+  void * cls;
+  int cnt;
+};
 
-static void addFile_(char * filename,
-                     char * dirName,
-                     PList_ * theList) {
-  if (theList->pos == theList->size) {
-    GROW(theList->list,
-         theList->size,
-         theList->size*2);
+static int processFile_(char * name,
+                       char * dirName,
+                       void * cls) {
+  struct lNCLS * c = cls;
+  struct PrivateKey * hk;
+  char * fileName;
+  PrivateKeyEncoded * hke;
+  char * dst;
+  unsigned short len;
+  HashCode512 namespace;
+  PublicKey pk;
+
+  if (c->cnt == SYSERR)
+    return SYSERR;
+
+  fileName = getPseudonymFileName(name);
+  len = getFileSize(fileName);
+  if (len < 2) {   
+    LOG(LOG_ERROR,
+        _("File '%s' does not contain a pseudonym.\n"),
+        fileName);
+    FREE(fileName);
+    return OK;
   }
-  theList->list[theList->pos++] = STRDUP(filename);
+  dst = MALLOC(len);
+  len = readFile(fileName, len, dst);
+  hke = (PrivateKeyEncoded*) dst;
+  if ( ntohs(hke->len) != len ) {
+    LOG(LOG_ERROR,
+        _("Format of file '%s' is invalid.\n"),
+        fileName);
+    FREE(hke);
+    FREE(fileName);
+    return OK;
+  }
+  hk = decodePrivateKey(hke);
+  FREE(hke);
+  if (hk == NULL) {
+    LOG(LOG_ERROR,
+        _("Format of file '%s' is invalid.\n"),
+        fileName);
+    FREE(fileName);
+    BREAK();
+    return SYSERR;
+  }
+  FREE(fileName);
+  getPublicKey(hk,
+              &pk);
+  freePrivateKey(hk);  
+  hash(&pk, sizeof(PublicKey), &namespace);
+  if (c->cb != NULL) {
+    if (OK == c->cb(&namespace,
+                   name,
+                   c->cls))
+      c->cnt++;
+    else
+      c->cnt = SYSERR;
+  }
+  return OK;
 }
 
 /**
@@ -490,33 +541,20 @@
  * @param list where to store the names (is allocated, caller frees)
  * @return SYSERR on error, otherwise the number of pseudonyms in list
  */
-int ECRS_listNamespaces(char *** list) {
-  int cnt;
-  PList_ myList;
+int ECRS_listNamespaces(ECRS_NamespaceInfoCallback cb,
+                       void * cls) {
   char * dirName;
+  struct lNCLS myCLS;
 
-  myList.list = NULL;
-  myList.size = 0;
-  myList.pos = 0;
-  GROW(myList.list,
-       myList.size,
-       8);
+  myCLS.cls = cls;
+  myCLS.cb = cb;
+  myCLS.cnt = 0;
   dirName = getPseudonymFileName("");
-  cnt = scanDirectory(dirName,
-                     (DirectoryEntryCallback)&addFile_,
-                     &myList);
+  scanDirectory(dirName,
+               (DirectoryEntryCallback) &processFile_,
+               &myCLS);
   FREE(dirName);
-  if (cnt != myList.pos) {
-    GROW(myList.list,
-        myList.size,
-        0);
-    return SYSERR;
-  }
-  GROW(myList.list,
-       myList.size,
-       myList.pos);
-  *list = myList.list;
-  return myList.pos;
+  return myCLS.cnt;
 }
 
 

Modified: GNUnet/src/applications/fs/ecrs/tree.h
===================================================================
--- GNUnet/src/applications/fs/ecrs/tree.h      2005-03-05 20:41:21 UTC (rev 
377)
+++ GNUnet/src/applications/fs/ecrs/tree.h      2005-03-06 05:58:27 UTC (rev 
378)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004 Christian Grothoff (and other contributing 
authors)
+     (C) 2001, 2002, 2003, 2004, 2005 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

Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c       2005-03-05 20:41:21 UTC (rev 
377)
+++ GNUnet/src/applications/fs/ecrs/uri.c       2005-03-06 05:58:27 UTC (rev 
378)
@@ -404,25 +404,37 @@
 }
 
 /**
- * Get the (globally unique) name for the given
- * namespace.
+ * Get the (globally unique) name for the given namespace.
+ *
  * @return the name (hash) of the namespace, caller
  *  must free it.
  */
-char * ECRS_getNamespaceName(const struct ECRS_URI * uri) {
+char * ECRS_getNamespaceName(const HashCode512 * id) {
   char * ret;
   
-  if (! ECRS_isNamespaceURI(uri)) {
-    BREAK();
-    return NULL;
-  }  
   ret = MALLOC(sizeof(EncName));
-  hash2enc(&uri->data.sks.namespace,
+  hash2enc(id,
           (EncName*)ret);
   return ret;
 }
 
 /**
+ * Get the (globally unique) ID of the namespace
+ * from the given namespace URI.
+ *
+ * @return OK on success
+ */
+int ECRS_getNamespaceId(const struct ECRS_URI * uri,
+                       HashCode512 * id) {
+  if (! ECRS_isNamespaceURI(uri)) {
+    BREAK();
+    return SYSERR;
+  }  
+  *id = uri->data.sks.namespace;
+  return OK;
+}
+
+/**
  * Is this a keyword URI?
  */
 int ECRS_isKeywordURI(const struct ECRS_URI * uri) {

Modified: GNUnet/src/applications/fs/fsui/namespace_info.c
===================================================================
--- GNUnet/src/applications/fs/fsui/namespace_info.c    2005-03-05 20:41:21 UTC 
(rev 377)
+++ GNUnet/src/applications/fs/fsui/namespace_info.c    2005-03-06 05:58:27 UTC 
(rev 378)
@@ -209,6 +209,35 @@
   int ret;
 } LNClosure;
 
+static int localListNamespaceHelper(const HashCode512 * nsid,
+                                   const char * name,
+                                   void * cls) {
+  LNClosure * c = cls;
+  int ret;
+  struct ECRS_MetaData * meta;
+  int rating;
+
+  if (c->ret == SYSERR)
+    return SYSERR;
+  if (OK != readNamespaceInfo(name,
+                             &meta,
+                             &rating)) {
+    rating = 0;
+    meta = ECRS_createMetaData();
+  }
+  ret = c->iterator(c->closure,
+                   name,
+                   nsid,
+                   meta,
+                   rating);
+  ECRS_freeMetaData(meta);
+  if (ret == SYSERR)
+    c->ret = ret;
+  else
+    c->ret++;
+  return OK;
+}
+
 static void listNamespaceHelper(const char * fn,
                                const char * dirName,
                                void * cls) {
@@ -216,15 +245,20 @@
   int ret;
   struct ECRS_MetaData * meta;
   int rating;
+  HashCode512 id;
 
   if (c->ret == SYSERR)
     return;
+  if (OK != enc2hash(fn,
+                    &id)) 
+    return; /* invalid name */
   if (OK != readNamespaceInfo(fn,
                              &meta,
                              &rating))
     return; /* ignore entry */
   ret = c->iterator(c->closure,
                    fn,
+                   &id,
                    meta,
                    rating);
   ECRS_freeMetaData(meta);
@@ -244,47 +278,19 @@
                        int local,
                        FSUI_NamespaceIterator iterator,
                        void * closure) {
-  int ret;
+  LNClosure cls;
 
+  cls.iterator = iterator;
+  cls.closure = closure;
+  cls.ret = 0;
+
   if (local == YES) {
-    int ret;
-    char ** names;
-    int i;
-    int rating;
-    int aborted;
-    struct ECRS_MetaData * meta;
-    
-    aborted = NO;
-    names = NULL;
-    ret = ECRS_listNamespaces(&names);
-    for (i=0;i<ret;i++) {
-      if (aborted == NO) {
-       if (OK != readNamespaceInfo(names[i],
-                                   &meta,
-                                   &rating)) {
-         rating = 0;
-         meta = ECRS_createMetaData();
-       }
-       if (SYSERR == iterator(closure,
-                              names[i],
-                              meta,
-                              rating))
-         aborted = YES;      
-       ECRS_freeMetaData(meta);
-      }
-      FREE(names[i]);
-    }
-    GROW(names, ret, 0);
-    if (aborted == YES)
-      ret = -1;
+    ECRS_listNamespaces(&localListNamespaceHelper,
+                       &cls);
   } else {
     char * fn;
     char * fnBase;
-    LNClosure cls;
 
-    cls.iterator = iterator;
-    cls.closure = closure;
-    cls.ret = 0;
     fn = getConfigurationString(NULL, "GNUNET_HOME");
     fnBase = expandFileName(fn);
     FREE(fn);
@@ -298,10 +304,9 @@
     scanDirectory(fn,
                  &listNamespaceHelper,
                  &cls);
-    ret = cls.ret;
     FREE(fn);
   }
-  return ret;
+  return cls.ret;
 }
 
 /**
@@ -381,12 +386,15 @@
   char * name;
   int ranking;
   struct ECRS_MetaData * old;
+  HashCode512 id;
 
   if (! ECRS_isNamespaceURI(uri)) {
     BREAK();
     return;
   }
-  name = ECRS_getNamespaceName(uri);
+  ECRS_getNamespaceId(uri,
+                     &id);
+  name = ECRS_getNamespaceName(&id);
   if (name == NULL)
     return;
   ranking = 0;

Modified: GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2005-03-05 20:41:21 UTC 
(rev 377)
+++ GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2005-03-06 05:58:27 UTC 
(rev 378)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2002, 2003, 2004 Christian Grothoff (and other contributing authors)
+     (C) 2002, 2003, 2004, 2005 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
@@ -227,6 +227,7 @@
 
 static int namespacePrinter(void * unused,
                            const char * namespaceName,
+                           const HashCode512 * id,
                            const struct ECRS_MetaData * md,
                            int rating) {
   EncName enc;
@@ -235,10 +236,17 @@
 
   set = getConfigurationString("PSEUDONYM",
                               "SET-RATING");
-  
-  printf(_("Namespace '%s' has rating %d.\n"),
-        namespaceName,
-        rating);
+  hash2enc(id,
+          &enc);
+  if (0 == strcmp(namespaceName, (char*)&enc))
+    printf(_("Namespace '%s' has rating %d.\n"),
+          namespaceName,
+          rating);
+  else
+    printf(_("Namespace '%s' (%s) has rating %d.\n"),
+          namespaceName,
+          (char*) &enc,
+          rating);
   printMeta(md);
 
   if (set != NULL) {    

Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h        2005-03-05 20:41:21 UTC (rev 
377)
+++ GNUnet/src/include/gnunet_ecrs_lib.h        2005-03-06 05:58:27 UTC (rev 
378)
@@ -87,6 +87,13 @@
 void ECRS_freeMetaData(struct ECRS_MetaData * md);
 
 /**
+ * Test if two MDs are equal.
+ */
+int ECRS_equalsMetaData(const struct ECRS_MetaData * md1,
+                       const struct ECRS_MetaData * md2);
+                       
+
+/**
  * Extend metadata.
  * @return OK on success, SYSERR if this entry already exists
  */
@@ -220,6 +227,13 @@
 struct ECRS_URI * ECRS_dupUri(const struct ECRS_URI * uri);
 
 /**
+ * Test if two URIs are equal.
+ */
+int ECRS_equalsUri(const struct ECRS_URI * u1,
+                  const struct ECRS_URI * u2);
+                       
+
+/**
  * Is this a namespace URI?
  */
 int ECRS_isNamespaceURI(const struct ECRS_URI * uri);
@@ -231,9 +245,16 @@
  * @return the name (hash) of the namespace, caller
  *  must free it.
  */
-char * ECRS_getNamespaceName(const struct ECRS_URI * uri);
+char * ECRS_getNamespaceName(const HashCode512 * nsid);
 
 /**
+ * Get the ID of a namespace from the given 
+ * namespace URI.
+ */
+int ECRS_getNamespaceId(const struct ECRS_URI * uri,
+                       HashCode512 * nsid);
+
+/**
  * Is this a keyword URI?
  */
 int ECRS_isKeywordURI(const struct ECRS_URI * uri);
@@ -255,12 +276,6 @@
 int ECRS_isLocationURI(const struct ECRS_URI * uri);
 
 /**
- * Are these two URIs equal?
- */
-int ECRS_equalsUri(const struct ECRS_URI * uri1,
-                  const struct ECRS_URI * uri2);
-
-/**
  * Construct a keyword-URI from meta-data (take all entries
  * in the meta-data and construct one large keyword URI
  * that lists all keywords that can be found in the meta-data).
@@ -385,6 +400,15 @@
 int ECRS_deleteNamespace(const char * namespaceName); /* namespace.c */
 
 /**
+ * Callback with information about local (!) namespaces.
+ * Contains the name of the local namespace and the global
+ * ID.
+ */
+typedef int (*ECRS_NamespaceInfoCallback)(const HashCode512 * id,
+                                         const char * name,
+                                         void * closure);
+
+/**
  * Build a list of all available local (!) namespaces
  * The returned names are only the nicknames since
  * we only iterate over the local namespaces.
@@ -392,7 +416,8 @@
  * @param list where to store the names (is allocated, caller frees)
  * @return SYSERR on error, otherwise the number of pseudonyms in list
  */
-int ECRS_listNamespaces(char *** list); /* namespace.c */
+int ECRS_listNamespaces(ECRS_NamespaceInfoCallback cb,
+                       void * cls); /* namespace.c */
 
 /**
  * Add an entry into a namespace.
@@ -515,7 +540,7 @@
  *         directory is malformed
  */
 int ECRS_listDirectory(const char * data,
-                      unsigned int len,
+                      unsigned long long len,
                       struct ECRS_MetaData ** md,
                       ECRS_SearchProgressCallback spcb,
                       void * spcbClosure); /* directory.c */

Modified: GNUnet/src/include/gnunet_fsui_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fsui_lib.h        2005-03-05 20:41:21 UTC (rev 
377)
+++ GNUnet/src/include/gnunet_fsui_lib.h        2005-03-06 05:58:27 UTC (rev 
378)
@@ -281,6 +281,7 @@
  */
 typedef int (*FSUI_NamespaceIterator)(void * cls,
                                      const char * namespaceName,
+                                     const HashCode512 * namespaceId,
                                      const struct ECRS_MetaData * md,
                                      int rating);
 

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-03-05 20:41:21 UTC (rev 377)
+++ GNUnet/todo 2005-03-06 05:58:27 UTC (rev 378)
@@ -8,7 +8,6 @@
 0.7.0pre1 [4'05] (aka "preview"):
 - testing:
   * sqlite-tests: test update function, concurrency with iterators
-  * ECRS-directories (build, iterate)
   * gnunet-directory
   * gnunet-pseudonym
 - topology:





reply via email to

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