fix
[oweals/gnunet.git] / src / fs / gnunet-publish.c
index e3918f6fb8a9383013a5394ab183da169a2cef98..c8c486bd74fad8d8e44054504fc1410bf7eeb5bc 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
+     (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2010 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
@@ -24,9 +24,6 @@
  * @author Krista Bennett
  * @author James Blackwell
  * @author Igor Wronsky
- *
- * TODO:
- * - support for some options is still missing (uri argument)
  */
 #include "platform.h"
 #include "gnunet_fs_service.h"
@@ -41,12 +38,16 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
 static struct GNUNET_FS_Handle *ctx;
 
+static struct GNUNET_SCHEDULER_Handle *sched;
+
 static struct GNUNET_FS_PublishContext *pc;
 
 static struct GNUNET_CONTAINER_MetaData *meta;
 
 static struct GNUNET_FS_Uri *topKeywords;
 
+static struct GNUNET_FS_Uri *uri;
+
 static unsigned int anonymity = 1;
 
 static unsigned int priority = 365;
@@ -69,6 +70,28 @@ static int extract_only;
 
 static int do_disable_creation_time;
 
+static GNUNET_SCHEDULER_TaskIdentifier kill_task;
+
+
+static void 
+do_stop_task (void *cls,
+             const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNUNET_FS_PublishContext *p;
+
+  if (pc != NULL)
+    {
+      p = pc;
+      pc = NULL;
+      GNUNET_FS_publish_stop (p);
+      if (NULL != meta) 
+       {
+         GNUNET_CONTAINER_meta_data_destroy (meta);
+         meta = NULL;
+       }
+    }
+}
+
 
 /**
  * Called by FS client to give information about the progress of an 
@@ -110,18 +133,42 @@ progress_cb (void *cls,
       fprintf (stderr,
               _("Error publishing: %s.\n"),
               info->value.publish.specifics.error.message);
-      GNUNET_FS_publish_stop (pc);      
+      if (kill_task != GNUNET_SCHEDULER_NO_TASK)
+       {
+         GNUNET_SCHEDULER_cancel (sched,
+                                  kill_task);
+         kill_task = GNUNET_SCHEDULER_NO_TASK;
+       }
+      GNUNET_SCHEDULER_add_continuation (sched,
+                                        &do_stop_task,
+                                        NULL,
+                                        GNUNET_SCHEDULER_REASON_PREREQ_DONE);
       break;
     case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
       fprintf (stdout,
               _("Publishing `%s' done.\n"),
               info->value.publish.filename);
+      s = GNUNET_FS_uri_to_string (info->value.publish.specifics.completed.chk_uri);
+      fprintf (stdout,
+              _("URI is `%s'.\n"),
+              s);
+      GNUNET_free (s);
       if (info->value.publish.pctx == NULL)
-       GNUNET_FS_publish_stop (pc);
+       {
+         if (kill_task != GNUNET_SCHEDULER_NO_TASK)
+           {
+             GNUNET_SCHEDULER_cancel (sched,
+                                      kill_task);
+             kill_task = GNUNET_SCHEDULER_NO_TASK;
+           }
+         GNUNET_SCHEDULER_add_continuation (sched,
+                                            &do_stop_task,
+                                            NULL,
+                                            GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+       }
       break;
     case GNUNET_FS_STATUS_PUBLISH_STOPPED: 
-      if (info->value.publish.sc == pc)
-       GNUNET_FS_stop (ctx);
+      GNUNET_break (NULL == pc);
       return NULL;      
     default:
       fprintf (stderr,
@@ -138,53 +185,40 @@ progress_cb (void *cls,
  * metadata and the filename).
  *
  * @param cls closure
+ * @param plugin_name name of the plugin that generated the meta data
  * @param type type of the meta data
+ * @param format format of data
+ * @param data_mime_type mime type of data
  * @param data value of the meta data
- * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
+ * @param data_size number of bytes in data
+ * @return always 0
  */
 static int
 meta_printer (void *cls,
-             EXTRACTOR_KeywordType type,
-             const char *data)
+             const char *plugin_name,
+             enum EXTRACTOR_MetaType type, 
+             enum EXTRACTOR_MetaFormat format,
+             const char *data_mime_type,
+             const char *data,
+             size_t data_size)
 {
-  if ( (type == EXTRACTOR_FILENAME) ||
-       (EXTRACTOR_isBinaryType (type)) )
-    return GNUNET_OK;
+  if ( (format != EXTRACTOR_METAFORMAT_UTF8) &&
+       (format != EXTRACTOR_METAFORMAT_C_STRING) )
+    return 0;
+  if (type == EXTRACTOR_METATYPE_FILENAME) 
+    return 0;
   fprintf (stdout, 
-          "%s - %s",
-          EXTRACTOR_getKeywordTypeAsString (type),
+          "\t%s - %s\n",
+          EXTRACTOR_metatype_to_string (type),
           data);
-  return GNUNET_OK;
-}
-
-
-/**
- * Merge metadata entries (except binary
- * metadata).
- *
- * @param cls closure, target metadata structure
- * @param type type of the meta data
- * @param data value of the meta data
- * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
- */
-static int
-meta_merger (void *cls,
-            EXTRACTOR_KeywordType type,
-            const char *data)
-{
-  struct GNUNET_CONTAINER_MetaData *m = cls;
-  GNUNET_CONTAINER_meta_data_insert (m,
-                                    type, 
-                                    data);
-  return GNUNET_OK;
+  return 0;
 }
 
 
 /**
- * Function called on all entries before the
- * publication.  This is where we perform
- * modifications to the default based on
- * command-line options.
+ * Function called on all entries before the publication.  This is
+ * where we perform modifications to the default based on command-line
+ * options.
  *
  * @param cls closure
  * @param fi the entry in the publish-structure
@@ -193,6 +227,7 @@ meta_merger (void *cls,
  * @param uri pointer to the keywords that will be used for this entry (can be modified)
  * @param anonymity pointer to selected anonymity level (can be modified)
  * @param priority pointer to selected priority (can be modified)
+ * @param do_index should we index?
  * @param expirationTime pointer to selected expiration time (can be modified)
  * @param client_info pointer to client context set upon creation (can be modified)
  * @return GNUNET_OK to continue, GNUNET_NO to remove
@@ -207,6 +242,7 @@ publish_inspector (void *cls,
                   struct GNUNET_FS_Uri **uri,
                   unsigned int *anonymity,
                   unsigned int *priority,
+                  int *do_index,
                   struct GNUNET_TIME_Absolute *expirationTime,
                   void **client_info)
 {
@@ -214,29 +250,36 @@ publish_inspector (void *cls,
   char *fs;
   struct GNUNET_FS_Uri *new_uri;
 
-  if (! do_disable_creation_time)
-    GNUNET_CONTAINER_meta_data_add_publication_date (meta);
+  if (cls == fi)
+    return GNUNET_OK;
   if (NULL != topKeywords)
     {
-      new_uri = GNUNET_FS_uri_ksk_merge (topKeywords,
-                                        *uri);
-      GNUNET_FS_uri_destroy (*uri);
-      *uri = new_uri;
-      GNUNET_FS_uri_destroy (topKeywords);
+      if (*uri != NULL)
+       {
+         new_uri = GNUNET_FS_uri_ksk_merge (topKeywords,
+                                            *uri);
+         GNUNET_FS_uri_destroy (*uri); 
+         *uri = new_uri;
+         GNUNET_FS_uri_destroy (topKeywords);
+       }
+      else
+       {
+         *uri = topKeywords;
+       }
       topKeywords = NULL;
     }
-  if (NULL != meta)
+  if (NULL != meta) 
     {
-      GNUNET_CONTAINER_meta_data_get_contents (meta,
-                                              &meta_merger,
-                                              m);
+      GNUNET_CONTAINER_meta_data_merge (m, meta);
       GNUNET_CONTAINER_meta_data_destroy (meta);
       meta = NULL;
     }
+  if (! do_disable_creation_time)
+    GNUNET_CONTAINER_meta_data_add_publication_date (m);
   if (extract_only)
     {
-      fn = GNUNET_CONTAINER_meta_data_get_by_type (meta,
-                                                  EXTRACTOR_FILENAME);
+      fn = GNUNET_CONTAINER_meta_data_get_by_type (m,
+                                                  EXTRACTOR_METATYPE_FILENAME);
       fs = GNUNET_STRINGS_byte_size_fancy (length);
       fprintf (stdout,
               _("Keywords for file `%s' (%s)\n"),
@@ -244,42 +287,120 @@ publish_inspector (void *cls,
               fs);
       GNUNET_free (fn);
       GNUNET_free (fs);
-      GNUNET_CONTAINER_meta_data_get_contents (meta,
-                                              &meta_printer,
-                                              NULL);
+      GNUNET_CONTAINER_meta_data_iterate (m,
+                                         &meta_printer,
+                                         NULL);
       fprintf (stdout, "\n");
     }
-  if (GNUNET_FS_meta_data_test_for_directory (meta))
+  if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m))
     GNUNET_FS_file_information_inspect (fi,
                                        &publish_inspector,
-                                       NULL);
+                                       fi);
   return GNUNET_OK;
 }
 
 
+static void 
+uri_sks_continuation (void *cls,
+                     const struct GNUNET_FS_Uri *ksk_uri,
+                     const char *emsg)
+{
+  if (emsg != NULL)
+    {
+      fprintf (stderr,
+              "%s\n",
+              emsg);
+      ret = 1;
+    }
+  GNUNET_FS_uri_destroy (uri);
+  uri = NULL;
+  GNUNET_FS_stop (ctx);
+  ctx = NULL;
+}
+
+
+static void 
+uri_ksk_continuation (void *cls,
+                     const struct GNUNET_FS_Uri *ksk_uri,
+                     const char *emsg)
+{
+  struct GNUNET_FS_Namespace *ns;
+
+  if (emsg != NULL)
+    {
+      fprintf (stderr,
+              "%s\n",
+              emsg);
+      ret = 1;
+    }
+  if (pseudonym != NULL)
+    {
+      ns = GNUNET_FS_namespace_create (ctx,
+                                      pseudonym);
+      if (ns == NULL)
+       {
+         fprintf (stderr,
+                  _("Failed to create namespace `%s'\n"),
+                  pseudonym);
+         ret = 1;
+       }
+      else
+       {
+         GNUNET_FS_publish_sks (ctx,
+                                ns,
+                                this_id,
+                                next_id,
+                                meta,
+                                uri,
+                                GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
+                                anonymity,
+                                priority,
+                                GNUNET_FS_PUBLISH_OPTION_NONE,
+                                uri_sks_continuation,
+                                NULL);
+         GNUNET_assert (GNUNET_OK ==
+                        GNUNET_FS_namespace_delete (ns, GNUNET_NO));
+         return;
+       }
+    }
+  GNUNET_FS_uri_destroy (uri);
+  uri = NULL;
+  GNUNET_FS_stop (ctx);
+  ctx = NULL;
+}
+
+
 /**
  * Main function that will be run by the scheduler.
  *
  * @param cls closure
- * @param sched the scheduler to use
+ * @param s the scheduler to use
  * @param args remaining command-line arguments
  * @param cfgfile name of the configuration file used (for saving, can be NULL!)
  * @param c configuration
  */
 static void
 run (void *cls,
-     struct GNUNET_SCHEDULER_Handle *sched,
+     struct GNUNET_SCHEDULER_Handle *s,
      char *const *args,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   struct GNUNET_FS_FileInformation *fi;
   struct GNUNET_FS_Namespace *namespace;
-  EXTRACTOR_ExtractorList *l;
+  struct EXTRACTOR_PluginList *plugins;
+  struct stat sbuf;
   char *ex;
   char *emsg;
   
+  sched = s;
   /* check arguments */
+  if ((uri_string != NULL) && (extract_only))
+    {
+      printf (_("Cannot extract metadata from a URI!\n"));
+      ret = -1;
+      return;
+    }
   if ( ( (uri_string == NULL) || (extract_only) ) 
        && ( (args[0] == NULL) || (args[1] != NULL) ) )
     {
@@ -294,12 +415,6 @@ run (void *cls,
       ret = -1;
       return;
     }
-  if ((uri_string != NULL) && (extract_only))
-    {
-      printf (_("Cannot extract metadata from a URI!\n"));
-      ret = -1;
-      return;
-    }
   if (pseudonym != NULL)
     {
       if (NULL == this_id)
@@ -330,13 +445,6 @@ run (void *cls,
          return;
         }
     }
-  if (args[0] == NULL)
-    {
-      fprintf (stderr,
-              _("Need the name of a file to publish!\n"));
-      ret = 1;
-      return;
-    }
   cfg = c;
   ctx = GNUNET_FS_start (sched,
                         cfg,
@@ -369,34 +477,89 @@ run (void *cls,
        }
     }
   if (NULL != uri_string)
-    {
-      // FIXME -- implement!
+    {      
+      emsg = NULL;
+      uri = GNUNET_FS_uri_parse (uri_string,
+                                &emsg);
+      if (uri == NULL)
+       {
+         fprintf (stderr, 
+                  _("Failed to parse URI: %s\n"),
+                  emsg);
+         GNUNET_free (emsg);
+         if (namespace != NULL)
+           GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
+         GNUNET_FS_stop (ctx);
+         ret = 1;
+         return;         
+       }
+      GNUNET_FS_publish_ksk (ctx,
+                            topKeywords,
+                            meta,
+                            uri,
+                            GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
+                            anonymity,
+                            priority,
+                            GNUNET_FS_PUBLISH_OPTION_NONE,
+                            &uri_ksk_continuation,
+                            NULL);
+      if (namespace != NULL)
+       GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
       return;
     }
-
-  l = NULL;
+  plugins = NULL;
   if (! disable_extractor)
     {
-      l = EXTRACTOR_loadDefaultLibraries ();
+      plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);
       if (GNUNET_OK ==
          GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS",
                                                 &ex))
        {
          if (strlen (ex) > 0)
-           l = EXTRACTOR_loadConfigLibraries (l, ex);
+           plugins = EXTRACTOR_plugin_add_config (plugins, ex, EXTRACTOR_OPTION_DEFAULT_POLICY);
          GNUNET_free (ex);
        }
     }
-  fi = GNUNET_FS_file_information_create_from_directory (NULL,
-                                                        args[0],
-                                                        &GNUNET_FS_directory_scanner_default,
-                                                        l,
-                                                        !do_insert,
-                                                        anonymity,
-                                                        priority,
-                                                        GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
-                                                        &emsg);
-  EXTRACTOR_removeAll (l);  
+  emsg = NULL;
+  if (0 != STAT (args[0], &sbuf))
+    {
+      GNUNET_asprintf (&emsg,
+                      _("Could not access file: %s\n"),
+                      STRERROR (errno));
+      fi = NULL;
+    }
+  else if (S_ISDIR (sbuf.st_mode))
+    {
+      fi = GNUNET_FS_file_information_create_from_directory (ctx,
+                                                            NULL,
+                                                            args[0],
+                                                            &GNUNET_FS_directory_scanner_default,
+                                                            plugins,
+                                                            !do_insert,
+                                                            anonymity,
+                                                            priority,
+                                                            GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
+                                                            &emsg);
+    }
+  else
+    {
+      if (meta == NULL)
+       meta = GNUNET_CONTAINER_meta_data_create ();
+      GNUNET_FS_meta_data_extract_from_file (meta,
+                                            args[0],
+                                            plugins);
+      fi = GNUNET_FS_file_information_create_from_file (ctx,
+                                                       NULL,
+                                                       args[0],
+                                                       NULL,
+                                                       NULL,
+                                                       !do_insert,
+                                                       anonymity,
+                                                       priority,
+                                                       GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION));
+      GNUNET_break (fi != NULL);
+    }
+  EXTRACTOR_plugin_remove_all (plugins);  
   if (fi == NULL)
     {
       fprintf (stderr,
@@ -437,72 +600,13 @@ run (void *cls,
       ret = 1;
       return;
     }
+  kill_task = GNUNET_SCHEDULER_add_delayed (sched,
+                                           GNUNET_TIME_UNIT_FOREVER_REL,
+                                           &do_stop_task,
+                                           NULL);
 }
 
 
-/**
- * gnunet-publish command line options
- */
-static struct GNUNET_GETOPT_CommandLineOption options[] = {
-  {'a', "anonymity", "LEVEL",
-   gettext_noop ("set the desired LEVEL of sender-anonymity"),
-   1, &GNUNET_GETOPT_set_uint, &anonymity},
-  {'d', "disable-creation-time", NULL,
-   gettext_noop
-   ("disable adding the creation time to the metadata of the uploaded file"),
-   0, &GNUNET_GETOPT_set_one, &do_disable_creation_time},
-  {'D', "disable-extractor", NULL,
-   gettext_noop
-   ("do not use libextractor to add keywords or metadata"),
-   0, &GNUNET_GETOPT_set_one, &disable_extractor},
-  {'e', "extract", NULL,
-   gettext_noop
-   ("print list of extracted keywords that would be used, but do not perform upload"),
-   0, &GNUNET_GETOPT_set_one, &extract_only},
-  {'k', "key", "KEYWORD",
-   gettext_noop
-   ("add an additional keyword for the top-level file or directory"
-    " (this option can be specified multiple times)"),
-   1, &GNUNET_FS_getopt_set_keywords, &topKeywords},
-  // *: option not yet used... (can handle in a pass over FI)
-  {'m', "meta", "TYPE:VALUE",
-   gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
-   1, &GNUNET_FS_getopt_set_metadata, &meta},
-  {'n', "noindex", NULL,
-   gettext_noop ("do not index, perform full insertion (stores entire "
-                 "file in encrypted form in GNUnet database)"),
-   0, &GNUNET_GETOPT_set_one, &do_insert},
-  {'N', "next", "ID",
-   gettext_noop
-   ("specify ID of an updated version to be published in the future"
-    " (for namespace insertions only)"),
-   1, &GNUNET_GETOPT_set_string, &next_id},
-  {'p', "priority", "PRIORITY",
-   gettext_noop ("specify the priority of the content"),
-   1, &GNUNET_GETOPT_set_uint, &priority},
-  {'P', "pseudonym", "NAME",
-   gettext_noop
-   ("publish the files under the pseudonym NAME (place file into namespace)"),
-   1, &GNUNET_GETOPT_set_string, &pseudonym},
-  // *: option not yet used... (need FS API support!)
-  {'s', "simulate-only", NULL,
-   gettext_noop ("only simulate the process but do not do any "
-                 "actual publishing (useful to compute URIs)"),
-   0, &GNUNET_GETOPT_set_one, &do_simulate},
-  {'t', "this", "ID",
-   gettext_noop ("set the ID of this version of the publication"
-                 " (for namespace insertions only)"),
-   1, &GNUNET_GETOPT_set_string, &this_id},
-  // *: option not yet used... (need FS API support!)
-  {'u', "uri", "URI",
-   gettext_noop ("URI to be published (can be used instead of passing a "
-                 "file to add keywords to the file with the respective URI)"),
-   1, &GNUNET_GETOPT_set_string, &uri_string}, 
-  {'V', "verbose", NULL,
-   gettext_noop ("be verbose (print progress information)"),
-   0, &GNUNET_GETOPT_set_one, &verbose},
-  GNUNET_GETOPT_OPTION_END
-};
 
 
 /**
@@ -515,6 +619,63 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
 int
 main (int argc, char *const *argv)
 {
+  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+    {'a', "anonymity", "LEVEL",
+     gettext_noop ("set the desired LEVEL of sender-anonymity"),
+     1, &GNUNET_GETOPT_set_uint, &anonymity},
+    {'d', "disable-creation-time", NULL,
+     gettext_noop
+     ("disable adding the creation time to the metadata of the uploaded file"),
+     0, &GNUNET_GETOPT_set_one, &do_disable_creation_time},
+    {'D', "disable-extractor", NULL,
+     gettext_noop
+     ("do not use libextractor to add keywords or metadata"),
+     0, &GNUNET_GETOPT_set_one, &disable_extractor},
+    {'e', "extract", NULL,
+     gettext_noop
+     ("print list of extracted keywords that would be used, but do not perform upload"),
+     0, &GNUNET_GETOPT_set_one, &extract_only},
+    {'k', "key", "KEYWORD",
+     gettext_noop
+     ("add an additional keyword for the top-level file or directory"
+      " (this option can be specified multiple times)"),
+     1, &GNUNET_FS_getopt_set_keywords, &topKeywords},
+    {'m', "meta", "TYPE:VALUE",
+     gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
+     1, &GNUNET_FS_getopt_set_metadata, &meta},
+    {'n', "noindex", NULL,
+     gettext_noop ("do not index, perform full insertion (stores entire "
+                  "file in encrypted form in GNUnet database)"),
+     0, &GNUNET_GETOPT_set_one, &do_insert},
+    {'N', "next", "ID",
+     gettext_noop
+     ("specify ID of an updated version to be published in the future"
+      " (for namespace insertions only)"),
+     1, &GNUNET_GETOPT_set_string, &next_id},
+    {'p', "priority", "PRIORITY",
+     gettext_noop ("specify the priority of the content"),
+     1, &GNUNET_GETOPT_set_uint, &priority},
+    {'P', "pseudonym", "NAME",
+     gettext_noop
+     ("publish the files under the pseudonym NAME (place file into namespace)"),
+     1, &GNUNET_GETOPT_set_string, &pseudonym},
+    {'s', "simulate-only", NULL,
+     gettext_noop ("only simulate the process but do not do any "
+                  "actual publishing (useful to compute URIs)"),
+     0, &GNUNET_GETOPT_set_one, &do_simulate},
+    {'t', "this", "ID",
+     gettext_noop ("set the ID of this version of the publication"
+                  " (for namespace insertions only)"),
+     1, &GNUNET_GETOPT_set_string, &this_id},
+    {'u', "uri", "URI",
+     gettext_noop ("URI to be published (can be used instead of passing a "
+                  "file to add keywords to the file with the respective URI)"),
+     1, &GNUNET_GETOPT_set_string, &uri_string}, 
+    {'V', "verbose", NULL,
+     gettext_noop ("be verbose (print progress information)"),
+     0, &GNUNET_GETOPT_set_one, &verbose},
+    GNUNET_GETOPT_OPTION_END
+  };
   return (GNUNET_OK ==
           GNUNET_PROGRAM_run (argc,
                               argv,
@@ -525,86 +686,3 @@ main (int argc, char *const *argv)
 }
 
 /* end of gnunet-publish.c */
-
-////////////////////////////////////////////////////////////////
-
-#if 0
-/**
- * Print progess message.
- */
-static void *
-printstatus (void *ctx, const GNUNET_FSUI_Event * event)
-{
-  unsigned long long delta;
-  char *fstring;
-
-  switch (event->type)
-    {
-    case GNUNET_FSUI_upload_progress:
-      if (*verboselevel)
-        {
-          char *ret;
-          GNUNET_CronTime now;
-
-          now = GNUNET_get_time ();
-          delta = event->data.UploadProgress.eta - now;
-          if (event->data.UploadProgress.eta < now)
-            delta = 0;
-          ret = GNUNET_get_time_interval_as_fancy_string (delta);
-          PRINTF (_("%16llu of %16llu bytes inserted "
-                    "(estimating %6s to completion) - %s\n"),
-                  event->data.UploadProgress.completed,
-                  event->data.UploadProgress.total,
-                  ret, event->data.UploadProgress.filename);
-          GNUNET_free (ret);
-        }
-      break;
-    case GNUNET_FSUI_upload_completed:
-      if (*verboselevel)
-        {
-          delta = GNUNET_get_time () - start_time;
-          PRINTF (_("Upload of `%s' complete, "
-                    "%llu bytes took %llu seconds (%8.3f KiB/s).\n"),
-                  event->data.UploadCompleted.filename,
-                  event->data.UploadCompleted.total,
-                  delta / GNUNET_CRON_SECONDS,
-                  (delta == 0)
-                  ? (double) (-1.0)
-                  : (double) (event->data.UploadCompleted.total
-                              / 1024.0 * GNUNET_CRON_SECONDS / delta));
-        }
-      fstring = GNUNET_ECRS_uri_to_string (event->data.UploadCompleted.uri);
-      printf (_("File `%s' has URI: %s\n"),
-              event->data.UploadCompleted.filename, fstring);
-      GNUNET_free (fstring);
-      if (ul == event->data.UploadCompleted.uc.pos)
-        {
-          postProcess (event->data.UploadCompleted.uri);
-          errorCode = 0;
-          GNUNET_shutdown_initiate ();
-        }
-      break;
-    case GNUNET_FSUI_upload_aborted:
-      printf (_("\nUpload aborted.\n"));
-      errorCode = 2;
-      GNUNET_shutdown_initiate ();
-      break;
-    case GNUNET_FSUI_upload_error:
-      printf (_("\nError uploading file: %s"),
-              event->data.UploadError.message);
-      errorCode = 3;
-      GNUNET_shutdown_initiate ();
-      break;
-    case GNUNET_FSUI_upload_started:
-    case GNUNET_FSUI_upload_stopped:
-      break;
-    default:
-      printf (_("\nUnexpected event: %d\n"), event->type);
-      GNUNET_GE_BREAK (ectx, 0);
-      break;
-    }
-  return NULL;
-}
-#endif
-
-/* end of gnunet-publish.c */