GNUnet 0.21.1
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
30#include "gnunet_fs_service.h"
32
36static int ret;
37
41static unsigned int verbose;
42
46static const struct GNUNET_CONFIGURATION_Handle *cfg;
47
51static struct GNUNET_FS_Handle *ctx;
52
57
61static struct GNUNET_FS_MetaData *meta;
62
67
71static struct GNUNET_FS_BlockOptions bo = { { 0LL }, 1, 365, 1 };
72
77static char *uri_string;
78
84static struct GNUNET_FS_Uri *uri;
85
90static char *next_id;
91
96static char *this_id;
97
101static char *pseudonym;
102
106static int do_insert;
107
112
116static int do_simulate;
117
121static int extract_only;
122
127
132
137static struct GNUNET_IDENTITY_Ego *namespace;
138
143
144
151static void
152do_stop_task (void *cls)
153{
155
156 if (NULL != ds)
157 {
159 ds = NULL;
160 }
161 if (NULL != identity)
162 {
164 identity = NULL;
165 }
166 if (NULL != pc)
167 {
168 p = pc;
169 pc = NULL;
171 }
172 if (NULL != ctx)
173 {
175 ctx = NULL;
176 }
177 if (NULL != meta)
178 {
180 meta = NULL;
181 }
182 if (NULL != uri)
183 {
185 uri = NULL;
186 }
187}
188
189
203static void *
204progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
205{
206 const char *s;
207 char *suri;
208
209 switch (info->status)
210 {
212 break;
213
215 if (verbose)
216 {
217 s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta,
218 GNUNET_YES);
219 fprintf (stdout,
220 _ ("Publishing `%s' at %llu/%llu (%s remaining)\n"),
221 info->value.publish.filename,
222 (unsigned long long) info->value.publish.completed,
223 (unsigned long long) info->value.publish.size,
224 s);
225 }
226 break;
227
229 if (verbose)
230 {
231 s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.specifics
232 .progress_directory.eta,
233 GNUNET_YES);
234 fprintf (stdout,
235 _ ("Publishing `%s' at %llu/%llu (%s remaining)\n"),
236 info->value.publish.filename,
237 (unsigned long long)
238 info->value.publish.specifics.progress_directory.completed,
239 (unsigned long long)
240 info->value.publish.specifics.progress_directory.total,
241 s);
242 }
243 break;
244
246 fprintf (stderr,
247 _ ("Error publishing: %s.\n"),
248 info->value.publish.specifics.error.message);
249 ret = 1;
251 break;
252
254 fprintf (stdout,
255 _ ("Publishing `%s' done.\n"),
256 info->value.publish.filename);
257 suri =
258 GNUNET_FS_uri_to_string (info->value.publish.specifics.completed.chk_uri);
259 fprintf (stdout, _ ("URI is `%s'.\n"), suri);
260 GNUNET_free (suri);
261 if (NULL != info->value.publish.specifics.completed.sks_uri)
262 {
264 info->value.publish.specifics.completed.sks_uri);
265 fprintf (stdout, _ ("Namespace URI is `%s'.\n"), suri);
266 GNUNET_free (suri);
267 }
268 if (NULL == info->value.publish.pctx)
269 {
270 ret = 0;
272 }
273 break;
274
276 GNUNET_break (NULL == pc);
277 return NULL;
278
280 fprintf (stderr, "%s", _ ("Starting cleanup after abort\n"));
281 return NULL;
282
284 return NULL;
285
287 fprintf (stderr, "%s", _ ("Cleanup after abort completed.\n"));
288 GNUNET_FS_unindex_stop (info->value.unindex.uc);
289 return NULL;
290
292 fprintf (stderr, "%s", _ ("Cleanup after abort failed.\n"));
293 GNUNET_FS_unindex_stop (info->value.unindex.uc);
294 return NULL;
295
297 return NULL;
298
299 default:
300 fprintf (stderr, _ ("Unexpected status: %d\n"), info->status);
301 return NULL;
302 }
303 return ""; /* non-null */
304}
305
306
320static int
321meta_printer (void *cls,
322 const char *plugin_name,
323 enum EXTRACTOR_MetaType type,
324 enum EXTRACTOR_MetaFormat format,
325 const char *data_mime_type,
326 const char *data,
327 size_t data_size)
328{
329 if ((EXTRACTOR_METAFORMAT_UTF8 != format) &&
330 (EXTRACTOR_METAFORMAT_C_STRING != format))
331 return 0;
333 return 0;
334#if HAVE_LIBEXTRACTOR
335 fprintf (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data);
336#else
337 fprintf (stdout, "\t%d - %s\n", type, data);
338#endif
339 return 0;
340}
341
342
351static int
352keyword_printer (void *cls, const char *keyword, int is_mandatory)
353{
354 fprintf (stdout, "\t%s\n", keyword);
355 return GNUNET_OK;
356}
357
358
376static int
379 uint64_t length,
380 struct GNUNET_FS_MetaData *m,
381 struct GNUNET_FS_Uri **uri,
383 int *do_index,
384 void **client_info)
385{
386 char *fn;
387 char *fs;
388 struct GNUNET_FS_Uri *new_uri;
389
390 if (cls == fi)
391 return GNUNET_OK;
392 if ((disable_extractor) && (NULL != *uri))
393 {
395 *uri = NULL;
396 }
397 if (NULL != topKeywords)
398 {
399 if (NULL != *uri)
400 {
403 *uri = new_uri;
405 }
406 else
407 {
408 *uri = topKeywords;
409 }
410 topKeywords = NULL;
411 }
412 if (NULL != meta)
413 {
416 meta = NULL;
417 }
420 if (extract_only)
421 {
423 m,
426 fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs);
428 fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs);
429 GNUNET_free (fn);
430 GNUNET_free (fs);
431 if (NULL != *uri)
433 fprintf (stdout, "%s", "\n");
434 }
437 return GNUNET_OK;
438}
439
440
450static void
452 const struct GNUNET_FS_Uri *sks_uri,
453 const char *emsg)
454{
455 if (NULL != emsg)
456 {
457 fprintf (stderr, "%s\n", emsg);
458 ret = 1;
459 }
461}
462
463
473static void
475 const struct GNUNET_FS_Uri *ksk_uri,
476 const char *emsg)
477{
478 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv;
479 const struct GNUNET_CRYPTO_PrivateKey *pk;
480
481 if (NULL != emsg)
482 {
483 fprintf (stderr, "%s\n", emsg);
484 ret = 1;
485 }
486 if (NULL == namespace)
487 {
489 return;
490 }
492 if (GNUNET_PUBLIC_KEY_TYPE_ECDSA != ntohl (pk->type))
493 return;
494 priv = &pk->ecdsa_key;
496 priv,
497 this_id,
498 next_id,
499 meta,
500 uri,
501 &bo,
504 NULL);
505}
506
507
515static struct GNUNET_FS_FileInformation *
517{
518 struct GNUNET_FS_FileInformation *fi;
519 struct GNUNET_FS_FileInformation *fic;
521
522 if (GNUNET_YES == item->is_directory)
523 {
524 if (NULL == item->meta)
527 EXTRACTOR_METATYPE_MIMETYPE,
528 NULL,
529 0);
531 if (NULL == item->ksk_uri)
532 {
533 const char *mime = GNUNET_FS_DIRECTORY_MIME;
535 }
536 else
539 GNUNET_NO);
541 NULL,
542 item->ksk_uri,
543 item->meta,
544 &bo,
545 item->filename);
546 for (child = item->children_head; child; child = child->next)
547 {
550 }
551 }
552 else
553 {
555 NULL,
556 item->filename,
557 item->ksk_uri,
558 item->meta,
559 ! do_insert,
560 &bo);
561 }
562 return fi;
563}
564
565
572static void
574{
575 struct GNUNET_FS_FileInformation *fi;
576 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv;
577 const struct GNUNET_CRYPTO_PrivateKey *pk;
578
579 fi = get_file_information (directory_scan_result);
580 GNUNET_FS_share_tree_free (directory_scan_result);
581 if (NULL == fi)
582 {
583 fprintf (stderr, "%s", _ ("Could not publish\n"));
584 ret = 1;
586 return;
587 }
589 if (extract_only)
590 {
591 GNUNET_FS_file_information_destroy (fi, NULL, NULL);
593 return;
594 }
595 priv = NULL;
596 if (NULL != namespace)
597 {
600 priv = &pk->ecdsa_key;
601 }
603 fi,
604 priv,
605 this_id,
606 next_id,
610 if (NULL == pc)
611 {
612 fprintf (stderr, "%s", _ ("Could not start publishing.\n"));
613 ret = 1;
615 return;
616 }
617}
618
619
631static void
633 const char *filename,
634 int is_directory,
636{
637 struct GNUNET_FS_ShareTreeItem *directory_scan_result;
638
639 switch (reason)
640 {
642 if (verbose > 1)
643 {
645 fprintf (stdout, _ ("Scanning directory `%s'.\n"), filename);
646 else
647 fprintf (stdout, _ ("Scanning file `%s'.\n"), filename);
648 }
649 break;
650
652 fprintf (stderr,
653 _ ("There was trouble processing file `%s', skipping it.\n"),
654 filename);
655 break;
656
658 if (verbose)
659 fprintf (stdout, "%s", _ ("Preprocessing complete.\n"));
660 break;
661
663 if (verbose > 2)
664 fprintf (stdout,
665 _ ("Extracting meta data from file `%s' complete.\n"),
666 filename);
667 break;
668
670 if (verbose > 1)
671 fprintf (stdout, "%s", _ ("Meta data extraction has finished.\n"));
672 directory_scan_result = GNUNET_FS_directory_scan_get_result (ds);
673 ds = NULL;
674 GNUNET_FS_share_tree_trim (directory_scan_result);
675 directory_trim_complete (directory_scan_result);
676 break;
677
679 fprintf (stdout, "%s", _ ("Error scanning directory.\n"));
680 ret = 1;
682 break;
683
684 default:
685 GNUNET_assert (0);
686 break;
687 }
688 fflush (stdout);
689}
690
691
698static void
699identity_continuation (const char *args0)
700{
701 char *ex;
702 char *emsg;
703
704 if ((NULL != pseudonym) && (NULL == namespace))
705 {
706 fprintf (stderr, _ ("Selected pseudonym `%s' unknown\n"), pseudonym);
707 ret = 1;
709 return;
710 }
711 if (NULL != uri_string)
712 {
713 emsg = NULL;
714 if (NULL == (uri = GNUNET_FS_uri_parse (uri_string, &emsg)))
715 {
716 fprintf (stderr, _ ("Failed to parse URI: %s\n"), emsg);
717 GNUNET_free (emsg);
718 ret = 1;
720 return;
721 }
724 meta,
725 uri,
726 &bo,
729 NULL);
730 return;
731 }
732 if (GNUNET_OK !=
733 GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex))
734 ex = NULL;
735 if (0 != access (args0, R_OK))
736 {
737 fprintf (stderr,
738 _ ("Failed to access `%s': %s\n"),
739 args0,
740 strerror (errno));
741 GNUNET_free (ex);
742 return;
743 }
746 ex,
748 NULL);
749 if (NULL == ds)
750 {
751 fprintf (
752 stderr,
753 "%s",
754 _ (
755 "Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n"));
756 GNUNET_free (ex);
757 return;
758 }
759 GNUNET_free (ex);
760}
761
762
774static void
775identity_cb (void *cls,
776 struct GNUNET_IDENTITY_Ego *ego,
777 void **ctx,
778 const char *name)
779{
780 const char *args0 = cls;
781
782 if (NULL == ego)
783 {
784 identity_continuation (args0);
785 return;
786 }
787 if (NULL == name)
788 return;
789 if (0 == strcmp (name, pseudonym))
790 namespace = ego;
791}
792
793
802static void
803run (void *cls,
804 char *const *args,
805 const char *cfgfile,
806 const struct GNUNET_CONFIGURATION_Handle *c)
807{
808 /* check arguments */
809 if ((NULL != uri_string) && (extract_only))
810 {
811 printf (_ ("Cannot extract metadata from a URI!\n"));
812 ret = -1;
813 return;
814 }
815 if (((NULL == uri_string) || (extract_only)) &&
816 ((NULL == args[0]) || (NULL != args[1])))
817 {
818 printf (_ ("You must specify one and only one filename for insertion.\n"));
819 ret = -1;
820 return;
821 }
822 if ((NULL != uri_string) && (NULL != args[0]))
823 {
824 printf (_ ("You must NOT specify an URI and a filename.\n"));
825 ret = -1;
826 return;
827 }
828 if (NULL != pseudonym)
829 {
830 if (NULL == this_id)
831 {
832 fprintf (stderr,
833 _ ("Option `%s' is required when using option `%s'.\n"),
834 "-t",
835 "-P");
836 ret = -1;
837 return;
838 }
839 }
840 else
841 { /* ordinary insertion checks */
842 if (NULL != next_id)
843 {
844 fprintf (stderr,
845 _ ("Option `%s' makes no sense without option `%s'.\n"),
846 "-N",
847 "-P");
848 ret = -1;
849 return;
850 }
851 if (NULL != this_id)
852 {
853 fprintf (stderr,
854 _ ("Option `%s' makes no sense without option `%s'.\n"),
855 "-t",
856 "-P");
857 ret = -1;
858 return;
859 }
860 }
861 cfg = c;
863 "gnunet-publish",
865 NULL,
868 if (NULL == ctx)
869 {
870 fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS");
871 ret = 1;
872 return;
873 }
875 if (NULL != pseudonym)
877 else
879}
880
881
889int
890main (int argc, char *const *argv)
891{
894 "anonymity",
895 "LEVEL",
897 "set the desired LEVEL of sender-anonymity"),
900 'D',
901 "disable-extractor",
902 gettext_noop ("do not use libextractor to add keywords or metadata"),
905 "enable-creation-time",
907 "enable adding the creation time to the "
908 "metadata of the uploaded file"),
911 "extract",
913 "print list of extracted keywords that would "
914 "be used, but do not perform upload"),
915 &extract_only),
917 'k',
918 "key",
919 "KEYWORD",
921 "add an additional keyword for the top-level "
922 "file or directory (this option can be specified multiple times)"),
923 &topKeywords),
925 'm',
926 "meta",
927 "TYPE:VALUE",
928 gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
929 &meta),
931 'n',
932 "noindex",
933 gettext_noop ("do not index, perform full insertion (stores "
934 "entire file in encrypted form in GNUnet database)"),
935 &do_insert),
937 'N',
938 "next",
939 "ID",
940 gettext_noop ("specify ID of an updated version to be "
941 "published in the future (for namespace insertions only)"),
942 &next_id),
944 "priority",
945 "PRIORITY",
947 "specify the priority of the content"),
950 "pseudonym",
951 "NAME",
953 "publish the files under the pseudonym "
954 "NAME (place file into namespace)"),
955 &pseudonym),
957 "replication",
958 "LEVEL",
960 "set the desired replication LEVEL"),
963 "simulate-only",
965 "only simulate the process but do not do "
966 "any actual publishing (useful to compute URIs)"),
967 &do_simulate),
969 "this",
970 "ID",
972 "set the ID of this version of the publication "
973 "(for namespace insertions only)"),
974 &this_id),
976 'u',
977 "uri",
978 "URI",
980 "URI to be published (can be used instead of passing a "
981 "file to add keywords to the file with the respective URI)"),
982 &uri_string),
983
985
987
990
991 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
992 return 2;
993 ret =
994 (GNUNET_OK ==
995 GNUNET_PROGRAM_run (argc,
996 argv,
997 "gnunet-publish [OPTIONS] FILENAME",
998 gettext_noop ("Publish a file or directory on GNUnet"),
999 options,
1000 &run,
1001 NULL))
1002 ? ret
1003 : 1;
1004 GNUNET_free_nz ((void *) argv);
1005 return ret;
1006}
1007
1008
1009/* end of gnunet-publish.c */
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:70
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static char * data
The data to insert into the dht.
static char * filename
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition: gnunet-fs.c:37
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static char * name
Name (label) of the records to list.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static int disable_extractor
Command-line option to disable meta data extraction.
static unsigned int verbose
Command line option 'verbose' set.
static struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
static int do_simulate
Command-line option to merely simulate publishing operation.
static char * uri_string
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
static char * pseudonym
Command-line option identifying the pseudonym to use for the publication.
static int publish_inspector(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_FS_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.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our configuration.
static void uri_sks_continuation(void *cls, const struct GNUNET_FS_Uri *sks_uri, const char *emsg)
Function called upon completion of the publishing of the UBLOCK for the SKS URI.
static void uri_ksk_continuation(void *cls, const struct GNUNET_FS_Uri *ksk_uri, const char *emsg)
Function called upon completion of the publishing of the UBLOCK for the KSK URI.
static int do_insert
Command-line option for 'inserting'.
static int ret
Global return value from main().
static void * progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Called by FS client to give information about the progress of an operation.
static int enable_creation_time
Command-line option to disable adding creation time.
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
static struct GNUNET_FS_Handle * ctx
Handle for interaction with file-sharing service.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
static void do_stop_task(void *cls)
We are finished with the publishing operation, clean up all FS state.
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
static struct GNUNET_FS_FileInformation * get_file_information(struct GNUNET_FS_ShareTreeItem *item)
Iterate over the results from the directory scan and extract the desired information for the publishi...
static char * this_id
Command-line option for namespace publishing: identifier for this publication.
static int keyword_printer(void *cls, const char *keyword, int is_mandatory)
Iterator printing keywords.
static void directory_scan_cb(void *cls, const char *filename, int is_directory, enum GNUNET_FS_DirScannerProgressUpdateReason reason)
Function called by the directory scanner as we build the tree that we will need to publish later.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Function called by identity service with known pseudonyms.
int main(int argc, char *const *argv)
The main function to publish content to GNUnet.
static int extract_only
Command-line option to only perform meta data extraction, but not publish.
static int meta_printer(void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_size)
Print metadata entries (except binary metadata and the filename).
static struct GNUNET_FS_Uri * topKeywords
Keywords provided via command-line option.
static void identity_continuation(const char *args0)
Continuation proceeding with initialization after identity subsystem has been initialized.
static void directory_trim_complete(struct GNUNET_FS_ShareTreeItem *directory_scan_result)
We've finished scanning the directory and optimized the meta data.
#define info
static char * plugin_name
Name of our plugin.
static pid_t child
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
API for file sharing via GNUnet.
Identity service; implements identity management for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
void GNUNET_FS_share_tree_free(struct GNUNET_FS_ShareTreeItem *toplevel)
Release memory of a share item tree.
Definition: fs_sharetree.c:437
struct GNUNET_FS_PublishContext * GNUNET_FS_publish_start(struct GNUNET_FS_Handle *h, struct GNUNET_FS_FileInformation *fi, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *nid, const char *nuid, enum GNUNET_FS_PublishOptions options)
Publish a file or directory.
Definition: fs_publish.c:1443
void GNUNET_FS_meta_data_make_directory(struct GNUNET_FS_MetaData *md)
Set the MIMETYPE information for the given metadata to "application/gnunet-directory".
Definition: fs_directory.c:81
#define GNUNET_FS_DIRECTORY_MIME
int GNUNET_FS_file_information_add(struct GNUNET_FS_FileInformation *dir, struct GNUNET_FS_FileInformation *ent)
Add an entry to a directory in a publish-structure.
struct GNUNET_FS_PublishKskContext * GNUNET_FS_publish_ksk(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *ksk_uri, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
Publish a KBlock on GNUnet.
void GNUNET_FS_file_information_inspect(struct GNUNET_FS_FileInformation *dir, GNUNET_FS_FileInformationProcessor proc, void *proc_cls)
Inspect a file or directory in a publish-structure.
void GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc)
Clean up after completion of an unindex operation.
Definition: fs_unindex.c:838
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2034
struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_empty_directory(struct GNUNET_FS_Handle *h, void *client_info, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_BlockOptions *bo, const char *filename)
Create an entry for an empty directory in a publish-structure.
struct GNUNET_FS_Handle * GNUNET_FS_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, enum GNUNET_FS_Flags flags,...)
Setup a connection to the file-sharing service.
Definition: fs_api.c:3244
struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_create_from_args(unsigned int argc, const char **argv)
Create an FS URI from a user-supplied command line of keywords.
Definition: fs_uri.c:1144
struct GNUNET_FS_ShareTreeItem * GNUNET_FS_directory_scan_get_result(struct GNUNET_FS_DirScanner *ds)
Obtain the result of the scan after the scan has signalled completion.
int GNUNET_FS_uri_ksk_get_keywords(const struct GNUNET_FS_Uri *uri, GNUNET_FS_KeywordIterator iterator, void *iterator_cls)
Iterate over all keywords in this keyword URI.
Definition: fs_uri.c:720
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:677
struct GNUNET_FS_PublishSksContext * GNUNET_FS_publish_sks(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *identifier, const char *update, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
Publish an SBlock on GNUnet.
Definition: fs_namespace.c:428
struct GNUNET_FS_DirScanner * GNUNET_FS_directory_scan_start(const char *filename, int disable_extractor, const char *ex, GNUNET_FS_DirScannerProgressCallback cb, void *cb_cls)
Start a directory scanner.
GNUNET_FS_DirScannerProgressUpdateReason
Progress reasons of the directory scanner.
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_FS_MetaData *md)
Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet direct...
Definition: fs_directory.c:55
struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_from_file(struct GNUNET_FS_Handle *h, void *client_info, const char *filename, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
Create an entry for a file in a publish-structure.
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
Definition: fs_api.c:3310
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
Definition: fs_uri.c:637
struct GNUNET_GETOPT_CommandLineOption GNUNET_FS_GETOPT_METADATA(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_FS_MetaData **meta)
Allow user to specify metadata.
Definition: fs_getopt.c:254
void GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc)
Stop a publication.
Definition: fs_publish.c:1571
void GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
Abort the scan.
void GNUNET_FS_file_information_destroy(struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
Destroy publish-structure.
void GNUNET_FS_share_tree_trim(struct GNUNET_FS_ShareTreeItem *toplevel)
Process a share item tree, moving frequent keywords up and copying frequent metadata up.
Definition: fs_sharetree.c:417
struct GNUNET_GETOPT_CommandLineOption GNUNET_FS_GETOPT_KEYWORDS(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_FS_Uri **topKeywords)
Allow user to specify keywords.
Definition: fs_getopt.c:129
struct GNUNET_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
void GNUNET_FS_uri_ksk_add_keyword(struct GNUNET_FS_Uri *uri, const char *keyword, int is_mandatory)
Add the given keyword to the set of keywords represented by the URI.
Definition: fs_uri.c:752
@ GNUNET_FS_FLAGS_NONE
No special flags set.
@ GNUNET_FS_OPTIONS_END
Last option in the VARARG list.
@ GNUNET_FS_STATUS_UNINDEX_PROGRESS
Notification that we made progress unindexing a file.
@ GNUNET_FS_STATUS_UNINDEX_START
Notification that we started to unindex a file.
@ GNUNET_FS_STATUS_PUBLISH_STOPPED
Notification that we have stopped the process of uploading a file structure; no further events will b...
@ GNUNET_FS_STATUS_PUBLISH_ERROR
Notification that an error was encountered sharing a file structure.
@ GNUNET_FS_STATUS_UNINDEX_STOPPED
Notification that the unindexing of this file was stopped (final event for this action).
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS
Notification that we are making progress sharing a file structure.
@ GNUNET_FS_STATUS_UNINDEX_COMPLETED
Notification that the unindexing of this file was completed.
@ GNUNET_FS_STATUS_UNINDEX_ERROR
Notification that we encountered an error unindexing a file.
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY
Notification that we are making progress sharing a directory.
@ GNUNET_FS_STATUS_PUBLISH_START
Notification that we have started to publish a file structure.
@ GNUNET_FS_STATUS_PUBLISH_COMPLETED
Notification that we completed sharing a file structure.
@ GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY
Simulate publishing.
@ GNUNET_FS_PUBLISH_OPTION_NONE
No options (use defaults for everything).
@ GNUNET_FS_DIRSCANNER_INTERNAL_ERROR
There was an internal error.
@ GNUNET_FS_DIRSCANNER_FILE_IGNORED
We're having trouble accessing a file (soft-error); it will be ignored.
@ GNUNET_FS_DIRSCANNER_FINISHED
Last call to the progress function: we have finished scanning the directory.
@ GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED
We've finished extracting meta data from a file.
@ GNUNET_FS_DIRSCANNER_ALL_COUNTED
We've found all files (in the pre-pass).
@ GNUNET_FS_DIRSCANNER_FILE_START
We've started processing a file or directory.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
const struct GNUNET_CRYPTO_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:517
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:487
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:732
@ GNUNET_PUBLIC_KEY_TYPE_ECDSA
The identity type.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
int GNUNET_FS_meta_data_iterate(const struct GNUNET_FS_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
Iterate over MD entries.
Definition: meta_data.c:418
char * GNUNET_FS_meta_data_get_by_type(const struct GNUNET_FS_MetaData *md, enum EXTRACTOR_MetaType type)
Get the first MD entry of the given type.
Definition: meta_data.c:438
void GNUNET_FS_meta_data_add_publication_date(struct GNUNET_FS_MetaData *md)
Add the current time as the publication date to the meta-data.
Definition: meta_data.c:391
struct GNUNET_FS_MetaData * GNUNET_FS_meta_data_create(void)
Create a fresh meta data container.
Definition: meta_data.c:127
void GNUNET_FS_meta_data_merge(struct GNUNET_FS_MetaData *md, const struct GNUNET_FS_MetaData *in)
Extend metadata.
Definition: meta_data.c:356
void GNUNET_FS_meta_data_destroy(struct GNUNET_FS_MetaData *md)
Free meta data.
Definition: meta_data.c:166
int GNUNET_FS_meta_data_delete(struct GNUNET_FS_MetaData *md, enum EXTRACTOR_MetaType type, const char *data, size_t data_size)
Remove an item.
Definition: meta_data.c:364
enum GNUNET_GenericReturnValue 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,...
Definition: program.c:400
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1340
char * GNUNET_STRINGS_byte_size_fancy(unsigned long long size)
Convert a given filesize into a fancy human-readable format.
Definition: strings.c:106
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1230
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:801
unsigned int GNUNET_TIME_get_current_year(void)
Return the current year (e.g.
Definition: time.c:747
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:570
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
Private ECC key encoded for transmission.
A private key for an identity as per LSD0001.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
Settings for publishing a block (which may of course also apply to an entire directory or file).
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP,...
uint32_t content_priority
How important is it for us to store the block? If we run out of space, the highest-priority,...
uint32_t replication_level
How often should we try to migrate the block to other peers? Only used if "CONTENT_PUSHING" is set to...
struct GNUNET_TIME_Absolute expiration_time
At what time should the block expire? Data blocks (DBLOCKS and IBLOCKS) may still be used even if the...
An opaque structure a pointer to which is returned to the caller to be used to control the scanner.
Information for a file or directory that is about to be published.
Definition: fs_api.h:228
Master context for most FS operations.
Definition: fs_api.h:1070
Meta data to associate with a file, directory or namespace.
Definition: meta_data.c:92
Argument given to the progress callback with information about what is going on.
Handle for controlling a publication process.
Definition: fs_api.h:1180
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1194
A node of a directory tree (produced by dirscanner)
int is_directory
GNUNET_YES if this is a directory
struct GNUNET_FS_Uri * ksk_uri
Keywords for this file or directory (derived from metadata).
struct GNUNET_FS_ShareTreeItem * children_head
This is a doubly-linked tree NULL for files and empty directories.
struct GNUNET_FS_MetaData * meta
Metadata for this file or directory.
char * filename
Name of the file/directory.
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:167
Definition of a command line option.
Handle for an ego.
Definition: identity.h:37
Handle for the service.
Definition: identity_api.c:97