GNUnet  0.11.x
gnunet-publish.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2001-2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
28 #include "platform.h"
29 #include "gnunet_fs_service.h"
31 
35 static int ret;
36 
40 static unsigned int verbose;
41 
45 static const struct GNUNET_CONFIGURATION_Handle *cfg;
46 
50 static struct GNUNET_FS_Handle *ctx;
51 
56 
61 
65 static struct GNUNET_FS_Uri *topKeywords;
66 
70 static struct GNUNET_FS_BlockOptions bo = { { 0LL }, 1, 365, 1 };
71 
76 static char *uri_string;
77 
83 static struct GNUNET_FS_Uri *uri;
84 
89 static char *next_id;
90 
95 static char *this_id;
96 
100 static char *pseudonym;
101 
105 static int do_insert;
106 
110 static int disable_extractor;
111 
115 static int do_simulate;
116 
120 static int extract_only;
121 
126 
130 static struct GNUNET_FS_DirScanner *ds;
131 
136 static struct GNUNET_IDENTITY_Ego *namespace;
137 
142 
143 
150 static void
151 do_stop_task (void *cls)
152 {
153  struct GNUNET_FS_PublishContext *p;
154 
155  if (NULL != ds)
156  {
158  ds = NULL;
159  }
160  if (NULL != identity)
161  {
162  GNUNET_IDENTITY_disconnect (identity);
163  identity = NULL;
164  }
165  if (NULL != pc)
166  {
167  p = pc;
168  pc = NULL;
170  }
171  if (NULL != ctx)
172  {
173  GNUNET_FS_stop (ctx);
174  ctx = NULL;
175  }
176  if (NULL != meta)
177  {
179  meta = NULL;
180  }
181  if (NULL != uri)
182  {
183  GNUNET_FS_uri_destroy (uri);
184  uri = NULL;
185  }
186 }
187 
188 
202 static void *
203 progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
204 {
205  const char *s;
206  char *suri;
207 
208  switch (info->status)
209  {
211  break;
212 
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,
223  s);
224  }
225  break;
226 
228  if (verbose)
229  {
231  .progress_directory.eta,
232  GNUNET_YES);
233  fprintf (stdout,
234  _ ("Publishing `%s' at %llu/%llu (%s remaining)\n"),
235  info->value.publish.filename,
236  (unsigned long long)
237  info->value.publish.specifics.progress_directory.completed,
238  (unsigned long long)
239  info->value.publish.specifics.progress_directory.total,
240  s);
241  }
242  break;
243 
245  fprintf (stderr,
246  _ ("Error publishing: %s.\n"),
247  info->value.publish.specifics.error.message);
248  ret = 1;
250  break;
251 
253  fprintf (stdout,
254  _ ("Publishing `%s' done.\n"),
255  info->value.publish.filename);
256  suri =
257  GNUNET_FS_uri_to_string (info->value.publish.specifics.completed.chk_uri);
258  fprintf (stdout, _ ("URI is `%s'.\n"), suri);
259  GNUNET_free (suri);
260  if (NULL != info->value.publish.specifics.completed.sks_uri)
261  {
262  suri = GNUNET_FS_uri_to_string (
263  info->value.publish.specifics.completed.sks_uri);
264  fprintf (stdout, _ ("Namespace URI is `%s'.\n"), suri);
265  GNUNET_free (suri);
266  }
267  if (NULL == info->value.publish.pctx)
268  {
269  ret = 0;
271  }
272  break;
273 
275  GNUNET_break (NULL == pc);
276  return NULL;
277 
279  fprintf (stderr, "%s", _ ("Starting cleanup after abort\n"));
280  return NULL;
281 
283  return NULL;
284 
286  fprintf (stderr, "%s", _ ("Cleanup after abort completed.\n"));
288  return NULL;
289 
291  fprintf (stderr, "%s", _ ("Cleanup after abort failed.\n"));
293  return NULL;
294 
296  return NULL;
297 
298  default:
299  fprintf (stderr, _ ("Unexpected status: %d\n"), info->status);
300  return NULL;
301  }
302  return ""; /* non-null */
303 }
304 
305 
319 static int
320 meta_printer (void *cls,
321  const char *plugin_name,
323  enum EXTRACTOR_MetaFormat format,
324  const char *data_mime_type,
325  const char *data,
326  size_t data_size)
327 {
328  if ((EXTRACTOR_METAFORMAT_UTF8 != format) &&
329  (EXTRACTOR_METAFORMAT_C_STRING != format))
330  return 0;
332  return 0;
333 #if HAVE_LIBEXTRACTOR
334  fprintf (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data);
335 #else
336  fprintf (stdout, "\t%d - %s\n", type, data);
337 #endif
338  return 0;
339 }
340 
341 
350 static int
351 keyword_printer (void *cls, const char *keyword, int is_mandatory)
352 {
353  fprintf (stdout, "\t%s\n", keyword);
354  return GNUNET_OK;
355 }
356 
357 
375 static int
376 publish_inspector (void *cls,
378  uint64_t length,
380  struct GNUNET_FS_Uri **uri,
381  struct GNUNET_FS_BlockOptions *bo,
382  int *do_index,
383  void **client_info)
384 {
385  char *fn;
386  char *fs;
387  struct GNUNET_FS_Uri *new_uri;
388 
389  if (cls == fi)
390  return GNUNET_OK;
391  if ((disable_extractor) && (NULL != *uri))
392  {
393  GNUNET_FS_uri_destroy (*uri);
394  *uri = NULL;
395  }
396  if (NULL != topKeywords)
397  {
398  if (NULL != *uri)
399  {
400  new_uri = GNUNET_FS_uri_ksk_merge (topKeywords, *uri);
401  GNUNET_FS_uri_destroy (*uri);
402  *uri = new_uri;
403  GNUNET_FS_uri_destroy (topKeywords);
404  }
405  else
406  {
407  *uri = topKeywords;
408  }
409  topKeywords = NULL;
410  }
411  if (NULL != meta)
412  {
415  meta = NULL;
416  }
419  if (extract_only)
420  {
422  m,
424  fs = GNUNET_STRINGS_byte_size_fancy (length);
425  fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs);
427  fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs);
428  GNUNET_free (fn);
429  GNUNET_free (fs);
430  if (NULL != *uri)
432  fprintf (stdout, "%s", "\n");
433  }
436  return GNUNET_OK;
437 }
438 
439 
449 static void
451  const struct GNUNET_FS_Uri *sks_uri,
452  const char *emsg)
453 {
454  if (NULL != emsg)
455  {
456  fprintf (stderr, "%s\n", emsg);
457  ret = 1;
458  }
460 }
461 
462 
472 static void
474  const struct GNUNET_FS_Uri *ksk_uri,
475  const char *emsg)
476 {
477  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv;
478  const struct GNUNET_IDENTITY_PrivateKey *pk;
479 
480  if (NULL != emsg)
481  {
482  fprintf (stderr, "%s\n", emsg);
483  ret = 1;
484  }
485  if (NULL == namespace)
486  {
488  return;
489  }
490  pk = GNUNET_IDENTITY_ego_get_private_key (namespace);
491  if (GNUNET_IDENTITY_TYPE_ECDSA != ntohl (pk->type))
492  return;
493  priv = &pk->ecdsa_key;
495  priv,
496  this_id,
497  next_id,
498  meta,
499  uri,
500  &bo,
503  NULL);
504 }
505 
506 
514 static struct GNUNET_FS_FileInformation *
516 {
517  struct GNUNET_FS_FileInformation *fi;
518  struct GNUNET_FS_FileInformation *fic;
520 
521  if (GNUNET_YES == item->is_directory)
522  {
523  if (NULL == item->meta)
527  NULL,
528  0);
530  if (NULL == item->ksk_uri)
531  {
532  const char *mime = GNUNET_FS_DIRECTORY_MIME;
533  item->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &mime);
534  }
535  else
538  GNUNET_NO);
540  NULL,
541  item->ksk_uri,
542  item->meta,
543  &bo,
544  item->filename);
545  for (child = item->children_head; child; child = child->next)
546  {
547  fic = get_file_information (child);
549  }
550  }
551  else
552  {
554  NULL,
555  item->filename,
556  item->ksk_uri,
557  item->meta,
558  ! do_insert,
559  &bo);
560  }
561  return fi;
562 }
563 
564 
571 static void
572 directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result)
573 {
574  struct GNUNET_FS_FileInformation *fi;
575  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv;
576  const struct GNUNET_IDENTITY_PrivateKey *pk;
577 
578  fi = get_file_information (directory_scan_result);
579  GNUNET_FS_share_tree_free (directory_scan_result);
580  if (NULL == fi)
581  {
582  fprintf (stderr, "%s", _ ("Could not publish\n"));
583  ret = 1;
585  return;
586  }
588  if (extract_only)
589  {
590  GNUNET_FS_file_information_destroy (fi, NULL, NULL);
592  return;
593  }
594  priv = NULL;
595  if (NULL != namespace)
596  {
597  pk = GNUNET_IDENTITY_ego_get_private_key (namespace);
599  priv = &pk->ecdsa_key;
600  }
601  pc = GNUNET_FS_publish_start (ctx,
602  fi,
603  priv,
604  this_id,
605  next_id,
606  (do_simulate)
609  if (NULL == pc)
610  {
611  fprintf (stderr, "%s", _ ("Could not start publishing.\n"));
612  ret = 1;
614  return;
615  }
616 }
617 
618 
630 static void
631 directory_scan_cb (void *cls,
632  const char *filename,
633  int is_directory,
635 {
636  struct GNUNET_FS_ShareTreeItem *directory_scan_result;
637 
638  switch (reason)
639  {
641  if (verbose > 1)
642  {
643  if (is_directory == GNUNET_YES)
644  fprintf (stdout, _ ("Scanning directory `%s'.\n"), filename);
645  else
646  fprintf (stdout, _ ("Scanning file `%s'.\n"), filename);
647  }
648  break;
649 
651  fprintf (stderr,
652  _ ("There was trouble processing file `%s', skipping it.\n"),
653  filename);
654  break;
655 
657  if (verbose)
658  fprintf (stdout, "%s", _ ("Preprocessing complete.\n"));
659  break;
660 
662  if (verbose > 2)
663  fprintf (stdout,
664  _ ("Extracting meta data from file `%s' complete.\n"),
665  filename);
666  break;
667 
669  if (verbose > 1)
670  fprintf (stdout, "%s", _ ("Meta data extraction has finished.\n"));
671  directory_scan_result = GNUNET_FS_directory_scan_get_result (ds);
672  ds = NULL;
673  GNUNET_FS_share_tree_trim (directory_scan_result);
674  directory_trim_complete (directory_scan_result);
675  break;
676 
678  fprintf (stdout, "%s", _ ("Error scanning directory.\n"));
679  ret = 1;
681  break;
682 
683  default:
684  GNUNET_assert (0);
685  break;
686  }
687  fflush (stdout);
688 }
689 
690 
697 static void
698 identity_continuation (const char *args0)
699 {
700  char *ex;
701  char *emsg;
702 
703  if ((NULL != pseudonym) && (NULL == namespace))
704  {
705  fprintf (stderr, _ ("Selected pseudonym `%s' unknown\n"), pseudonym);
706  ret = 1;
708  return;
709  }
710  if (NULL != uri_string)
711  {
712  emsg = NULL;
713  if (NULL == (uri = GNUNET_FS_uri_parse (uri_string, &emsg)))
714  {
715  fprintf (stderr, _ ("Failed to parse URI: %s\n"), emsg);
716  GNUNET_free (emsg);
717  ret = 1;
719  return;
720  }
722  topKeywords,
723  meta,
724  uri,
725  &bo,
728  NULL);
729  return;
730  }
731  if (GNUNET_OK !=
732  GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex))
733  ex = NULL;
734  if (0 != access (args0, R_OK))
735  {
736  fprintf (stderr,
737  _ ("Failed to access `%s': %s\n"),
738  args0,
739  strerror (errno));
740  GNUNET_free (ex);
741  return;
742  }
743  ds = GNUNET_FS_directory_scan_start (args0,
745  ex,
747  NULL);
748  if (NULL == ds)
749  {
750  fprintf (
751  stderr,
752  "%s",
753  _ (
754  "Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n"));
755  GNUNET_free (ex);
756  return;
757  }
758  GNUNET_free (ex);
759 }
760 
761 
773 static void
774 identity_cb (void *cls,
775  struct GNUNET_IDENTITY_Ego *ego,
776  void **ctx,
777  const char *name)
778 {
779  const char *args0 = cls;
780 
781  if (NULL == ego)
782  {
783  identity_continuation (args0);
784  return;
785  }
786  if (NULL == name)
787  return;
788  if (0 == strcmp (name, pseudonym))
789  namespace = ego;
790 }
791 
792 
801 static void
802 run (void *cls,
803  char *const *args,
804  const char *cfgfile,
805  const struct GNUNET_CONFIGURATION_Handle *c)
806 {
807  /* check arguments */
808  if ((NULL != uri_string) && (extract_only))
809  {
810  printf (_ ("Cannot extract metadata from a URI!\n"));
811  ret = -1;
812  return;
813  }
814  if (((NULL == uri_string) || (extract_only)) &&
815  ((NULL == args[0]) || (NULL != args[1])))
816  {
817  printf (_ ("You must specify one and only one filename for insertion.\n"));
818  ret = -1;
819  return;
820  }
821  if ((NULL != uri_string) && (NULL != args[0]))
822  {
823  printf (_ ("You must NOT specify an URI and a filename.\n"));
824  ret = -1;
825  return;
826  }
827  if (NULL != pseudonym)
828  {
829  if (NULL == this_id)
830  {
831  fprintf (stderr,
832  _ ("Option `%s' is required when using option `%s'.\n"),
833  "-t",
834  "-P");
835  ret = -1;
836  return;
837  }
838  }
839  else
840  { /* ordinary insertion checks */
841  if (NULL != next_id)
842  {
843  fprintf (stderr,
844  _ ("Option `%s' makes no sense without option `%s'.\n"),
845  "-N",
846  "-P");
847  ret = -1;
848  return;
849  }
850  if (NULL != this_id)
851  {
852  fprintf (stderr,
853  _ ("Option `%s' makes no sense without option `%s'.\n"),
854  "-t",
855  "-P");
856  ret = -1;
857  return;
858  }
859  }
860  cfg = c;
861  ctx = GNUNET_FS_start (cfg,
862  "gnunet-publish",
863  &progress_cb,
864  NULL,
867  if (NULL == ctx)
868  {
869  fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS");
870  ret = 1;
871  return;
872  }
874  if (NULL != pseudonym)
875  identity = GNUNET_IDENTITY_connect (cfg, &identity_cb, args[0]);
876  else
877  identity_continuation (args[0]);
878 }
879 
880 
888 int
889 main (int argc, char *const *argv)
890 {
891  struct GNUNET_GETOPT_CommandLineOption options[] =
893  "anonymity",
894  "LEVEL",
895  gettext_noop (
896  "set the desired LEVEL of sender-anonymity"),
897  &bo.anonymity_level),
899  'D',
900  "disable-extractor",
901  gettext_noop ("do not use libextractor to add keywords or metadata"),
904  "enable-creation-time",
905  gettext_noop (
906  "enable adding the creation time to the "
907  "metadata of the uploaded file"),
910  "extract",
911  gettext_noop (
912  "print list of extracted keywords that would "
913  "be used, but do not perform upload"),
914  &extract_only),
916  'k',
917  "key",
918  "KEYWORD",
919  gettext_noop (
920  "add an additional keyword for the top-level "
921  "file or directory (this option can be specified multiple times)"),
922  &topKeywords),
924  'm',
925  "meta",
926  "TYPE:VALUE",
927  gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
928  &meta),
930  'n',
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  'N',
937  "next",
938  "ID",
939  gettext_noop ("specify ID of an updated version to be "
940  "published in the future (for namespace insertions only)"),
941  &next_id),
943  "priority",
944  "PRIORITY",
945  gettext_noop (
946  "specify the priority of the content"),
947  &bo.content_priority),
949  "pseudonym",
950  "NAME",
951  gettext_noop (
952  "publish the files under the pseudonym "
953  "NAME (place file into namespace)"),
954  &pseudonym),
956  "replication",
957  "LEVEL",
958  gettext_noop (
959  "set the desired replication LEVEL"),
960  &bo.replication_level),
962  "simulate-only",
963  gettext_noop (
964  "only simulate the process but do not do "
965  "any actual publishing (useful to compute URIs)"),
966  &do_simulate),
968  "this",
969  "ID",
970  gettext_noop (
971  "set the ID of this version of the publication "
972  "(for namespace insertions only)"),
973  &this_id),
975  'u',
976  "uri",
977  "URI",
978  gettext_noop (
979  "URI to be published (can be used instead of passing a "
980  "file to add keywords to the file with the respective URI)"),
981  &uri_string),
982 
984 
986 
987  bo.expiration_time =
989 
990  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
991  return 2;
992  ret =
993  (GNUNET_OK ==
994  GNUNET_PROGRAM_run (argc,
995  argv,
996  "gnunet-publish [OPTIONS] FILENAME",
997  gettext_noop ("Publish a file or directory on GNUnet"),
998  options,
999  &run,
1000  NULL))
1001  ? ret
1002  : 1;
1003  GNUNET_free_nz ((void *) argv);
1004  return ret;
1005 }
1006 
1007 
1008 /* end of gnunet-publish.c */
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:610
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:726
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:416
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.
EXTRACTOR_MetaFormat
Format in which the extracted meta data is presented.
void GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc)
Stop an upload.
Definition: fs_publish.c:1570
void GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc)
Clean up after completion of an unindex operation.
Definition: fs_unindex.c:837
Notification that we started to unindex a file.
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:1154
static void directory_trim_complete(struct GNUNET_FS_ShareTreeItem *directory_scan_result)
We&#39;ve finished scanning the directory and optimized the meta data.
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:80
Notification that we are making progress sharing a file 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:762
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:1442
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.
char * GNUNET_STRINGS_byte_size_fancy(unsigned long long size)
Convert a given filesize into a fancy human-readable format.
Definition: strings.c:177
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:644
Notification that we made progress unindexing a file.
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:1331
Master context for most FS operations.
Definition: fs_api.h:1068
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.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the &#39;-V&#39; verbosity option.
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.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1459
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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:442
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 struct GNUNET_FS_Handle * ctx
Handle for interaction with file-sharing service.
Last option in the VARARG list.
#define GNUNET_FS_DIRECTORY_MIME
A private key for an identity as per LSD0001.
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).
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.
int main(int argc, char *const *argv)
The main function to publish content to GNUnet.
0-terminated, UTF-8 encoded string.
An opaque structure a pointer to which is returned to the caller to be used to control the scanner...
Definition of a command line option.
Private ECC key encoded for transmission.
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
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.
EXTRACTOR_MetaType
Enumeration defining various sources of keywords.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
Definition: fs_api.c:3338
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:254
We&#39;ve found all files (in the pre-pass).
struct GNUNET_FS_ProgressInfo::@25::@29 unindex
Values for all "GNUNET_FS_STATUS_UNINDEX_*" events.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
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.
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:3263
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.
No special flags set.
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
Notification that we have stopped the process of uploading a file structure; no further events will b...
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2027
static int enable_creation_time
Command-line option to disable adding creation time.
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 struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP, >1: with cover traffic).
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.
struct GNUNET_FS_ShareTreeItem * next
This is a doubly-linked list.
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:730
Notification that we have started to publish a file structure.
static char * uri_string
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
Meta data to associate with a file, directory or namespace.
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
Handle for an ego.
Definition: identity.h:36
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 struct GNUNET_FS_Uri * topKeywords
Keywords provided via command-line option.
A node of a directory tree (produced by dirscanner)
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
Notification that we are making progress sharing a directory.
void GNUNET_CONTAINER_meta_data_merge(struct GNUNET_CONTAINER_MetaData *md, const struct GNUNET_CONTAINER_MetaData *in)
Extend metadata.
struct GNUNET_FS_ShareTreeItem * children_head
This is a doubly-linked tree NULL for files and empty directories.
static char * fn
Filename of the unique file.
Handle for the service.
Definition: identity_api.c:95
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_create(void)
Create a fresh meta data container.
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:702
static void do_stop_task(void *cls)
We are finished with the publishing operation, clean up all FS state.
static char * filename
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
static int ret
Global return value from main().
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:921
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:678
There was an internal error.
Handle for controlling a publication process.
Definition: fs_api.h:1178
GNUNET_FS_DirScannerProgressUpdateReason
Progress reasons of the directory scanner.
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.
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.
#define GNUNET_free_nz(ptr)
Wrapper around free.
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 struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static int keyword_printer(void *cls, const char *keyword, int is_mandatory)
Iterator printing keywords.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our configuration.
Notification that the unindexing of this file was stopped (final event for this action).
static int do_insert
Command-line option for &#39;inserting&#39;.
Last call to the progress function: we have finished scanning the directory.
Settings for publishing a block (which may of course also apply to an entire directory or file)...
Notification that the unindexing of this file was completed.
Notification that we completed sharing a file structure.
uint32_t type
Type of public key.
int is_directory
GNUNET_YES if this is a directory
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.
char * filename
Name of the file/directory.
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
struct GNUNET_CONTAINER_MetaData * meta
Metadata for this file or directory.
static char * this_id
Command-line option for namespace publishing: identifier for this publication.
We&#39;ve started processing a file or directory.
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:686
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1193
Notification that an error was encountered sharing a file structure.
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
static struct GNUNET_OS_Process * child
The child process we spawn.
struct GNUNET_FS_ProgressInfo::@25::@26 publish
Values for all "GNUNET_FS_STATUS_PUBLISH_*" events.
configuration data
Definition: configuration.c:84
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
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:436
const char * name
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
const struct GNUNET_IDENTITY_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:639
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.
int GNUNET_CONTAINER_meta_data_iterate(const struct GNUNET_CONTAINER_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
Iterate over MD entries.
We&#39;ve finished extracting meta data from a file.
void GNUNET_FS_file_information_destroy(struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
Destroy publish-structure.
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 void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Function called by identity service with known pseudonyms.
static unsigned int verbose
Command line option &#39;verbose&#39; 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:372
static void identity_continuation(const char *args0)
Continuation proceeding with initialization after identity subsystem has been initialized.
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:941
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
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.
static struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
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 void directory_scan_cb(void *cls, const char *filename, int is_directory, enum GNUNET_FS_DirScannerProgressUpdateReason reason)
Function called by the directory scanner as we build the tree that we will need to publish later...
static int do_simulate
Command-line option to merely simulate publishing operation.
No options (use defaults for everything).
uint32_t data
The data value.
Notification that we encountered an error unindexing a file.
static char * plugin_name
Name of our plugin.
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.
Argument given to the progress callback with information about what is going on.
We&#39;re having trouble accessing a file (soft-error); it will be ignored.
#define gettext_noop(String)
Definition: gettext.h:69