GNUnet  0.10.x
Functions | Variables
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_CONTAINER_MetaData *m, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, 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_Handlectx
 Handle for interaction with file-sharing service. More...
 
static struct GNUNET_FS_PublishContextpc
 Handle to FS-publishing operation. More...
 
static struct GNUNET_CONTAINER_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 151 of file gnunet-publish.c.

References GNUNET_CONTAINER_meta_data_destroy(), GNUNET_FS_directory_scan_abort(), GNUNET_FS_publish_stop(), GNUNET_FS_stop(), GNUNET_FS_uri_destroy(), GNUNET_IDENTITY_disconnect(), p, and pc.

Referenced by run().

152 {
153  struct GNUNET_FS_PublishContext *p;
154 
155  if (NULL != ds)
156  {
158  ds = NULL;
159  }
160  if (NULL != identity)
161  {
163  identity = NULL;
164  }
165  if (NULL != pc)
166  {
167  p = pc;
168  pc = NULL;
170  }
171  if (NULL != ctx)
172  {
174  ctx = NULL;
175  }
176  if (NULL != meta)
177  {
179  meta = NULL;
180  }
181  if (NULL != uri)
182  {
184  uri = NULL;
185  }
186 }
void GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc)
Stop an upload.
Definition: fs_publish.c:1558
static struct GNUNET_FS_Handle * ctx
Handle for interaction with file-sharing service.
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
Definition: fs_api.c:3163
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_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:838
void GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
Abort the scan.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:670
Handle for controlling a publication process.
Definition: fs_api.h:1198
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_PublishContext * pc
Handle to FS-publishing operation.
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
static struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
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 203 of file gnunet-publish.c.

References _, FPRINTF, 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, GNUNET_FS_ProgressInfo::publish, ret, GNUNET_FS_ProgressInfo::status, GNUNET_FS_ProgressInfo::unindex, GNUNET_FS_ProgressInfo::value, and verbose.

Referenced by run().

205 {
206  const char *s;
207  char *suri;
208 
209  switch (info->status)
210  {
212  break;
214  if (verbose)
215  {
217  GNUNET_YES);
218  FPRINTF (stdout,
219  _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
220  info->value.publish.filename,
221  (unsigned long long) info->value.publish.completed,
222  (unsigned long long) info->value.publish.size, s);
223  }
224  break;
226  if (verbose)
227  {
228  s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.specifics.progress_directory.eta,
229  GNUNET_YES);
230  FPRINTF (stdout,
231  _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
232  info->value.publish.filename,
233  (unsigned long long) info->value.publish.specifics.progress_directory.completed,
234  (unsigned long long) info->value.publish.specifics.progress_directory.total, s);
235  }
236  break;
238  FPRINTF (stderr,
239  _("Error publishing: %s.\n"),
240  info->value.publish.specifics.error.message);
241  ret = 1;
243  break;
245  FPRINTF (stdout,
246  _("Publishing `%s' done.\n"),
247  info->value.publish.filename);
248  suri = GNUNET_FS_uri_to_string (info->value.publish.specifics.
249  completed.chk_uri);
250  FPRINTF (stdout,
251  _("URI is `%s'.\n"),
252  suri);
253  GNUNET_free (suri);
254  if (NULL != info->value.publish.specifics.completed.sks_uri)
255  {
256  suri = GNUNET_FS_uri_to_string (info->value.publish.specifics.
257  completed.sks_uri);
258  FPRINTF (stdout,
259  _("Namespace URI is `%s'.\n"),
260  suri);
261  GNUNET_free (suri);
262  }
263  if (NULL == info->value.publish.pctx)
264  {
265  ret = 0;
267  }
268  break;
270  GNUNET_break (NULL == pc);
271  return NULL;
273  FPRINTF (stderr,
274  "%s",
275  _("Starting cleanup after abort\n"));
276  return NULL;
278  return NULL;
280  FPRINTF (stderr,
281  "%s",
282  _("Cleanup after abort completed.\n"));
284  return NULL;
286  FPRINTF (stderr,
287  "%s",
288  _("Cleanup after abort failed.\n"));
290  return NULL;
292  return NULL;
293  default:
294  FPRINTF (stderr,
295  _("Unexpected status: %d\n"),
296  info->status);
297  return NULL;
298  }
299  return ""; /* non-null */
300 }
void GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc)
Clean up after completion of an unindex operation.
Definition: fs_unindex.c:833
Notification that we started to unindex a file.
Notification that we are making progress sharing a file structure.
#define FPRINTF
Definition: plibc.h:683
Notification that we made progress unindexing a file.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
Notification that we have stopped the process of uploading a file structure; no futher events will be...
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:1988
Notification that we have started to publish a file structure.
union GNUNET_FS_ProgressInfo::@28 value
Values that depend on the event type.
Notification that we are making progress sharing a directory.
enum GNUNET_FS_Status status
Specific status code (determines the event type).
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:727
struct GNUNET_FS_ProgressInfo::@28::@29 publish
Values for all "GNUNET_FS_STATUS_PUBLISH_*" events.
static int ret
Global return value from main().
Notification that the unindexing of this file was stopped (final event for this action).
Notification that the unindexing of this file was completed.
Notification that we completed sharing a file structure.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
Notification that an error was encountered sharing a file structure.
static unsigned int verbose
Command line option 'verbose' set.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_FS_ProgressInfo::@28::@32 unindex
Values for all "GNUNET_FS_STATUS_UNINDEX_*" events.
Notification that we encountered an error unindexing a file.
#define GNUNET_free(ptr)
Wrapper around free.
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 317 of file gnunet-publish.c.

References EXTRACTOR_METAFORMAT_C_STRING, EXTRACTOR_METAFORMAT_UTF8, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, and FPRINTF.

Referenced by publish_inspector().

323 {
324  if ((EXTRACTOR_METAFORMAT_UTF8 != format) &&
325  (EXTRACTOR_METAFORMAT_C_STRING != format))
326  return 0;
328  return 0;
329 #if HAVE_LIBEXTRACTOR
330  FPRINTF (stdout,
331  "\t%s - %s\n",
332  EXTRACTOR_metatype_to_string (type),
333  data);
334 #else
335  FPRINTF (stdout,
336  "\t%d - %s\n",
337  type,
338  data);
339 #endif
340  return 0;
341 }
#define FPRINTF
Definition: plibc.h:683
0-terminated, UTF-8 encoded string.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
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.

References FPRINTF, and GNUNET_OK.

Referenced by publish_inspector().

356 {
357  FPRINTF (stdout, "\t%s\n", keyword);
358  return GNUNET_OK;
359 }
#define FPRINTF
Definition: plibc.h:683
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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_CONTAINER_MetaData m,
struct GNUNET_FS_Uri **  uri,
struct GNUNET_FS_BlockOptions bo,
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 380 of file gnunet-publish.c.

References _, disable_extractor, enable_creation_time, extract_only, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, fn, FPRINTF, fs, GNUNET_CONTAINER_meta_data_add_publication_date(), GNUNET_CONTAINER_meta_data_destroy(), GNUNET_CONTAINER_meta_data_get_by_type(), GNUNET_CONTAINER_meta_data_iterate(), GNUNET_CONTAINER_meta_data_merge(), GNUNET_free, GNUNET_FS_file_information_inspect(), 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(), meta_printer(), and topKeywords.

Referenced by directory_trim_complete().

388 {
389  char *fn;
390  char *fs;
391  struct GNUNET_FS_Uri *new_uri;
392 
393  if (cls == fi)
394  return GNUNET_OK;
395  if ( (disable_extractor) &&
396  (NULL != *uri) )
397  {
398  GNUNET_FS_uri_destroy (*uri);
399  *uri = NULL;
400  }
401  if (NULL != topKeywords)
402  {
403  if (NULL != *uri)
404  {
405  new_uri = GNUNET_FS_uri_ksk_merge (topKeywords, *uri);
406  GNUNET_FS_uri_destroy (*uri);
407  *uri = new_uri;
409  }
410  else
411  {
412  *uri = topKeywords;
413  }
414  topKeywords = NULL;
415  }
416  if (NULL != meta)
417  {
420  meta = NULL;
421  }
424  if (extract_only)
425  {
428  fs = GNUNET_STRINGS_byte_size_fancy (length);
429  FPRINTF (stdout,
430  _("Meta data for file `%s' (%s)\n"),
431  fn,
432  fs);
434  FPRINTF (stdout,
435  _("Keywords for file `%s' (%s)\n"),
436  fn,
437  fs);
438  GNUNET_free (fn);
439  GNUNET_free (fs);
440  if (NULL != *uri)
442  FPRINTF (stdout,
443  "%s",
444  "\n");
445  }
448  &publish_inspector, fi);
449  return GNUNET_OK;
450 }
char * GNUNET_STRINGS_byte_size_fancy(unsigned long long size)
Convert a given filesize into a fancy human-readable format.
Definition: strings.c:174
#define FPRINTF
Definition: plibc.h:683
void GNUNET_CONTAINER_meta_data_add_publication_date(struct GNUNET_CONTAINER_MetaData *md)
Add the current time as the publication date to the meta-data.
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 int extract_only
Command-line option to only perform meta data extraction, but not publish.
static int publish_inspector(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_CONTAINER_MetaData *m, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Function called on all entries before the publication.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
char * GNUNET_CONTAINER_meta_data_get_by_type(const struct GNUNET_CONTAINER_MetaData *md, enum EXTRACTOR_MetaType type)
Get the first MD entry of the given type.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static int enable_creation_time
Command-line option to disable adding creation time.
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:719
static struct GNUNET_FS_Uri * topKeywords
Keywords provided via command-line option.
void GNUNET_CONTAINER_meta_data_merge(struct GNUNET_CONTAINER_MetaData *md, const struct GNUNET_CONTAINER_MetaData *in)
Extend metadata.
static char * fn
Filename of the unique file.
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:670
static int keyword_printer(void *cls, const char *keyword, int is_mandatory)
Iterator printing keywords.
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_CONTAINER_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:54
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition: gnunet-fs.c:36
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.
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:168
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
int GNUNET_CONTAINER_meta_data_iterate(const struct GNUNET_CONTAINER_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
Iterate over MD entries.
static int disable_extractor
Command-line option to disable meta data extraction.
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
#define GNUNET_YES
Definition: gnunet_common.h:80
#define GNUNET_free(ptr)
Wrapper around free.
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 463 of file gnunet-publish.c.

References FPRINTF, GNUNET_SCHEDULER_shutdown(), and ret.

Referenced by uri_ksk_continuation().

466 {
467  if (NULL != emsg)
468  {
469  FPRINTF (stderr,
470  "%s\n",
471  emsg);
472  ret = 1;
473  }
475 }
#define FPRINTF
Definition: plibc.h:683
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static int ret
Global return value from main().
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 488 of file gnunet-publish.c.

References FPRINTF, GNUNET_FS_PUBLISH_OPTION_NONE, GNUNET_FS_publish_sks(), GNUNET_IDENTITY_ego_get_private_key(), GNUNET_SCHEDULER_shutdown(), next_id, ret, this_id, and uri_sks_continuation().

Referenced by identity_continuation().

491 {
492  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv;
493 
494  if (NULL != emsg)
495  {
496  FPRINTF (stderr,
497  "%s\n",
498  emsg);
499  ret = 1;
500  }
501  if (NULL == namespace)
502  {
504  return;
505  }
506  priv = GNUNET_IDENTITY_ego_get_private_key (namespace);
508  priv,
509  this_id,
510  next_id,
511  meta,
512  uri,
513  &bo,
516  NULL);
517 }
#define FPRINTF
Definition: plibc.h:683
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_CONTAINER_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:440
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:556
static struct GNUNET_FS_Handle * ctx
Handle for interaction with file-sharing service.
Private ECC key encoded for transmission.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
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_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static int ret
Global return value from main().
static char * this_id
Command-line option for namespace publishing: identifier for this publication.
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
No options (use defaults for everything).
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
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 directroy scan
Returns
handle with the information for the publishing operation

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

References child, GNUNET_FS_ShareTreeItem::children_head, do_insert, EXTRACTOR_METATYPE_MIMETYPE, GNUNET_FS_ShareTreeItem::filename, GNUNET_break, GNUNET_CONTAINER_meta_data_create(), GNUNET_CONTAINER_meta_data_delete(), 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_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, GNUNET_FS_ShareTreeItem::meta, and GNUNET_FS_ShareTreeItem::next.

Referenced by directory_trim_complete().

529 {
530  struct GNUNET_FS_FileInformation *fi;
531  struct GNUNET_FS_FileInformation *fic;
533 
534  if (GNUNET_YES == item->is_directory)
535  {
536  if (NULL == item->meta)
540  NULL, 0);
542  if (NULL == item->ksk_uri)
543  {
544  const char *mime = GNUNET_FS_DIRECTORY_MIME;
545  item->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &mime);
546  }
547  else
549  GNUNET_NO);
551  item->ksk_uri,
552  item->meta,
553  &bo, item->filename);
554  for (child = item->children_head; child; child = child->next)
555  {
556  fic = get_file_information (child);
558  }
559  }
560  else
561  {
563  item->filename,
564  item->ksk_uri, item->meta,
565  !do_insert,
566  &bo);
567  }
568  return fi;
569 }
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_CONTAINER_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:1146
void GNUNET_FS_meta_data_make_directory(struct GNUNET_CONTAINER_MetaData *md)
Set the MIMETYPE information for the given metadata to "application/gnunet-directory".
Definition: fs_directory.c:77
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:751
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...
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.
static struct GNUNET_FS_Handle * ctx
Handle for interaction with file-sharing service.
#define GNUNET_FS_DIRECTORY_MIME
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_CONTAINER_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
Create an entry for a file in a publish-structure.
struct GNUNET_FS_Uri * ksk_uri
Keywords for this file or directory (derived from metadata).
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Information for a file or directory that is about to be published.
Definition: fs_api.h:231
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_FS_ShareTreeItem * next
This is a doubly-linked list.
A node of a directory tree (produced by dirscanner)
struct GNUNET_FS_ShareTreeItem * children_head
This is a doubly-linked tree NULL for files and empty directories.
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_create(void)
Create a fresh meta data container.
int GNUNET_CONTAINER_meta_data_delete(struct GNUNET_CONTAINER_MetaData *md, enum EXTRACTOR_MetaType type, const char *data, size_t data_size)
Remove an item.
static int do_insert
Command-line option for 'inserting'.
int is_directory
GNUNET_YES if this is a directory
char * filename
Name of the file/directory.
struct GNUNET_CONTAINER_MetaData * meta
Metadata for this file or directory.
static struct GNUNET_OS_Process * child
The child process we spawn.
#define GNUNET_YES
Definition: gnunet_common.h:80
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
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 579 of file gnunet-publish.c.

References _, do_simulate, extract_only, FPRINTF, get_file_information(), 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_SCHEDULER_shutdown(), next_id, publish_inspector(), ret, and this_id.

Referenced by directory_scan_cb().

580 {
581  struct GNUNET_FS_FileInformation *fi;
582  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv;
583 
584  fi = get_file_information (directory_scan_result);
585  GNUNET_FS_share_tree_free (directory_scan_result);
586  if (NULL == fi)
587  {
588  FPRINTF (stderr,
589  "%s",
590  _("Could not publish\n"));
591  ret = 1;
593  return;
594  }
596  if (extract_only)
597  {
598  GNUNET_FS_file_information_destroy (fi, NULL, NULL);
600  return;
601  }
602  if (NULL == namespace)
603  priv = NULL;
604  else
605  priv = GNUNET_IDENTITY_ego_get_private_key (namespace);
607  priv, this_id, next_id,
608  (do_simulate) ?
611  if (NULL == pc)
612  {
613  FPRINTF (stderr,
614  "%s",
615  _("Could not start publishing.\n"));
616  ret = 1;
618  return;
619  }
620 }
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...
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:1431
#define FPRINTF
Definition: plibc.h:683
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:556
static int extract_only
Command-line option to only perform meta data extraction, but not publish.
static struct GNUNET_FS_Handle * ctx
Handle for interaction with file-sharing service.
static int publish_inspector(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_CONTAINER_MetaData *m, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Function called on all entries before the publication.
Private ECC key encoded for transmission.
Information for a file or directory that is about to be published.
Definition: fs_api.h:231
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static int ret
Global return value from main().
static char * this_id
Command-line option for namespace publishing: identifier for this publication.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
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_share_tree_free(struct GNUNET_FS_ShareTreeItem *toplevel)
Release memory of a share item tree.
Definition: fs_sharetree.c:432
void GNUNET_FS_file_information_destroy(struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
Destroy publish-structure.
static int do_simulate
Command-line option to merely simulate publishing operation.
No options (use defaults for everything).
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 635 of file gnunet-publish.c.

References _, directory_trim_complete(), FPRINTF, 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, ret, and verbose.

Referenced by identity_continuation().

639 {
640  struct GNUNET_FS_ShareTreeItem *directory_scan_result;
641 
642  switch (reason)
643  {
645  if (verbose > 1)
646  {
647  if (is_directory == GNUNET_YES)
648  FPRINTF (stdout,
649  _("Scanning directory `%s'.\n"),
650  filename);
651  else
652  FPRINTF (stdout,
653  _("Scanning file `%s'.\n"),
654  filename);
655  }
656  break;
658  FPRINTF (stderr,
659  _("There was trouble processing file `%s', skipping it.\n"),
660  filename);
661  break;
663  if (verbose)
664  FPRINTF (stdout,
665  "%s",
666  _("Preprocessing complete.\n"));
667  break;
669  if (verbose > 2)
670  FPRINTF (stdout,
671  _("Extracting meta data from file `%s' complete.\n"),
672  filename);
673  break;
675  if (verbose > 1)
676  FPRINTF (stdout,
677  "%s",
678  _("Meta data extraction has finished.\n"));
679  directory_scan_result = GNUNET_FS_directory_scan_get_result (ds);
680  ds = NULL;
681  GNUNET_FS_share_tree_trim (directory_scan_result);
682  directory_trim_complete (directory_scan_result);
683  break;
685  FPRINTF (stdout,
686  "%s",
687  _("Error scanning directory.\n"));
688  ret = 1;
690  break;
691  default:
692  GNUNET_assert (0);
693  break;
694  }
695  fflush (stdout);
696 }
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:412
static void directory_trim_complete(struct GNUNET_FS_ShareTreeItem *directory_scan_result)
We've finished scanning the directory and optimized the meta data.
#define FPRINTF
Definition: plibc.h:683
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
We've found all files (in the pre-pass).
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
A node of a directory tree (produced by dirscanner)
static char * filename
static int ret
Global return value from main().
There was an internal error.
Last call to the progress function: we have finished scanning the directory.
int is_directory
GNUNET_YES if this is a directory
We've started processing a file or directory.
We've finished extracting meta data from a file.
static unsigned int verbose
Command line option 'verbose' set.
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.
#define GNUNET_YES
Definition: gnunet_common.h:80
static struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
We're having trouble accessing a file (soft-error); it will be ignored.
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 706 of file gnunet-publish.c.

References _, ACCESS, directory_scan_cb(), disable_extractor, FPRINTF, GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, GNUNET_free_non_null, GNUNET_FS_directory_scan_start(), GNUNET_FS_publish_ksk(), GNUNET_FS_PUBLISH_OPTION_NONE, GNUNET_FS_uri_parse(), GNUNET_OK, GNUNET_SCHEDULER_shutdown(), pseudonym, ret, STRERROR, uri_ksk_continuation(), and uri_string.

Referenced by identity_cb(), and run().

707 {
708  char *ex;
709  char *emsg;
710 
711  if ( (NULL != pseudonym) &&
712  (NULL == namespace) )
713  {
714  FPRINTF (stderr,
715  _("Selected pseudonym `%s' unknown\n"),
716  pseudonym);
717  ret = 1;
719  return;
720  }
721  if (NULL != uri_string)
722  {
723  emsg = NULL;
724  if (NULL == (uri = GNUNET_FS_uri_parse (uri_string, &emsg)))
725  {
726  FPRINTF (stderr,
727  _("Failed to parse URI: %s\n"),
728  emsg);
729  GNUNET_free (emsg);
730  ret = 1;
732  return;
733  }
735  topKeywords,
736  meta, uri,
737  &bo,
740  NULL);
741  return;
742  }
743  if (GNUNET_OK !=
744  GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex))
745  ex = NULL;
746  if (0 != ACCESS (args0, R_OK))
747  {
748  FPRINTF (stderr,
749  _("Failed to access `%s': %s\n"),
750  args0,
751  STRERROR (errno));
753  return;
754  }
757  ex,
758  &directory_scan_cb, NULL);
759  if (NULL == ds)
760  {
761  FPRINTF (stderr,
762  "%s",
763  _("Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n"));
765  return;
766  }
768 }
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 thread.
#define FPRINTF
Definition: plibc.h:683
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:635
#define STRERROR(i)
Definition: plibc.h:676
static struct GNUNET_FS_Handle * ctx
Handle for interaction with file-sharing service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
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.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
struct GNUNET_FS_PublishKskContext * GNUNET_FS_publish_ksk(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *ksk_uri, const struct GNUNET_CONTAINER_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 CHK under various keywords on GNUnet.
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_Uri * topKeywords
Keywords provided via command-line option.
static int ret
Global return value from main().
int 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.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our configuration.
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
static int disable_extractor
Command-line option to disable meta data extraction.
static struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
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...
No options (use defaults for everything).
#define ACCESS(p, m)
Definition: plibc.h:656
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
static char * pseudonym
Command-line option identifying the pseudonym to use for the publication.
#define GNUNET_free(ptr)
Wrapper around free.
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 783 of file gnunet-publish.c.

References identity_continuation(), and pseudonym.

Referenced by run().

787 {
788  const char *args0 = cls;
789 
790  if (NULL == ego)
791  {
792  identity_continuation (args0);
793  return;
794  }
795  if (NULL == name)
796  return;
797  if (0 == strcmp (name, pseudonym))
798  namespace = ego;
799 }
const char * name
static void identity_continuation(const char *args0)
Continuation proceeding with initialization after identity subsystem has been initialized.
static char * pseudonym
Command-line option identifying the pseudonym to use for the publication.
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 811 of file gnunet-publish.c.

References _, do_stop_task(), extract_only, FPRINTF, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END, GNUNET_FS_start(), GNUNET_IDENTITY_connect(), GNUNET_SCHEDULER_add_shutdown(), identity_cb(), identity_continuation(), next_id, progress_cb(), pseudonym, ret, this_id, and uri_string.

Referenced by main().

815 {
816  /* check arguments */
817  if ((NULL != uri_string) && (extract_only))
818  {
819  printf (_("Cannot extract metadata from a URI!\n"));
820  ret = -1;
821  return;
822  }
823  if (((NULL == uri_string) || (extract_only)) &&
824  ((NULL == args[0]) || (NULL != args[1])))
825  {
826  printf (_("You must specify one and only one filename for insertion.\n"));
827  ret = -1;
828  return;
829  }
830  if ((NULL != uri_string) && (NULL != args[0]))
831  {
832  printf (_("You must NOT specify an URI and a filename.\n"));
833  ret = -1;
834  return;
835  }
836  if (NULL != pseudonym)
837  {
838  if (NULL == this_id)
839  {
840  FPRINTF (stderr, _("Option `%s' is required when using option `%s'.\n"),
841  "-t", "-P");
842  ret = -1;
843  return;
844  }
845  }
846  else
847  { /* ordinary insertion checks */
848  if (NULL != next_id)
849  {
850  FPRINTF (stderr,
851  _("Option `%s' makes no sense without option `%s'.\n"),
852  "-N", "-P");
853  ret = -1;
854  return;
855  }
856  if (NULL != this_id)
857  {
858  FPRINTF (stderr,
859  _("Option `%s' makes no sense without option `%s'.\n"),
860  "-t", "-P");
861  ret = -1;
862  return;
863  }
864  }
865  cfg = c;
866  ctx =
867  GNUNET_FS_start (cfg, "gnunet-publish", &progress_cb, NULL,
869  if (NULL == ctx)
870  {
871  FPRINTF (stderr,
872  _("Could not initialize `%s' subsystem.\n"),
873  "FS");
874  ret = 1;
875  return;
876  }
878  NULL);
879  if (NULL != pseudonym)
881  &identity_cb,
882  args[0]);
883  else
885 }
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:528
#define FPRINTF
Definition: plibc.h:683
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
static int extract_only
Command-line option to only perform meta data extraction, but not publish.
static struct GNUNET_FS_Handle * ctx
Handle for interaction with file-sharing service.
Last option in the VARARG list.
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:3097
No special flags set.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static char * uri_string
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
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 int ret
Global return value from main().
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our configuration.
static char * this_id
Command-line option for namespace publishing: identifier for this publication.
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
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 void identity_continuation(const char *args0)
Continuation proceeding with initialization after identity subsystem has been initialized.
static char * pseudonym
Command-line option identifying the pseudonym to use for the publication.
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 896 of file gnunet-publish.c.

References GNUNET_FS_BlockOptions::anonymity_level, GNUNET_FS_BlockOptions::content_priority, disable_extractor, do_insert, do_simulate, enable_creation_time, GNUNET_FS_BlockOptions::expiration_time, extract_only, gettext_noop, GNUNET_free, 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_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), GNUNET_TIME_get_current_year(), GNUNET_TIME_year_to_time(), next_id, pseudonym, GNUNET_FS_BlockOptions::replication_level, ret, run(), this_id, uri_string, and verbose.

898 {
901  "anonymity",
902  "LEVEL",
903  gettext_noop ("set the desired LEVEL of sender-anonymity"),
906  "disable-extractor",
907  gettext_noop ("do not use libextractor to add keywords or metadata"),
910  "enable-creation-time",
911  gettext_noop ("enable adding the creation time to the "
912  "metadata of the uploaded file"),
915  "extract",
916  gettext_noop ("print list of extracted keywords that would "
917  "be used, but do not perform upload"),
918  &extract_only),
920  "key",
921  "KEYWORD",
922  gettext_noop ("add an additional keyword for the top-level "
923  "file or directory (this option can be specified multiple times)"),
924  &topKeywords),
926  "meta",
927  "TYPE:VALUE",
928  gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
929  &meta),
931  "noindex",
932  gettext_noop ("do not index, perform full insertion (stores "
933  "entire file in encrypted form in GNUnet database)"),
934  &do_insert),
936  "next",
937  "ID",
938  gettext_noop ("specify ID of an updated version to be "
939  "published in the future (for namespace insertions only)"),
940  &next_id),
942  "priority",
943  "PRIORITY",
944  gettext_noop ("specify the priority of the content"),
947  "pseudonym",
948  "NAME",
949  gettext_noop ("publish the files under the pseudonym "
950  "NAME (place file into namespace)"),
951  &pseudonym),
953  "replication",
954  "LEVEL",
955  gettext_noop ("set the desired replication LEVEL"),
958  "simulate-only",
959  gettext_noop ("only simulate the process but do not do "
960  "any actual publishing (useful to compute URIs)"),
961  &do_simulate),
963  "this",
964  "ID",
965  gettext_noop ("set the ID of this version of the publication "
966  "(for namespace insertions only)"),
967  &this_id),
969  "uri",
970  "URI",
971  gettext_noop ("URI to be published (can be used instead of passing a "
972  "file to add keywords to the file with the respective URI)"),
973  &uri_string),
974 
976 
978  };
981 
982  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
983  return 2;
984  ret = (GNUNET_OK ==
985  GNUNET_PROGRAM_run (argc,
986  argv,
987  "gnunet-publish [OPTIONS] FILENAME",
989  ("Publish a file or directory on GNUnet"),
990  options,
991  &run,
992  NULL)) ? ret : 1;
993  GNUNET_free ((void*) argv);
994  return ret;
995 }
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...
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:725
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1521
static int extract_only
Command-line option to only perform meta data extraction, but not publish.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Definition of a command line option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_FS_GETOPT_METADATA(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_CONTAINER_MetaData **meta)
Allow user to specify metadata.
Definition: fs_getopt.c:251
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
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.
static int enable_creation_time
Command-line option to disable adding creation time.
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP, >1: with cover traffic).
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_Uri * topKeywords
Keywords provided via command-line option.
static int ret
Global return value from main().
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
static int do_insert
Command-line option for 'inserting'.
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 char * this_id
Command-line option for namespace publishing: identifier for this publication.
uint32_t replication_level
How often should we try to migrate the block to other peers? Only used if "CONTENT_PUSHING" is set to...
unsigned int GNUNET_TIME_get_current_year(void)
Return the current year (i.e.
Definition: time.c:684
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line 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.
static int disable_extractor
Command-line option to disable meta data extraction.
uint32_t content_priority
How important is it for us to store the block? If we run out of space, the highest-priority, non-expired blocks will be kept.
static unsigned int verbose
Command line option 'verbose' set.
int GNUNET_PROGRAM_run(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, parse options).
Definition: program.c:361
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.
static int do_simulate
Command-line option to merely simulate publishing operation.
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
static char * pseudonym
Command-line option identifying the pseudonym to use for the publication.
#define GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
Definition: gettext.h:69
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 40 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 45 of file gnunet-publish.c.

◆ ctx

struct GNUNET_FS_Handle* ctx
static

Handle for interaction with file-sharing service.

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

◆ pc

struct GNUNET_FS_PublishContext* pc
static

◆ meta

struct GNUNET_CONTAINER_MetaData* meta
static

◆ topKeywords

struct GNUNET_FS_Uri* topKeywords
static

Keywords provided via command-line option.

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

Referenced by GNUNET_FS_GETOPT_KEYWORDS(), and publish_inspector().

◆ bo

struct GNUNET_FS_BlockOptions bo = { {0LL}, 1, 365, 1 }
static

Options we set for published blocks.

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

Referenced by GNUNET_FS_file_information_create_empty_directory(), and GNUNET_FS_file_information_create_from_reader().

◆ 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 76 of file gnunet-publish.c.

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

◆ uri

struct GNUNET_FS_Uri* uri
static

◆ next_id

char* next_id
static

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

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

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

◆ this_id

char* this_id
static

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

Definition at line 95 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 100 of file gnunet-publish.c.

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

◆ do_insert

int do_insert
static

Command-line option for 'inserting'.

Definition at line 105 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 110 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 115 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 120 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 125 of file gnunet-publish.c.

Referenced by main(), and publish_inspector().

◆ ds

struct GNUNET_FS_DirScanner* ds
static

◆ identity

struct GNUNET_IDENTITY_Handle* identity
static