gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3224 - in GNUnet: . src/applications/fs src/applications/f


From: grothoff
Subject: [GNUnet-SVN] r3224 - in GNUnet: . src/applications/fs src/applications/fs/collection src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/namespace src/applications/fs/uritrack src/include
Date: Sun, 13 Aug 2006 12:32:17 -0700 (PDT)

Author: grothoff
Date: 2006-08-13 12:32:06 -0700 (Sun, 13 Aug 2006)
New Revision: 3224

Added:
   GNUnet/src/applications/fs/collection/
   GNUnet/src/applications/fs/collection/Makefile.am
   GNUnet/src/applications/fs/collection/collection.c
   GNUnet/src/applications/fs/ecrs/helper.c
   GNUnet/src/applications/fs/namespace/
   GNUnet/src/applications/fs/namespace/Makefile.am
   GNUnet/src/applications/fs/namespace/namespace_info.c
   GNUnet/src/applications/fs/namespace/namespace_infotest.c
   GNUnet/src/applications/fs/uritrack/
   GNUnet/src/applications/fs/uritrack/Makefile.am
   GNUnet/src/applications/fs/uritrack/file_info.c
Removed:
   GNUnet/src/applications/fs/fsui/collection.c
   GNUnet/src/applications/fs/fsui/file_info.c
   GNUnet/src/applications/fs/fsui/helper.c
   GNUnet/src/applications/fs/fsui/namespace_info.c
   GNUnet/src/applications/fs/fsui/namespace_infotest.c
Modified:
   GNUnet/configure.ac
   GNUnet/src/applications/fs/Makefile.am
   GNUnet/src/applications/fs/OVERVIEW
   GNUnet/src/applications/fs/ecrs/Makefile.am
   GNUnet/src/applications/fs/fsui/Makefile.am
   GNUnet/src/applications/fs/fsui/fsui.h
   GNUnet/src/include/Makefile.am
   GNUnet/src/include/gnunet_ecrs_lib.h
   GNUnet/src/include/gnunet_fsui_lib.h
   GNUnet/todo
Log:
redesigning FSUI API, fixing uritrack

Modified: GNUnet/configure.ac
===================================================================
--- GNUnet/configure.ac 2006-08-13 03:45:47 UTC (rev 3223)
+++ GNUnet/configure.ac 2006-08-13 19:32:06 UTC (rev 3224)
@@ -528,10 +528,13 @@
 src/applications/dht/module/Makefile
 src/applications/fragmentation/Makefile
 src/applications/fs/Makefile
+src/applications/fs/collection/Makefile
 src/applications/fs/ecrs/Makefile
 src/applications/fs/fsui/Makefile
 src/applications/fs/lib/Makefile
 src/applications/fs/module/Makefile
+src/applications/fs/namespace/Makefile
+src/applications/fs/uritrack/Makefile
 src/applications/fs/tools/Makefile
 src/applications/gap/Makefile
 src/applications/getoption/Makefile

Modified: GNUnet/src/applications/fs/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/Makefile.am      2006-08-13 03:45:47 UTC (rev 
3223)
+++ GNUnet/src/applications/fs/Makefile.am      2006-08-13 19:32:06 UTC (rev 
3224)
@@ -1,5 +1,5 @@
 SUBDIRS = \
- . module lib ecrs fsui tools
+ . module lib ecrs uritrack fsui namespace collection tools 
 
 INCLUDES = -I$(top_srcdir)/src/include
 

Modified: GNUnet/src/applications/fs/OVERVIEW
===================================================================
--- GNUnet/src/applications/fs/OVERVIEW 2006-08-13 03:45:47 UTC (rev 3223)
+++ GNUnet/src/applications/fs/OVERVIEW 2006-08-13 19:32:06 UTC (rev 3224)
@@ -1,8 +1,11 @@
-The FS application is divided into five parts:
+The FS application is divided into eight parts:
 
-ecrs_core: shared code for on-demand encoding and block verification
-module/    plugin into gnunetd
-lib/       code to communicate with the plugin from clients (block-level)
-ecrs/      file-sharing abstraction (file-level)
-fsui/      high-level library for building the user interfaces
-tools/     simple text user interfaces
+ecrs_core:  shared code for on-demand encoding and block verification
+module/     plugin into gnunetd
+lib/        code to communicate with the plugin from clients (block-level)
+ecrs/       file-sharing abstraction (file-level)
+fsui/       high-level library for building the user interfaces
+namespace/  high-level namespace API
+collection/ collection management
+uritrack/   URI tracking
+tools/      simple text user interfaces

Added: GNUnet/src/applications/fs/collection/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/collection/Makefile.am   2006-08-13 03:45:47 UTC 
(rev 3223)
+++ GNUnet/src/applications/fs/collection/Makefile.am   2006-08-13 19:32:06 UTC 
(rev 3224)
@@ -0,0 +1,16 @@
+INCLUDES = -I$(top_srcdir)/src/include
+
+lib_LTLIBRARIES = \
+  libgnunetcollection.la 
+
+libgnunetcollection_la_SOURCES = \
+  collection.c 
+libgnunetcollection_la_LIBADD = \
+ $(top_builddir)/src/applications/fs/namespace/libgnunetnamespace.la \
+ $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+ $(top_builddir)/src/util/libgnunetutil.la 
+
+
+
+

Copied: GNUnet/src/applications/fs/collection/collection.c (from rev 3219, 
GNUnet/src/applications/fs/fsui/collection.c)

Modified: GNUnet/src/applications/fs/ecrs/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/ecrs/Makefile.am 2006-08-13 03:45:47 UTC (rev 
3223)
+++ GNUnet/src/applications/fs/ecrs/Makefile.am 2006-08-13 19:32:06 UTC (rev 
3224)
@@ -7,6 +7,7 @@
   directory.c \
   download.c \
   ecrs.c ecrs.h \
+  helper.c \
   indexinfo.c \
   keyspace.c \
   meta.c \

Copied: GNUnet/src/applications/fs/ecrs/helper.c (from rev 3219, 
GNUnet/src/applications/fs/fsui/helper.c)
===================================================================
--- GNUnet/src/applications/fs/fsui/helper.c    2006-08-12 15:45:04 UTC (rev 
3219)
+++ GNUnet/src/applications/fs/ecrs/helper.c    2006-08-13 19:32:06 UTC (rev 
3224)
@@ -0,0 +1,192 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 2003, 2004, 2005, 2006 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/helper.c
+ * @brief ECRS helper functions
+ * @author Krista Bennett
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_ecrs_lib.h"
+
+/**
+ * Create an ECRS URI from a single user-supplied string of keywords.
+ * The string may contain the reserved word 'AND' to create a boolean
+ * search over multiple keywords.
+ *
+ * @return an ECRS URI for the given keywords, NULL
+ *  if keywords is not legal (i.e. empty).
+ */
+struct ECRS_URI * ECRS_parseCharKeywordURI(struct GE_Context * ectx,
+                                          const char * input) {
+  char ** keywords;
+  unsigned int num_Words;
+  int inWord;
+  char * c;
+  struct ECRS_URI * uri;
+  char * searchString;
+
+  if (input == NULL) {
+    GE_BREAK(ectx, 0);
+    return NULL;
+  }
+  searchString = STRDUP(input);
+  num_Words = 0;
+  for (inWord = 0, c = searchString; *c != '\0'; ++c) {
+    if (isspace(*c)) {
+      inWord = 0;
+    } else if (!inWord) {
+      inWord = 1;
+      ++num_Words;
+    }
+  }
+
+  if (num_Words == 0) {
+    FREENONNULL(searchString);
+    GE_LOG(ectx, 
+          GE_ERROR | GE_IMMEDIATE | GE_USER,
+          _("No keywords specified!\n"));
+    return NULL;
+  }
+  keywords = MALLOC(num_Words * sizeof(char *));
+  num_Words = 0;
+  for (inWord = 0, c = searchString; *c != '\0'; ++c) {
+    if (isspace(*c)) {
+      inWord = 0;
+      *c = '\0';
+    } else if (!inWord) {
+      keywords[num_Words] = c;
+      inWord = 1;
+      ++num_Words;
+    }
+  }
+  uri = ECRS_parseArgvKeywordURI(ectx,
+                                num_Words,
+                                (const char**) keywords);
+  FREE(keywords);
+  FREE(searchString);
+  return uri;
+}
+
+/**
+ * Create an ECRS URI from a user-supplied command line of keywords.
+ * The command line may contain the reserved word 'AND' to create a
+ * boolean search over multiple keywords.
+ *
+ * @return an ECRS URI for the given keywords, NULL
+ *  if keywords is not legal (i.e. empty).
+ */
+struct ECRS_URI * ECRS_parseArgvKeywordURI(struct GE_Context * ectx,
+                                          unsigned int num_keywords,
+                                          const char ** keywords) {
+  unsigned int i;
+  unsigned int uriLen;
+  char * uriString;
+  unsigned int uriSize;
+  struct ECRS_URI * uri;
+
+  uriString = NULL;
+  uriSize = 0;
+  GROW(uriString,
+       uriSize,
+       4096);
+  strcpy(uriString, ECRS_URI_PREFIX);
+  strcat(uriString, ECRS_SEARCH_INFIX);
+  uriLen = 1 + strlen(ECRS_URI_PREFIX) + strlen(ECRS_SEARCH_INFIX);
+
+
+  for (i=0;i<num_keywords;i++) {
+    if (uriSize < uriLen + strlen(_("AND")) + 1 + strlen(keywords[i]))
+      GROW(uriString,
+          uriSize,
+          uriSize + 4096 + strlen(keywords[i]));
+    if ( (i > 0) &&
+        (0 == strcmp(keywords[i], _("AND"))) ) {
+      strcat(uriString, "+");
+      if (i == num_keywords-1)
+       strcat(uriString, _("AND")); /* last keyword 'AND'? keep it! */
+      uriLen += 1;
+    } else {
+      if ( (i > 0) &&
+          (0 != strcmp(keywords[i-1], _("AND"))) ) {
+       strcat(uriString, " ");
+       uriLen += 1;
+      }
+      strcat(uriString, keywords[i]);
+      uriLen += strlen(keywords[i]);
+    }
+  }
+  uri = ECRS_stringToUri(ectx, uriString);
+  GROW(uriString,
+       uriSize,
+       0);
+  return uri;
+}
+
+/**
+ * Create an ECRS URI from a user-supplied list of keywords.
+ * The keywords are NOT separated by AND but already
+ * given individually.
+ *
+ * @return an ECRS URI for the given keywords, NULL
+ *  if keywords is not legal (i.e. empty).
+ */
+struct ECRS_URI * ECRS_parseListKeywordURI(struct GE_Context * ectx,
+                                          unsigned int num_keywords,
+                                          const char ** keywords) {
+  unsigned int i;
+  unsigned int uriLen;
+  char * uriString;
+  unsigned int uriSize;
+  struct ECRS_URI * uri;
+
+  uriString = NULL;
+  uriSize = 0;
+  GROW(uriString,
+       uriSize,
+       4096);
+  strcpy(uriString, ECRS_URI_PREFIX);
+  strcat(uriString, ECRS_SEARCH_INFIX);
+  uriLen = 1 + strlen(ECRS_URI_PREFIX) + strlen(ECRS_SEARCH_INFIX);
+
+
+  for (i=0;i<num_keywords;i++) {
+    if (uriSize < uriLen + 1 + strlen(keywords[i]))
+      GROW(uriString,
+          uriSize,
+          uriSize + 4096 + strlen(keywords[i]));
+    if (i > 0) {
+      strcat(uriString, "+");
+      uriLen++;
+    }
+    strcat(uriString, keywords[i]);
+    uriLen += strlen(keywords[i]);
+  }
+  uri = ECRS_stringToUri(ectx, uriString);
+  GROW(uriString,
+       uriSize,
+       0);
+  return uri;
+}
+
+
+/* end of helper.c */

Modified: GNUnet/src/applications/fs/fsui/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/fsui/Makefile.am 2006-08-13 03:45:47 UTC (rev 
3223)
+++ GNUnet/src/applications/fs/fsui/Makefile.am 2006-08-13 19:32:06 UTC (rev 
3224)
@@ -6,12 +6,8 @@
 noinst_PROGRAMS = fsui-loader
 
 libgnunetfsui_la_SOURCES = \
-  collection.c \
   download.c \
-  file_info.c \
   fsui.c fsui.h \
-  helper.c \
-  namespace_info.c \
   search.c \
   unindex.c \
   upload.c
@@ -23,7 +19,6 @@
 EXTRA_DIST = \
   check.conf
 
-
 fsui_loader_SOURCES = \
  fsui-loader.c 
 fsui_loader_LDADD = \
@@ -35,8 +30,7 @@
   fsuitest \
   fsuitest2 \
   searchtest \
-  downloadtest \
-  namespace_infotest
+  downloadtest 
 
 TESTS = $(check_PROGRAMS)
 
@@ -54,13 +48,6 @@
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
-namespace_infotest_SOURCES = \
-  namespace_infotest.c 
-namespace_infotest_LDADD = \
-  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
-  $(top_builddir)/src/util/libgnunetutil.la 
-
 searchtest_SOURCES = \
   searchtest.c 
 searchtest_LDADD = \

Deleted: GNUnet/src/applications/fs/fsui/collection.c
===================================================================
--- GNUnet/src/applications/fs/fsui/collection.c        2006-08-13 03:45:47 UTC 
(rev 3223)
+++ GNUnet/src/applications/fs/fsui/collection.c        2006-08-13 19:32:06 UTC 
(rev 3224)
@@ -1,391 +0,0 @@
-/*
-     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
-     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/fsui/collection.c
- * @brief Helper functions for building a collection
- * @author Christian Grothoff
- *
- * A collection is a special kind of namespace.  A collection is the
- * set of files provided by the same user, but unlike namespaces it is
- * automatically managed by the GNUnet UI.  A collection is a single
- * directory in a namespace that is automatically updated each time
- * the user updates or deletes a file.  That is, once the user starts
- * a collection the gnunet-tools will always keep the corresponding
- * directory and namespace entries up-to-date.
- *
- * A good way of thinking about a collection is a lazy user's
- * namespace.
- */
-
-#include "platform.h"
-#include "gnunet_fsui_lib.h"
-#include "fsui.h"
-
-/**
- * Entry in the state-DB that caches the current
- * collection.
- */
-#define COLLECTION "collection"
-
-/**
- * How long does a collection advertisement live?
- */
-#define COLLECTION_ADV_LIFETIME (12 * cronMONTHS)
-
-#define DEFAULT_ADVERTISEMENT_PRIORITY 128
-
-/**
- * @brief information about a collection
- */
-typedef struct CollectionData {
-  DataContainer hdr;
-  /**
-   * Has this collection changed since the last publication? (NBO)
-   */
-  int changed;
-  /**
-   * What is the last ID for the publication?
-   */
-  HashCode512 lastId;
-  /**
-   * What is the next ID for the publication?
-   */
-  HashCode512 nextId;
-  /**
-   * What is the update interval? (NBO!)
-   */
-  TIME_T updateInterval;
-  /**
-   * What is the update interval? (NBO!)
-   */
-  TIME_T lastPublication;
-  /**
-   * Anonymity level for the collection. (NBO)
-   */
-  unsigned int anonymityLevel;
-  /**
-   * Name of the collection
-   */
-  char name[1];
-  /* the name is followed by a
-     serialized ECRS directory */
-} CollectionData;
-
-
-/**
- * Start collection.
- *
- * @param updateInterval of ECRS_SBLOCK_UPDATE_NONE
- *        means to update _immediately_ on any change,
- *        wherease ECRS_SBLOCK_UPDATE_SPORADIC means
- *        to publish updates when the FSUI_Context
- *        is destroyed (i.e. on exit from the UI).
- */
-int FSUI_startCollection(struct FSUI_Context * ctx,
-                        unsigned int anonymityLevel,
-                        TIME_T updateInterval,
-                        const char * name,
-                        const struct ECRS_MetaData * meta) {
-  struct ECRS_URI * advertisement;
-  struct ECRS_URI * rootURI;
-  HashCode512 nextId;
-  TIME_T now;
-  unsigned int prio;
-  CollectionData * cd;
-  unsigned long long dirLen;
-  char * dirData;
-  struct ECRS_MetaData * dirMeta;
-
-  FSUI_stopCollection(ctx); /* cancel old collection */
-  GE_ASSERT(ectx, name != NULL);
-  advertisement = FSUI_parseCharKeywordURI(COLLECTION);
-  GE_ASSERT(ectx, advertisement != NULL);
-  TIME(&now);
-  prio = getConfigurationInt("FS",
-                            "ADVERTISEMENT-PRIORITY");
-  if (prio == 0)
-    prio = DEFAULT_ADVERTISEMENT_PRIORITY;
-  makeRandomId(&nextId);
-  rootURI = ECRS_createNamespace(name,
-                                meta,
-                                anonymityLevel,
-                                prio,
-                                now + COLLECTION_ADV_LIFETIME,
-                                advertisement,
-                                &nextId);
-  if (rootURI == NULL) {
-    ECRS_freeUri(advertisement);
-    return SYSERR;
-  }
-  ECRS_freeUri(advertisement);
-  ECRS_freeUri(rootURI);
-  dirMeta = ECRS_dupMetaData(meta);
-  GE_ASSERT(ectx, OK == ECRS_createDirectory(&dirData,
-                                          &dirLen,
-                                          0,
-                                          NULL,
-                                          dirMeta));
-  ECRS_freeMetaData(dirMeta);
-  cd = MALLOC(sizeof(CollectionData) + strlen(name) + dirLen);
-  ctx->collectionData = &cd->hdr;
-  cd->hdr.size = ntohl(sizeof(CollectionData) + strlen(name));
-  makeRandomId(&cd->lastId);
-  cd->nextId = nextId;
-  cd->updateInterval = htonll(updateInterval);
-  cd->anonymityLevel = htonl(anonymityLevel);
-  cd->changed = htonl(NO);
-  strcpy(cd->name, name);
-  memcpy(&cd->name[strlen(name)+1],
-        dirData,
-        dirLen);
-  FREE(dirData);
-  return OK;
-}
-
-/**
- * Stop collection.
- *
- * @return OK on success, SYSERR if no collection is active
- */
-int FSUI_stopCollection(struct FSUI_Context * ctx) {
-  CollectionData * cd;
-
-  if (ctx->collectionData == NULL)
-    return SYSERR;
-  cd = (CollectionData*) ctx->collectionData;
-  ECRS_deleteNamespace(cd->name);
-  FREE(cd);
-  ctx->collectionData = NULL;
-  return OK;
-}
-
-/**
- * Are we using a collection?
- *
- * @return NULL if there is no collection, otherwise its name
- */
-const char * FSUI_getCollection(struct FSUI_Context * ctx) {
-  CollectionData * cd;
-
-  cd = (CollectionData*) ctx->collectionData;
-  if (cd == NULL)
-    return NULL;
-  return &cd->name[0];
-}
-
-/**
- * Upload an update of the current collection information to the
- * network now.  The function has no effect if the collection has not
- * changed since the last publication.  If we are currently not
- * collecting, this function does nothing.
- *
- * Note that clients typically don't have to call this
- * function explicitly.  FSUI will call the function on
- * exit (for sporadically updated collections), on any
- * change to the collection (for immediately updated
- * content) or when the publication time has arrived
- * (for periodically updated collections).
- *
- * However, clients may want to call this function if
- * explicit publication of an update at another
- * time is desired.
- */
-void FSUI_publishCollectionNow(struct FSUI_Context * ctx) {
-  CollectionData * cd;
-  TIME_T now;
-  struct ECRS_URI * uri;
-  struct ECRS_URI * directoryURI;
-  struct ECRS_MetaData *  metaData;
-  unsigned long long dirLen;
-  char * tmpName;
-  int fd;
-
-  if (ctx->collectionData == NULL)
-    return;
-  cd = (CollectionData*) ctx->collectionData;
-  if (ntohl(cd->changed) == NO)
-    return;
-
-  TIME(&now);
-  if ( (ntohl(cd->updateInterval) != ECRS_SBLOCK_UPDATE_NONE) &&
-       (ntohl(cd->updateInterval) != ECRS_SBLOCK_UPDATE_SPORADIC) &&
-       (ntohl(cd->lastPublication) + ntohl(cd->updateInterval) < now) )
-    return;
-  if ( (ntohl(cd->updateInterval) != ECRS_SBLOCK_UPDATE_NONE) &&
-       (ntohl(cd->updateInterval) != ECRS_SBLOCK_UPDATE_SPORADIC) ) {
-    HashCode512 delta;
-
-    deltaId(&cd->nextId,
-           &cd->lastId,
-           &delta);
-    cd->lastId = cd->nextId;
-    addHashCodes(&cd->nextId,
-                &delta,
-                &cd->nextId);
-  } else {
-    cd->lastId = cd->nextId;
-    makeRandomId(&cd->nextId);
-  }
-  tmpName = STRDUP("/tmp/gnunet-collectionXXXXXX");
-  fd = mkstemp(tmpName);
-  if (fd == -1) {
-    LOG_STRERROR(LOG_ERROR, "mkstemp");
-    FREE(tmpName);
-    return;
-  }
-  dirLen = ntohl(cd->hdr.size) - sizeof(CollectionData) - strlen(cd->name);
-  if (-1 == WRITE(fd, &cd->name[strlen(cd->name)+1], dirLen)) {
-    LOG_STRERROR(LOG_ERROR, "write");
-    FREE(tmpName);
-    return;
-  }
-  closefile(fd);
-  if (OK != ECRS_uploadFile(tmpName,
-                           NO, /* indexing */
-                           ntohl(cd->anonymityLevel),
-                           getConfigurationInt("FS",
-                                               "ADVERTISEMENT-PRIORITY"),
-                           now + COLLECTION_ADV_LIFETIME,
-                           NULL,
-                           NULL,
-                           NULL,
-                           NULL,
-                           &directoryURI)) {
-    UNLINK(tmpName);
-    FREE(tmpName);
-    return;
-  }
-  UNLINK(tmpName);
-  FREE(tmpName);
-  metaData = NULL;
-  GE_ASSERT(ectx, OK == ECRS_listDirectory(&cd->name[strlen(cd->name)+1],
-                                        dirLen,
-                                        &metaData,
-                                        NULL,
-                                        NULL));
-  uri = ECRS_addToNamespace(cd->name,
-                           ntohl(cd->anonymityLevel),
-                           getConfigurationInt("FS",
-                                               "ADVERTISEMENT-PRIORITY"),
-                           now + COLLECTION_ADV_LIFETIME,
-                           now,
-                           ntohl(cd->updateInterval),
-                           &cd->lastId,
-                           &cd->nextId,
-                           directoryURI,
-                           metaData);
-  if (uri != NULL) {
-    cd->lastPublication = htonl(now);
-    cd->changed = htonl(NO);
-    ECRS_freeUri(uri);
-  }
-  ECRS_freeMetaData(metaData);
-}
-
-struct CCcls {
-  unsigned int count;
-  ECRS_FileInfo * fis;
-};
-
-static int collectCallback(const ECRS_FileInfo * fi,
-                          const HashCode512 * key,
-                          int isRoot,
-                          void * closure) {
-  struct CCcls * cls = closure;
-  GROW(cls->fis,
-       cls->count,
-       cls->count+1);
-  cls->fis[cls->count-1].uri = ECRS_dupUri(fi->uri);
-  cls->fis[cls->count-1].meta = ECRS_dupMetaData(fi->meta);
-  return OK;
-}
-
-/**
- * If we are currently building a collection, publish
- * the given file information in that collection.
- * If we are currently not collecting, this function
- * does nothing.
- *
- * Note that clients typically don't have to call this
- * function explicitly -- by using the FSUI library it
- * should be called automatically by FSUI code whenever
- * needed.  However, the function maybe useful if you're
- * inserting files using libECRS directly or need other
- * ways to explicitly extend a collection.
- */
-void FSUI_publishToCollection(struct FSUI_Context * ctx,
-                             const ECRS_FileInfo * fi) {
-  CollectionData * cd;
-  unsigned long long dirLen;
-  char * dirData;
-  struct ECRS_MetaData * metaData;
-  struct CCcls cls;
-  int i;
-
-  if (ctx->collectionData == NULL)
-    return;
-  if ((ECRS_isKeywordUri(fi->uri))) {
-    GE_BREAK(ectx, 0);
-    return;
-  }
-  cd = (CollectionData*) ctx->collectionData;
-  dirLen = ntohl(cd->hdr.size) - strlen(cd->name) - sizeof(CollectionData);
-  cls.count = 0;
-  cls.fis = NULL;
-  GE_ASSERT(ectx, OK ==
-               ECRS_listDirectory(&cd->name[strlen(cd->name)+1],
-                                  dirLen,
-                                  &metaData,
-                                  &collectCallback,
-                                  &cls));
-  collectCallback(fi,
-                 NULL,
-                 NO,
-                 &cls);
-  dirData = NULL;
-  GE_ASSERT(ectx, OK ==
-               ECRS_createDirectory(&dirData,
-                                    &dirLen,
-                                    cls.count,
-                                    cls.fis,
-                                    metaData));
-  ECRS_freeMetaData(metaData);
-  for (i=0;i<cls.count;i++) {
-    ECRS_freeUri(cls.fis[i].uri);
-    ECRS_freeMetaData(cls.fis[i].meta);
-  }
-  GROW(cls.fis,
-       cls.count,
-       0);
-  REALLOC(cd,
-         sizeof(CollectionData) + strlen(cd->name) + dirLen);
-  memcpy(&cd->name[strlen(cd->name)+1],
-        dirData,
-        dirLen);
-  FREE(dirData);
-  cd->changed = htonl(YES);
-  if (ntohll(cd->updateInterval) == ECRS_SBLOCK_UPDATE_NONE)
-    FSUI_publishCollectionNow(ctx);
-}
-
-
-
-/* end of collection.c */

Deleted: GNUnet/src/applications/fs/fsui/file_info.c
===================================================================
--- GNUnet/src/applications/fs/fsui/file_info.c 2006-08-13 03:45:47 UTC (rev 
3223)
+++ GNUnet/src/applications/fs/fsui/file_info.c 2006-08-13 19:32:06 UTC (rev 
3224)
@@ -1,294 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2003, 2004, 2006 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/fsui/file_info.c
- * @brief Helper functions for keeping track of files for building directories.
- * @author Christian Grothoff
- *
- * The "state" database (see util/state.c) is used to store the toggle
- * flag. An mmapped file (STATE_NAME) is used to store the actual URIs.
- * An IPC semaphore is used to guard the access.
- */
-
-#include "platform.h"
-#include "gnunet_fsui_lib.h"
-#include "gnunet_ecrs_lib.h"
-
-#define DEBUG_FILE_INFO NO
-
-#define STATE_NAME DIR_SEPARATOR_STR "data" DIR_SEPARATOR_STR "fs_uridb"
-#define TRACK_OPTION "fs_uridb_status"
-
-static IPC_Semaphore * createIPC() {
-  char * basename;
-  char * tmpname;
-  char * ipcName;
-  IPC_Semaphore * sem;
-  size_t n;
-
-  basename = getConfigurationString("GNUNET",
-                                   "GNUNET_HOME");
-  n = strlen(basename) + 512;
-  tmpname = MALLOC(n);
-  SNPRINTF(tmpname, n, "%s/directory_ipc_lock", basename);
-  ipcName = expandFileName(tmpname);
-  FREE(basename);
-  FREE(tmpname);
-  sem = IPC_SEMAPHORE_CREATE(ipcName, 1);
-  FREE(ipcName);
-  return sem;                          
-}
-
-static char * getUriDbName() {
-  char * new;
-  char * pfx;
-
-  pfx = getFileName("GNUNET", 
-                   "GNUNET_HOME",
-                   _("Configuration file must specify a "
-                     "directory for GNUnet to store "
-                     "per-peer data under %s%s\n"));
-  new = MALLOC(strlen(pfx) + strlen(STATE_NAME) + 1);
-  strcpy(new, pfx);
-  strcat(new, STATE_NAME); 
-  FREE(pfx);
-  return new;
-}
-
-
-
-/**
- * Get the FSUI URI tracking status.
- *
- * @return YES of tracking is enabled, NO if not
- */
-int FSUI_trackStatus() {
-  int * status;
-
-  status = NULL;
-  if ( (sizeof(int) != stateReadContent(TRACK_OPTION,
-                                       (void**)&status)) ||
-       (ntohl(*status) != YES) ) {
-    FREENONNULL(status);
-#if DEBUG_FILE_INFO
-    GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-       _("Collecting file identifiers disabled.\n"));
-#endif
-    return NO;
-  } else {
-    FREENONNULL(status);
-    return YES;
-  }
-}
-
-/**
- * Makes a URI available for directory building.
- */
-void FSUI_trackURI(const ECRS_FileInfo * fi) {
-  IPC_Semaphore * sem;
-  char * data;
-  unsigned int size;
-  char * suri;
-  int fh;
-  char * fn;
-
-  if (NO == FSUI_trackStatus())
-    return;
-  size = ECRS_sizeofMetaData(fi->meta,
-                            ECRS_SERIALIZE_FULL);
-  data = MALLOC(size);
-  GE_ASSERT(ectx, size == ECRS_serializeMetaData(fi->meta,
-                                              data,
-                                              size,
-                                              ECRS_SERIALIZE_FULL));
-  size = htonl(size);
-  suri = ECRS_uriToString(fi->uri);
-  sem = createIPC();
-  IPC_SEMAPHORE_DOWN(sem);
-  fn = getUriDbName();
-  fh = fileopen(fn, O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE, S_IRUSR|S_IWUSR);
-  if (fh == -1) {
-    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING,
-                     "open",
-                     fn);
-  } else {
-    WRITE(fh, suri, strlen(suri) + 1);
-    WRITE(fh, &size, sizeof(unsigned int));
-    WRITE(fh, data, ntohl(size));
-    CLOSE(fh);
-  }
-  FREE(fn);
-  IPC_SEMAPHORE_UP(sem);
-  IPC_SEMAPHORE_DESTROY(sem);
-  FREE(data);
-  FREE(suri);
-}
-
-/**
- * Remove all of the root-nodes of a particular type
- * from the tracking database.
- */
-void FSUI_clearTrackedURIS() {
-  IPC_Semaphore * sem;
-  char * fn;
-
-  sem = createIPC();
-  IPC_SEMAPHORE_DOWN(sem);
-  fn = getUriDbName();
-  if (0 != UNLINK(fn))
-    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING,
-                     "unlink",
-                     fn);
-  FREE(fn);
-  IPC_SEMAPHORE_UP(sem);
-  IPC_SEMAPHORE_DESTROY(sem);
-}
-
-/**
- * Toggle tracking URIs.
- *
- * @param onOff YES to enable tracking, NO to disable
- *  disabling tracking
- */
-void FSUI_trackURIS(int onOff) {
-  onOff = htonl(onOff);
-  stateWriteContent(TRACK_OPTION,
-                   sizeof(int),
-                   &onOff);
-}
-
-/**
- * Iterate over all entries that match the given context
- * mask.
- *
- * @param iterator function to call on each entry, may be NULL
- * @param closure extra argument to the callback
- * @return number of entries found
- */
-int FSUI_listURIs(ECRS_SearchProgressCallback iterator, void *closure)
-{
-  IPC_Semaphore *sem;
-  int rval;
-  char *result;
-  off_t ret;
-  off_t pos;
-  off_t spos;
-  unsigned int msize;
-  ECRS_FileInfo fi;
-  int fd;
-  char *fn;
-  struct stat buf;
-
-  fn = getUriDbName();
-  sem = createIPC();
-  IPC_SEMAPHORE_DOWN(sem);
-  if(0 != STAT(fn, &buf)) {
-    IPC_SEMAPHORE_UP(sem);
-    IPC_SEMAPHORE_DESTROY(sem);
-    return 0;                   /* no URI db */
-  }
-  fd = fileopen(fn, O_LARGEFILE | O_RDONLY);
-  if(fd == -1) {
-    IPC_SEMAPHORE_UP(sem);
-    IPC_SEMAPHORE_DESTROY(sem);
-    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "open", fn);
-    FREE(fn);
-    return SYSERR;              /* error opening URI db */
-  }
-  result = MMAP(NULL, buf.st_size, PROT_READ, MAP_SHARED, fd, 0);
-  if(result == MAP_FAILED) {
-    CLOSE(fd);
-    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "mmap", fn);
-    FREE(fn);
-    IPC_SEMAPHORE_UP(sem);
-    IPC_SEMAPHORE_DESTROY(sem);
-    return SYSERR;
-  }
-  ret = buf.st_size;
-  pos = 0;
-  rval = 0;
-  while(pos < ret) {
-    spos = pos;
-    while((spos < ret) && (result[spos] != '\0'))
-      spos++;
-    spos++;                     /* skip '\0' */
-    if((spos + sizeof(int) >= ret) || (spos + sizeof(int) < spos)) {
-      GE_BREAK(ectx, 0);
-      goto FORMATERROR;
-    }
-    fi.uri = ECRS_stringToUri(&result[pos]);
-    if(fi.uri == NULL) {
-      GE_BREAK(ectx, 0);
-      goto FORMATERROR;
-    }
-    memcpy(&msize, &result[spos], sizeof(int));
-    msize = ntohl(msize);
-    spos += sizeof(int);
-    if((spos + msize > ret) || (spos + msize < spos)) {
-      GE_BREAK(ectx, 0);
-      ECRS_freeUri(fi.uri);
-      goto FORMATERROR;
-    }
-    fi.meta = ECRS_deserializeMetaData(&result[spos], msize);
-    if(fi.meta == NULL) {
-      GE_BREAK(ectx, 0);
-      ECRS_freeUri(fi.uri);
-      goto FORMATERROR;
-    }
-    pos = spos + msize;
-    if(iterator != NULL) {
-      if(OK != iterator(&fi, NULL, NO, closure)) {
-        ECRS_freeMetaData(fi.meta);
-        ECRS_freeUri(fi.uri);
-        if(0 != MUNMAP(result, buf.st_size))
-          GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "munmap", fn);
-        CLOSE(fd);
-        FREE(fn);
-        IPC_SEMAPHORE_UP(sem);
-        IPC_SEMAPHORE_DESTROY(sem);
-        return SYSERR;          /* iteration aborted */
-      }
-    }
-    rval++;
-    ECRS_freeMetaData(fi.meta);
-    ECRS_freeUri(fi.uri);
-  }
-  if(0 != MUNMAP(result, buf.st_size))
-    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "munmap", fn);
-  CLOSE(fd);
-  FREE(fn);
-  IPC_SEMAPHORE_UP(sem);
-  IPC_SEMAPHORE_DESTROY(sem);
-  return rval;
-FORMATERROR:
-  GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER, _("Deleted corrupt URI database 
in `%s'."), STATE_NAME);
-  if(0 != MUNMAP(result, buf.st_size))
-    GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "munmap", fn);
-  CLOSE(fd);
-  FREE(fn);
-  IPC_SEMAPHORE_UP(sem);
-  IPC_SEMAPHORE_DESTROY(sem);
-  FSUI_clearTrackedURIS();
-  return SYSERR;
-}
-
-
-/* end of file_info.c */

Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h      2006-08-13 03:45:47 UTC (rev 
3223)
+++ GNUnet/src/applications/fs/fsui/fsui.h      2006-08-13 19:32:06 UTC (rev 
3224)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other 
contributing authors)
+     (C) 2001, 2002, 2003, 2004, 2005, 2006 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
@@ -44,7 +44,7 @@
   /**
    * Handle to a thread.
    */
-  PTHREAD_T handle;
+  struct PTHREAD * handle;
 
   /**
    * Flag that indicates if it is safe (i.e.
@@ -94,7 +94,7 @@
   /**
    * Handle to the thread which performs the search.
    */
-  PTHREAD_T handle;
+  struct PTHREAD * handle;
 
   /**
    * Set this to YES to signal the search thread that
@@ -232,7 +232,7 @@
   /**
    * Currently assigned thread (if any).
    */
-  PTHREAD_T handle;
+  struct PTHREAD * handle;
 
   /**
    * How many bytes is this download in total
@@ -316,7 +316,7 @@
    * between different processes of the same name
    * that all use resume.
    */
-  IPC_Semaphore * ipc;
+  struct IPC_SEMAPHORE * ipc;
 
   /**
    * Name of the tool using FSUI (used for resume).
@@ -326,7 +326,7 @@
   /**
    * Lock to synchronize access to the FSUI Context.
    */
-  Mutex lock;
+  struct MUTEX * lock;
 
   /**
    * Callback for notifying the client about events.

Deleted: GNUnet/src/applications/fs/fsui/helper.c
===================================================================
--- GNUnet/src/applications/fs/fsui/helper.c    2006-08-13 03:45:47 UTC (rev 
3223)
+++ GNUnet/src/applications/fs/fsui/helper.c    2006-08-13 19:32:06 UTC (rev 
3224)
@@ -1,189 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (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
-     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/fsui/helper.c
- * @brief FSUI helper functions
- * @author Krista Bennett
- * @author Christian Grothoff
- */
-
-#include "platform.h"
-#include "gnunet_ecrs_lib.h"
-#include "gnunet_fsui_lib.h"
-#include "fsui.h"
-
-/**
- * Create an ECRS URI from a single user-supplied string of keywords.
- * The string may contain the reserved word 'AND' to create a boolean
- * search over multiple keywords.
- *
- * @return an ECRS URI for the given keywords, NULL
- *  if keywords is not legal (i.e. empty).
- */
-struct ECRS_URI * FSUI_parseCharKeywordURI(const char * input) {
-  char ** keywords;
-  unsigned int num_Words;
-  int inWord;
-  char * c;
-  struct ECRS_URI * uri;
-  char * searchString;
-
-  if (input == NULL) {
-    GE_BREAK(ectx, 0);
-    return NULL;
-  }
-  searchString = STRDUP(input);
-  num_Words = 0;
-  for (inWord = 0, c = searchString; *c != '\0'; ++c) {
-    if (isspace(*c)) {
-      inWord = 0;
-    } else if (!inWord) {
-      inWord = 1;
-      ++num_Words;
-    }
-  }
-
-  if (num_Words == 0) {
-    FREENONNULL(searchString);
-    GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER,
-       _("No keywords specified!\n"));
-    return NULL;
-  }
-  keywords = MALLOC(num_Words * sizeof(char *));
-  num_Words = 0;
-  for (inWord = 0, c = searchString; *c != '\0'; ++c) {
-    if (isspace(*c)) {
-      inWord = 0;
-      *c = '\0';
-    } else if (!inWord) {
-      keywords[num_Words] = c;
-      inWord = 1;
-      ++num_Words;
-    }
-  }
-  uri = FSUI_parseArgvKeywordURI(num_Words,
-                                (const char**) keywords);
-  FREE(keywords);
-  FREE(searchString);
-  return uri;
-}
-
-/**
- * Create an ECRS URI from a user-supplied command line of keywords.
- * The command line may contain the reserved word 'AND' to create a
- * boolean search over multiple keywords.
- *
- * @return an ECRS URI for the given keywords, NULL
- *  if keywords is not legal (i.e. empty).
- */
-struct ECRS_URI * FSUI_parseArgvKeywordURI(unsigned int num_keywords,
-                                          const char ** keywords) {
-  unsigned int i;
-  unsigned int uriLen;
-  char * uriString;
-  unsigned int uriSize;
-  struct ECRS_URI * uri;
-
-  uriString = NULL;
-  uriSize = 0;
-  GROW(uriString,
-       uriSize,
-       4096);
-  strcpy(uriString, ECRS_URI_PREFIX);
-  strcat(uriString, ECRS_SEARCH_INFIX);
-  uriLen = 1 + strlen(ECRS_URI_PREFIX) + strlen(ECRS_SEARCH_INFIX);
-
-
-  for (i=0;i<num_keywords;i++) {
-    if (uriSize < uriLen + strlen(_("AND")) + 1 + strlen(keywords[i]))
-      GROW(uriString,
-          uriSize,
-          uriSize + 4096 + strlen(keywords[i]));
-    if ( (i > 0) &&
-        (0 == strcmp(keywords[i], _("AND"))) ) {
-      strcat(uriString, "+");
-      if (i == num_keywords-1)
-       strcat(uriString, _("AND")); /* last keyword 'AND'? keep it! */
-      uriLen += 1;
-    } else {
-      if ( (i > 0) &&
-          (0 != strcmp(keywords[i-1], _("AND"))) ) {
-       strcat(uriString, " ");
-       uriLen += 1;
-      }
-      strcat(uriString, keywords[i]);
-      uriLen += strlen(keywords[i]);
-    }
-  }
-  uri = ECRS_stringToUri(uriString);
-  GROW(uriString,
-       uriSize,
-       0);
-  return uri;
-}
-
-/**
- * Create an ECRS URI from a user-supplied list of keywords.
- * The keywords are NOT separated by AND but already
- * given individually.
- *
- * @return an ECRS URI for the given keywords, NULL
- *  if keywords is not legal (i.e. empty).
- */
-struct ECRS_URI * FSUI_parseListKeywordURI(unsigned int num_keywords,
-                                          const char ** keywords) {
-  unsigned int i;
-  unsigned int uriLen;
-  char * uriString;
-  unsigned int uriSize;
-  struct ECRS_URI * uri;
-
-  uriString = NULL;
-  uriSize = 0;
-  GROW(uriString,
-       uriSize,
-       4096);
-  strcpy(uriString, ECRS_URI_PREFIX);
-  strcat(uriString, ECRS_SEARCH_INFIX);
-  uriLen = 1 + strlen(ECRS_URI_PREFIX) + strlen(ECRS_SEARCH_INFIX);
-
-
-  for (i=0;i<num_keywords;i++) {
-    if (uriSize < uriLen + 1 + strlen(keywords[i]))
-      GROW(uriString,
-          uriSize,
-          uriSize + 4096 + strlen(keywords[i]));
-    if (i > 0) {
-      strcat(uriString, "+");
-      uriLen++;
-    }
-    strcat(uriString, keywords[i]);
-    uriLen += strlen(keywords[i]);
-  }
-  uri = ECRS_stringToUri(uriString);
-  GROW(uriString,
-       uriSize,
-       0);
-  return uri;
-}
-
-
-/* end of helper.c */

Deleted: GNUnet/src/applications/fs/fsui/namespace_info.c
===================================================================
--- GNUnet/src/applications/fs/fsui/namespace_info.c    2006-08-13 03:45:47 UTC 
(rev 3223)
+++ GNUnet/src/applications/fs/fsui/namespace_info.c    2006-08-13 19:32:06 UTC 
(rev 3224)
@@ -1,857 +0,0 @@
-/*
-     This file is part of GNUnet
-     (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
-     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/fsui/namespace_info.c
- * @brief keeping track of namespaces.  This module
- *  is supposed to keep track of other namespaces (and
- *  their advertisments), as well as of our own namespaces
- *  and the updateable content stored therein.
- * @author Christian Grothoff
- */
-
-#include "platform.h"
-#include "gnunet_fsui_lib.h"
-#include "fsui.h"
-
-#define NS_DIR "data" DIR_SEPARATOR_STR "namespaces" DIR_SEPARATOR_STR
-#define NS_UPDATE_DIR "data" DIR_SEPARATOR_STR "namespace-updates" 
DIR_SEPARATOR_STR
-#define NS_ROOTS "data" DIR_SEPARATOR_STR "namespace-root" DIR_SEPARATOR_STR
-
-static void writeNamespaceInfo(const char * namespaceName,
-                              const struct ECRS_MetaData * meta,
-                              int ranking) {
-  unsigned int size;
-  unsigned int tag;
-  char * buf;
-  char * fn;
-  char * fnBase;
-
-  fn = getConfigurationString("GNUNET", "GNUNET_HOME");
-  fnBase = expandFileName(fn);
-  FREE(fn);
-  fn = MALLOC(strlen(fnBase) +
-             strlen(NS_DIR) +
-             strlen(namespaceName) +
-             6);
-  strcpy(fn, fnBase);
-  strcat(fn, DIR_SEPARATOR_STR);
-  strcat(fn, NS_DIR);
-  mkdirp(fn);
-  strcat(fn, DIR_SEPARATOR_STR);
-  strcat(fn, namespaceName);
-  FREE(fnBase);
-
-  size = ECRS_sizeofMetaData(meta,
-                            ECRS_SERIALIZE_FULL);
-  tag = size + sizeof(int);
-  buf = MALLOC(tag);
-  ((int *) buf)[0] = htonl(ranking); /* ranking */
-  GE_ASSERT(ectx, size == ECRS_serializeMetaData(meta,
-                                              &buf[sizeof(int)],
-                                              size,
-                                              ECRS_SERIALIZE_FULL));
-  writeFile(fn,
-           buf,
-           tag,
-           "660");
-  FREE(fn);
-  FREE(buf);
-}
-
-static int readNamespaceInfo(const char * namespaceName,
-                            struct ECRS_MetaData ** meta,
-                            int * ranking) {
-  unsigned long long len;
-  unsigned int size;
-  char * buf;
-  char * fn;
-  char * fnBase;
-
-  *meta = NULL;
-  fn = getConfigurationString("GNUNET", "GNUNET_HOME");
-  fnBase = expandFileName(fn);
-  FREE(fn);
-  fn = MALLOC(strlen(fnBase) +
-             strlen(NS_DIR) +
-             strlen(namespaceName) +
-             6);
-  strcpy(fn, fnBase);
-  strcat(fn, DIR_SEPARATOR_STR);
-  strcat(fn, NS_DIR);
-  mkdirp(fn);
-  strcat(fn, DIR_SEPARATOR_STR);
-  strcat(fn, namespaceName);
-  FREE(fnBase);
-
-  if (OK != getFileSize(fn,
-                       &len)) {
-    FREE(fn);
-    return SYSERR;
-  }
-  if (len <= sizeof(int)) {
-    FREE(fn);
-    return SYSERR;
-  }
-  if (len > 16 * 1024 * 1024) {
-    /* too big, must be invalid! remove! */
-    GE_BREAK(ectx, 0);
-    UNLINK(fn);
-    FREE(fn);
-    return SYSERR;
-  }
-  buf = MALLOC(len);
-  if (len != readFile(fn,
-                     len,
-                     buf)) {
-    FREE(buf);
-    FREE(fn);
-    return SYSERR;
-  }
-
-  size = len - sizeof(int);
-  *ranking = ntohl(((int *) buf)[0]);
-  *meta = ECRS_deserializeMetaData(&buf[sizeof(int)],
-                                  size);
-  if ((*meta) == NULL) {
-    /* invalid data! remove! */
-    GE_BREAK(ectx, 0);
-    UNLINK(fn);
-    FREE(buf);
-    FREE(fn);
-    return SYSERR;
-  }
-  FREE(fn);
-  FREE(buf);
-  return OK;
-}
-                                       
-
-/**
- * Create a new namespace (and publish an advertismement).
- * This function is synchronous, but may block the system
- * for a while since it must create a public-private key pair!
- *
- * @param meta meta-data about the namespace (maybe NULL)
- * @return URI on success, NULL on error (namespace already exists)
- */
-struct ECRS_URI *
-FSUI_createNamespace(struct FSUI_Context * ctx,
-                    unsigned int anonymityLevel,
-                    const char * namespaceName,
-                    const struct ECRS_MetaData * meta,
-                    const struct ECRS_URI * advertisementURI,
-                    const HashCode512 * rootEntry) {
-  struct ECRS_URI * ret;
-
-  ret = ECRS_createNamespace(namespaceName,
-                            meta,
-                            anonymityLevel,
-                            getConfigurationInt("FS", "INSERT-PRIORITY"),
-                            getConfigurationInt("FS",
-                                                "INSERT-EXPIRATION")
-                            * cronYEARS + get_time(),
-                            advertisementURI,
-                            rootEntry);
-  /* store binding of namespaceName to 'meta' in state DB! */
-  if (ret != NULL) {
-    HashCode512 id;
-    char * name;
-
-    ECRS_getNamespaceId(ret,
-                       &id);
-    name = ECRS_getNamespaceName(&id);
-    writeNamespaceInfo(name,
-                      meta,
-                      0);
-    FREE(name);
-  }
-  return ret;
-}
-
-/**
- * Change the ranking of a (non-local) namespace.
- *
- * @param ns the name of the namespace, as obtained
- *  from ECRS_getNamespaceName
- * @param delta by how much should the rating be
- *  changed?
- * @return new rating of the namespace
- */
-int FSUI_rankNamespace(struct FSUI_Context * ctx,
-                      const char * ns,
-                      int delta) {
-  struct ECRS_MetaData * meta;
-  int ret;
-  int ranking;
-
-  ret = readNamespaceInfo(ns,
-                         &meta,
-                         &ranking);
-  if (ret == SYSERR) {
-    ranking = 0;
-    meta = ECRS_createMetaData();
-  }
-  ranking += delta;
-  writeNamespaceInfo(ns,
-                    meta,
-                    ranking);
-  ECRS_freeMetaData(meta);
-  return ranking;
-}
-
-typedef struct {
-  FSUI_NamespaceIterator iterator;
-  void * closure;
-} LNClosure;
-
-static int localListNamespaceHelper(const HashCode512 * nsid,
-                                   const char * name,
-                                   void * cls) {
-  LNClosure * c = cls;
-  int ret;
-  struct ECRS_MetaData * meta;
-  int rating;
-
-  meta = NULL;
-  rating = 0;
-  readNamespaceInfo(name,
-                   &meta,
-                   &rating);
-  if (meta == NULL)
-    meta = ECRS_createMetaData();
-  if (c->iterator != NULL) {
-    ret = c->iterator(c->closure,
-                     name,
-                     nsid,
-                     meta,
-                     rating);
-  } else
-    ret = OK;
-  ECRS_freeMetaData(meta);
-  return ret;
-}
-
-static int listNamespaceHelper(const char * fn,
-                              const char * dirName,
-                              void * cls) {
-  LNClosure * c = cls;
-  int ret;
-  struct ECRS_MetaData * meta;
-  int rating;
-  HashCode512 id;
-
-  if (OK != enc2hash(fn,
-                    &id))
-    return OK; /* invalid name */
-  if (OK != readNamespaceInfo(fn,
-                             &meta,
-                             &rating))
-    return OK; /* ignore entry */
-  if (c->iterator != NULL) {
-    ret = c->iterator(c->closure,
-                     fn,
-                     &id,
-                     meta,
-                     rating);
-  } else
-    ret = OK;
-  ECRS_freeMetaData(meta);
-  return OK;
-}
-
-/**
- * List all available (local or non-local) namespaces.
- *
- * @param local only list local namespaces (if NO, only
- *   non-local known namespaces are listed)
- */
-int FSUI_listNamespaces(struct FSUI_Context * ctx,
-                       int local,
-                       FSUI_NamespaceIterator iterator,
-                       void * closure) {
-  LNClosure cls;
-  int ret;
-
-  cls.iterator = iterator;
-  cls.closure = closure;
-  if (local == YES) {
-    ret = ECRS_listNamespaces(&localListNamespaceHelper,
-                             &cls);
-  } else {
-    char * fn;
-    char * fnBase;
-
-    fn = getConfigurationString("GNUNET", "GNUNET_HOME");
-    fnBase = expandFileName(fn);
-    FREE(fn);
-    fn = MALLOC(strlen(fnBase) +
-               strlen(NS_DIR) +
-               4);
-    strcpy(fn, fnBase);
-    FREE(fnBase);
-    strcat(fn, DIR_SEPARATOR_STR);
-    strcat(fn, NS_DIR);
-    mkdirp(fn);
-    ret = scanDirectory(fn,
-                       &listNamespaceHelper,
-                       &cls);
-    FREE(fn);
-  }
-  return ret;
-}
-
-/**
- * Get the filename (or directory name) for the given
- * namespace and content identifier.
- * @param lastId maybe NULL
- */
-static char * getUpdateDataFilename(const char * nsname,
-                                   const HashCode512 * lastId) {
-  char * tmp;
-  char * ret;
-
-  ret = getConfigurationString("GNUNET", "GNUNET_HOME");
-  tmp = expandFileName(ret);
-  FREE(ret);
-  ret = MALLOC(strlen(tmp) + strlen(NS_UPDATE_DIR) +
-              strlen(nsname) + sizeof(EncName) + 20);
-  strcpy(ret, tmp);
-  FREE(tmp);
-  strcat(ret, DIR_SEPARATOR_STR);
-  strcat(ret, NS_UPDATE_DIR);
-  strcat(ret, nsname);
-  strcat(ret, DIR_SEPARATOR_STR);
-  mkdirp(ret);
-  if (lastId != NULL) {
-    EncName enc;
-
-    hash2enc(lastId, &enc);
-    strcat(ret, (char*) &enc);
-  }
-  return ret;
-}
-
-struct UpdateData {
-  TIME_T updateInterval;
-  TIME_T lastPubTime;
-  HashCode512 nextId;
-  HashCode512 thisId;
-};
-
-/**
- * Read content update information about content
- * published in the given namespace under 'lastId'.
- *
- * @param fi maybe NULL
- * @return OK if update data was found, SYSERR if not.
- */
-static int readUpdateData(const char * nsname,
-                         const HashCode512 * lastId,
-                         HashCode512 * nextId,
-                         ECRS_FileInfo * fi,
-                         TIME_T * updateInterval,
-                         TIME_T * lastPubTime) {
-  char * fn;
-  struct UpdateData * buf;
-  char * uri;
-  unsigned long long size;
-  size_t pos;
-
-  fn = getUpdateDataFilename(nsname,
-                            lastId);
-  if (OK != getFileSize(fn,
-                       &size)) {
-    FREE(fn);
-    return SYSERR;
-  }
-  if ( (size == 0) ||
-       (size <= sizeof(struct UpdateData)) ||
-       (size > 1024 * 1024 * 16) ) {
-    FREE(fn);
-    return SYSERR;
-  }
-
-  buf = MALLOC(size);
-  if (size != readFile(fn,
-                      size,    
-                      buf)) {
-    FREE(buf);
-    FREE(fn);
-    return SYSERR;
-  }
-  FREE(fn);
-  if ( ! equalsHashCode512(lastId,
-                          &buf->thisId)) {
-    FREE(buf);
-    return SYSERR;
-  }
-  uri = (char*) &buf[1];
-  size -= sizeof(struct UpdateData);
-  pos = 0;
-  while ( (pos < size) &&
-         (uri[pos] != '\0') )
-    pos++;
-  pos++;
-  size -= pos;
-  if (size == 0) {
-    FREE(buf);
-    GE_BREAK(ectx, 0);
-    return SYSERR;
-  }
-  if (fi != NULL) {
-    fi->meta = ECRS_deserializeMetaData(&uri[pos],
-                                       size);
-    if (fi->meta == NULL) {
-      FREE(buf);
-      GE_BREAK(ectx, 0);
-      return SYSERR;
-    }
-    fi->uri = ECRS_stringToUri(uri);
-    if (fi->uri == NULL) {
-      ECRS_freeMetaData(fi->meta);
-      fi->meta = NULL;
-      FREE(buf);
-      GE_BREAK(ectx, 0);
-      return SYSERR;
-    }
-  }
-  if (updateInterval != NULL)
-    *updateInterval = ntohl(buf->updateInterval);
-  if (lastPubTime != NULL)
-    *lastPubTime = ntohl(buf->lastPubTime);
-  if (nextId != NULL)
-    *nextId = buf->nextId;
-  FREE(buf);
-  return OK;
-}
-
-/**
- * Write content update information.
- */
-static int writeUpdateData(const char * nsname,
-                          const HashCode512 * thisId,
-                          const HashCode512 * nextId,
-                          const ECRS_FileInfo * fi,
-                          const TIME_T updateInterval,
-                          const TIME_T lastPubTime) {
-  char * fn;
-  char * uri;
-  size_t metaSize;
-  size_t size;
-  struct UpdateData * buf;
-
-  uri = ECRS_uriToString(fi->uri);
-  metaSize = ECRS_sizeofMetaData(fi->meta,
-                                ECRS_SERIALIZE_FULL);
-  size = sizeof(struct UpdateData) + metaSize + strlen(uri) + 1;
-  buf = MALLOC(size);
-  buf->nextId = *nextId;
-  buf->thisId = *thisId;
-  buf->updateInterval = htonl(updateInterval);
-  buf->lastPubTime = htonl(lastPubTime);
-  memcpy(&buf[1],
-        uri,
-        strlen(uri)+1);
-  GE_ASSERT(ectx, metaSize ==
-               ECRS_serializeMetaData(fi->meta,
-                                      &((char*)&buf[1])[strlen(uri)+1],
-                                      metaSize,
-                                      ECRS_SERIALIZE_FULL));
-  FREE(uri);
-  fn = getUpdateDataFilename(nsname,
-                            thisId);
-  writeFile(fn,
-           buf,
-           size,
-           "400"); /* no editing, just deletion */
-  FREE(fn);
-  FREE(buf);
-  return OK;
-}
-                       
-
-/**
- * Compute the next ID for peridodically updated content.
- * @param updateInterval MUST be a peridic interval (not NONE or SPORADIC)
- * @param thisId MUST be known to FSUI
- * @return OK on success, SYSERR on error
- */
-int FSUI_computeNextId(const char * name,
-                      const HashCode512 * lastId,
-                      const HashCode512 * thisId,
-                      TIME_T updateInterval,
-                      HashCode512 * nextId) {
-  HashCode512 delta;
-  cron_t now;
-  TIME_T tnow;
-  TIME_T lastTime;
-  TIME_T ui;
-
-  if ( (updateInterval == ECRS_SBLOCK_UPDATE_SPORADIC) ||
-       (updateInterval == ECRS_SBLOCK_UPDATE_NONE) )
-    return SYSERR;
-
-  if (OK != readUpdateData(name,
-                          lastId,
-                          NULL,
-                          NULL,
-                          &ui,
-                          &lastTime))
-    return SYSERR;
-  deltaId(lastId,
-         thisId,
-         &delta);      
-  now = get_time();
-  TIME(&tnow);
-  *nextId = *thisId;
-  while (lastTime < tnow + updateInterval/2) {
-    lastTime += updateInterval;
-    addHashCodes(nextId,
-                &delta,
-                nextId);
-  }
-  return OK;
-}
-
-
-/**
- * Add an entry into a namespace (also for publishing
- * updates).
- *
- * @param name in which namespace to publish
- * @param updateInterval the desired frequency for updates
- * @param lastId the ID of the last value (maybe NULL)
- * @param thisId the ID of the update (maybe NULL)
- * @param nextId the ID of the next update (maybe NULL)
- * @param dst to which URI should the namespace entry refer?
- * @param md what meta-data should be associated with the
- *        entry?
- * @param uri set to the resulting URI
- */
-struct ECRS_URI *
-FSUI_addToNamespace(struct FSUI_Context * ctx,
-                   unsigned int anonymityLevel,
-                   const char * name,
-                   TIME_T updateInterval,
-                   const HashCode512 * lastId,
-                   const HashCode512 * thisId,
-                   const HashCode512 * nextId,
-                   const struct ECRS_URI * dst,
-                   const struct ECRS_MetaData * md) {
-  TIME_T creationTime;
-  HashCode512 nid;
-  HashCode512 tid;
-  TIME_T now;
-  TIME_T lastTime;
-  TIME_T lastInterval;
-  ECRS_FileInfo fi;
-  char * old;
-  struct ECRS_URI * uri;
-
-  /* computation of IDs of update(s).  Not as terrible as
-     it looks, just enumerating all of the possible cases
-     of periodic/sporadic updates and how IDs are computed. */
-  creationTime = TIME(&now);
-  if (updateInterval != ECRS_SBLOCK_UPDATE_NONE) {
-    if ( (lastId != NULL) &&
-        (OK == readUpdateData(name,
-                              lastId,
-                              &tid,
-                              NULL,
-                              &lastInterval,
-                              &lastTime)) ) {
-      if (lastInterval != updateInterval) {
-       GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
-           _("Publication interval for periodic publication changed."));
-      }
-      /* try to compute tid and/or
-        nid based on information read from lastId */
-
-      if (updateInterval != ECRS_SBLOCK_UPDATE_SPORADIC) {
-       HashCode512 delta;
-
-       deltaId(lastId,
-               &tid,
-               &delta);        
-
-       creationTime = lastTime + updateInterval;
-       while (creationTime < now - updateInterval) {
-         creationTime += updateInterval;
-         addHashCodes(&tid,
-                      &delta,
-                      &tid);
-       }
-       if (creationTime > get_time() + 7 * cronDAYS) {
-         GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
-             _("Publishing update for periodically updated "
-               "content more than a week ahead of schedule.\n"));
-       }
-       if (thisId != NULL)
-         tid = *thisId; /* allow override! */
-       addHashCodes(&tid,
-                    &delta,
-                    &nid);
-       if (nextId != NULL)
-         nid = *nextId; /* again, allow override */
-      } else {
-       /* sporadic ones are unpredictable,
-          tid has been obtained from IO, pick random nid if
-          not specified */
-       if (thisId != NULL)
-         tid = *thisId; /* allow user override */      
-       if (nextId == NULL) {
-         makeRandomId(&nid);
-       } else {
-         nid = *nextId;
-       }
-      }
-    } else { /* no previous ID found or given */
-      if (nextId == NULL) {
-       /* no previous block found and nextId not specified;
-          pick random nid */
-       makeRandomId(&nid);
-      } else {
-       nid = *nextId;
-      }
-      if (thisId != NULL) {
-       tid = *thisId;
-      } else {
-       makeRandomId(&tid);
-      }
-    }
-  } else {
-    if (thisId != NULL) {
-      nid = tid = *thisId;
-    } else {
-      makeRandomId(&tid);
-      nid = tid;
-    }
-  }
-  uri = ECRS_addToNamespace(name,
-                           anonymityLevel,
-                           getConfigurationInt("FS", "INSERT-PRIORITY"),
-                           getConfigurationInt("FS",
-                                               "INSERT-EXPIRATION")
-                           * cronYEARS + get_time(),
-                           creationTime,
-                           updateInterval,
-                           &tid,
-                           &nid,
-                           dst,
-                           md);
-  if (uri != NULL) {
-    if (updateInterval != ECRS_SBLOCK_UPDATE_NONE) {
-      fi.uri = uri;
-      fi.meta = (struct ECRS_MetaData*) md;
-      writeUpdateData(name,
-                     &tid,
-                     &nid,
-                     &fi,
-                     updateInterval,
-                     creationTime);
-    }
-    if (lastId != NULL) {
-      old = getUpdateDataFilename(name,
-                                 lastId);
-      UNLINK(old);
-      FREE(old);
-    }
-  }
-  return uri;
-}
-
-struct lNCC {
-  const char * name;
-  FSUI_UpdateIterator it;
-  void * closure;
-  int cnt;
-};
-
-static int lNCHelper(const char * fil,
-                    const char * dir,
-                    void * ptr) {
-  struct lNCC * cls = ptr;
-  ECRS_FileInfo fi;
-  HashCode512 lastId;
-  HashCode512 nextId;
-  TIME_T pubFreq;
-  TIME_T lastTime;
-  TIME_T nextTime;
-  TIME_T now;
-
-  if (OK != enc2hash(fil,
-                    &lastId)) {
-    GE_BREAK(ectx, 0);
-    return OK;
-  }
-  fi.uri = NULL;
-  fi.meta = NULL;
-  if (OK != readUpdateData(cls->name,
-                          &lastId,
-                          &nextId,
-                          &fi,
-                          &pubFreq,
-                          &lastTime)) {
-    GE_BREAK(ectx, 0);
-    return OK;
-  }
-  cls->cnt++;
-  if (pubFreq == ECRS_SBLOCK_UPDATE_SPORADIC) {
-    nextTime = 0;
-  } else {
-    TIME(&now);
-    nextTime = lastTime;
-    if ( (nextTime + pubFreq < now) &&
-           (nextTime + pubFreq > nextTime) )
-      nextTime += pubFreq * ((now - nextTime) / pubFreq);  
-  }
-  if (cls->it != NULL) {
-    if (OK != cls->it(cls->closure,
-                     &fi,
-                     &lastId,
-                     &nextId,
-                     pubFreq,
-                     nextTime)) {
-      ECRS_freeUri(fi.uri);
-      ECRS_freeMetaData(fi.meta);
-      return SYSERR;
-    }
-  }
-  ECRS_freeUri(fi.uri);
-  ECRS_freeMetaData(fi.meta);
-  return OK;
-}
-
-/**
- * List all updateable content in a given namespace.
- */
-int FSUI_listNamespaceContent(struct FSUI_Context * ctx,
-                             const char * name,
-                             FSUI_UpdateIterator iterator,
-                             void * closure) {
-  struct lNCC cls;
-  char * dirName;
-
-  cls.name = name;
-  cls.it = iterator;
-  cls.closure = closure;
-  cls.cnt = 0;
-  dirName = getUpdateDataFilename(name,
-                                 NULL);
-  mkdirp(dirName);
-  if (SYSERR == scanDirectory(dirName,
-                             &lNCHelper,
-                             &cls)) {
-    FREE(dirName);
-    return SYSERR;
-  }
-  FREE(dirName);
-  return cls.cnt;
-}
-
-static int mergeMeta(EXTRACTOR_KeywordType type,
-                    const char * data,
-                    void * cls) {
-  struct ECRS_MetaData * meta = cls;
-  ECRS_addToMetaData(meta,
-                    type,
-                    data);
-  return OK;
-}
-
-/**
- * Add a namespace to the set of known namespaces.
- * For all namespace advertisements that we discover
- * FSUI should automatically call this function.
- *
- * @param ns the namespace identifier
- */
-void FSUI_addNamespaceInfo(const struct ECRS_URI * uri,
-                          const struct ECRS_MetaData * meta) {
-  char * name;
-  int ranking;
-  struct ECRS_MetaData * old;
-  HashCode512 id;
-
-  if (! ECRS_isNamespaceUri(uri)) {
-    GE_BREAK(ectx, 0);
-    return;
-  }
-  ECRS_getNamespaceId(uri,
-                     &id);
-  name = ECRS_getNamespaceName(&id);
-  if (name == NULL)
-    return;
-  ranking = 0;
-  if (OK == readNamespaceInfo(name,
-                             &old,
-                             &ranking)) {
-    ECRS_getMetaData(meta,
-                    &mergeMeta,
-                    old);
-    writeNamespaceInfo(name,
-                      old,
-                      ranking);
-    ECRS_freeMetaData(old);
-  } else {
-    writeNamespaceInfo(name,
-                      meta,
-                      ranking);
-  }
-  FREE(name);
-}
-
-
-/**
- * Get the root of the namespace (if we have one).
- * @return SYSERR on error, OK on success
- */
-int FSUI_getNamespaceRoot(const char * ns,
-                         HashCode512 * root) {
-  char * fn;
-  char * fnBase;
-  int ret;
-
-  fn = getConfigurationString("GNUNET", "GNUNET_HOME");
-  fnBase = expandFileName(fn);
-  FREE(fn);
-  fn = MALLOC(strlen(fnBase) +
-             strlen(NS_ROOTS) +
-             strlen(ns) +
-             6);
-  strcpy(fn, fnBase);
-  strcat(fn, DIR_SEPARATOR_STR);
-  strcat(fn, NS_ROOTS);
-  mkdirp(fn);
-  strcat(fn, DIR_SEPARATOR_STR);
-  strcat(fn, ns);
-  FREE(fnBase);
-  if (sizeof(HashCode512)
-      == readFile(fn, sizeof(HashCode512), root))
-    ret = OK;
-  else
-    ret = SYSERR;
-  FREE(fn);
-  return ret;
-}
-
-
-/* end of namespace_info.c */

Deleted: GNUnet/src/applications/fs/fsui/namespace_infotest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/namespace_infotest.c        2006-08-13 
03:45:47 UTC (rev 3223)
+++ GNUnet/src/applications/fs/fsui/namespace_infotest.c        2006-08-13 
19:32:06 UTC (rev 3224)
@@ -1,148 +0,0 @@
-/*
-     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/fsui/namespace_infotest.c
- * @brief testcase for namespace_info.c
- * @author Christian Grothoff
- */
-
-#include "platform.h"
-#include "gnunet_util.h"
-#include "gnunet_ecrs_lib.h"
-#include "gnunet_fsui_lib.h"
-
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
-
-static int parseCommandLine(int argc,
-                           char * argv[]) {
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "_MAGIC_",
-                                    "NO"));
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "LOGFILE",
-                                    NULL));
-  FREENONNULL(setConfigurationString("GNUNET",
-                                    "LOGLEVEL",
-                                    "NOTHING"));
-  FREENONNULL(setConfigurationString("GNUNET",
-                                    "GNUNETD-CONFIG",
-                                    "check.conf"));
-  FREENONNULL(setConfigurationString("GNUNET",
-                                    "GNUNET_HOME",
-                                    "/tmp/gnunet-namespace-infotest"));
-  return OK;
-}
-
-
-static void eventCallback(void * cls,
-                         const FSUI_Event * event) {
-}
-
-
-int main(int argc, char * argv[]){
-  pid_t daemon;
-  int ok;
-  struct ECRS_URI * uri = NULL;
-  struct ECRS_URI * euri = NULL;
-  struct ECRS_MetaData * meta = NULL;
-  HashCode512 root;
-  int old;
-  int newVal;
-  struct FSUI_Context * ctx;
-
-  if (OK != initUtil(argc,
-                    argv,
-                    &parseCommandLine))
-    return -1;
-  daemon = startGNUnetDaemon(NO);
-  GE_ASSERT(ectx, daemon > 0);
-  ok = YES;
-  startCron();
-  GE_ASSERT(ectx, OK == waitForGNUnetDaemonRunning(2 * cronMINUTES));
-  ECRS_deleteNamespace("test");
-  PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
-
-  /* ACTUAL TEST CODE */
-  ctx = FSUI_start("namespace_infotest",
-                  NO,
-                  &eventCallback,
-                  NULL);
-  CHECK(ctx != NULL);
-  old = FSUI_listNamespaces(ctx,
-                           YES,
-                           NULL,
-                           NULL);
-                               
-  meta = ECRS_createMetaData();
-  ECRS_addToMetaData(meta,
-                    0,
-                    "test");
-  makeRandomId(&root);
-  uri = FSUI_createNamespace(ctx,
-                            1,
-                            "test",
-                            meta,
-                            NULL,
-                            &root);
-  CHECK(uri != NULL);
-  CHECK(old + 1 == FSUI_listNamespaces(ctx,
-                                      YES,
-                                      NULL,
-                                      NULL));
-  old = FSUI_listNamespaceContent(ctx,
-                                 "test",
-                                 NULL,
-                                 NULL);
-  euri = FSUI_addToNamespace(ctx,
-                            1,
-                            "test",
-                            42,
-                            NULL,
-                            &root,
-                            NULL,
-                            uri,
-                            meta);
-  CHECK(euri != NULL);
-  newVal = FSUI_listNamespaceContent(ctx,
-                                    "test",
-                                    NULL,
-                                    NULL);
-  CHECK(old + 1 == newVal);
-  CHECK(OK == ECRS_deleteNamespace("test"));
-  /* END OF TEST CODE */
- FAILURE:
-  if (ctx != NULL)
-    FSUI_stop(ctx);
-  if (uri != NULL)
-    ECRS_freeUri(uri);
-  if (euri != NULL)
-    ECRS_freeUri(euri);
-  if (meta != NULL)
-    ECRS_freeMetaData(meta);
-  ECRS_deleteNamespace("test");
-  stopCron();
-  GE_ASSERT(ectx, OK == stopGNUnetDaemon());
-  GE_ASSERT(ectx, OK == waitForGNUnetDaemonTermination(daemon));
-  doneUtil();
-  return (ok == YES) ? 0 : 1;
-}
-
-/* end of namespace_infotest.c */

Added: GNUnet/src/applications/fs/namespace/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/namespace/Makefile.am    2006-08-13 03:45:47 UTC 
(rev 3223)
+++ GNUnet/src/applications/fs/namespace/Makefile.am    2006-08-13 19:32:06 UTC 
(rev 3224)
@@ -0,0 +1,24 @@
+INCLUDES = -I$(top_srcdir)/src/include
+
+lib_LTLIBRARIES = \
+  libgnunetnamespace.la 
+
+libgnunetnamespace_la_SOURCES = \
+  namespace_info.c 
+libgnunetnamespace_la_LIBADD = \
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+ $(top_builddir)/src/util/libgnunetutil.la 
+
+check_PROGRAMS = \
+  namespace_infotest
+
+TESTS = $(check_PROGRAMS)
+
+namespace_infotest_SOURCES = \
+  namespace_infotest.c 
+namespace_infotest_LDADD = \
+  $(top_builddir)/src/applications/fs/namespace/libgnunetnamespace.la \
+  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+  $(top_builddir)/src/util/libgnunetutil.la 
+
+

Copied: GNUnet/src/applications/fs/namespace/namespace_info.c (from rev 3223, 
GNUnet/src/applications/fs/fsui/namespace_info.c)
===================================================================
--- GNUnet/src/applications/fs/fsui/namespace_info.c    2006-08-13 03:45:47 UTC 
(rev 3223)
+++ GNUnet/src/applications/fs/namespace/namespace_info.c       2006-08-13 
19:32:06 UTC (rev 3224)
@@ -0,0 +1,857 @@
+/*
+     This file is part of GNUnet
+     (C) 2003, 2004, 2005, 2006 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/namespace/namespace_info.c
+ * @brief keeping track of namespaces.  This module
+ *  is supposed to keep track of other namespaces (and
+ *  their advertisments), as well as of our own namespaces
+ *  and the updateable content stored therein.
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_fsui_lib.h"
+#include "fsui.h"
+
+#define NS_DIR "data" DIR_SEPARATOR_STR "namespaces" DIR_SEPARATOR_STR
+#define NS_UPDATE_DIR "data" DIR_SEPARATOR_STR "namespace-updates" 
DIR_SEPARATOR_STR
+#define NS_ROOTS "data" DIR_SEPARATOR_STR "namespace-root" DIR_SEPARATOR_STR
+
+static void writeNamespaceInfo(const char * namespaceName,
+                              const struct ECRS_MetaData * meta,
+                              int ranking) {
+  unsigned int size;
+  unsigned int tag;
+  char * buf;
+  char * fn;
+  char * fnBase;
+
+  fn = getConfigurationString("GNUNET", "GNUNET_HOME");
+  fnBase = expandFileName(fn);
+  FREE(fn);
+  fn = MALLOC(strlen(fnBase) +
+             strlen(NS_DIR) +
+             strlen(namespaceName) +
+             6);
+  strcpy(fn, fnBase);
+  strcat(fn, DIR_SEPARATOR_STR);
+  strcat(fn, NS_DIR);
+  mkdirp(fn);
+  strcat(fn, DIR_SEPARATOR_STR);
+  strcat(fn, namespaceName);
+  FREE(fnBase);
+
+  size = ECRS_sizeofMetaData(meta,
+                            ECRS_SERIALIZE_FULL);
+  tag = size + sizeof(int);
+  buf = MALLOC(tag);
+  ((int *) buf)[0] = htonl(ranking); /* ranking */
+  GE_ASSERT(ectx, size == ECRS_serializeMetaData(meta,
+                                              &buf[sizeof(int)],
+                                              size,
+                                              ECRS_SERIALIZE_FULL));
+  writeFile(fn,
+           buf,
+           tag,
+           "660");
+  FREE(fn);
+  FREE(buf);
+}
+
+static int readNamespaceInfo(const char * namespaceName,
+                            struct ECRS_MetaData ** meta,
+                            int * ranking) {
+  unsigned long long len;
+  unsigned int size;
+  char * buf;
+  char * fn;
+  char * fnBase;
+
+  *meta = NULL;
+  fn = getConfigurationString("GNUNET", "GNUNET_HOME");
+  fnBase = expandFileName(fn);
+  FREE(fn);
+  fn = MALLOC(strlen(fnBase) +
+             strlen(NS_DIR) +
+             strlen(namespaceName) +
+             6);
+  strcpy(fn, fnBase);
+  strcat(fn, DIR_SEPARATOR_STR);
+  strcat(fn, NS_DIR);
+  mkdirp(fn);
+  strcat(fn, DIR_SEPARATOR_STR);
+  strcat(fn, namespaceName);
+  FREE(fnBase);
+
+  if (OK != getFileSize(fn,
+                       &len)) {
+    FREE(fn);
+    return SYSERR;
+  }
+  if (len <= sizeof(int)) {
+    FREE(fn);
+    return SYSERR;
+  }
+  if (len > 16 * 1024 * 1024) {
+    /* too big, must be invalid! remove! */
+    GE_BREAK(ectx, 0);
+    UNLINK(fn);
+    FREE(fn);
+    return SYSERR;
+  }
+  buf = MALLOC(len);
+  if (len != readFile(fn,
+                     len,
+                     buf)) {
+    FREE(buf);
+    FREE(fn);
+    return SYSERR;
+  }
+
+  size = len - sizeof(int);
+  *ranking = ntohl(((int *) buf)[0]);
+  *meta = ECRS_deserializeMetaData(&buf[sizeof(int)],
+                                  size);
+  if ((*meta) == NULL) {
+    /* invalid data! remove! */
+    GE_BREAK(ectx, 0);
+    UNLINK(fn);
+    FREE(buf);
+    FREE(fn);
+    return SYSERR;
+  }
+  FREE(fn);
+  FREE(buf);
+  return OK;
+}
+                                       
+
+/**
+ * Create a new namespace (and publish an advertismement).
+ * This function is synchronous, but may block the system
+ * for a while since it must create a public-private key pair!
+ *
+ * @param meta meta-data about the namespace (maybe NULL)
+ * @return URI on success, NULL on error (namespace already exists)
+ */
+struct ECRS_URI *
+NAMESPACE_createNamespace(struct NAMESPACE_Context * ctx,
+                         unsigned int anonymityLevel,
+                         const char * namespaceName,
+                         const struct ECRS_MetaData * meta,
+                         const struct ECRS_URI * advertisementURI,
+                         const HashCode512 * rootEntry) {
+  struct ECRS_URI * ret;
+
+  ret = ECRS_createNamespace(namespaceName,
+                            meta,
+                            anonymityLevel,
+                            getConfigurationInt("FS", "INSERT-PRIORITY"),
+                            getConfigurationInt("FS",
+                                                "INSERT-EXPIRATION")
+                            * cronYEARS + get_time(),
+                            advertisementURI,
+                            rootEntry);
+  /* store binding of namespaceName to 'meta' in state DB! */
+  if (ret != NULL) {
+    HashCode512 id;
+    char * name;
+
+    ECRS_getNamespaceId(ret,
+                       &id);
+    name = ECRS_getNamespaceName(&id);
+    writeNamespaceInfo(name,
+                      meta,
+                      0);
+    FREE(name);
+  }
+  return ret;
+}
+
+/**
+ * Change the ranking of a (non-local) namespace.
+ *
+ * @param ns the name of the namespace, as obtained
+ *  from ECRS_getNamespaceName
+ * @param delta by how much should the rating be
+ *  changed?
+ * @return new rating of the namespace
+ */
+int NAMESPACE_rankNamespace(struct NAMESPACE_Context * ctx,
+                      const char * ns,
+                      int delta) {
+  struct ECRS_MetaData * meta;
+  int ret;
+  int ranking;
+
+  ret = readNamespaceInfo(ns,
+                         &meta,
+                         &ranking);
+  if (ret == SYSERR) {
+    ranking = 0;
+    meta = ECRS_createMetaData();
+  }
+  ranking += delta;
+  writeNamespaceInfo(ns,
+                    meta,
+                    ranking);
+  ECRS_freeMetaData(meta);
+  return ranking;
+}
+
+typedef struct {
+  NAMESPACE_NamespaceIterator iterator;
+  void * closure;
+} LNClosure;
+
+static int localListNamespaceHelper(const HashCode512 * nsid,
+                                   const char * name,
+                                   void * cls) {
+  LNClosure * c = cls;
+  int ret;
+  struct ECRS_MetaData * meta;
+  int rating;
+
+  meta = NULL;
+  rating = 0;
+  readNamespaceInfo(name,
+                   &meta,
+                   &rating);
+  if (meta == NULL)
+    meta = ECRS_createMetaData();
+  if (c->iterator != NULL) {
+    ret = c->iterator(c->closure,
+                     name,
+                     nsid,
+                     meta,
+                     rating);
+  } else
+    ret = OK;
+  ECRS_freeMetaData(meta);
+  return ret;
+}
+
+static int listNamespaceHelper(const char * fn,
+                              const char * dirName,
+                              void * cls) {
+  LNClosure * c = cls;
+  int ret;
+  struct ECRS_MetaData * meta;
+  int rating;
+  HashCode512 id;
+
+  if (OK != enc2hash(fn,
+                    &id))
+    return OK; /* invalid name */
+  if (OK != readNamespaceInfo(fn,
+                             &meta,
+                             &rating))
+    return OK; /* ignore entry */
+  if (c->iterator != NULL) {
+    ret = c->iterator(c->closure,
+                     fn,
+                     &id,
+                     meta,
+                     rating);
+  } else
+    ret = OK;
+  ECRS_freeMetaData(meta);
+  return OK;
+}
+
+/**
+ * List all available (local or non-local) namespaces.
+ *
+ * @param local only list local namespaces (if NO, only
+ *   non-local known namespaces are listed)
+ */
+int NAMESPACE_listNamespaces(struct NAMESPACE_Context * ctx,
+                       int local,
+                       NAMESPACE_NamespaceIterator iterator,
+                       void * closure) {
+  LNClosure cls;
+  int ret;
+
+  cls.iterator = iterator;
+  cls.closure = closure;
+  if (local == YES) {
+    ret = ECRS_listNamespaces(&localListNamespaceHelper,
+                             &cls);
+  } else {
+    char * fn;
+    char * fnBase;
+
+    fn = getConfigurationString("GNUNET", "GNUNET_HOME");
+    fnBase = expandFileName(fn);
+    FREE(fn);
+    fn = MALLOC(strlen(fnBase) +
+               strlen(NS_DIR) +
+               4);
+    strcpy(fn, fnBase);
+    FREE(fnBase);
+    strcat(fn, DIR_SEPARATOR_STR);
+    strcat(fn, NS_DIR);
+    mkdirp(fn);
+    ret = scanDirectory(fn,
+                       &listNamespaceHelper,
+                       &cls);
+    FREE(fn);
+  }
+  return ret;
+}
+
+/**
+ * Get the filename (or directory name) for the given
+ * namespace and content identifier.
+ * @param lastId maybe NULL
+ */
+static char * getUpdateDataFilename(const char * nsname,
+                                   const HashCode512 * lastId) {
+  char * tmp;
+  char * ret;
+
+  ret = getConfigurationString("GNUNET", "GNUNET_HOME");
+  tmp = expandFileName(ret);
+  FREE(ret);
+  ret = MALLOC(strlen(tmp) + strlen(NS_UPDATE_DIR) +
+              strlen(nsname) + sizeof(EncName) + 20);
+  strcpy(ret, tmp);
+  FREE(tmp);
+  strcat(ret, DIR_SEPARATOR_STR);
+  strcat(ret, NS_UPDATE_DIR);
+  strcat(ret, nsname);
+  strcat(ret, DIR_SEPARATOR_STR);
+  mkdirp(ret);
+  if (lastId != NULL) {
+    EncName enc;
+
+    hash2enc(lastId, &enc);
+    strcat(ret, (char*) &enc);
+  }
+  return ret;
+}
+
+struct UpdateData {
+  TIME_T updateInterval;
+  TIME_T lastPubTime;
+  HashCode512 nextId;
+  HashCode512 thisId;
+};
+
+/**
+ * Read content update information about content
+ * published in the given namespace under 'lastId'.
+ *
+ * @param fi maybe NULL
+ * @return OK if update data was found, SYSERR if not.
+ */
+static int readUpdateData(const char * nsname,
+                         const HashCode512 * lastId,
+                         HashCode512 * nextId,
+                         ECRS_FileInfo * fi,
+                         TIME_T * updateInterval,
+                         TIME_T * lastPubTime) {
+  char * fn;
+  struct UpdateData * buf;
+  char * uri;
+  unsigned long long size;
+  size_t pos;
+
+  fn = getUpdateDataFilename(nsname,
+                            lastId);
+  if (OK != getFileSize(fn,
+                       &size)) {
+    FREE(fn);
+    return SYSERR;
+  }
+  if ( (size == 0) ||
+       (size <= sizeof(struct UpdateData)) ||
+       (size > 1024 * 1024 * 16) ) {
+    FREE(fn);
+    return SYSERR;
+  }
+
+  buf = MALLOC(size);
+  if (size != readFile(fn,
+                      size,    
+                      buf)) {
+    FREE(buf);
+    FREE(fn);
+    return SYSERR;
+  }
+  FREE(fn);
+  if ( ! equalsHashCode512(lastId,
+                          &buf->thisId)) {
+    FREE(buf);
+    return SYSERR;
+  }
+  uri = (char*) &buf[1];
+  size -= sizeof(struct UpdateData);
+  pos = 0;
+  while ( (pos < size) &&
+         (uri[pos] != '\0') )
+    pos++;
+  pos++;
+  size -= pos;
+  if (size == 0) {
+    FREE(buf);
+    GE_BREAK(ectx, 0);
+    return SYSERR;
+  }
+  if (fi != NULL) {
+    fi->meta = ECRS_deserializeMetaData(&uri[pos],
+                                       size);
+    if (fi->meta == NULL) {
+      FREE(buf);
+      GE_BREAK(ectx, 0);
+      return SYSERR;
+    }
+    fi->uri = ECRS_stringToUri(uri);
+    if (fi->uri == NULL) {
+      ECRS_freeMetaData(fi->meta);
+      fi->meta = NULL;
+      FREE(buf);
+      GE_BREAK(ectx, 0);
+      return SYSERR;
+    }
+  }
+  if (updateInterval != NULL)
+    *updateInterval = ntohl(buf->updateInterval);
+  if (lastPubTime != NULL)
+    *lastPubTime = ntohl(buf->lastPubTime);
+  if (nextId != NULL)
+    *nextId = buf->nextId;
+  FREE(buf);
+  return OK;
+}
+
+/**
+ * Write content update information.
+ */
+static int writeUpdateData(const char * nsname,
+                          const HashCode512 * thisId,
+                          const HashCode512 * nextId,
+                          const ECRS_FileInfo * fi,
+                          const TIME_T updateInterval,
+                          const TIME_T lastPubTime) {
+  char * fn;
+  char * uri;
+  size_t metaSize;
+  size_t size;
+  struct UpdateData * buf;
+
+  uri = ECRS_uriToString(fi->uri);
+  metaSize = ECRS_sizeofMetaData(fi->meta,
+                                ECRS_SERIALIZE_FULL);
+  size = sizeof(struct UpdateData) + metaSize + strlen(uri) + 1;
+  buf = MALLOC(size);
+  buf->nextId = *nextId;
+  buf->thisId = *thisId;
+  buf->updateInterval = htonl(updateInterval);
+  buf->lastPubTime = htonl(lastPubTime);
+  memcpy(&buf[1],
+        uri,
+        strlen(uri)+1);
+  GE_ASSERT(ectx, metaSize ==
+               ECRS_serializeMetaData(fi->meta,
+                                      &((char*)&buf[1])[strlen(uri)+1],
+                                      metaSize,
+                                      ECRS_SERIALIZE_FULL));
+  FREE(uri);
+  fn = getUpdateDataFilename(nsname,
+                            thisId);
+  writeFile(fn,
+           buf,
+           size,
+           "400"); /* no editing, just deletion */
+  FREE(fn);
+  FREE(buf);
+  return OK;
+}
+                       
+
+/**
+ * Compute the next ID for peridodically updated content.
+ * @param updateInterval MUST be a peridic interval (not NONE or SPORADIC)
+ * @param thisId MUST be known to NAMESPACE
+ * @return OK on success, SYSERR on error
+ */
+int NAMESPACE_computeNextId(const char * name,
+                           const HashCode512 * lastId,
+                           const HashCode512 * thisId,
+                           TIME_T updateInterval,
+                           HashCode512 * nextId) {
+  HashCode512 delta;
+  cron_t now;
+  TIME_T tnow;
+  TIME_T lastTime;
+  TIME_T ui;
+
+  if ( (updateInterval == ECRS_SBLOCK_UPDATE_SPORADIC) ||
+       (updateInterval == ECRS_SBLOCK_UPDATE_NONE) )
+    return SYSERR;
+
+  if (OK != readUpdateData(name,
+                          lastId,
+                          NULL,
+                          NULL,
+                          &ui,
+                          &lastTime))
+    return SYSERR;
+  deltaId(lastId,
+         thisId,
+         &delta);      
+  now = get_time();
+  TIME(&tnow);
+  *nextId = *thisId;
+  while (lastTime < tnow + updateInterval/2) {
+    lastTime += updateInterval;
+    addHashCodes(nextId,
+                &delta,
+                nextId);
+  }
+  return OK;
+}
+
+
+/**
+ * Add an entry into a namespace (also for publishing
+ * updates).
+ *
+ * @param name in which namespace to publish
+ * @param updateInterval the desired frequency for updates
+ * @param lastId the ID of the last value (maybe NULL)
+ * @param thisId the ID of the update (maybe NULL)
+ * @param nextId the ID of the next update (maybe NULL)
+ * @param dst to which URI should the namespace entry refer?
+ * @param md what meta-data should be associated with the
+ *        entry?
+ * @param uri set to the resulting URI
+ */
+struct ECRS_URI *
+NAMESPACE_addToNamespace(struct NAMESPACE_Context * ctx,
+                        unsigned int anonymityLevel,
+                        const char * name,
+                        TIME_T updateInterval,
+                        const HashCode512 * lastId,
+                        const HashCode512 * thisId,
+                        const HashCode512 * nextId,
+                        const struct ECRS_URI * dst,
+                        const struct ECRS_MetaData * md) {
+  TIME_T creationTime;
+  HashCode512 nid;
+  HashCode512 tid;
+  TIME_T now;
+  TIME_T lastTime;
+  TIME_T lastInterval;
+  ECRS_FileInfo fi;
+  char * old;
+  struct ECRS_URI * uri;
+
+  /* computation of IDs of update(s).  Not as terrible as
+     it looks, just enumerating all of the possible cases
+     of periodic/sporadic updates and how IDs are computed. */
+  creationTime = TIME(&now);
+  if (updateInterval != ECRS_SBLOCK_UPDATE_NONE) {
+    if ( (lastId != NULL) &&
+        (OK == readUpdateData(name,
+                              lastId,
+                              &tid,
+                              NULL,
+                              &lastInterval,
+                              &lastTime)) ) {
+      if (lastInterval != updateInterval) {
+       GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+           _("Publication interval for periodic publication changed."));
+      }
+      /* try to compute tid and/or
+        nid based on information read from lastId */
+
+      if (updateInterval != ECRS_SBLOCK_UPDATE_SPORADIC) {
+       HashCode512 delta;
+
+       deltaId(lastId,
+               &tid,
+               &delta);        
+
+       creationTime = lastTime + updateInterval;
+       while (creationTime < now - updateInterval) {
+         creationTime += updateInterval;
+         addHashCodes(&tid,
+                      &delta,
+                      &tid);
+       }
+       if (creationTime > get_time() + 7 * cronDAYS) {
+         GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+             _("Publishing update for periodically updated "
+               "content more than a week ahead of schedule.\n"));
+       }
+       if (thisId != NULL)
+         tid = *thisId; /* allow override! */
+       addHashCodes(&tid,
+                    &delta,
+                    &nid);
+       if (nextId != NULL)
+         nid = *nextId; /* again, allow override */
+      } else {
+       /* sporadic ones are unpredictable,
+          tid has been obtained from IO, pick random nid if
+          not specified */
+       if (thisId != NULL)
+         tid = *thisId; /* allow user override */      
+       if (nextId == NULL) {
+         makeRandomId(&nid);
+       } else {
+         nid = *nextId;
+       }
+      }
+    } else { /* no previous ID found or given */
+      if (nextId == NULL) {
+       /* no previous block found and nextId not specified;
+          pick random nid */
+       makeRandomId(&nid);
+      } else {
+       nid = *nextId;
+      }
+      if (thisId != NULL) {
+       tid = *thisId;
+      } else {
+       makeRandomId(&tid);
+      }
+    }
+  } else {
+    if (thisId != NULL) {
+      nid = tid = *thisId;
+    } else {
+      makeRandomId(&tid);
+      nid = tid;
+    }
+  }
+  uri = ECRS_addToNamespace(name,
+                           anonymityLevel,
+                           getConfigurationInt("FS", "INSERT-PRIORITY"),
+                           getConfigurationInt("FS",
+                                               "INSERT-EXPIRATION")
+                           * cronYEARS + get_time(),
+                           creationTime,
+                           updateInterval,
+                           &tid,
+                           &nid,
+                           dst,
+                           md);
+  if (uri != NULL) {
+    if (updateInterval != ECRS_SBLOCK_UPDATE_NONE) {
+      fi.uri = uri;
+      fi.meta = (struct ECRS_MetaData*) md;
+      writeUpdateData(name,
+                     &tid,
+                     &nid,
+                     &fi,
+                     updateInterval,
+                     creationTime);
+    }
+    if (lastId != NULL) {
+      old = getUpdateDataFilename(name,
+                                 lastId);
+      UNLINK(old);
+      FREE(old);
+    }
+  }
+  return uri;
+}
+
+struct lNCC {
+  const char * name;
+  NAMESPACE_UpdateIterator it;
+  void * closure;
+  int cnt;
+};
+
+static int lNCHelper(const char * fil,
+                    const char * dir,
+                    void * ptr) {
+  struct lNCC * cls = ptr;
+  ECRS_FileInfo fi;
+  HashCode512 lastId;
+  HashCode512 nextId;
+  TIME_T pubFreq;
+  TIME_T lastTime;
+  TIME_T nextTime;
+  TIME_T now;
+
+  if (OK != enc2hash(fil,
+                    &lastId)) {
+    GE_BREAK(ectx, 0);
+    return OK;
+  }
+  fi.uri = NULL;
+  fi.meta = NULL;
+  if (OK != readUpdateData(cls->name,
+                          &lastId,
+                          &nextId,
+                          &fi,
+                          &pubFreq,
+                          &lastTime)) {
+    GE_BREAK(ectx, 0);
+    return OK;
+  }
+  cls->cnt++;
+  if (pubFreq == ECRS_SBLOCK_UPDATE_SPORADIC) {
+    nextTime = 0;
+  } else {
+    TIME(&now);
+    nextTime = lastTime;
+    if ( (nextTime + pubFreq < now) &&
+           (nextTime + pubFreq > nextTime) )
+      nextTime += pubFreq * ((now - nextTime) / pubFreq);  
+  }
+  if (cls->it != NULL) {
+    if (OK != cls->it(cls->closure,
+                     &fi,
+                     &lastId,
+                     &nextId,
+                     pubFreq,
+                     nextTime)) {
+      ECRS_freeUri(fi.uri);
+      ECRS_freeMetaData(fi.meta);
+      return SYSERR;
+    }
+  }
+  ECRS_freeUri(fi.uri);
+  ECRS_freeMetaData(fi.meta);
+  return OK;
+}
+
+/**
+ * List all updateable content in a given namespace.
+ */
+int NAMESPACE_listNamespaceContent(struct NAMESPACE_Context * ctx,
+                                  const char * name,
+                                  NAMESPACE_UpdateIterator iterator,
+                                  void * closure) {
+  struct lNCC cls;
+  char * dirName;
+
+  cls.name = name;
+  cls.it = iterator;
+  cls.closure = closure;
+  cls.cnt = 0;
+  dirName = getUpdateDataFilename(name,
+                                 NULL);
+  mkdirp(dirName);
+  if (SYSERR == scanDirectory(dirName,
+                             &lNCHelper,
+                             &cls)) {
+    FREE(dirName);
+    return SYSERR;
+  }
+  FREE(dirName);
+  return cls.cnt;
+}
+
+static int mergeMeta(EXTRACTOR_KeywordType type,
+                    const char * data,
+                    void * cls) {
+  struct ECRS_MetaData * meta = cls;
+  ECRS_addToMetaData(meta,
+                    type,
+                    data);
+  return OK;
+}
+
+/**
+ * Add a namespace to the set of known namespaces.
+ * For all namespace advertisements that we discover
+ * NAMESPACE should automatically call this function.
+ *
+ * @param ns the namespace identifier
+ */
+void NAMESPACE_addNamespaceInfo(const struct ECRS_URI * uri,
+                               const struct ECRS_MetaData * meta) {
+  char * name;
+  int ranking;
+  struct ECRS_MetaData * old;
+  HashCode512 id;
+
+  if (! ECRS_isNamespaceUri(uri)) {
+    GE_BREAK(ectx, 0);
+    return;
+  }
+  ECRS_getNamespaceId(uri,
+                     &id);
+  name = ECRS_getNamespaceName(&id);
+  if (name == NULL)
+    return;
+  ranking = 0;
+  if (OK == readNamespaceInfo(name,
+                             &old,
+                             &ranking)) {
+    ECRS_getMetaData(meta,
+                    &mergeMeta,
+                    old);
+    writeNamespaceInfo(name,
+                      old,
+                      ranking);
+    ECRS_freeMetaData(old);
+  } else {
+    writeNamespaceInfo(name,
+                      meta,
+                      ranking);
+  }
+  FREE(name);
+}
+
+
+/**
+ * Get the root of the namespace (if we have one).
+ * @return SYSERR on error, OK on success
+ */
+int NAMESPACE_getNamespaceRoot(const char * ns,
+                              HashCode512 * root) {
+  char * fn;
+  char * fnBase;
+  int ret;
+
+  fn = getConfigurationString("GNUNET", "GNUNET_HOME");
+  fnBase = expandFileName(fn);
+  FREE(fn);
+  fn = MALLOC(strlen(fnBase) +
+             strlen(NS_ROOTS) +
+             strlen(ns) +
+             6);
+  strcpy(fn, fnBase);
+  strcat(fn, DIR_SEPARATOR_STR);
+  strcat(fn, NS_ROOTS);
+  mkdirp(fn);
+  strcat(fn, DIR_SEPARATOR_STR);
+  strcat(fn, ns);
+  FREE(fnBase);
+  if (sizeof(HashCode512)
+      == readFile(fn, sizeof(HashCode512), root))
+    ret = OK;
+  else
+    ret = SYSERR;
+  FREE(fn);
+  return ret;
+}
+
+
+/* end of namespace_info.c */

Copied: GNUnet/src/applications/fs/namespace/namespace_infotest.c (from rev 
3219, GNUnet/src/applications/fs/fsui/namespace_infotest.c)

Added: GNUnet/src/applications/fs/uritrack/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/uritrack/Makefile.am     2006-08-13 03:45:47 UTC 
(rev 3223)
+++ GNUnet/src/applications/fs/uritrack/Makefile.am     2006-08-13 19:32:06 UTC 
(rev 3224)
@@ -0,0 +1,11 @@
+INCLUDES = -I$(top_srcdir)/src/include
+
+lib_LTLIBRARIES = \
+  libgnuneturitrack.la 
+
+libgnuneturitrack_la_SOURCES = \
+  file_info.c 
+libgnuneturitrack_la_LIBADD = \
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+ $(top_builddir)/src/util/libgnunetutil.la 
+

Copied: GNUnet/src/applications/fs/uritrack/file_info.c (from rev 3219, 
GNUnet/src/applications/fs/fsui/file_info.c)
===================================================================
--- GNUnet/src/applications/fs/fsui/file_info.c 2006-08-12 15:45:04 UTC (rev 
3219)
+++ GNUnet/src/applications/fs/uritrack/file_info.c     2006-08-13 19:32:06 UTC 
(rev 3224)
@@ -0,0 +1,371 @@
+/*
+     This file is part of GNUnet.
+     (C) 2003, 2004, 2006 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/uritrack/file_info.c
+ * @brief Helper functions for keeping track of files for building directories.
+ * @author Christian Grothoff
+ *
+ * The "state" database (see util/state.c) is used to store the toggle
+ * flag. An mmapped file (STATE_NAME) is used to store the actual URIs.
+ * An IPC semaphore is used to guard the access.
+ */
+
+#include "gnunet_directories.h"
+#include "gnunet_util.h"
+#include "gnunet_uritrack_lib.h"
+#include "platform.h"
+
+#define DEBUG_FILE_INFO NO
+
+#define STATE_NAME DIR_SEPARATOR_STR "data" DIR_SEPARATOR_STR "fs_uridb"
+#define TRACK_OPTION "fs_uridb_status"
+
+static struct IPC_SEMAPHORE * createIPC(struct GE_Context * ectx,
+                                       struct GC_Configuration * cfg) {
+  char * basename;
+  char * tmpname;
+  char * ipcName;
+  struct IPC_SEMAPHORE * sem;
+  size_t n;
+
+  GC_get_configuration_value_string(cfg,
+                                   "GNUNET",
+                                   "GNUNET_HOME",
+                                   GNUNET_HOME_DIRECTORY,
+                                   &basename);
+  n = strlen(basename) + 512;
+  tmpname = MALLOC(n);
+  SNPRINTF(tmpname, n, "%s/directory_ipc_lock", basename);
+  ipcName = string_expandFileName(ectx,
+                                 tmpname);
+  FREE(basename);
+  FREE(tmpname);
+  sem = IPC_SEMAPHORE_CREATE(ectx, ipcName, 1);
+  FREE(ipcName);
+  return sem;                          
+}
+
+static char * getUriDbName(struct GE_Context * ectx,
+                          struct GC_Configuration * cfg) {
+  char * new;
+  char * pfx;
+
+  GC_get_configuration_value_string(cfg,
+                                   "GNUNET",
+                                   "GNUNET_HOME",
+                                   GNUNET_HOME_DIRECTORY,
+                                   &pfx);
+  new = MALLOC(strlen(pfx) + strlen(STATE_NAME) + 2);
+  strcpy(new, pfx);
+  strcat(new, "/");
+  strcat(new, STATE_NAME); 
+  FREE(pfx);
+  return new;
+}
+
+static char * getToggleName(struct GE_Context * ectx,
+                           struct GC_Configuration * cfg) {
+  char * new;
+  char * pfx;
+
+  GC_get_configuration_value_string(cfg,
+                                   "GNUNET",
+                                   "GNUNET_HOME",
+                                   GNUNET_HOME_DIRECTORY,
+                                   &pfx);
+  new = MALLOC(strlen(pfx) + strlen(TRACK_OPTION) + 2);
+  strcpy(new, pfx);
+  strcat(new, "/");
+  strcat(new, TRACK_OPTION); 
+  FREE(pfx);
+  return new;
+}
+
+/**
+ * Get the URITRACK URI tracking status.
+ *
+ * @return YES of tracking is enabled, NO if not
+ */
+int URITRACK_trackStatus(struct GE_Context * ectx,
+                        struct GC_Configuration * cfg) {
+  int status;
+  char * tn;
+
+  tn = getToggleName(ectx,
+                    cfg);
+  if ( (sizeof(int) != disk_file_read(ectx,
+                                     tn,
+                                     sizeof(int),
+                                     &status)) ||
+       (ntohl(status) != YES) ) {
+    FREE(tn);
+#if DEBUG_FILE_INFO
+    GE_LOG(ectx, 
+          GE_DEBUG | GE_REQUEST | GE_USER,
+          _("Collecting file identifiers disabled.\n"));
+#endif
+    return NO;
+  } else {
+    FREE(tn);
+    return YES;
+  }
+}
+
+/**
+ * Makes a URI available for directory building.
+ */
+void URITRACK_trackURI(struct GE_Context * ectx,
+                      struct GC_Configuration * cfg,
+                      const ECRS_FileInfo * fi) {
+  struct IPC_SEMAPHORE * sem;
+  char * data;
+  unsigned int size;
+  char * suri;
+  int fh;
+  char * fn;
+
+  if (NO == URITRACK_trackStatus(ectx, cfg))
+    return;
+  size = ECRS_sizeofMetaData(fi->meta,
+                            ECRS_SERIALIZE_FULL);
+  data = MALLOC(size);
+  GE_ASSERT(ectx, size == ECRS_serializeMetaData(ectx,
+                                                fi->meta,
+                                                data,
+                                                size,
+                                                ECRS_SERIALIZE_FULL));
+  size = htonl(size);
+  suri = ECRS_uriToString(fi->uri);
+  sem = createIPC(ectx, cfg);
+  IPC_SEMAPHORE_DOWN(sem, YES);
+  fn = getUriDbName(ectx, cfg);
+  fh = disk_file_open(ectx,
+                     fn, 
+                     O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE, 
+                     S_IRUSR|S_IWUSR);
+  if (fh == -1) {
+    GE_LOG_STRERROR_FILE(ectx,
+                        GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+                        "open",
+                        fn);
+  } else {
+    WRITE(fh, suri, strlen(suri) + 1);
+    WRITE(fh, &size, sizeof(unsigned int));
+    WRITE(fh, data, ntohl(size));
+    CLOSE(fh);
+  }
+  FREE(fn);
+  IPC_SEMAPHORE_UP(sem);
+  IPC_SEMAPHORE_DESTROY(sem);
+  FREE(data);
+  FREE(suri);
+}
+
+/**
+ * Remove all of the root-nodes of a particular type
+ * from the tracking database.
+ */
+void URITRACK_clearTrackedURIS(struct GE_Context * ectx,
+                              struct GC_Configuration * cfg) {
+  struct IPC_SEMAPHORE * sem;
+  char * fn;
+
+  sem = createIPC(ectx, cfg);
+  IPC_SEMAPHORE_DOWN(sem, YES);
+  fn = getUriDbName(ectx, cfg);
+  if (0 != UNLINK(fn))
+    GE_LOG_STRERROR_FILE(ectx,
+                        GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+                        "unlink",
+                        fn);
+  FREE(fn);
+  IPC_SEMAPHORE_UP(sem);
+  IPC_SEMAPHORE_DESTROY(sem);
+}
+
+/**
+ * Toggle tracking URIs.
+ *
+ * @param onOff YES to enable tracking, NO to disable
+ *  disabling tracking
+ */
+void URITRACK_trackURIS(struct GE_Context * ectx,
+                       struct GC_Configuration * cfg,
+                       int onOff) {
+  int o = htonl(onOff);
+  char * tn;
+
+  tn = getToggleName(ectx,
+                    cfg);
+  disk_file_write(ectx,
+                 tn,
+                 &o,
+                 sizeof(int),
+                 "600");
+  FREE(tn);
+}
+
+/**
+ * Iterate over all entries that match the given context
+ * mask.
+ *
+ * @param iterator function to call on each entry, may be NULL
+ * @param closure extra argument to the callback
+ * @return number of entries found
+ */
+int URITRACK_listURIs(struct GE_Context * ectx,
+                     struct GC_Configuration * cfg,
+                     ECRS_SearchProgressCallback iterator, 
+                     void *closure) {
+  struct IPC_SEMAPHORE *sem;
+  int rval;
+  char *result;
+  off_t ret;
+  off_t pos;
+  off_t spos;
+  unsigned int msize;
+  ECRS_FileInfo fi;
+  int fd;
+  char *fn;
+  struct stat buf;
+
+  fn = getUriDbName(ectx, cfg);
+  sem = createIPC(ectx, cfg);
+  IPC_SEMAPHORE_DOWN(sem, YES);
+  if(0 != STAT(fn, &buf)) {
+    IPC_SEMAPHORE_UP(sem);
+    IPC_SEMAPHORE_DESTROY(sem);
+    return 0;                   /* no URI db */
+  }
+  fd = disk_file_open(ectx,
+                     fn, 
+                     O_LARGEFILE | O_RDONLY);
+  if (fd == -1) {
+    IPC_SEMAPHORE_UP(sem);
+    IPC_SEMAPHORE_DESTROY(sem);
+    GE_LOG_STRERROR_FILE(ectx,
+                        GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+                        "open", 
+                        fn);
+    FREE(fn);
+    return SYSERR;              /* error opening URI db */
+  }
+  result = MMAP(NULL,
+               buf.st_size,
+               PROT_READ,
+               MAP_SHARED,
+               fd,
+               0);
+  if (result == MAP_FAILED) {
+    CLOSE(fd);
+    GE_LOG_STRERROR_FILE(ectx,
+                        GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+                        "mmap",
+                        fn);
+    FREE(fn);
+    IPC_SEMAPHORE_UP(sem);
+    IPC_SEMAPHORE_DESTROY(sem);
+    return SYSERR;
+  }
+  ret = buf.st_size;
+  pos = 0;
+  rval = 0;
+  while(pos < ret) {
+    spos = pos;
+    while((spos < ret) && (result[spos] != '\0'))
+      spos++;
+    spos++;                     /* skip '\0' */
+    if((spos + sizeof(int) >= ret) || (spos + sizeof(int) < spos)) {
+      GE_BREAK(ectx, 0);
+      goto FORMATERROR;
+    }
+    fi.uri = ECRS_stringToUri(ectx, 
+                             &result[pos]);
+    if(fi.uri == NULL) {
+      GE_BREAK(ectx, 0);
+      goto FORMATERROR;
+    }
+    memcpy(&msize, &result[spos], sizeof(int));
+    msize = ntohl(msize);
+    spos += sizeof(int);
+    if((spos + msize > ret) || (spos + msize < spos)) {
+      GE_BREAK(ectx, 0);
+      ECRS_freeUri(fi.uri);
+      goto FORMATERROR;
+    }
+    fi.meta = ECRS_deserializeMetaData(ectx,
+                                      &result[spos], msize);
+    if(fi.meta == NULL) {
+      GE_BREAK(ectx, 0);
+      ECRS_freeUri(fi.uri);
+      goto FORMATERROR;
+    }
+    pos = spos + msize;
+    if(iterator != NULL) {
+      if(OK != iterator(&fi, NULL, NO, closure)) {
+        ECRS_freeMetaData(fi.meta);
+        ECRS_freeUri(fi.uri);
+        if(0 != MUNMAP(result, buf.st_size))
+          GE_LOG_STRERROR_FILE(ectx,
+                              GE_ERROR | GE_ADMIN | GE_BULK,
+                              "munmap",
+                              fn);
+        CLOSE(fd);
+        FREE(fn);
+        IPC_SEMAPHORE_UP(sem);
+        IPC_SEMAPHORE_DESTROY(sem);
+        return SYSERR;          /* iteration aborted */
+      }
+    }
+    rval++;
+    ECRS_freeMetaData(fi.meta);
+    ECRS_freeUri(fi.uri);
+  }
+  if(0 != MUNMAP(result, buf.st_size))
+    GE_LOG_STRERROR_FILE(ectx,
+                        GE_ERROR | GE_ADMIN | GE_BULK,
+                        "munmap", 
+                        fn);
+  CLOSE(fd);
+  FREE(fn);
+  IPC_SEMAPHORE_UP(sem);
+  IPC_SEMAPHORE_DESTROY(sem);
+  return rval;
+FORMATERROR:
+  GE_LOG(ectx,
+        GE_WARNING | GE_BULK | GE_USER,
+        _("Deleted corrupt URI database in `%s'."), 
+        STATE_NAME);
+  if(0 != MUNMAP(result, buf.st_size))
+    GE_LOG_STRERROR_FILE(ectx,
+                        GE_ERROR | GE_ADMIN | GE_BULK,
+                        "munmap",
+                        fn);
+  CLOSE(fd);
+  FREE(fn);
+  IPC_SEMAPHORE_UP(sem);
+  IPC_SEMAPHORE_DESTROY(sem);
+  URITRACK_clearTrackedURIS(ectx, cfg);
+  return SYSERR;
+}
+
+
+/* end of file_info.c */

Modified: GNUnet/src/include/Makefile.am
===================================================================
--- GNUnet/src/include/Makefile.am      2006-08-13 03:45:47 UTC (rev 3223)
+++ GNUnet/src/include/Makefile.am      2006-08-13 19:32:06 UTC (rev 3224)
@@ -14,6 +14,7 @@
 gnunetinclude_HEADERS = \
   gnunet_blockstore.h \
   gnunet_bootstrap_service.h \
+  gnunet_collection_lib.h \
   gnunet_core.h \
   gnunet_datastore_service.h \
   gnunet_dht.h \
@@ -29,6 +30,7 @@
   gnunet_getoption_lib.h \
   gnunet_identity_service.h \
   gnunet_kvstore_service.h \
+  gnunet_namespace_lib.h \
   gnunet_pingpong_service.h \
   gnunet_protocols.h \
   gnunet_rpc_service.h \
@@ -41,6 +43,7 @@
   gnunet_traffic_service.h \
   gnunet_transport.h \
   gnunet_transport_service.h \
+  gnunet_uritrack_lib.h \
   gnunet_util.h \
   gnunet_util_common.h \
   gnunet_util_config.h \

Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h        2006-08-13 03:45:47 UTC (rev 
3223)
+++ GNUnet/src/include/gnunet_ecrs_lib.h        2006-08-13 19:32:06 UTC (rev 
3224)
@@ -308,6 +308,45 @@
 struct ECRS_URI * ECRS_dateExpandKeywordUri(const struct ECRS_URI * uri);
 
 /**
+ * Create an ECRS URI from a single user-supplied string of keywords.
+ * The string may contain the reserved word 'AND' to create a boolean
+ * search over multiple keywords.
+ *
+ * @return an ECRS URI for the given keywords, NULL
+ *  if keywords is not legal (i.e. empty).
+ */
+struct ECRS_URI * 
+ECRS_parseCharKeywordURI(struct GE_Context * ectx,
+                        const char * keywords); /* helper.c */
+
+/**
+ * Create an ECRS URI from a user-supplied command line of keywords.
+ * The command line may contain the reserved word 'AND' to create a
+ * boolean search over multiple keywords.
+ *
+ * @return an ECRS URI for the given keywords, NULL
+ *  if keywords is not legal (i.e. empty).
+ */
+struct ECRS_URI * 
+ECRS_parseArgvKeywordURI(struct GE_Context * ectx,
+                        unsigned int argc,
+                        const char ** argv); /* helper.c */
+
+/**
+ * Create an ECRS URI from a user-supplied list of keywords.
+ * The keywords are NOT separated by AND but already
+ * given individually.
+ *
+ * @return an ECRS URI for the given keywords, NULL
+ *  if keywords is not legal (i.e. empty).
+ */
+struct ECRS_URI * 
+ECRS_parseListKeywordURI(struct GE_Context * ectx,
+                        unsigned int num_keywords,
+                        const char ** keywords);
+
+
+/**
  * Test if two URIs are equal.
  */
 int ECRS_equalsUri(const struct ECRS_URI * u1,

Modified: GNUnet/src/include/gnunet_fsui_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fsui_lib.h        2006-08-13 03:45:47 UTC (rev 
3223)
+++ GNUnet/src/include/gnunet_fsui_lib.h        2006-08-13 19:32:06 UTC (rev 
3224)
@@ -84,25 +84,51 @@
  */
 struct FSUI_DownloadList;
 
+struct FSUI_UploadList;
+
+struct FSUI_SearchList;
+
+struct FSUI_UnindexList;
+
 /**
  * @brief types of FSUI events.
+ * 
+ * For the types aborted, error, suspending and complete,
+ * the client MUST free the "cctx" context associated with
+ * the event (if allocated).<p>
+ *
+ * Resume events are issued when operations resume as well
+ * as when they are first initiated!<p>
+ *
+ * Searches "complete" if they time out or the maximum
+ * number of results has been found.
  */
 enum FSUI_EventType {
-  /**
-   * We found a new search result.
-   */
+
   FSUI_search_result,
+  FSUI_search_completed,
+  FSUI_search_aborted,
   FSUI_search_error,
+  FSUI_search_suspending,
+  FSUI_search_resuming,
   FSUI_download_progress,
   FSUI_download_complete,
   FSUI_download_aborted,
   FSUI_download_error,
+  FSUI_download_suspending,
+  FSUI_download_resuming,
   FSUI_upload_progress,
   FSUI_upload_complete,
+  FSUI_upload_aborted,
   FSUI_upload_error,
+  FSUI_upload_suspending,
+  FSUI_upload_resuming,
   FSUI_unindex_progress,
   FSUI_unindex_complete,
+  FSUI_unindex_aborted,
   FSUI_unindex_error,
+  FSUI_unindex_suspending,
+  FSUI_unindex_resuming,
   /**
    * Connection status with gnunetd changed.
    */
@@ -111,201 +137,420 @@
    * Connection status with gnunetd changed.
    */
   FSUI_gnunetd_disconnected,
-  FSUI_download_suspending,
+
 };
 
 /**
+ * @brief Description of a download.  Gives the
+ *  identifier of the download for FSUI and
+ *  the client context.  For downloads that
+ *  are not top-level, also gives the handle
+ *  and client context for the parent download.
+ */
+typedef struct {
+  
+  /**
+   * What file in the download tree are we
+   * refering to?
+   */
+  struct FSUI_DownloadList * pos;
+  
+  void * cctx;
+  
+  /**
+   * What is our parent download in the download tree?
+   * NULL if this is the top-level download.
+   */
+  struct FSUI_DownloadList * ppos;
+  
+  void * pcctx;
+
+} FSUI_DownloadContext;
+
+typedef struct {
+
+  /**
+   * What file in the upload tree are we
+   * refering to?
+   */
+  struct FSUI_UploadList * pos;
+  
+  void * cctx;
+  
+  /**
+   * What is our parent upload in the upload tree?
+   * NULL if this is the top-level upload.
+   */
+  struct FSUI_UploadList * ppos;
+  
+  void * pcctx;
+
+} FSUI_UploadContext;
+
+typedef struct {
+  
+  struct FSUI_SearchList * pos;
+
+  void * cctx;
+
+} FSUI_SearchContext;
+
+typedef struct {
+
+  struct FSUI_UnindexList * pos;
+
+  void * cctx;
+
+} FSUI_UnindexContext;
+
+/**
  * @brief FSUI Event.
  */
 typedef struct {
   enum FSUI_EventType type;
   union {
+
     struct {
+
+      FSUI_SearchContext sc;
+
       /**
        * File-Info of the data that was found.
        */
       ECRS_FileInfo fi;
-     /**
+
+      /**
        * The URI of the search for which data was
        * found.
        */
       struct ECRS_URI * searchURI;
+
     } SearchResult;
+
+
+    struct {
+
+      struct FSUI_SearchList * pos;
+
+    } SearchCompleted;
+
+    struct {
+
+      struct FSUI_SearchList * pos;
+
+    } SearchAborted;
+
+
+    struct {
+
+      FSUI_SearchContext sc;
+
+      char * message;
+
+    } SearchError;
+
+
+    struct {
+
+      FSUI_SearchContext sc;
+
+    } SearchSuspending;
+
+
+    struct {
+
+      FSUI_SearchContext sc;
+
+      ECRS_FileInfo * fis;
+
+      unsigned int fisSize;
+
+      unsigned int anonymityLevel;
+
+      struct ECRS_URI * searchURI;
+
+    } SearchResuming;
+
+
     /**
      * Download Progress information.  Also used
      * for download_completed event.
      */
     struct {
+
+      FSUI_DownloadContext dc;
+
       /**
        * How far are we?
        */
       unsigned long long completed;
+
       /**
        * How large is the total download (as far
        * as known so far).
        */
       unsigned long long total;
+
       /**
        * Offset of the last block obtained.
        */
       unsigned long long last_offset;
+
       /**
-       * The last block (in plaintext)
+       * Estimated completion time.
        */
-      const void * last_block;
+      cron_t eta;
+
       /**
-       * Size of the last block
-       */
-      unsigned int last_size;
-      /**
        * Information about the download.
        */
       char * filename;
+
       /**
        * Original URI.
        */
       struct ECRS_URI * uri;
+
       /**
-       * Estimated completion time.
+       * The last block (in plaintext)
        */
-      cron_t eta;
+      const void * last_block;
+
       /**
-       * Start time.
+       * Size of the last block
        */
-      cron_t start_time;
-      /**
-       * Is this (part of) a recursive download?
-       */
-      int is_recursive;
-      /**
-       * If the download is recursive, what is the
-       * main file? (otherwise equal to filename);
-       */
-      char * main_filename;
-      /**
-       * If the download is recursive, what is the
-       * main URI? (otherwise equal to uri);
-       */
-      struct ECRS_URI * main_uri;
-      /**
-       * What file in the download tree are we
-       * refering to?
-       */
-      struct FSUI_DownloadList * pos;
+      unsigned int last_size;
+
     } DownloadProgress;
-    /**
-     * DownloadError is used for both
-     * download_aborted and download_error
-     * message types.
-     */
+
+
     struct {
+
+      FSUI_DownloadContext dc;
+
       /**
        * Error message.
        */
       const char * message;
-      /**
-       * What file in the download tree are we
-       * refering to?
-       */
-      struct FSUI_DownloadList * pos;
+
     } DownloadError;
+
+
     struct {
+
+      FSUI_DownloadContext dc;
+
+    } DownloadAborted;
+
+
+    struct {
+
+      FSUI_DownloadContext dc;
+
+    } DownloadSuspending;
+
+
+    struct {
+
+      FSUI_DownloadContext dc;
+
       /**
-       * How far are we? (for the current file)
+       * How far are we?
        */
       unsigned long long completed;
+
       /**
-       * How large is the total upload (for the current file)
+       * How large is the total download (as far
+       * as known so far).
        */
       unsigned long long total;
+
       /**
-       * Information about the upload.
+       * Estimated completion time.
        */
-      char * filename;
-      /**
-       * Estimated completion time (for the current file)
-       */
       cron_t eta;
+
       /**
-       * How far are we? (for the recursive upload)
+       * Information about the download.
        */
-      unsigned long long main_completed;
+      char * filename;
+
+      unsigned int anonymityLevel;
+
       /**
-       * How large is the total upload (for the recursive upload)
+       * Original URI.
        */
-      unsigned long long main_total;
+      struct ECRS_URI * uri;
+
+    } DownloadResuming;
+
+
+    struct {
+
+      FSUI_UploadContext uc;
+
       /**
-       * Estimated completion time (for the recursive upload)
+       * How far are we? (for the current file)
        */
-      cron_t main_eta;
+      unsigned long long completed;
+
       /**
-       * Start time.
+       * How large is the total upload (for the current file)
        */
-      cron_t start_time;
+      unsigned long long total;
+
       /**
-       * Is this (part of) a recursive upload?
+       * Estimated completion time (for the current file)
        */
-      int is_recursive;
+      cron_t eta;
+
       /**
-       * If the download is recursive, what is the
-       * main file? (otherwise equal to filename);
+       * Information about the upload.
        */
-      char * main_filename;
+      char * filename;
+
     } UploadProgress;
+
+
     struct {
+
+      FSUI_UploadContext uc;
+
       /**
        * How large is the total upload.
        */
       unsigned long long total;
-      /**
-       * How much has been done so far.
-       */
-      unsigned long long completed;
 
       /**
        * Which file was uploaded?
        */
       char * filename;
+
       /**
        * URI of the uploaded file.
        */
       struct ECRS_URI * uri;
+
+    } UploadComplete;
+
+
+    struct {
+
+      FSUI_UploadContext uc;
+
+    } UploadAborted;
+
+
+    struct {
+
+      FSUI_UploadContext uc;
+
+      char * message;
+
+    } UploadError;
+
+
+    struct {
+
+      FSUI_UploadContext uc;
+
+    } UploadSuspending;
+
+
+    struct {
+
+      FSUI_UploadContext uc;
+
       /**
-       * Estimated completion time for the entire
-       * upload (!= now only for recursive uploads).
+       * How far are we? (for the current file)
        */
-      cron_t eta;
+      unsigned long long completed;
+
       /**
-       * Start time.
+       * How large is the total upload (for the current file)
        */
-      cron_t start_time;
+      unsigned long long total;
+
       /**
-       * Is this (part of) a recursive upload?
+       * Estimated completion time (for the current file)
        */
-      int is_recursive;
+      cron_t eta;
+
+      unsigned int anonymityLevel;
+
       /**
-       * If the download is recursive, what is the
-       * main file? (otherwise equal to filename);
+       * Information about the upload.
        */
-      char * main_filename;
-    } UploadComplete;
+      char * filename;
+
+    } UploadResuming;
+
+
     struct {
+
+      FSUI_UnindexContext uc;
+
       unsigned long long total;
+
       unsigned long long completed;
+
       cron_t eta;
+
       char * filename;
-      cron_t start_time;
+
     } UnindexProgress;
+
+
     struct {
+
+      FSUI_UnindexContext uc;
+
       unsigned long long total;
+
       char * filename;
-      cron_t start_time;
+
     } UnindexComplete;
-    /**
-     * Used for errors.
-     */
-    char * message;
+
+
+    struct {
+
+      FSUI_UnindexContext uc;
+
+    } UnindexAborted;
+
+
+    struct {
+
+      FSUI_UnindexContext uc;
+
+    } UnindexSuspending;
+
+
+    struct {
+
+      FSUI_UnindexContext uc;
+      
+      unsigned long long total;
+
+      unsigned long long completed;
+
+      cron_t eta;
+
+      char * filename;
+
+    } UnindexResuming;
+
+
+    struct {
+
+      FSUI_UnindexContext uc;
+
+      char * message;
+
+    } UnindexError;    
+
   } data;
+
 } FSUI_Event;
 
 /**
@@ -316,73 +561,18 @@
 /**
  * Generic callback for all kinds of FSUI progress and error messages.
  * This function will be called for download progress, download
- * completion, upload progress and completion, search results, etc.
+ * completion, upload progress and completion, search results, etc.<p>
  *
  * The details of the argument format are yet to be defined.  What
  * FSUI guarantees is that only one thread at a time will call the
- * callback (so it need not be re-entrant).
- */
-typedef void (*FSUI_EventCallback)(void * cls,
-                                  const FSUI_Event * event);
-
-/**
- * Iterator over all namespaces.
+ * callback (so it need not be re-entrant).<p>
  *
- * @param rating the local rating of the namespace
- * @return OK to continue iteration, SYSERR to abort
+ * @return cctx for resume events, otherwise NULL
  */
-typedef int (*FSUI_NamespaceIterator)(void * cls,
-                                     const char * namespaceName,
-                                     const HashCode512 * namespaceId,
-                                     const struct ECRS_MetaData * md,
-                                     int rating);
+typedef void * (*FSUI_EventCallback)(void * cls,
+                                    const FSUI_Event * event);
 
 /**
- * Iterator over all searches and search results.
- *
- * @return OK to continue iteration, SYSERR to abort
- */
-typedef int (*FSUI_SearchIterator)(void * cls,
-                                  const struct ECRS_URI * searchUri,
-                                  unsigned int anonymityLevel,
-                                  unsigned int resultCount,
-                                  const ECRS_FileInfo * results);
-
-/**
- * Iterator over all updateable content.
- *
- * @param uri URI of the last content published
- * @param lastId the ID of the last publication
- * @param nextId the ID of the next update
- * @param publicationFrequency how often are updates scheduled?
- * @param nextPublicationTime the scheduled time for the
- *  next update (0 for sporadic updates)
- * @return OK to continue iteration, SYSERR to abort
- */
-typedef int (*FSUI_UpdateIterator)(void * cls,
-                                  const ECRS_FileInfo * uri,
-                                  const HashCode512 * lastId,
-                                  const HashCode512 * nextId,
-                                  TIME_T publicationFrequency,
-                                  TIME_T nextPublicationTime);
-
-/**
- * Iterator over active downloads.
- *
- * @param pos What file in the download tree are we
- * refering to?
- * @return OK to continue iteration, SYSERR to abort
- */
-typedef int (*FSUI_DownloadIterator)(void * cls,
-                                    const struct FSUI_DownloadList * pos,
-                                    const char * filename,
-                                    const struct ECRS_URI * uri,
-                                    unsigned long long filesize,
-                                    unsigned long long bytesCompleted,
-                                    int isRecursive,
-                                    unsigned int anonymityLevel);
-
-/**
  * @brief Start the FSUI manager.  Use the given progress callback to
  * notify the UI about events.  May resume processing pending
  * activities that were running when FSUI_stop was called
@@ -413,10 +603,13 @@
  * @param closure extra argument to cb
  * @return NULL on error
  */
-struct FSUI_Context * FSUI_start(const char * name,
-                                int doResume,
-                                FSUI_EventCallback cb,
-                                void * closure); /* fsui.c */
+struct FSUI_Context * 
+FSUI_start(struct GE_Context * ectx,
+          struct GC_Configuration * cfg,
+          const char * name,
+          int doResume,
+          FSUI_EventCallback cb,
+          void * closure); /* fsui.c */
 
 /**
  * Stop all processes under FSUI control (may serialize
@@ -426,414 +619,104 @@
  */
 void FSUI_stop(struct FSUI_Context * ctx); /* fsui.c */
 
-/* ******************** simple FS API **************** */
 
 /**
- * Create an ECRS URI from a single user-supplied string of keywords.
- * The string may contain the reserved word 'AND' to create a boolean
- * search over multiple keywords.
- *
- * @return an ECRS URI for the given keywords, NULL
- *  if keywords is not legal (i.e. empty).
- */
-struct ECRS_URI * FSUI_parseCharKeywordURI(const char * keywords); /* helper.c 
*/
-
-/**
- * Create an ECRS URI from a user-supplied command line of keywords.
- * The command line may contain the reserved word 'AND' to create a
- * boolean search over multiple keywords.
- *
- * @return an ECRS URI for the given keywords, NULL
- *  if keywords is not legal (i.e. empty).
- */
-struct ECRS_URI * FSUI_parseArgvKeywordURI(unsigned int argc,
-                                          const char ** argv); /* helper.c */
-
-/**
- * Create an ECRS URI from a user-supplied list of keywords.
- * The keywords are NOT separated by AND but already
- * given individually.
- *
- * @return an ECRS URI for the given keywords, NULL
- *  if keywords is not legal (i.e. empty).
- */
-struct ECRS_URI * FSUI_parseListKeywordURI(unsigned int num_keywords,
-                                          const char ** keywords);
-
-/**
  * Start a search.
+ *
  * @return SYSERR if such a search is already pending, OK on
  *  success
  */
-int FSUI_startSearch(struct FSUI_Context * ctx,
-                    unsigned int anonymityLevel,
-                    const struct ECRS_URI * uri); /* search.c */
+struct FSUI_SearchList *
+FSUI_startSearch(struct FSUI_Context * ctx,
+                unsigned int anonymityLevel,
+                const struct ECRS_URI * uri); /* search.c */
 
 /**
  * Stop a search.
+ *
  * @return SYSERR if such a search is not known
  */
 int FSUI_stopSearch(struct FSUI_Context * ctx,
-                   const struct ECRS_URI * uri); /* search.c */
+                   struct FSUI_SearchList * sl); /* search.c */
 
 /**
- * List active searches.  Can also be used to obtain
- * search results that were already signaled earlier.
- */
-int FSUI_listSearches(struct FSUI_Context * ctx,
-                     FSUI_SearchIterator iter,
-                     void * closure); /* search.c */
-
-/**
- * Start to download a file.
+ * Start to download a file or directory.
  *
- * @return OK on success, SYSERR if the target file is
- *  already used for another download at the moment (or
- *  if the disk does not have enough space).
+ * @return NULL on error
  */
-int FSUI_startDownload(struct FSUI_Context * ctx,
-                      unsigned int anonymityLevel,
-                      const struct ECRS_URI * uri,
-                      const char * filename); /* download.c */
+struct FSUI_DownloadList *
+FSUI_startDownload(struct FSUI_Context * ctx,
+                  unsigned int anonymityLevel,
+                  int doRecursive,
+                  const struct ECRS_URI * uri,
+                  const char * filename); /* download.c */
 
 /**
- * Abort a download.  If the URI was for a recursive
+ * Abort a download.  If the dl is for a recursive
  * download, all sub-downloads will also be aborted.
- * Cannot be used to terminate a single file download
- * that is part of a recursive download.
  *
- * @return SYSERR if no such download is pending
+ * @return SYSERR on error
  */
 int FSUI_stopDownload(struct FSUI_Context * ctx,
-                     const struct ECRS_URI * uri,
-                     const char * filename); /* download.c */
+                     struct FSUI_DownloadList * dl); /* download.c */
 
 /**
- * List active downloads.  Will NOT list completed
- * downloads, FSUI clients should listen closely
- * to the FSUI_EventCallback to not miss completion
- * events.
+ * Start uploading a file or directory.
  *
- * @param root subtree to iterate over, use
- *        NULL for all top-level downloads
+ * @param ctx 
+ * @param filename name of file or directory to upload (directory
+ *        implies use of recursion)
+ * @param doIndex use indexing, not insertion
+ * @param doExtract use libextractor
+ * @param individualKeywords add KBlocks for non-top-level files
+ * @param topLevelMetaData metadata for top-level file or directory
+ * @param globalURI keywords for all files 
+ * @param keyURI keywords for top-level file
+ * @return NULL on error
  */
-int FSUI_listDownloads(struct FSUI_Context * ctx,
-                      const struct FSUI_DownloadList * root,
-                      FSUI_DownloadIterator iter,
-                      void * closure); /* download.c */
+struct FSUI_UploadList *
+FSUI_startUpload(struct FSUI_Context * ctx,
+                const char * filename,
+                unsigned int anonymityLevel,
+                int doIndex,
+                int doExtract,
+                int individualKeywords,
+                const struct ECRS_MetaData * topLevelMetaData,
+                const struct ECRS_URI * globalURI,
+                const struct ECRS_URI * keyUri);
 
+
 /**
- * Clear all completed top-level downloads from the FSUI list.
+ * Abort an upload.  If the context is for a recursive
+ * upload, all sub-uploads will also be aborted.
  *
- * @param callback function to call on each completed download
- *        that is being cleared.
- * @return SYSERR on error, otherwise number of downloads cleared
+ * @return SYSERR on error
  */
-int FSUI_clearCompletedDownloads(struct FSUI_Context * ctx,
-                                FSUI_DownloadIterator iter,
-                                void * closure); /* download.c */
+int FSUI_stopUpload(struct FSUI_Context * ctx,
+                   struct FSUI_UploadList * ul);
 
 
 /**
- * Get parent of active download.
- * @return NULL if there is no parent
- */
-const struct FSUI_DownloadList *
-FSUI_getDownloadParent(const struct FSUI_DownloadList * child); /* download.c 
*/
-
-/**
- * Start uploading a file.  Note that an upload cannot be stopped once
- * started (not necessary anyway), but it can fail.  The function also
- * automatically the uploaded file in the global keyword space under
- * the given keywords.
- *
- * @return OK on success (at least we started with it),
- *  SYSERR if the file does not exist or gnunetd is not
- *  running
- */
-int FSUI_upload(struct FSUI_Context * ctx,
-               const char * filename,
-               unsigned int anonymityLevel,
-               int doIndex,
-               int doExtract,
-               const struct ECRS_MetaData * md,
-               const struct ECRS_URI * keyUri);
-
-/**
  * "delete" operation for uploaded files.  May fail
  * asynchronously, check progress callback.
  *
- * @return OK on success (at least we started with it),
- *  SYSERR if the file does not exist
+ * @return NULL on error
  */
-int FSUI_unindex(struct FSUI_Context * ctx,
-                const char * filename);
+struct FSUI_UnindexList *
+FSUI_unindex(struct FSUI_Context * ctx,
+            const char * filename);
 
-/* ***************** recursive FS API ***************** */
 
-
 /**
- * Start uploading a directory.  Note that an upload cannot be stopped
- * once started (not necessary anyway), but it can fail.  All files
- * in the recursive tree will be indexed under all keywords found by
- * the specified extractor plugins AND the globalKeywords.  The
- * main directory will furthermore be published with the given keywords
- * and the specified directoryMetaData.
+ * Abort an upload.  If the context is for a recursive
+ * upload, all sub-uploads will also be aborted.
  *
- * @return OK on success (at least we started with it),
- *  SYSERR if the file does not exist
-*/
-int FSUI_uploadAll(struct FSUI_Context * ctx,
-                  const char * dirname,
-                  unsigned int anonymityLevel,
-                  int doIndex,
-                  int individualKeywords,
-                  const struct ECRS_MetaData * directoryMetaData,
-                  const struct ECRS_URI * globalURI,
-                  const struct ECRS_URI * topURI); /* upload.c */
-
-/**
- * Start to download a file or directory recursively.
- *
- * @return OK on success (at least we started with it),
- *  SYSERR if the file does not exist
+ * @return SYSERR on error
  */
-int FSUI_startDownloadAll(struct FSUI_Context * ctx,
-                         unsigned int anonymityLevel,
-                         const struct ECRS_URI * uri,
-                         const char * dirname); /* download.c */
+int FSUI_stopUnindex(struct FSUI_Context * ctx,
+                    struct FSUI_UnindexList * ul);
 
-/* ******************** collections API **************** */
 
-/**
- * Start collection.
- */
-int FSUI_startCollection(struct FSUI_Context * ctx,
-                        unsigned int anonymityLevel,
-                        TIME_T updateInterval,
-                        const char * name,
-                        const struct ECRS_MetaData * meta); /* collection.c */
-
-/**
- * Stop collection.
- *
- * @return OK on success, SYSERR if no collection is active
- */
-int FSUI_stopCollection(struct FSUI_Context * ctx); /* collection.c */
-
-/**
- * Are we using a collection?
- *
- * @return NULL if there is no collection, otherwise its name
- */
-const char * FSUI_getCollection(struct FSUI_Context * ctx); /* collection.c */
-
-/**
- * Upload an update of the current collection information to the
- * network now.  The function has no effect if the collection has not
- * changed since the last publication.  If we are currently not
- * collecting, this function does nothing.
- *
- * Note that clients typically don't have to call this function
- * explicitly.  FSUI will call the function on exit (for sporadically
- * updated collections), on any change to the collection (for
- * immediately updated content) or when the publication time has
- * arrived (for periodically updated collections).
- *
- * However, clients may want to call this function if explicit
- * publication of an update at another time is desired.
- */
-void FSUI_publishCollectionNow(struct FSUI_Context * ctx);
-
-/**
- * If we are currently building a collection, publish the given file
- * information in that collection.  If we are currently not
- * collecting, this function does nothing.
- *
- * Note that clients typically don't have to call this function
- * explicitly -- by using the FSUI library it should be called
- * automatically by FSUI code whenever needed.  However, the function
- * maybe useful if you're inserting files using libECRS directly or
- * need other ways to explicitly extend a collection.
- */
-void FSUI_publishToCollection(struct FSUI_Context * ctx,
-                             const ECRS_FileInfo * fi);
-
-
-/* ******************** Namespace API ***************** */
-
-/**
- * Create a new namespace (and publish an advertismement).
- * This function is synchronous, but may block the system
- * for a while since it must create a public-private key pair!
- *
- * @param meta meta-data about the namespace (maybe NULL)
- * @return URI on success, NULL on error (namespace already exists)
- */
-struct ECRS_URI *
-FSUI_createNamespace(struct FSUI_Context * ctx,
-                    unsigned int anonymityLevel,
-                    const char * namespaceName,
-                    const struct ECRS_MetaData * meta,
-                    const struct ECRS_URI * advertisementURI,
-                    const HashCode512 * rootEntry); /* namespace_info.c */
-
-/**
- * Delete a local namespace.  Only prevents future insertions into the
- * namespace, does not delete any content from the network!
- *
- * @return OK on success, SYSERR on error
- */
-#define FSUI_deleteNamespace ECRS_deleteNamespace
-
-/**
- * Change the ranking of a (non-local) namespace.
- *
- * @param ns the name of the namespace, as obtained
- *  from ECRS_getNamespaceName
- * @param delta by how much should the rating be
- *  changed?
- * @return new rating of the namespace
- */
-int FSUI_rankNamespace(struct FSUI_Context * ctx,
-                      const char * ns,
-                      int delta); /* namespace_info.c */
-
-/**
- * Add a namespace to the set of known namespaces.  For all namespace
- * advertisements that we discover FSUI should automatically call this
- * function.
- *
- * @param ns the namespace identifier
- */
-void FSUI_addNamespaceInfo(const struct ECRS_URI * uri,
-                          const struct ECRS_MetaData * meta);
-
-
-/**
- * Get the root of the namespace (if we have one).
- * @return SYSERR on error, OK on success
- */
-int FSUI_getNamespaceRoot(const char * ns,
-                         HashCode512 * root);
-
-
-/**
- * List all available (local or non-local) namespaces.
- *
- * @param local only list local namespaces (if NO, only
- *   non-local known namespaces are listed)
- */
-int FSUI_listNamespaces(struct FSUI_Context * ctx,
-                       int local,
-                       FSUI_NamespaceIterator iterator,
-                       void * closure); /* namespace_info.c */
-
-/**
- * Add an entry into a namespace (also for publishing
- * updates).  Typical uses are (all others would be odd):
- * <ul>
- *  <li>updateInterval NONE, thisId some user-specified value
- *      or NULL if user wants system to pick random value;
- *      nextId and lastId NULL (irrelevant)</li>
- *  <li>updateInterval SPORADIC, thisId given (initial
- *      submission), nextId maybe given or NULL,
- *      lastId NULL</li>
- *  <li>updateInterval SPORADIC, lastId given (either
- *      user-provided or from listNamespaceContent
- *      iterator); thisId NULL or given (from lNC);
- *      nextId maybe given or NULL, depending on user preference</li>
- *  <li>updateInterval non-NULL, non-SPORADIC; lastId
- *      is NULL (inital submission), thisId non-NULL or
- *      rarely NULL (if user does not care about name of
- *      starting entry), nextId maybe NULL or not</li>
- *  <li>updateInterval non-NULL, non-SPORADIC; lastId
- *      is non-NULL (periodic update), thisId NULL (computed!)
- *      nextID NULL (computed)</li>
- * </ul>
- * And yes, reading the ECRS paper maybe a good idea.
- *
- * @param name in which namespace to publish
- * @param updateInterval the desired frequency for updates
- * @param lastId the ID of the last value (maybe NULL)
- *        set if this is an update to an existing entry
- * @param thisId the ID of the update (maybe NULL if
- *        lastId determines the value or if no specific value
- *        is desired)
- * @param nextId the ID of the next update (maybe NULL);
- *        set for sporadic updates if a specific next ID is
- *        desired
- * @param dst to which URI should the namespace entry refer?
- * @param md what meta-data should be associated with the
- *        entry?
- * @return the resulting URI, NULL on error
- */
-struct ECRS_URI *
-FSUI_addToNamespace(struct FSUI_Context * ctx,
-                   unsigned int anonymityLevel,
-                   const char * name,
-                   TIME_T updateInterval,
-                   const HashCode512 * lastId,
-                   const HashCode512 * thisId,
-                   const HashCode512 * nextId,
-                   const struct ECRS_URI * dst,
-                   const struct ECRS_MetaData * md); /* namespace_info.c */
-
-/**
- * Compute the next ID for peridodically updated content.
- * @param updateInterval MUST be a peridic interval (not NONE or SPORADIC)
- * @param thisId MUST be known to FSUI
- * @return OK on success, SYSERR on error
- */
-int FSUI_computeNextId(const char * name,
-                      const HashCode512 * lastId,
-                      const HashCode512 * thisId,
-                      TIME_T updateInterval,
-                      HashCode512 * nextId);
-
-/**
- * List all updateable content in a given namespace.
- */
-int FSUI_listNamespaceContent(struct FSUI_Context * ctx,
-                             const char * name,
-                             FSUI_UpdateIterator iterator,
-                             void * closure); /* namespace_info.c */
-
-/* **************** TRACKING API ****************** */
-
-/**
- * Toggle tracking URIs.
- *
- * @param onOff YES to enable tracking, NO to disable
- *  disabling tracking
- */
-void FSUI_trackURIS(int onOff); /* file_info.c */
-
-/**
- * Deletes all entries in the FSUI tracking cache.
- */
-void FSUI_clearTrackedURIS(void); /* file_info.c */
-
-/**
- * Get the FSUI URI tracking status.
- *
- * @return YES of tracking is enabled, NO if not
- */
-int FSUI_trackStatus(void); /* file_info.c */
-
-/**
- * Makes a URI available for directory building.  This function is
- * automatically called by all FSUI functions and only in the
- * interface for clients that call ECRS directly.
- */
-void FSUI_trackURI(const ECRS_FileInfo * fi); /* file_info.c */
-
-/**
- * List all URIs.
- */
-int FSUI_listURIs(ECRS_SearchProgressCallback iterator,
-                 void * closure); /* file_info.c */
-
 #if 0 /* keep Emacsens' auto-indent happy */
 {
 #endif

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-08-13 03:45:47 UTC (rev 3223)
+++ GNUnet/todo 2006-08-13 19:32:06 UTC (rev 3224)
@@ -27,9 +27,10 @@
     + fragmentation, identity,  pingpong, session, transport,
       stats, topology_default, state, getoption, advertising,
       traffic, ecrs_core, template, tbench, tracekit, fs/fslib,
-      fs/module, gap, fs/ecrs compile
+      fs/module, gap, fs/ecrs, fs/uritrack compile
     + bootstrap_http: maybe switch to libwww?
-    + for fs: fs/fsui (5500), fs/tools (2500)
+    + for fs: fs/fsui (3700), fs/namespace (1000), 
+              fs/collection (400), fs/tools (2500)
     + rest: sqstore_mysql, dht, rpc, topology_f2f, vpn
     + low priority: chat, kvstore_sqlite, testbed
   * setup:





reply via email to

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