/*
This file is part of GNUnet.
- (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ (C) 2001-2013 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
*/
#include "platform.h"
#include "gnunet_fs_service.h"
+#include "gnunet_identity_service.h"
-static int ret;
+/**
+ * Global return value from 'main'.
+ */
+static int ret = 1;
+/**
+ * Command line option 'verbose' set
+ */
static int verbose;
+/**
+ * Handle to our configuration.
+ */
static const struct GNUNET_CONFIGURATION_Handle *cfg;
+/**
+ * Handle for interaction with file-sharing service.
+ */
static struct GNUNET_FS_Handle *ctx;
+/**
+ * Handle to FS-publishing operation.
+ */
static struct GNUNET_FS_PublishContext *pc;
+/**
+ * Meta-data provided via command-line option.
+ */
static struct GNUNET_CONTAINER_MetaData *meta;
+/**
+ * Keywords provided via command-line option.
+ */
static struct GNUNET_FS_Uri *topKeywords;
-static struct GNUNET_FS_Uri *uri;
-
+/**
+ * Options we set for published blocks.
+ */
static struct GNUNET_FS_BlockOptions bo = { {0LL}, 1, 365, 1 };
+/**
+ * Value of URI provided on command-line (when not publishing
+ * a file but just creating UBlocks to refer to an existing URI).
+ */
static char *uri_string;
+/**
+ * Value of URI provided on command-line (when not publishing
+ * a file but just creating UBlocks to refer to an existing URI);
+ * parsed version of 'uri_string'.
+ */
+static struct GNUNET_FS_Uri *uri;
+
+/**
+ * Command-line option for namespace publishing: identifier for updates
+ * to this publication.
+ */
static char *next_id;
+/**
+ * Command-line option for namespace publishing: identifier for this
+ * publication.
+ */
static char *this_id;
+/**
+ * Command-line option identifying the pseudonym to use for the publication.
+ */
static char *pseudonym;
+/**
+ * Command-line option for 'inserting'
+ */
static int do_insert;
+/**
+ * Command-line option to disable meta data extraction.
+ */
static int disable_extractor;
+/**
+ * Command-line option to merely simulate publishing operation.
+ */
static int do_simulate;
+/**
+ * Command-line option to only perform meta data extraction, but not publish.
+ */
static int extract_only;
+/**
+ * Command-line option to disable adding creation time.
+ */
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).
+ */
static struct GNUNET_FS_DirScanner *ds;
-static struct GNUNET_FS_ShareTreeItem * directory_scan_intermediary_result;
-
-static struct GNUNET_FS_ShareTreeItem * directory_scan_result;
+/**
+ * Which namespace do we publish to? NULL if we do not publish to
+ * a namespace.
+ */
+static struct GNUNET_IDENTITY_Ego *namespace;
-static struct GNUNET_FS_ProcessMetadataContext *pmc;
+/**
+ * Handle to identity service.
+ */
+static struct GNUNET_IDENTITY_Handle *identity;
-static struct GNUNET_FS_Namespace *namespace;
/**
- * FIXME: docu
+ * We are finished with the publishing operation, clean up all
+ * FS state.
+ *
+ * @param cls NULL
+ * @param tc scheduler context
*/
static void
do_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct GNUNET_FS_PublishContext *p;
kill_task = GNUNET_SCHEDULER_NO_TASK;
- if (pc != NULL)
+ if (NULL != pc)
{
p = pc;
pc = NULL;
{
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)
+ {
+ GNUNET_IDENTITY_disconnect (identity);
+ identity = NULL;
+ }
+ GNUNET_FS_stop (ctx);
+ ctx = NULL;
+ ret = 1;
}
static void *
progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
{
- char *s;
+ const char *s;
+ char *suri;
switch (info->status)
{
case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
if (verbose)
{
- s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta);
- FPRINTF (stdout, _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
+ s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta,
+ GNUNET_YES);
+ FPRINTF (stdout,
+ _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
info->value.publish.filename,
(unsigned long long) info->value.publish.completed,
(unsigned long long) info->value.publish.size, s);
- GNUNET_free (s);
+ }
+ break;
+ case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY:
+ if (verbose)
+ {
+ s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.specifics.progress_directory.eta,
+ GNUNET_YES);
+ FPRINTF (stdout,
+ _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
+ info->value.publish.filename,
+ (unsigned long long) info->value.publish.specifics.progress_directory.completed,
+ (unsigned long long) info->value.publish.specifics.progress_directory.total, s);
}
break;
case GNUNET_FS_STATUS_PUBLISH_ERROR:
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.
+ suri = 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)
+ FPRINTF (stdout, _("URI is `%s'.\n"), suri);
+ GNUNET_free (suri);
+ if (NULL == info->value.publish.pctx)
{
- if (kill_task != GNUNET_SCHEDULER_NO_TASK)
+ if (GNUNET_SCHEDULER_NO_TASK != kill_task)
{
GNUNET_SCHEDULER_cancel (kill_task);
kill_task = GNUNET_SCHEDULER_NO_TASK;
}
kill_task = GNUNET_SCHEDULER_add_now (&do_stop_task, NULL);
}
+ ret = 0;
break;
case GNUNET_FS_STATUS_PUBLISH_STOPPED:
GNUNET_break (NULL == pc);
enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
const char *data, size_t data_size)
{
- if ((format != EXTRACTOR_METAFORMAT_UTF8) &&
- (format != EXTRACTOR_METAFORMAT_C_STRING))
+ if ((EXTRACTOR_METAFORMAT_UTF8 != format) &&
+ (EXTRACTOR_METAFORMAT_C_STRING != format))
return 0;
- if (type == EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME)
+ if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type)
return 0;
FPRINTF (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data);
return 0;
if (cls == fi)
return GNUNET_OK;
+ if ( (disable_extractor) &&
+ (NULL != *uri) )
+ {
+ GNUNET_FS_uri_destroy (*uri);
+ *uri = NULL;
+ }
if (NULL != topKeywords)
{
- if (*uri != NULL)
+ if (NULL != *uri)
{
new_uri = GNUNET_FS_uri_ksk_merge (topKeywords, *uri);
GNUNET_FS_uri_destroy (*uri);
/**
- * FIXME: docu
+ * Function called upon completion of the publishing
+ * of the UBLOCK for the SKS URI. As this is the last
+ * step, stop our interaction with FS (clean up).
+ *
+ * @param cls NULL (closure)
+ * @param sks_uri URI for the block that was published
+ * @param emsg error message, NULL on success
*/
static void
-uri_sks_continuation (void *cls, const struct GNUNET_FS_Uri *ksk_uri,
+uri_sks_continuation (void *cls, const struct GNUNET_FS_Uri *sks_uri,
const char *emsg)
{
- if (emsg != NULL)
+ if (NULL != emsg)
{
FPRINTF (stderr, "%s\n", emsg);
ret = 1;
/**
- * FIXME: docu
+ * Function called upon completion of the publishing
+ * of the UBLOCK for the KSK URI. Continue with
+ * publishing the SKS URI (if applicable) or clean up.
+ *
+ * @param cls NULL (closure)
+ * @param ksk_uri URI for the block that was published
+ * @param emsg error message, NULL on success
*/
static void
uri_ksk_continuation (void *cls, const struct GNUNET_FS_Uri *ksk_uri,
const char *emsg)
{
- struct GNUNET_FS_Namespace *ns;
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv;
- if (emsg != NULL)
+ if (NULL != emsg)
{
FPRINTF (stderr, "%s\n", emsg);
ret = 1;
}
- if (pseudonym != NULL)
+ if (NULL != namespace)
{
- 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, &bo,
- GNUNET_FS_PUBLISH_OPTION_NONE,
- uri_sks_continuation, NULL);
- GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_NO));
- return;
- }
+ priv = GNUNET_IDENTITY_ego_get_private_key (namespace);
+ 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;
ctx = NULL;
}
+
+/**
+ * Iterate over the results from the directory scan and extract
+ * the desired information for the publishing operation.
+ *
+ * @param item root with the data from the directroy scan
+ * @return handle with the information for the publishing operation
+ */
static struct GNUNET_FS_FileInformation *
get_file_information (struct GNUNET_FS_ShareTreeItem *item)
{
struct GNUNET_FS_FileInformation *fic;
struct GNUNET_FS_ShareTreeItem *child;
- if (item->is_directory)
+ if (GNUNET_YES == item->is_directory)
{
GNUNET_CONTAINER_meta_data_delete (item->meta,
- EXTRACTOR_METATYPE_MIMETYPE, NULL, 0);
+ EXTRACTOR_METATYPE_MIMETYPE,
+ NULL, 0);
GNUNET_FS_meta_data_make_directory (item->meta);
- GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME,
- GNUNET_NO);
- fi = GNUNET_FS_file_information_create_empty_directory (
- ctx, NULL, item->ksk_uri,
- item->meta, &bo, item->filename);
+ if (NULL == item->ksk_uri)
+ {
+ const char *mime = GNUNET_FS_DIRECTORY_MIME;
+ item->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &mime);
+ }
+ else
+ GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME,
+ GNUNET_NO);
+ fi = GNUNET_FS_file_information_create_empty_directory (ctx, NULL,
+ item->ksk_uri,
+ item->meta,
+ &bo, item->filename);
for (child = item->children_head; child; child = child->next)
{
fic = get_file_information (child);
}
else
{
- fi = GNUNET_FS_file_information_create_from_file (
- ctx, NULL, item->filename,
- item->ksk_uri, item->meta, !do_insert,
- &bo);
+ fi = GNUNET_FS_file_information_create_from_file (ctx, NULL,
+ item->filename,
+ item->ksk_uri, item->meta,
+ !do_insert,
+ &bo);
}
- GNUNET_CONTAINER_meta_data_destroy (item->meta);
- GNUNET_FS_uri_destroy (item->ksk_uri);
- GNUNET_free (item->short_filename);
- GNUNET_free (item->filename);
- GNUNET_free (item);
return fi;
}
+
+/**
+ * We've finished scanning the directory and optimized the meta data.
+ * Begin the publication process.
+ *
+ * @param directory_scan_result result from the directory scan, freed in this function
+ */
static void
-directory_trim_complete (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result)
{
struct GNUNET_FS_FileInformation *fi;
- directory_scan_result = directory_scan_intermediary_result;
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv;
+
fi = get_file_information (directory_scan_result);
- directory_scan_result = NULL;
- if (fi == NULL)
+ GNUNET_FS_share_tree_free (directory_scan_result);
+ if (NULL == fi)
{
FPRINTF (stderr, "%s", _("Could not publish\n"));
- if (namespace != NULL)
- GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
- GNUNET_FS_stop (ctx);
+ GNUNET_SCHEDULER_shutdown ();
ret = 1;
return;
}
GNUNET_FS_file_information_inspect (fi, &publish_inspector, NULL);
if (extract_only)
{
- if (namespace != NULL)
- GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
GNUNET_FS_file_information_destroy (fi, NULL, NULL);
- GNUNET_FS_stop (ctx);
+ GNUNET_SCHEDULER_shutdown ();
return;
}
- pc = GNUNET_FS_publish_start (ctx, fi, namespace, this_id, next_id,
+ if (NULL == namespace)
+ priv = NULL;
+ else
+ priv = GNUNET_IDENTITY_ego_get_private_key (namespace);
+ pc = GNUNET_FS_publish_start (ctx, fi,
+ priv, this_id, next_id,
(do_simulate) ?
GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY :
GNUNET_FS_PUBLISH_OPTION_NONE);
if (NULL == pc)
{
FPRINTF (stderr, "%s", _("Could not start publishing.\n"));
- GNUNET_FS_stop (ctx);
+ GNUNET_SCHEDULER_shutdown ();
ret = 1;
return;
}
}
-static int
-directory_scan_cb (void *cls, struct GNUNET_FS_DirScanner *ds,
- const char *filename, char is_directory,
- enum GNUNET_FS_DirScannerProgressUpdateReason reason)
+
+/**
+ * Function called by the directory scanner as we build the tree
+ * that we will need to publish later.
+ *
+ * @param cls closure
+ * @param filename which file we are making progress on
+ * @param is_directory GNUNET_YES if this is a directory,
+ * GNUNET_NO if this is a file
+ * GNUNET_SYSERR if it is neither (or unknown)
+ * @param reason kind of progress we are making
+ */
+static void
+directory_scan_cb (void *cls,
+ const char *filename,
+ int is_directory,
+ enum GNUNET_FS_DirScannerProgressUpdateReason reason)
{
+ struct GNUNET_FS_ShareTreeItem *directory_scan_result;
+
switch (reason)
{
- case GNUNET_DIR_SCANNER_NEW_FILE:
- if (filename != NULL)
- {
- if (is_directory)
- FPRINTF (stdout, _("Scanning directory `%s'.\n"), filename);
- else
- FPRINTF (stdout, _("Scanning file `%s'.\n"), filename);
- }
- break;
- case GNUNET_DIR_SCANNER_DOES_NOT_EXIST:
- if (filename != NULL)
- {
- FPRINTF (stdout,
- _("Failed to scan `%s', because it does not exist.\n"),
- filename);
- }
- break;
- case GNUNET_DIR_SCANNER_ASKED_TO_STOP:
- if (filename != NULL)
- {
- FPRINTF (stdout,
- _("Scanner was about to scan `%s', but is now stopping.\n"),
- filename);
- }
+ case GNUNET_FS_DIRSCANNER_FILE_START:
+ if (verbose > 1)
+ {
+ if (is_directory == GNUNET_YES)
+ FPRINTF (stdout, _("Scanning directory `%s'.\n"), filename);
else
- FPRINTF (stdout, "%s", _("Scanner is stopping.\n"));
- break;
- case GNUNET_DIR_SCANNER_SHUTDOWN:
- FPRINTF (stdout, "%s", _("Client is shutting down.\n"));
- break;
- case GNUNET_DIR_SCANNER_FINISHED:
- FPRINTF (stdout, "%s", _("Scanner has finished.\n"));
- break;
- case GNUNET_DIR_SCANNER_PROTOCOL_ERROR:
- FPRINTF (stdout, "%s",
- _("There was a failure communicating with the scanner.\n"));
- break;
- default:
- FPRINTF (stdout, _("Got unknown scanner update with filename `%s'.\n"),
- filename);
- break;
+ FPRINTF (stdout, _("Scanning file `%s'.\n"), filename);
+ }
+ break;
+ case GNUNET_FS_DIRSCANNER_FILE_IGNORED:
+ FPRINTF (stderr,
+ _("There was trouble processing file `%s', skipping it.\n"),
+ filename);
+ break;
+ case GNUNET_FS_DIRSCANNER_ALL_COUNTED:
+ if (verbose)
+ FPRINTF (stdout, "%s", _("Preprocessing complete.\n"));
+ break;
+ case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED:
+ if (verbose > 2)
+ FPRINTF (stdout, _("Extracting meta data from file `%s' complete.\n"), filename);
+ break;
+ case GNUNET_FS_DIRSCANNER_FINISHED:
+ if (verbose > 1)
+ FPRINTF (stdout, "%s", _("Meta data extraction has finished.\n"));
+ directory_scan_result = GNUNET_FS_directory_scan_get_result (ds);
+ ds = NULL;
+ GNUNET_FS_share_tree_trim (directory_scan_result);
+ directory_trim_complete (directory_scan_result);
+ break;
+ case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR:
+ 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);
+ break;
+ default:
+ GNUNET_assert (0);
+ break;
}
- if ((filename == NULL && GNUNET_DIR_SCANNER_FINISHED)
- || reason == GNUNET_DIR_SCANNER_PROTOCOL_ERROR
- || reason == GNUNET_DIR_SCANNER_SHUTDOWN)
+ fflush (stdout);
+}
+
+
+/**
+ * Continuation proceeding with initialization after identity subsystem
+ * has been initialized.
+ *
+ * @param args0 filename to publish
+ */
+static void
+identity_continuation (const char *args0)
+{
+ char *ex;
+ char *emsg;
+
+ if ( (NULL != pseudonym) &&
+ (NULL == namespace) )
+ {
+ FPRINTF (stderr, _("Selected pseudonym `%s' unknown\n"), pseudonym);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ if (NULL != uri_string)
{
- /* Any of this causes us to try to clean up the scanner */
- directory_scan_intermediary_result = GNUNET_FS_directory_scan_cleanup (ds);
- pmc = GNUNET_FS_trim_share_tree (directory_scan_intermediary_result,
- &directory_trim_complete, NULL);
+ emsg = NULL;
+ if (NULL == (uri = GNUNET_FS_uri_parse (uri_string, &emsg)))
+ {
+ FPRINTF (stderr, _("Failed to parse URI: %s\n"), emsg);
+ GNUNET_free (emsg);
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
+ GNUNET_FS_publish_ksk (ctx, topKeywords, meta, uri, &bo,
+ GNUNET_FS_PUBLISH_OPTION_NONE, &uri_ksk_continuation,
+ NULL);
+ return;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex))
+ ex = NULL;
+ if (0 != ACCESS (args0, R_OK))
+ {
+ FPRINTF (stderr,
+ _("Failed to access `%s': %s\n"),
+ args0,
+ STRERROR (errno));
+ GNUNET_free_non_null (ex);
+ return;
+ }
+ ds = GNUNET_FS_directory_scan_start (args0,
+ disable_extractor,
+ ex,
+ &directory_scan_cb, NULL);
+ if (NULL == ds)
+ {
+ FPRINTF (stderr,
+ "%s", _("Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n"));
+ GNUNET_free_non_null (ex);
+ return;
+ }
+ GNUNET_free_non_null (ex);
+}
- ds = NULL;
- /* FIXME: change the tree processor to be able to free untrimmed trees
- * right here instead of waiting for trimming to complete, if we need to
- * cancel everything.
- */
+
+/**
+ * Function called by identity service with known pseudonyms.
+ *
+ * @param cls closure with 'const char *' of filename to publish
+ * @param ego ego handle
+ * @param ctx context for application to store data for this ego
+ * (during the lifetime of this process, initially NULL)
+ * @param name name assigned by the user for this ego,
+ * NULL if the user just deleted the ego and it
+ * must thus no longer be used
+ */
+static void
+identity_cb (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *name)
+{
+ const char *args0 = cls;
+
+ if (NULL == ego)
+ {
+ identity_continuation (args0);
+ return;
}
- return 0;
+ if (0 == strcmp (name, pseudonym))
+ namespace = ego;
}
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
- char *ex;
- char *emsg;
-
/* check arguments */
- if ((uri_string != NULL) && (extract_only))
+ if ((NULL != uri_string) && (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)))
+ if (((NULL == uri_string) || (extract_only)) &&
+ ((NULL == args[0]) || (NULL != args[1])))
{
printf (_("You must specify one and only one filename for insertion.\n"));
ret = -1;
return;
}
- if ((uri_string != NULL) && (args[0] != NULL))
+ if ((NULL != uri_string) && (NULL != args[0]))
{
printf (_("You must NOT specify an URI and a filename.\n"));
ret = -1;
return;
}
- if (pseudonym != NULL)
+ if (NULL != pseudonym)
{
if (NULL == this_id)
{
ret = 1;
return;
}
- namespace = NULL;
- if (NULL != pseudonym)
- {
- namespace = GNUNET_FS_namespace_create (ctx, pseudonym);
- if (NULL == namespace)
- {
- FPRINTF (stderr, _("Could not create namespace `%s'\n"), pseudonym);
- GNUNET_FS_stop (ctx);
- ret = 1;
- return;
- }
- }
- if (NULL != uri_string)
- {
- 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, &bo,
- GNUNET_FS_PUBLISH_OPTION_NONE, &uri_ksk_continuation,
- NULL);
- if (namespace != NULL)
- GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
- return;
- }
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex))
- ex = NULL;
-
- ds = GNUNET_FS_directory_scan_start (args[0],
- disable_extractor,
- ex,
- &directory_scan_cb, NULL);
kill_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_stop_task,
NULL);
+ if (NULL != pseudonym)
+ identity = GNUNET_IDENTITY_connect (cfg,
+ &identity_cb, args[0]);
+ else
+ identity_continuation (args[0]);
}
0, &GNUNET_GETOPT_set_one, &verbose},
GNUNET_GETOPT_OPTION_END
};
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "GNUnet publish starts\n");
bo.expiration_time =
- GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);
- return (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc, argv, "gnunet-publish [OPTIONS] FILENAME",
- gettext_noop
- ("Publish a file or directory on GNUnet"),
- options, &run, NULL)) ? ret : 1;
+ GNUNET_TIME_year_to_time (GNUNET_TIME_get_current_year () + 2);
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+ ret = (GNUNET_OK ==
+ GNUNET_PROGRAM_run (argc, argv, "gnunet-publish [OPTIONS] FILENAME",
+ gettext_noop
+ ("Publish a file or directory on GNUnet"),
+ options, &run, NULL)) ? ret : 1;
+ GNUNET_free ((void*) argv);
+ return ret;
}
/* end of gnunet-publish.c */