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
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
static struct GNUNET_FS_Handle *ctx;
-static struct GNUNET_SCHEDULER_Handle *sched;
-
static struct GNUNET_FS_PublishContext *pc;
static struct GNUNET_CONTAINER_MetaData *meta;
info->value.publish.specifics.error.message);
if (kill_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (sched,
- kill_task);
+ GNUNET_SCHEDULER_cancel (kill_task);
kill_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_SCHEDULER_add_continuation (sched,
- &do_stop_task,
+ GNUNET_SCHEDULER_add_continuation (&do_stop_task,
NULL,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
{
if (kill_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (sched,
- kill_task);
+ GNUNET_SCHEDULER_cancel (kill_task);
kill_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_SCHEDULER_add_continuation (sched,
- &do_stop_task,
+ GNUNET_SCHEDULER_add_continuation (&do_stop_task,
NULL,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
}
* @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
struct GNUNET_FS_Uri **uri,
unsigned int *anonymity,
unsigned int *priority,
+ int *do_index,
struct GNUNET_TIME_Absolute *expirationTime,
void **client_info)
{
* Main function that will be run by the scheduler.
*
* @param cls closure
- * @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 *s,
char *const *args,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
struct GNUNET_FS_FileInformation *fi;
struct GNUNET_FS_Namespace *namespace;
- struct EXTRACTOR_PluginList *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) ) )
{
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)
return;
}
}
- if ( (args[0] == NULL) &&
- (uri_string == NULL) )
- {
- fprintf (stderr,
- _("Need the name of a file to publish!\n"));
- ret = 1;
- return;
- }
cfg = c;
- ctx = GNUNET_FS_start (sched,
- cfg,
+ ctx = GNUNET_FS_start (cfg,
"gnunet-publish",
&progress_cb,
NULL,
GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
return;
}
- l = NULL;
+ plugins = NULL;
if (! disable_extractor)
{
- l = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);
+ 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_plugin_add_config (l, ex, EXTRACTOR_OPTION_DEFAULT_POLICY);
+ plugins = EXTRACTOR_plugin_add_config (plugins, ex, EXTRACTOR_OPTION_DEFAULT_POLICY);
GNUNET_free (ex);
}
}
NULL,
args[0],
&GNUNET_FS_directory_scanner_default,
- l,
+ plugins,
!do_insert,
anonymity,
priority,
meta = GNUNET_CONTAINER_meta_data_create ();
GNUNET_FS_meta_data_extract_from_file (meta,
args[0],
- l);
+ plugins);
fi = GNUNET_FS_file_information_create_from_file (ctx,
NULL,
args[0],
GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION));
GNUNET_break (fi != NULL);
}
- EXTRACTOR_plugin_remove_all (l);
+ EXTRACTOR_plugin_remove_all (plugins);
if (fi == NULL)
{
fprintf (stderr,
ret = 1;
return;
}
- kill_task = GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_TIME_UNIT_FOREVER_REL,
+ kill_task = GNUNET_SCHEDULER_add_delayed (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},
- {'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
-};
/**
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,