/*
This file is part of GNUnet.
- (C) 2001-2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2001-2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
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.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
* @file fs/gnunet-publish.c
#include "gnunet_identity_service.h"
/**
- * Global return value from 'main'.
+ * Global return value from #main().
*/
-static int ret = 1;
+static int ret;
/**
* Command line option 'verbose' set
*/
static int do_disable_creation_time;
-/**
- * Task run on CTRL-C to kill everything nicely.
- */
-static GNUNET_SCHEDULER_TaskIdentifier kill_task;
-
/**
* Handle to the directory scanner (for recursive insertions).
*/
* FS state.
*
* @param cls NULL
- * @param tc scheduler context
*/
static void
-do_stop_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_stop_task (void *cls)
{
struct GNUNET_FS_PublishContext *p;
- kill_task = GNUNET_SCHEDULER_NO_TASK;
+ if (NULL != ds)
+ {
+ GNUNET_FS_directory_scan_abort (ds);
+ ds = NULL;
+ }
if (NULL != identity)
{
GNUNET_IDENTITY_disconnect (identity);
pc = NULL;
GNUNET_FS_publish_stop (p);
}
+ if (NULL != ctx)
+ {
+ GNUNET_FS_stop (ctx);
+ ctx = NULL;
+ }
if (NULL != meta)
{
GNUNET_CONTAINER_meta_data_destroy (meta);
meta = NULL;
}
-}
-
-
-/**
- * Stop the directory scanner (we had an error).
- *
- * @param cls closure
- * @param tc scheduler context
- */
-static void
-stop_scanner_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- kill_task = GNUNET_SCHEDULER_NO_TASK;
- if (NULL != ds)
- {
- GNUNET_FS_directory_scan_abort (ds);
- ds = NULL;
- }
- if (NULL != identity)
+ if (NULL != uri)
{
- GNUNET_IDENTITY_disconnect (identity);
- identity = NULL;
+ GNUNET_FS_uri_destroy (uri);
+ uri = NULL;
}
- GNUNET_FS_stop (ctx);
- ctx = NULL;
- ret = 1;
}
}
break;
case GNUNET_FS_STATUS_PUBLISH_ERROR:
- FPRINTF (stderr, _("Error publishing: %s.\n"),
+ FPRINTF (stderr,
+ _("Error publishing: %s.\n"),
info->value.publish.specifics.error.message);
- if (kill_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (kill_task);
- kill_task = GNUNET_SCHEDULER_NO_TASK;
- }
- kill_task = GNUNET_SCHEDULER_add_now (&do_stop_task, NULL);
+ ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
break;
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
FPRINTF (stdout,
}
if (NULL == info->value.publish.pctx)
{
- if (GNUNET_SCHEDULER_NO_TASK != kill_task)
- GNUNET_SCHEDULER_cancel (kill_task);
- kill_task = GNUNET_SCHEDULER_add_now (&do_stop_task, NULL);
+ ret = 0;
+ GNUNET_SCHEDULER_shutdown ();
}
- ret = 0;
break;
case GNUNET_FS_STATUS_PUBLISH_STOPPED:
GNUNET_break (NULL == pc);
return NULL;
+ case GNUNET_FS_STATUS_UNINDEX_START:
+ FPRINTF (stderr,
+ "%s",
+ _("Starting cleanup after abort\n"));
+ return NULL;
case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
return NULL;
case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
FPRINTF (stderr,
"%s",
- _("Cleanup after abort complete.\n"));
+ _("Cleanup after abort completed.\n"));
+ GNUNET_FS_unindex_stop (info->value.unindex.uc);
+ return NULL;
+ case GNUNET_FS_STATUS_UNINDEX_ERROR:
+ FPRINTF (stderr,
+ "%s",
+ _("Cleanup after abort failed.\n"));
+ GNUNET_FS_unindex_stop (info->value.unindex.uc);
+ return NULL;
+ case GNUNET_FS_STATUS_UNINDEX_STOPPED:
return NULL;
default:
- FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);
+ FPRINTF (stderr,
+ _("Unexpected status: %d\n"),
+ info->status);
return NULL;
}
return ""; /* non-null */
* @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_mime_type mime type of @a data
* @param data value of the meta data
* @param data_size number of bytes in @a data
* @return always 0
return 0;
if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type)
return 0;
- FPRINTF (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data);
+#if HAVE_LIBEXTRACTOR
+ FPRINTF (stdout,
+ "\t%s - %s\n",
+ EXTRACTOR_metatype_to_string (type),
+ data);
+#else
+ FPRINTF (stdout,
+ "\t%d - %s\n",
+ type,
+ data);
+#endif
return 0;
}
fn = GNUNET_CONTAINER_meta_data_get_by_type (m,
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
fs = GNUNET_STRINGS_byte_size_fancy (length);
- FPRINTF (stdout, _("Meta data for file `%s' (%s)\n"), fn, fs);
+ FPRINTF (stdout,
+ _("Meta data for file `%s' (%s)\n"),
+ fn,
+ fs);
GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL);
- FPRINTF (stdout, _("Keywords for file `%s' (%s)\n"), fn, fs);
+ FPRINTF (stdout,
+ _("Keywords for file `%s' (%s)\n"),
+ fn,
+ fs);
GNUNET_free (fn);
GNUNET_free (fs);
if (NULL != *uri)
GNUNET_FS_uri_ksk_get_keywords (*uri, &keyword_printer, NULL);
- FPRINTF (stdout, "%s", "\n");
+ FPRINTF (stdout,
+ "%s",
+ "\n");
}
if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m))
- GNUNET_FS_file_information_inspect (fi, &publish_inspector, fi);
+ GNUNET_FS_file_information_inspect (fi,
+ &publish_inspector, fi);
return GNUNET_OK;
}
{
if (NULL != emsg)
{
- FPRINTF (stderr, "%s\n", emsg);
+ FPRINTF (stderr,
+ "%s\n",
+ emsg);
ret = 1;
}
- GNUNET_FS_uri_destroy (uri);
- uri = NULL;
- GNUNET_FS_stop (ctx);
- ctx = NULL;
+ GNUNET_SCHEDULER_shutdown ();
}
if (NULL != emsg)
{
- FPRINTF (stderr, "%s\n", emsg);
+ FPRINTF (stderr,
+ "%s\n",
+ emsg);
ret = 1;
}
if (NULL != namespace)
{
priv = GNUNET_IDENTITY_ego_get_private_key (namespace);
- GNUNET_FS_publish_sks (ctx, priv, this_id, next_id, meta, uri, &bo,
+ GNUNET_FS_publish_sks (ctx,
+ priv,
+ this_id,
+ next_id,
+ meta,
+ uri,
+ &bo,
GNUNET_FS_PUBLISH_OPTION_NONE,
&uri_sks_continuation, NULL);
return;
}
- GNUNET_FS_uri_destroy (uri);
- uri = NULL;
- GNUNET_FS_stop (ctx);
- ctx = NULL;
+ GNUNET_SCHEDULER_shutdown ();
}
if (GNUNET_YES == item->is_directory)
{
+ if (NULL == item->meta)
+ item->meta = GNUNET_CONTAINER_meta_data_create ();
GNUNET_CONTAINER_meta_data_delete (item->meta,
EXTRACTOR_METATYPE_MIMETYPE,
NULL, 0);
FPRINTF (stderr,
"%s",
_("Could not publish\n"));
- GNUNET_SCHEDULER_shutdown ();
ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_FS_file_information_inspect (fi, &publish_inspector, NULL);
FPRINTF (stderr,
"%s",
_("Could not start publishing.\n"));
- GNUNET_SCHEDULER_shutdown ();
ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
return;
}
}
FPRINTF (stdout,
"%s",
_("Internal error scanning directory.\n"));
- if (kill_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (kill_task);
- kill_task = GNUNET_SCHEDULER_NO_TASK;
- }
- kill_task = GNUNET_SCHEDULER_add_now (&stop_scanner_task, NULL);
+ ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
break;
default:
GNUNET_assert (0);
FPRINTF (stderr,
_("Selected pseudonym `%s' unknown\n"),
pseudonym);
+ ret = 1;
GNUNET_SCHEDULER_shutdown ();
return;
}
_("Failed to parse URI: %s\n"),
emsg);
GNUNET_free (emsg);
- GNUNET_SCHEDULER_shutdown ();
ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_FS_publish_ksk (ctx, topKeywords,
ret = 1;
return;
}
- kill_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &do_stop_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&do_stop_task,
+ NULL);
if (NULL != pseudonym)
identity = GNUNET_IDENTITY_connect (cfg,
&identity_cb,