206 static char progress_canary[] =
"canary";
210 switch (
info->status)
221 _ (
"Publishing `%s' at %llu/%llu (%s remaining)\n"),
222 info->value.publish.filename,
223 (
unsigned long long)
info->value.publish.completed,
224 (
unsigned long long)
info->value.publish.size,
233 .progress_directory.eta,
236 _ (
"Publishing `%s' at %llu/%llu (%s remaining)\n"),
237 info->value.publish.filename,
239 info->value.publish.specifics.progress_directory.completed,
241 info->value.publish.specifics.progress_directory.total,
248 _ (
"Error publishing: %s.\n"),
249 info->value.publish.specifics.error.message);
256 _ (
"Publishing `%s' done.\n"),
257 info->value.publish.filename);
260 fprintf (stdout,
_ (
"URI is `%s'.\n"), suri);
262 if (NULL !=
info->value.publish.specifics.completed.sks_uri)
265 info->value.publish.specifics.completed.sks_uri);
266 fprintf (stdout,
_ (
"Namespace URI is `%s'.\n"), suri);
269 if (NULL ==
info->value.publish.pctx)
281 fprintf (stderr,
"%s",
_ (
"Starting cleanup after abort\n"));
288 fprintf (stderr,
"%s",
_ (
"Cleanup after abort completed.\n"));
293 fprintf (stderr,
"%s",
_ (
"Cleanup after abort failed.\n"));
301 fprintf (stderr,
_ (
"Unexpected status: %d\n"),
info->status);
304 return progress_canary;
324 enum EXTRACTOR_MetaType
type,
325 enum EXTRACTOR_MetaFormat format,
326 const char *data_mime_type,
330 if ((EXTRACTOR_METAFORMAT_UTF8 != format) &&
331 (EXTRACTOR_METAFORMAT_C_STRING != format))
336 fprintf (stdout,
"\t%s - %s\n", EXTRACTOR_metatype_to_string (
type),
data);
338 fprintf (stdout,
"\t%d - %s\n",
type,
data);
355 fprintf (stdout,
"\t%s\n", keyword);
400 if (NULL != *uri_info)
427 fprintf (stdout,
_ (
"Meta data for file `%s' (%s)\n"), fn,
fs);
429 fprintf (stdout,
_ (
"Keywords for file `%s' (%s)\n"), fn,
fs);
432 if (NULL != *uri_info)
434 fprintf (stdout,
"%s",
"\n");
458 fprintf (stderr,
"%s\n", emsg);
484 fprintf (stderr,
"%s\n", emsg);
487 if (NULL ==
namespace)
525 if (NULL == item->
meta)
528 EXTRACTOR_METATYPE_MIMETYPE,
584 fprintf (stderr,
"%s",
_ (
"Could not publish\n"));
597 if (NULL !=
namespace)
613 fprintf (stderr,
"%s",
_ (
"Could not start publishing.\n"));
646 fprintf (stdout,
_ (
"Scanning directory `%s'.\n"),
filename);
648 fprintf (stdout,
_ (
"Scanning file `%s'.\n"),
filename);
654 _ (
"There was trouble processing file `%s', skipping it.\n"),
660 fprintf (stdout,
"%s",
_ (
"Preprocessing complete.\n"));
666 _ (
"Extracting meta data from file `%s' complete.\n"),
672 fprintf (stdout,
"%s",
_ (
"Meta data extraction has finished.\n"));
680 fprintf (stdout,
"%s",
_ (
"Error scanning directory.\n"));
705 if ((NULL !=
pseudonym) && (NULL ==
namespace))
707 fprintf (stderr,
_ (
"Selected pseudonym `%s' unknown\n"),
pseudonym);
717 fprintf (stderr,
_ (
"Failed to parse URI: %s\n"), emsg);
736 if (0 != access (args0, R_OK))
739 _ (
"Failed to access `%s': %s\n"),
756 "Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n"));
781 const char *args0 = cls;
812 printf (
_ (
"Cannot extract metadata from a URI!\n"));
817 ((NULL ==
args[0]) || (NULL !=
args[1])))
819 printf (
_ (
"You must specify one and only one filename for insertion.\n"));
825 printf (
_ (
"You must NOT specify an URI and a filename.\n"));
834 _ (
"Option `%s' is required when using option `%s'.\n"),
846 _ (
"Option `%s' makes no sense without option `%s'.\n"),
855 _ (
"Option `%s' makes no sense without option `%s'.\n"),
871 fprintf (stderr,
_ (
"Could not initialize `%s' subsystem.\n"),
"FS");
891main (
int argc,
char *
const *argv)
898 "set the desired LEVEL of sender-anonymity"),
903 gettext_noop (
"do not use libextractor to add keywords or metadata"),
906 "enable-creation-time",
908 "enable adding the creation time to the "
909 "metadata of the uploaded file"),
914 "print list of extracted keywords that would "
915 "be used, but do not perform upload"),
922 "add an additional keyword for the top-level "
923 "file or directory (this option can be specified multiple times)"),
929 gettext_noop (
"set the meta-data for the given TYPE to the given VALUE"),
934 gettext_noop (
"do not index, perform full insertion (stores "
935 "entire file in encrypted form in GNUnet database)"),
942 "published in the future (for namespace insertions only)"),
948 "specify the priority of the content"),
954 "publish the files under the pseudonym "
955 "NAME (place file into namespace)"),
961 "set the desired replication LEVEL"),
966 "only simulate the process but do not do "
967 "any actual publishing (useful to compute URIs)"),
973 "set the ID of this version of the publication "
974 "(for namespace insertions only)"),
981 "URI to be published (can be used instead of passing a "
982 "file to add keywords to the file with the respective URI)"),
997 "gnunet-publish [OPTIONS] FILENAME",
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static char * plugin_name
Name of our plugin.
static char * data
The data to insert into the dht.
static struct GNUNET_FS_Handle * ctx
static struct GNUNET_FS_Handle * fs
Handle to FS service.
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static char * name
Name (label) of the records to list.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static int disable_extractor
Command-line option to disable meta data extraction.
static unsigned int verbose
Command line option 'verbose' set.
static struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
static int do_simulate
Command-line option to merely simulate publishing operation.
static char * uri_string
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
static char * pseudonym
Command-line option identifying the pseudonym to use for the publication.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our configuration.
static void uri_sks_continuation(void *cls, const struct GNUNET_FS_Uri *sks_uri, const char *emsg)
Function called upon completion of the publishing of the UBLOCK for the SKS URI.
static void uri_ksk_continuation(void *cls, const struct GNUNET_FS_Uri *ksk_uri, const char *emsg)
Function called upon completion of the publishing of the UBLOCK for the KSK URI.
static int do_insert
Command-line option for 'inserting'.
static int ret
Global return value from main().
static void * progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Called by FS client to give information about the progress of an operation.
static int enable_creation_time
Command-line option to disable adding creation time.
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
static int publish_inspector(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_FS_MetaData *m, struct GNUNET_FS_Uri **uri_info, struct GNUNET_FS_BlockOptions *bo_info, int *do_index, void **client_info)
Function called on all entries before the publication.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
static void do_stop_task(void *cls)
We are finished with the publishing operation, clean up all FS state.
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
static struct GNUNET_FS_FileInformation * get_file_information(struct GNUNET_FS_ShareTreeItem *item)
Iterate over the results from the directory scan and extract the desired information for the publishi...
static char * this_id
Command-line option for namespace publishing: identifier for this publication.
static int keyword_printer(void *cls, const char *keyword, int is_mandatory)
Iterator printing keywords.
static void directory_scan_cb(void *cls, const char *filename, int 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.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Function called by identity service with known pseudonyms.
static struct GNUNET_FS_Handle * fs_handle
Handle for interaction with file-sharing service.
int main(int argc, char *const *argv)
The main function to publish content to GNUnet.
static int extract_only
Command-line option to only perform meta data extraction, but not publish.
static int meta_printer(void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_size)
Print metadata entries (except binary metadata and the filename).
static struct GNUNET_FS_Uri * topKeywords
Keywords provided via command-line option.
static void identity_continuation(const char *args0)
Continuation proceeding with initialization after identity subsystem has been initialized.
static void directory_trim_complete(struct GNUNET_FS_ShareTreeItem *directory_scan_result)
We've finished scanning the directory and optimized the meta data.
static struct GNUNET_OS_Process * p
Helper process we started.
API for file sharing via GNUnet.
Identity service; implements identity management for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
void GNUNET_FS_share_tree_free(struct GNUNET_FS_ShareTreeItem *toplevel)
Release memory of a share item tree.
struct GNUNET_FS_PublishContext * GNUNET_FS_publish_start(struct GNUNET_FS_Handle *h, struct GNUNET_FS_FileInformation *fi, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *nid, const char *nuid, enum GNUNET_FS_PublishOptions options)
Publish a file or directory.
void GNUNET_FS_meta_data_make_directory(struct GNUNET_FS_MetaData *md)
Set the MIMETYPE information for the given metadata to "application/gnunet-directory".
#define GNUNET_FS_DIRECTORY_MIME
int GNUNET_FS_file_information_add(struct GNUNET_FS_FileInformation *dir, struct GNUNET_FS_FileInformation *ent)
Add an entry to a directory in a publish-structure.
struct GNUNET_FS_PublishKskContext * GNUNET_FS_publish_ksk(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *ksk_uri, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
Publish a KBlock on GNUnet.
void GNUNET_FS_file_information_inspect(struct GNUNET_FS_FileInformation *dir, GNUNET_FS_FileInformationProcessor proc, void *proc_cls)
Inspect a file or directory in a publish-structure.
void GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc)
Clean up after completion of an unindex operation.
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_empty_directory(struct GNUNET_FS_Handle *h, void *client_info, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_BlockOptions *bo, const char *filename)
Create an entry for an empty directory in a publish-structure.
struct GNUNET_FS_Handle * GNUNET_FS_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, enum GNUNET_FS_Flags flags,...)
Setup a connection to the file-sharing service.
struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_create_from_args(unsigned int argc, const char **argv)
Create an FS URI from a user-supplied command line of keywords.
struct GNUNET_FS_ShareTreeItem * GNUNET_FS_directory_scan_get_result(struct GNUNET_FS_DirScanner *ds)
Obtain the result of the scan after the scan has signalled completion.
int GNUNET_FS_uri_ksk_get_keywords(const struct GNUNET_FS_Uri *uri, GNUNET_FS_KeywordIterator iterator, void *iterator_cls)
Iterate over all keywords in this keyword URI.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
struct GNUNET_FS_PublishSksContext * GNUNET_FS_publish_sks(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *identifier, const char *update, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
Publish an SBlock on GNUnet.
struct GNUNET_FS_DirScanner * GNUNET_FS_directory_scan_start(const char *filename, int disable_extractor, const char *ex, GNUNET_FS_DirScannerProgressCallback cb, void *cb_cls)
Start a directory scanner.
GNUNET_FS_DirScannerProgressUpdateReason
Progress reasons of the directory scanner.
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_FS_MetaData *md)
Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet direct...
struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_from_file(struct GNUNET_FS_Handle *h, void *client_info, const char *filename, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
Create an entry for a file in a publish-structure.
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
struct GNUNET_GETOPT_CommandLineOption GNUNET_FS_GETOPT_METADATA(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_FS_MetaData **meta)
Allow user to specify metadata.
void GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc)
Stop a publication.
void GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
Abort the scan.
void GNUNET_FS_file_information_destroy(struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
Destroy publish-structure.
void GNUNET_FS_share_tree_trim(struct GNUNET_FS_ShareTreeItem *toplevel)
Process a share item tree, moving frequent keywords up and copying frequent metadata up.
struct GNUNET_GETOPT_CommandLineOption GNUNET_FS_GETOPT_KEYWORDS(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_FS_Uri **topKeywords)
Allow user to specify keywords.
struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_merge(const struct GNUNET_FS_Uri *u1, const struct GNUNET_FS_Uri *u2)
Merge the sets of keywords from two KSK URIs.
void GNUNET_FS_uri_ksk_add_keyword(struct GNUNET_FS_Uri *uri, const char *keyword, int is_mandatory)
Add the given keyword to the set of keywords represented by the URI.
@ GNUNET_FS_FLAGS_NONE
No special flags set.
@ GNUNET_FS_OPTIONS_END
Last option in the VARARG list.
@ GNUNET_FS_STATUS_UNINDEX_PROGRESS
Notification that we made progress unindexing a file.
@ GNUNET_FS_STATUS_UNINDEX_START
Notification that we started to unindex a file.
@ GNUNET_FS_STATUS_PUBLISH_STOPPED
Notification that we have stopped the process of uploading a file structure; no further events will b...
@ GNUNET_FS_STATUS_PUBLISH_ERROR
Notification that an error was encountered sharing a file structure.
@ GNUNET_FS_STATUS_UNINDEX_STOPPED
Notification that the unindexing of this file was stopped (final event for this action).
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS
Notification that we are making progress sharing a file structure.
@ GNUNET_FS_STATUS_UNINDEX_COMPLETED
Notification that the unindexing of this file was completed.
@ GNUNET_FS_STATUS_UNINDEX_ERROR
Notification that we encountered an error unindexing a file.
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY
Notification that we are making progress sharing a directory.
@ GNUNET_FS_STATUS_PUBLISH_START
Notification that we have started to publish a file structure.
@ GNUNET_FS_STATUS_PUBLISH_COMPLETED
Notification that we completed sharing a file structure.
@ GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY
Simulate publishing.
@ GNUNET_FS_PUBLISH_OPTION_NONE
No options (use defaults for everything).
@ GNUNET_FS_DIRSCANNER_INTERNAL_ERROR
There was an internal error.
@ GNUNET_FS_DIRSCANNER_FILE_IGNORED
We're having trouble accessing a file (soft-error); it will be ignored.
@ GNUNET_FS_DIRSCANNER_FINISHED
Last call to the progress function: we have finished scanning the directory.
@ GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED
We've finished extracting meta data from a file.
@ GNUNET_FS_DIRSCANNER_ALL_COUNTED
We've found all files (in the pre-pass).
@ GNUNET_FS_DIRSCANNER_FILE_START
We've started processing a file or directory.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
const struct GNUNET_CRYPTO_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
@ GNUNET_PUBLIC_KEY_TYPE_ECDSA
The identity type.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
char * GNUNET_STRINGS_byte_size_fancy(unsigned long long size)
Convert a given filesize into a fancy human-readable format.
struct GNUNET_TIME_Absolute GNUNET_TIME_year_to_time(unsigned int year)
Convert a year to an expiration time of January 1st of that year.
unsigned int GNUNET_TIME_get_current_year(void)
Return the current year (e.g.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Private ECC key encoded for transmission.
A private key for an identity as per LSD0001.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
Settings for publishing a block (which may of course also apply to an entire directory or file).
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP,...
uint32_t content_priority
How important is it for us to store the block? If we run out of space, the highest-priority,...
uint32_t replication_level
How often should we try to migrate the block to other peers? Only used if "CONTENT_PUSHING" is set to...
struct GNUNET_TIME_Absolute expiration_time
At what time should the block expire? Data blocks (DBLOCKS and IBLOCKS) may still be used even if the...
An opaque structure a pointer to which is returned to the caller to be used to control the scanner.
Master context for most FS operations.
Argument given to the progress callback with information about what is going on.
Handle for controlling a publication process.
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
A node of a directory tree (produced by dirscanner)
int is_directory
GNUNET_YES if this is a directory
struct GNUNET_FS_Uri * ksk_uri
Keywords for this file or directory (derived from metadata).
struct GNUNET_FS_ShareTreeItem * children_head
This is a doubly-linked tree NULL for files and empty directories.
struct GNUNET_FS_MetaData * meta
Metadata for this file or directory.
char * filename
Name of the file/directory.
A Universal Resource Identifier (URI), opaque.
Definition of a command line option.