GNUnet 0.22.2
gnunet-publish.c File Reference

publishing files on GNUnet More...

#include "platform.h"
#include "gnunet_fs_service.h"
#include "gnunet_identity_service.h"
Include dependency graph for gnunet-publish.c:

Go to the source code of this file.

Functions

static void do_stop_task (void *cls)
 We are finished with the publishing operation, clean up all FS state. More...
 
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. More...
 
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). More...
 
static int keyword_printer (void *cls, const char *keyword, int is_mandatory)
 Iterator printing keywords. More...
 
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. More...
 
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. More...
 
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. More...
 
static struct GNUNET_FS_FileInformationget_file_information (struct GNUNET_FS_ShareTreeItem *item)
 Iterate over the results from the directory scan and extract the desired information for the publishing operation. More...
 
static void directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result)
 We've finished scanning the directory and optimized the meta data. More...
 
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. More...
 
static void identity_continuation (const char *args0)
 Continuation proceeding with initialization after identity subsystem has been initialized. More...
 
static void identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
 Function called by identity service with known pseudonyms. More...
 
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. More...
 
int main (int argc, char *const *argv)
 The main function to publish content to GNUnet. More...
 

Variables

static int ret
 Global return value from main(). More...
 
static unsigned int verbose
 Command line option 'verbose' set. More...
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 Handle to our configuration. More...
 
static struct GNUNET_FS_Handlefs_handle
 Handle for interaction with file-sharing service. More...
 
static struct GNUNET_FS_PublishContextpc
 Handle to FS-publishing operation. More...
 
static struct GNUNET_FS_MetaDatameta
 Meta-data provided via command-line option. More...
 
static struct GNUNET_FS_UritopKeywords
 Keywords provided via command-line option. More...
 
static struct GNUNET_FS_BlockOptions bo = { { 0LL }, 1, 365, 1 }
 Options we set for published blocks. More...
 
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). More...
 
static struct GNUNET_FS_Uriuri
 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'. More...
 
static char * next_id
 Command-line option for namespace publishing: identifier for updates to this publication. More...
 
static char * this_id
 Command-line option for namespace publishing: identifier for this publication. More...
 
static char * pseudonym
 Command-line option identifying the pseudonym to use for the publication. More...
 
static int do_insert
 Command-line option for 'inserting'. More...
 
static int disable_extractor
 Command-line option to disable meta data extraction. More...
 
static int do_simulate
 Command-line option to merely simulate publishing operation. More...
 
static int extract_only
 Command-line option to only perform meta data extraction, but not publish. More...
 
static int enable_creation_time
 Command-line option to disable adding creation time. More...
 
static struct GNUNET_FS_DirScannerds
 Handle to the directory scanner (for recursive insertions). More...
 
static struct GNUNET_IDENTITY_Handleidentity
 Which namespace do we publish to? NULL if we do not publish to a namespace. More...
 

Detailed Description

publishing files on GNUnet

Author
Christian Grothoff
Krista Bennett
James Blackwell
Igor Wronsky

Definition in file gnunet-publish.c.

Function Documentation

◆ do_stop_task()

static void do_stop_task ( void *  cls)
static

We are finished with the publishing operation, clean up all FS state.

Parameters
clsNULL

Definition at line 152 of file gnunet-publish.c.

153{
155
156 if (NULL != ds)
157 {
159 ds = NULL;
160 }
161 if (NULL != identity)
162 {
164 identity = NULL;
165 }
166 if (NULL != pc)
167 {
168 p = pc;
169 pc = NULL;
171 }
172 if (NULL != fs_handle)
173 {
175 fs_handle = NULL;
176 }
177 if (NULL != meta)
178 {
180 meta = NULL;
181 }
182 if (NULL != uri)
183 {
185 uri = NULL;
186 }
187}
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 struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
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 struct GNUNET_FS_Handle * fs_handle
Handle for interaction with file-sharing service.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:677
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
Definition: fs_api.c:3330
void GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc)
Stop a publication.
Definition: fs_publish.c:1571
void GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
Abort the scan.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:732
void GNUNET_FS_meta_data_destroy(struct GNUNET_FS_MetaData *md)
Free meta data.
Definition: meta_data.c:166
Handle for controlling a publication process.
Definition: fs_api.h:1180

References ds, fs_handle, GNUNET_FS_directory_scan_abort(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_publish_stop(), GNUNET_FS_stop(), GNUNET_FS_uri_destroy(), GNUNET_IDENTITY_disconnect(), identity, meta, p, pc, and uri.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ progress_cb()

static void * progress_cb ( void *  cls,
const struct GNUNET_FS_ProgressInfo info 
)
static

Called by FS client to give information about the progress of an operation.

Parameters
clsclosure
infodetails about the event, specifying the event type and various bits about the event
Returns
client-context (for the next progress call for this operation; should be set to NULL for SUSPEND and STOPPED events). The value returned will be passed to future callbacks in the respective field in the GNUNET_FS_ProgressInfo struct.

Definition at line 204 of file gnunet-publish.c.

205{
206 static char progress_canary[] = "canary";
207 const char *s;
208 char *suri;
209
210 switch (info->status)
211 {
213 break;
214
216 if (verbose)
217 {
218 s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta,
219 GNUNET_YES);
220 fprintf (stdout,
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,
225 s);
226 }
227 break;
228
230 if (verbose)
231 {
232 s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.specifics
233 .progress_directory.eta,
234 GNUNET_YES);
235 fprintf (stdout,
236 _ ("Publishing `%s' at %llu/%llu (%s remaining)\n"),
237 info->value.publish.filename,
238 (unsigned long long)
239 info->value.publish.specifics.progress_directory.completed,
240 (unsigned long long)
241 info->value.publish.specifics.progress_directory.total,
242 s);
243 }
244 break;
245
247 fprintf (stderr,
248 _ ("Error publishing: %s.\n"),
249 info->value.publish.specifics.error.message);
250 ret = 1;
252 break;
253
255 fprintf (stdout,
256 _ ("Publishing `%s' done.\n"),
257 info->value.publish.filename);
258 suri =
259 GNUNET_FS_uri_to_string (info->value.publish.specifics.completed.chk_uri);
260 fprintf (stdout, _ ("URI is `%s'.\n"), suri);
261 GNUNET_free (suri);
262 if (NULL != info->value.publish.specifics.completed.sks_uri)
263 {
265 info->value.publish.specifics.completed.sks_uri);
266 fprintf (stdout, _ ("Namespace URI is `%s'.\n"), suri);
267 GNUNET_free (suri);
268 }
269 if (NULL == info->value.publish.pctx)
270 {
271 ret = 0;
273 }
274 break;
275
277 GNUNET_break (NULL == pc);
278 return NULL;
279
281 fprintf (stderr, "%s", _ ("Starting cleanup after abort\n"));
282 return NULL;
283
285 return NULL;
286
288 fprintf (stderr, "%s", _ ("Cleanup after abort completed.\n"));
289 GNUNET_FS_unindex_stop (info->value.unindex.uc);
290 return NULL;
291
293 fprintf (stderr, "%s", _ ("Cleanup after abort failed.\n"));
294 GNUNET_FS_unindex_stop (info->value.unindex.uc);
295 return NULL;
296
298 return NULL;
299
300 default:
301 fprintf (stderr, _ ("Unexpected status: %d\n"), info->status);
302 return NULL;
303 }
304 return progress_canary; /* non-null */
305}
static unsigned int verbose
Command line option 'verbose' set.
static int ret
Global return value from main().
#define info
void GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc)
Clean up after completion of an unindex operation.
Definition: fs_unindex.c:838
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2034
@ 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_YES
#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.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:579
#define _(String)
GNU gettext support macro.
Definition: platform.h:178

References _, GNUNET_break, GNUNET_free, GNUNET_FS_STATUS_PUBLISH_COMPLETED, GNUNET_FS_STATUS_PUBLISH_ERROR, GNUNET_FS_STATUS_PUBLISH_PROGRESS, GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY, GNUNET_FS_STATUS_PUBLISH_START, GNUNET_FS_STATUS_PUBLISH_STOPPED, GNUNET_FS_STATUS_UNINDEX_COMPLETED, GNUNET_FS_STATUS_UNINDEX_ERROR, GNUNET_FS_STATUS_UNINDEX_PROGRESS, GNUNET_FS_STATUS_UNINDEX_START, GNUNET_FS_STATUS_UNINDEX_STOPPED, GNUNET_FS_unindex_stop(), GNUNET_FS_uri_to_string(), GNUNET_SCHEDULER_shutdown(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, info, pc, ret, and verbose.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ meta_printer()

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 
)
static

Print metadata entries (except binary metadata and the filename).

Parameters
clsclosure
plugin_namename of the plugin that generated the meta data
typetype of the meta data
formatformat of data
data_mime_typemime type of data
datavalue of the meta data
data_sizenumber of bytes in data
Returns
always 0

Definition at line 322 of file gnunet-publish.c.

329{
330 if ((EXTRACTOR_METAFORMAT_UTF8 != format) &&
331 (EXTRACTOR_METAFORMAT_C_STRING != format))
332 return 0;
334 return 0;
335#if HAVE_LIBEXTRACTOR
336 fprintf (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data);
337#else
338 fprintf (stdout, "\t%d - %s\n", type, data);
339#endif
340 return 0;
341}
static char * data
The data to insert into the dht.
static uint32_t type
Type string converted to DNS type value.
#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME

References data, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, and type.

Referenced by publish_inspector().

Here is the caller graph for this function:

◆ keyword_printer()

static int keyword_printer ( void *  cls,
const char *  keyword,
int  is_mandatory 
)
static

Iterator printing keywords.

Parameters
clsclosure
keywordthe keyword
is_mandatoryis the keyword mandatory (in a search)
Returns
GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort

Definition at line 353 of file gnunet-publish.c.

354{
355 fprintf (stdout, "\t%s\n", keyword);
356 return GNUNET_OK;
357}
@ GNUNET_OK

References GNUNET_OK.

Referenced by publish_inspector().

Here is the caller graph for this function:

◆ publish_inspector()

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 
)
static

Function called on all entries before the publication.

This is where we perform modifications to the default based on command-line options.

Parameters
clsclosure
fithe entry in the publish-structure
lengthlength of the file or directory
mmetadata for the file or directory (can be modified)
uripointer to the keywords that will be used for this entry (can be modified)
boblock options
do_indexshould we index?
client_infopointer to client context set upon creation (can be modified)
Returns
GNUNET_OK to continue, GNUNET_NO to remove this entry from the directory, GNUNET_SYSERR to abort the iteration

Definition at line 378 of file gnunet-publish.c.

386{
387 char *fn;
388 char *fs;
389 struct GNUNET_FS_Uri *new_uri;
390
391 if (cls == fi)
392 return GNUNET_OK;
393 if ((disable_extractor) && (NULL != *uri_info))
394 {
395 GNUNET_FS_uri_destroy (*uri_info);
396 *uri_info = NULL;
397 }
398 if (NULL != topKeywords)
399 {
400 if (NULL != *uri_info)
401 {
402 new_uri = GNUNET_FS_uri_ksk_merge (topKeywords, *uri_info);
403 GNUNET_FS_uri_destroy (*uri_info);
404 *uri_info = new_uri;
406 }
407 else
408 {
409 *uri_info = topKeywords;
410 }
411 topKeywords = NULL;
412 }
413 if (NULL != meta)
414 {
417 meta = NULL;
418 }
421 if (extract_only)
422 {
424 m,
427 fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs);
429 fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs);
430 GNUNET_free (fn);
431 GNUNET_free (fs);
432 if (NULL != *uri_info)
434 fprintf (stdout, "%s", "\n");
435 }
438 return GNUNET_OK;
439}
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:103
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition: gnunet-fs.c:35
static int disable_extractor
Command-line option to disable meta data extraction.
static int enable_creation_time
Command-line option to disable adding creation time.
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 int keyword_printer(void *cls, const char *keyword, int is_mandatory)
Iterator printing keywords.
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.
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.
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.
Definition: fs_uri.c:720
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...
Definition: fs_directory.c:55
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.
Definition: fs_uri.c:931
int GNUNET_FS_meta_data_iterate(const struct GNUNET_FS_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
Iterate over MD entries.
Definition: meta_data.c:418
char * GNUNET_FS_meta_data_get_by_type(const struct GNUNET_FS_MetaData *md, enum EXTRACTOR_MetaType type)
Get the first MD entry of the given type.
Definition: meta_data.c:438
void GNUNET_FS_meta_data_add_publication_date(struct GNUNET_FS_MetaData *md)
Add the current time as the publication date to the meta-data.
Definition: meta_data.c:391
void GNUNET_FS_meta_data_merge(struct GNUNET_FS_MetaData *md, const struct GNUNET_FS_MetaData *in)
Extend metadata.
Definition: meta_data.c:356
char * GNUNET_STRINGS_byte_size_fancy(unsigned long long size)
Convert a given filesize into a fancy human-readable format.
Definition: strings.c:105
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:167

References _, disable_extractor, enable_creation_time, extract_only, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, fs, GNUNET_free, GNUNET_FS_file_information_inspect(), GNUNET_FS_meta_data_add_publication_date(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_meta_data_get_by_type(), GNUNET_FS_meta_data_iterate(), GNUNET_FS_meta_data_merge(), GNUNET_FS_meta_data_test_for_directory(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_ksk_get_keywords(), GNUNET_FS_uri_ksk_merge(), GNUNET_OK, GNUNET_STRINGS_byte_size_fancy(), GNUNET_YES, keyword_printer(), m, meta, meta_printer(), publish_inspector(), and topKeywords.

Referenced by directory_trim_complete(), and publish_inspector().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uri_sks_continuation()

static void uri_sks_continuation ( void *  cls,
const struct GNUNET_FS_Uri sks_uri,
const char *  emsg 
)
static

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).

Parameters
clsNULL (closure)
sks_uriURI for the block that was published
emsgerror message, NULL on success

Definition at line 452 of file gnunet-publish.c.

455{
456 if (NULL != emsg)
457 {
458 fprintf (stderr, "%s\n", emsg);
459 ret = 1;
460 }
462}

References GNUNET_SCHEDULER_shutdown(), and ret.

Referenced by uri_ksk_continuation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uri_ksk_continuation()

static void uri_ksk_continuation ( void *  cls,
const struct GNUNET_FS_Uri ksk_uri,
const char *  emsg 
)
static

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.

Parameters
clsNULL (closure)
ksk_uriURI for the block that was published
emsgerror message, NULL on success

Definition at line 475 of file gnunet-publish.c.

478{
479 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv;
480 const struct GNUNET_CRYPTO_PrivateKey *pk;
481
482 if (NULL != emsg)
483 {
484 fprintf (stderr, "%s\n", emsg);
485 ret = 1;
486 }
487 if (NULL == namespace)
488 {
490 return;
491 }
493 if (GNUNET_PUBLIC_KEY_TYPE_ECDSA != ntohl (pk->type))
494 return;
495 priv = &pk->ecdsa_key;
497 priv,
498 this_id,
499 next_id,
500 meta,
501 uri,
502 &bo,
505 NULL);
506}
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
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 struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
static char * this_id
Command-line option for namespace publishing: identifier for this publication.
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.
Definition: fs_namespace.c:432
@ GNUNET_FS_PUBLISH_OPTION_NONE
No options (use defaults for everything).
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.
Definition: identity_api.c:517
@ GNUNET_PUBLIC_KEY_TYPE_ECDSA
The identity type.
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.

References bo, GNUNET_CRYPTO_PrivateKey::ecdsa_key, fs_handle, GNUNET_FS_PUBLISH_OPTION_NONE, GNUNET_FS_publish_sks(), GNUNET_IDENTITY_ego_get_private_key(), GNUNET_PUBLIC_KEY_TYPE_ECDSA, GNUNET_SCHEDULER_shutdown(), meta, next_id, pk, ret, this_id, GNUNET_CRYPTO_PrivateKey::type, uri, and uri_sks_continuation().

Referenced by identity_continuation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_file_information()

static struct GNUNET_FS_FileInformation * get_file_information ( struct GNUNET_FS_ShareTreeItem item)
static

Iterate over the results from the directory scan and extract the desired information for the publishing operation.

Parameters
itemroot with the data from the directory scan
Returns
handle with the information for the publishing operation

Definition at line 517 of file gnunet-publish.c.

518{
519 struct GNUNET_FS_FileInformation *fi;
520 struct GNUNET_FS_FileInformation *fic;
522
523 if (GNUNET_YES == item->is_directory)
524 {
525 if (NULL == item->meta)
528 EXTRACTOR_METATYPE_MIMETYPE,
529 NULL,
530 0);
532 if (NULL == item->ksk_uri)
533 {
534 const char *mime = GNUNET_FS_DIRECTORY_MIME;
536 }
537 else
540 GNUNET_NO);
542 NULL,
543 item->ksk_uri,
544 item->meta,
545 &bo,
546 item->filename);
547 for (child = item->children_head; child; child = child->next)
548 {
551 }
552 }
553 else
554 {
556 NULL,
557 item->filename,
558 item->ksk_uri,
559 item->meta,
560 ! do_insert,
561 &bo);
562 }
563 return fi;
564}
static int do_insert
Command-line option for 'inserting'.
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 pid_t child
void GNUNET_FS_meta_data_make_directory(struct GNUNET_FS_MetaData *md)
Set the MIMETYPE information for the given metadata to "application/gnunet-directory".
Definition: fs_directory.c:81
#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_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_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.
Definition: fs_uri.c:1144
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_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.
Definition: fs_uri.c:752
@ GNUNET_NO
struct GNUNET_FS_MetaData * GNUNET_FS_meta_data_create(void)
Create a fresh meta data container.
Definition: meta_data.c:127
int GNUNET_FS_meta_data_delete(struct GNUNET_FS_MetaData *md, enum EXTRACTOR_MetaType type, const char *data, size_t data_size)
Remove an item.
Definition: meta_data.c:364
Information for a file or directory that is about to be published.
Definition: fs_api.h:228
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.

References bo, child, GNUNET_FS_ShareTreeItem::children_head, do_insert, GNUNET_FS_ShareTreeItem::filename, fs_handle, get_file_information(), GNUNET_break, GNUNET_FS_DIRECTORY_MIME, GNUNET_FS_file_information_add(), GNUNET_FS_file_information_create_empty_directory(), GNUNET_FS_file_information_create_from_file(), GNUNET_FS_meta_data_create(), GNUNET_FS_meta_data_delete(), GNUNET_FS_meta_data_make_directory(), GNUNET_FS_uri_ksk_add_keyword(), GNUNET_FS_uri_ksk_create_from_args(), GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_FS_ShareTreeItem::is_directory, GNUNET_FS_ShareTreeItem::ksk_uri, and GNUNET_FS_ShareTreeItem::meta.

Referenced by directory_trim_complete(), and get_file_information().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ directory_trim_complete()

static void directory_trim_complete ( struct GNUNET_FS_ShareTreeItem directory_scan_result)
static

We've finished scanning the directory and optimized the meta data.

Begin the publication process.

Parameters
directory_scan_resultresult from the directory scan, freed in this function

Definition at line 574 of file gnunet-publish.c.

575{
576 struct GNUNET_FS_FileInformation *fi;
577 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv;
578 const struct GNUNET_CRYPTO_PrivateKey *pk;
579
580 fi = get_file_information (directory_scan_result);
581 GNUNET_FS_share_tree_free (directory_scan_result);
582 if (NULL == fi)
583 {
584 fprintf (stderr, "%s", _ ("Could not publish\n"));
585 ret = 1;
587 return;
588 }
590 if (extract_only)
591 {
592 GNUNET_FS_file_information_destroy (fi, NULL, NULL);
594 return;
595 }
596 priv = NULL;
597 if (NULL != namespace)
598 {
601 priv = &pk->ecdsa_key;
602 }
604 fi,
605 priv,
606 this_id,
607 next_id,
611 if (NULL == pc)
612 {
613 fprintf (stderr, "%s", _ ("Could not start publishing.\n"));
614 ret = 1;
616 return;
617 }
618}
static int do_simulate
Command-line option to merely simulate publishing operation.
void GNUNET_FS_share_tree_free(struct GNUNET_FS_ShareTreeItem *toplevel)
Release memory of a share item tree.
Definition: fs_sharetree.c:437
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.
Definition: fs_publish.c:1443
void GNUNET_FS_file_information_destroy(struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
Destroy publish-structure.
@ GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY
Simulate publishing.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.

References _, do_simulate, GNUNET_CRYPTO_PrivateKey::ecdsa_key, extract_only, fs_handle, get_file_information(), GNUNET_assert, GNUNET_FS_file_information_destroy(), GNUNET_FS_file_information_inspect(), GNUNET_FS_PUBLISH_OPTION_NONE, GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY, GNUNET_FS_publish_start(), GNUNET_FS_share_tree_free(), GNUNET_IDENTITY_ego_get_private_key(), GNUNET_PUBLIC_KEY_TYPE_ECDSA, GNUNET_SCHEDULER_shutdown(), next_id, pc, pk, publish_inspector(), ret, this_id, and GNUNET_CRYPTO_PrivateKey::type.

Referenced by directory_scan_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ directory_scan_cb()

static void directory_scan_cb ( void *  cls,
const char *  filename,
int  is_directory,
enum GNUNET_FS_DirScannerProgressUpdateReason  reason 
)
static

Function called by the directory scanner as we build the tree that we will need to publish later.

Parameters
clsclosure
filenamewhich file we are making progress on
is_directoryGNUNET_YES if this is a directory, GNUNET_NO if this is a file GNUNET_SYSERR if it is neither (or unknown)
reasonkind of progress we are making

Definition at line 633 of file gnunet-publish.c.

637{
638 struct GNUNET_FS_ShareTreeItem *directory_scan_result;
639
640 switch (reason)
641 {
643 if (verbose > 1)
644 {
646 fprintf (stdout, _ ("Scanning directory `%s'.\n"), filename);
647 else
648 fprintf (stdout, _ ("Scanning file `%s'.\n"), filename);
649 }
650 break;
651
653 fprintf (stderr,
654 _ ("There was trouble processing file `%s', skipping it.\n"),
655 filename);
656 break;
657
659 if (verbose)
660 fprintf (stdout, "%s", _ ("Preprocessing complete.\n"));
661 break;
662
664 if (verbose > 2)
665 fprintf (stdout,
666 _ ("Extracting meta data from file `%s' complete.\n"),
667 filename);
668 break;
669
671 if (verbose > 1)
672 fprintf (stdout, "%s", _ ("Meta data extraction has finished.\n"));
673 directory_scan_result = GNUNET_FS_directory_scan_get_result (ds);
674 ds = NULL;
675 GNUNET_FS_share_tree_trim (directory_scan_result);
676 directory_trim_complete (directory_scan_result);
677 break;
678
680 fprintf (stdout, "%s", _ ("Error scanning directory.\n"));
681 ret = 1;
683 break;
684
685 default:
686 GNUNET_assert (0);
687 break;
688 }
689 fflush (stdout);
690}
static char * filename
static void directory_trim_complete(struct GNUNET_FS_ShareTreeItem *directory_scan_result)
We've finished scanning the directory and optimized the meta data.
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.
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.
Definition: fs_sharetree.c:417
@ 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.

References _, directory_trim_complete(), ds, filename, GNUNET_assert, GNUNET_FS_directory_scan_get_result(), GNUNET_FS_DIRSCANNER_ALL_COUNTED, GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED, GNUNET_FS_DIRSCANNER_FILE_IGNORED, GNUNET_FS_DIRSCANNER_FILE_START, GNUNET_FS_DIRSCANNER_FINISHED, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR, GNUNET_FS_share_tree_trim(), GNUNET_SCHEDULER_shutdown(), GNUNET_YES, GNUNET_FS_ShareTreeItem::is_directory, ret, and verbose.

Referenced by identity_continuation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ identity_continuation()

static void identity_continuation ( const char *  args0)
static

Continuation proceeding with initialization after identity subsystem has been initialized.

Parameters
args0filename to publish

Definition at line 700 of file gnunet-publish.c.

701{
702 char *ex;
703 char *emsg;
704
705 if ((NULL != pseudonym) && (NULL == namespace))
706 {
707 fprintf (stderr, _ ("Selected pseudonym `%s' unknown\n"), pseudonym);
708 ret = 1;
710 return;
711 }
712 if (NULL != uri_string)
713 {
714 emsg = NULL;
715 if (NULL == (uri = GNUNET_FS_uri_parse (uri_string, &emsg)))
716 {
717 fprintf (stderr, _ ("Failed to parse URI: %s\n"), emsg);
718 GNUNET_free (emsg);
719 ret = 1;
721 return;
722 }
725 meta,
726 uri,
727 &bo,
730 NULL);
731 return;
732 }
733 if (GNUNET_OK !=
734 GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex))
735 ex = NULL;
736 if (0 != access (args0, R_OK))
737 {
738 fprintf (stderr,
739 _ ("Failed to access `%s': %s\n"),
740 args0,
741 strerror (errno));
742 GNUNET_free (ex);
743 return;
744 }
747 ex,
749 NULL);
750 if (NULL == ds)
751 {
752 fprintf (
753 stderr,
754 "%s",
755 _ (
756 "Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n"));
757 GNUNET_free (ex);
758 return;
759 }
760 GNUNET_free (ex);
761}
static char * uri_string
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
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_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 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.
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.
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.
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.
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
Definition: fs_uri.c:637

References _, bo, cfg, directory_scan_cb(), disable_extractor, ds, fs_handle, GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, GNUNET_FS_directory_scan_start(), GNUNET_FS_publish_ksk(), GNUNET_FS_PUBLISH_OPTION_NONE, GNUNET_FS_uri_parse(), GNUNET_OK, GNUNET_SCHEDULER_shutdown(), meta, pseudonym, ret, topKeywords, uri, uri_ksk_continuation(), and uri_string.

Referenced by identity_cb(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ identity_cb()

static void identity_cb ( void *  cls,
struct GNUNET_IDENTITY_Ego ego,
void **  ctx,
const char *  name 
)
static

Function called by identity service with known pseudonyms.

Parameters
clsclosure with 'const char *' of filename to publish
egoego handle
ctxcontext for application to store data for this ego (during the lifetime of this process, initially NULL)
namename assigned by the user for this ego, NULL if the user just deleted the ego and it must thus no longer be used

Definition at line 776 of file gnunet-publish.c.

780{
781 const char *args0 = cls;
782
783 if (NULL == ego)
784 {
785 identity_continuation (args0);
786 return;
787 }
788 if (NULL == name)
789 return;
790 if (0 == strcmp (name, pseudonym))
791 namespace = ego;
792}
static char * name
Name (label) of the records to list.
static void identity_continuation(const char *args0)
Continuation proceeding with initialization after identity subsystem has been initialized.

References identity_continuation(), name, and pseudonym.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle c 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cconfiguration

Definition at line 804 of file gnunet-publish.c.

808{
809 /* check arguments */
810 if ((NULL != uri_string) && (extract_only))
811 {
812 printf (_ ("Cannot extract metadata from a URI!\n"));
813 ret = -1;
814 return;
815 }
816 if (((NULL == uri_string) || (extract_only)) &&
817 ((NULL == args[0]) || (NULL != args[1])))
818 {
819 printf (_ ("You must specify one and only one filename for insertion.\n"));
820 ret = -1;
821 return;
822 }
823 if ((NULL != uri_string) && (NULL != args[0]))
824 {
825 printf (_ ("You must NOT specify an URI and a filename.\n"));
826 ret = -1;
827 return;
828 }
829 if (NULL != pseudonym)
830 {
831 if (NULL == this_id)
832 {
833 fprintf (stderr,
834 _ ("Option `%s' is required when using option `%s'.\n"),
835 "-t",
836 "-P");
837 ret = -1;
838 return;
839 }
840 }
841 else
842 { /* ordinary insertion checks */
843 if (NULL != next_id)
844 {
845 fprintf (stderr,
846 _ ("Option `%s' makes no sense without option `%s'.\n"),
847 "-N",
848 "-P");
849 ret = -1;
850 return;
851 }
852 if (NULL != this_id)
853 {
854 fprintf (stderr,
855 _ ("Option `%s' makes no sense without option `%s'.\n"),
856 "-t",
857 "-P");
858 ret = -1;
859 return;
860 }
861 }
862 cfg = c;
864 "gnunet-publish",
866 NULL,
869 if (NULL == fs_handle)
870 {
871 fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS");
872 ret = 1;
873 return;
874 }
876 if (NULL != pseudonym)
878 else
880}
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 void do_stop_task(void *cls)
We are finished with the publishing operation, clean up all FS state.
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Function called by identity service with known pseudonyms.
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.
Definition: fs_api.c:3264
@ GNUNET_FS_FLAGS_NONE
No special flags set.
@ GNUNET_FS_OPTIONS_END
Last option in the VARARG list.
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.
Definition: identity_api.c:487
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,...
Definition: scheduler.c:1339

References _, consensus-simulation::args, cfg, do_stop_task(), extract_only, fs_handle, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END, GNUNET_FS_start(), GNUNET_IDENTITY_connect(), GNUNET_SCHEDULER_add_shutdown(), identity, identity_cb(), identity_continuation(), next_id, progress_cb(), pseudonym, ret, this_id, and uri_string.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function to publish content to GNUnet.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 891 of file gnunet-publish.c.

892{
895 "anonymity",
896 "LEVEL",
898 "set the desired LEVEL of sender-anonymity"),
901 'D',
902 "disable-extractor",
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"),
912 "extract",
914 "print list of extracted keywords that would "
915 "be used, but do not perform upload"),
916 &extract_only),
918 'k',
919 "key",
920 "KEYWORD",
922 "add an additional keyword for the top-level "
923 "file or directory (this option can be specified multiple times)"),
924 &topKeywords),
926 'm',
927 "meta",
928 "TYPE:VALUE",
929 gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
930 &meta),
932 'n',
933 "noindex",
934 gettext_noop ("do not index, perform full insertion (stores "
935 "entire file in encrypted form in GNUnet database)"),
936 &do_insert),
938 'N',
939 "next",
940 "ID",
941 gettext_noop ("specify ID of an updated version to be "
942 "published in the future (for namespace insertions only)"),
943 &next_id),
945 "priority",
946 "PRIORITY",
948 "specify the priority of the content"),
951 "pseudonym",
952 "NAME",
954 "publish the files under the pseudonym "
955 "NAME (place file into namespace)"),
956 &pseudonym),
958 "replication",
959 "LEVEL",
961 "set the desired replication LEVEL"),
964 "simulate-only",
966 "only simulate the process but do not do "
967 "any actual publishing (useful to compute URIs)"),
968 &do_simulate),
970 "this",
971 "ID",
973 "set the ID of this version of the publication "
974 "(for namespace insertions only)"),
975 &this_id),
977 'u',
978 "uri",
979 "URI",
981 "URI to be published (can be used instead of passing a "
982 "file to add keywords to the file with the respective URI)"),
983 &uri_string),
984
986
988
991
992 ret =
993 (GNUNET_OK ==
995 argc,
996 argv,
997 "gnunet-publish [OPTIONS] FILENAME",
998 gettext_noop ("Publish a file or directory on GNUnet"),
999 options,
1000 &run,
1001 NULL))
1002 ? ret
1003 : 1;
1004 return ret;
1005}
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:74
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.
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.
Definition: fs_getopt.c:250
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.
Definition: fs_getopt.c:129
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_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,...
Definition: program.c:407
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.
Definition: time.c:805
unsigned int GNUNET_TIME_get_current_year(void)
Return the current year (e.g.
Definition: time.c:751
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...
Definition of a command line option.

References GNUNET_FS_BlockOptions::anonymity_level, bo, GNUNET_FS_BlockOptions::content_priority, disable_extractor, do_insert, do_simulate, enable_creation_time, GNUNET_FS_BlockOptions::expiration_time, extract_only, gettext_noop, GNUNET_FS_GETOPT_KEYWORDS(), GNUNET_FS_GETOPT_METADATA(), GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_GETOPT_option_verbose(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), GNUNET_TIME_get_current_year(), GNUNET_TIME_year_to_time(), meta, next_id, options, pseudonym, GNUNET_FS_BlockOptions::replication_level, ret, run(), this_id, topKeywords, uri_string, and verbose.

Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

◆ verbose

unsigned int verbose
static

Command line option 'verbose' set.

Definition at line 41 of file gnunet-publish.c.

Referenced by directory_scan_cb(), main(), and progress_cb().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Handle to our configuration.

Definition at line 46 of file gnunet-publish.c.

Referenced by identity_continuation(), and run().

◆ fs_handle

struct GNUNET_FS_Handle* fs_handle
static

Handle for interaction with file-sharing service.

Definition at line 51 of file gnunet-publish.c.

Referenced by directory_trim_complete(), do_stop_task(), get_file_information(), identity_continuation(), run(), and uri_ksk_continuation().

◆ pc

◆ meta

◆ topKeywords

struct GNUNET_FS_Uri* topKeywords
static

Keywords provided via command-line option.

Definition at line 66 of file gnunet-publish.c.

Referenced by GNUNET_FS_GETOPT_KEYWORDS(), identity_continuation(), main(), and publish_inspector().

◆ bo

◆ uri_string

char* uri_string
static

Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer to an existing URI).

Definition at line 77 of file gnunet-publish.c.

Referenced by identity_continuation(), main(), and run().

◆ uri

struct GNUNET_FS_Uri* uri
static

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'.

Definition at line 84 of file gnunet-publish.c.

Referenced by check_advertisement(), create_download_context(), dns_string_to_value(), dns_value_to_string(), do_stop_task(), fip_signal_start(), gather_uri_data(), GDS_try_connect(), getopt_set_keywords(), GNUNET_DNSPARSER_builder_add_uri(), GNUNET_DNSPARSER_free_uri(), GNUNET_DNSPARSER_parse_uri(), GNUNET_FS_directory_builder_add(), GNUNET_FS_directory_list_contents(), GNUNET_FS_download_start(), GNUNET_FS_probe(), GNUNET_FS_publish_ksk(), GNUNET_FS_publish_sks(), GNUNET_FS_publish_ublock_(), GNUNET_FS_search_start(), GNUNET_FS_uri_chk_get_file_hash(), GNUNET_FS_uri_chk_get_file_size(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_dup(), GNUNET_FS_uri_ksk_add_keyword(), GNUNET_FS_uri_ksk_create(), GNUNET_FS_uri_ksk_create_from_args(), GNUNET_FS_uri_ksk_get_keyword_count(), GNUNET_FS_uri_ksk_get_keywords(), GNUNET_FS_uri_ksk_remove_keyword(), GNUNET_FS_uri_ksk_to_string_fancy(), GNUNET_FS_uri_loc_create(), GNUNET_FS_uri_loc_get_expiration(), GNUNET_FS_uri_loc_get_peer_identity(), GNUNET_FS_uri_loc_get_uri(), GNUNET_FS_uri_parse(), GNUNET_FS_uri_sks_get_content_id(), GNUNET_FS_uri_sks_get_namespace(), GNUNET_FS_uri_test_chk(), GNUNET_FS_uri_test_ksk(), GNUNET_FS_uri_test_loc(), GNUNET_FS_uri_test_sks(), GNUNET_FS_uri_to_key(), GNUNET_FS_uri_to_string(), GNUNET_HELLO_parser_from_url(), GNUNET_STRINGS_path_is_absolute(), handle_advertisement(), handle_gns_resolution_result(), handle_uri(), handler_advertisement(), hello_for_client_cb(), hello_for_incoming_cb(), identity_continuation(), iterate_address_and_compare_cb(), iterate_address_start_burst(), linked_list_contains(), load_hostlist_file(), print_entry(), print_hello_addrs(), print_search_result(), process_kblock(), process_ksk_result(), process_sblock(), process_sks_result(), progress_cb(), publish_sblocks_cont(), run(), search_start(), test_result_present(), trigger_recursive_download(), uri_chk_to_string(), uri_ksk_continuation(), uri_ksk_to_string(), uri_loc_parse(), uri_loc_to_string(), uri_sks_to_string(), and wait_child().

◆ next_id

char* next_id
static

Command-line option for namespace publishing: identifier for updates to this publication.

Definition at line 90 of file gnunet-publish.c.

Referenced by directory_trim_complete(), GNUNET_FS_namespace_list_updateable(), load_member_session_next(), main(), run(), save_member_session(), and uri_ksk_continuation().

◆ this_id

char* this_id
static

Command-line option for namespace publishing: identifier for this publication.

Definition at line 96 of file gnunet-publish.c.

Referenced by directory_trim_complete(), main(), run(), and uri_ksk_continuation().

◆ pseudonym

char* pseudonym
static

Command-line option identifying the pseudonym to use for the publication.

Definition at line 101 of file gnunet-publish.c.

Referenced by GNUNET_FS_uri_sks_get_namespace(), identity_cb(), identity_continuation(), main(), and run().

◆ do_insert

int do_insert
static

Command-line option for 'inserting'.

Definition at line 106 of file gnunet-publish.c.

Referenced by get_file_information(), and main().

◆ disable_extractor

int disable_extractor
static

Command-line option to disable meta data extraction.

Definition at line 111 of file gnunet-publish.c.

Referenced by identity_continuation(), main(), and publish_inspector().

◆ do_simulate

int do_simulate
static

Command-line option to merely simulate publishing operation.

Definition at line 116 of file gnunet-publish.c.

Referenced by directory_trim_complete(), and main().

◆ extract_only

int extract_only
static

Command-line option to only perform meta data extraction, but not publish.

Definition at line 121 of file gnunet-publish.c.

Referenced by directory_trim_complete(), main(), publish_inspector(), and run().

◆ enable_creation_time

int enable_creation_time
static

Command-line option to disable adding creation time.

Definition at line 126 of file gnunet-publish.c.

Referenced by main(), and publish_inspector().

◆ ds

◆ identity