2 This file is part of GNUnet
3 (C) 2004--2013 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file include/gnunet_fs_service.h
22 * @brief API for file-sharing via GNUnet
23 * @author Christian Grothoff
25 #ifndef GNUNET_FS_LIB_H
26 #define GNUNET_FS_LIB_H
28 #include "gnunet_util_lib.h"
33 #if 0 /* keep Emacsens' auto-indent happy */
39 * Version number of the implementation.
42 * 1.x.x: initial version with triple GNUNET_hash and merkle tree
43 * 2.x.x: root node with mime-type, filename and version number
44 * 2.1.x: combined GNUNET_EC_ContentHashKey/3HASH encoding with 25:1 super-nodes
45 * 2.2.x: with directories
46 * 3.0.x: with namespaces
47 * 3.1.x: with namespace meta-data
48 * 3.2.x: with collections
49 * 4.0.x: with expiration, variable meta-data, kblocks
50 * 4.1.x: with new error and configuration handling
51 * 5.0.x: with location URIs
52 * 6.0.0: with support for OR in KSKs
53 * 6.1.x: with simplified namespace support
54 * 9.0.0: CPS-style integrated API
55 * 9.1.1: asynchronous directory scanning
56 * 9.2.0: unified K-Block and S-block format (#2564)
58 #define GNUNET_FS_VERSION 0x00090200
61 /* ******************** URI API *********************** */
63 #define GNUNET_FS_URI_PREFIX "gnunet://fs/"
64 #define GNUNET_FS_URI_KSK_INFIX "ksk/"
65 #define GNUNET_FS_URI_SKS_INFIX "sks/"
66 #define GNUNET_FS_URI_CHK_INFIX "chk/"
67 #define GNUNET_FS_URI_LOC_INFIX "loc/"
71 * How often do we signal applications that a probe for a particular
72 * search result is running? (used to visualize probes).
74 #define GNUNET_FS_PROBE_UPDATE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
77 * A Universal Resource Identifier (URI), opaque.
83 * Iterator over keywords
86 * @param keyword the keyword
87 * @param is_mandatory is the keyword mandatory (in a search)
88 * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
90 typedef int (*GNUNET_FS_KeywordIterator) (void *cls, const char *keyword,
96 * Iterator over all known pseudonyms.
99 * @param pseudonym public key of pseudonym
100 * @param name name of the pseudonym (might be NULL)
101 * @param unique_name unique name of the pseudonym (might be NULL)
102 * @param md meta data known about the pseudonym
103 * @param rating the local rating of the pseudonym
104 * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
106 typedef int (*GNUNET_FS_PseudonymIterator) (void *cls,
107 const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
109 const char *unique_name,
110 const struct GNUNET_CONTAINER_MetaData *md,
115 * Change the rank of a pseudonym.
117 * @param cfg overall configuration
118 * @param pseudonym identity of the pseudonym
119 * @param delta by how much should the rating be changed?
120 * @return new rating of the pseudonym
123 GNUNET_FS_pseudonym_rank (const struct GNUNET_CONFIGURATION_Handle *cfg,
124 const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
129 * Add a pseudonym to the set of known pseudonyms.
130 * For all pseudonym advertisements that we discover
131 * FS should automatically call this function.
133 * @param cfg overall configuration
134 * @param pseudonym the pseudonym identifier
135 * @param meta metadata for the pseudonym
136 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
139 GNUNET_FS_pseudonym_add (const struct GNUNET_CONFIGURATION_Handle *cfg,
140 const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
141 const struct GNUNET_CONTAINER_MetaData *meta);
145 * List all known pseudonyms.
147 * @param cfg overall configuration
148 * @param iterator function to call for each pseudonym
149 * @param iterator_cls closure for iterator
150 * @return number of pseudonyms found
153 GNUNET_FS_pseudonym_list_all (const struct GNUNET_CONFIGURATION_Handle *cfg,
154 GNUNET_FS_PseudonymIterator iterator,
159 * Handle for a discovery callback registration.
161 struct GNUNET_FS_Pseudonym_DiscoveryHandle;
165 * Register callback to be invoked whenever we discover
168 * @param cfg our configuration
169 * @param iterator function to invoke on discovery
170 * @param iterator_cls closure for iterator
171 * @return registration handle
173 struct GNUNET_FS_Pseudonym_DiscoveryHandle *
174 GNUNET_FS_pseudonym_discovery_callback_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
175 GNUNET_FS_PseudonymIterator iterator,
180 * Unregister pseudonym discovery callback.
182 * @param dh registration to unregister
185 GNUNET_FS_pseudonym_discovery_callback_unregister (struct GNUNET_FS_Pseudonym_DiscoveryHandle *dh);
189 * Return unique variant of the pseudonym name. Use after
190 * GNUNET_FS_pseudonym_id_to_name() to make sure that name is unique.
192 * @param cfg configuration
193 * @param pseudonym cryptographic ID of the pseudonym
194 * @param name name to uniquify
195 * @param suffix if not NULL, filled with the suffix value
196 * @return NULL on failure (should never happen), name on success.
197 * Free the name with GNUNET_free().
200 GNUNET_FS_pseudonym_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg,
201 const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
203 unsigned int *suffix);
207 * Get pseudonym name, metadata and rank. This is a wrapper around
208 * internal read_info() call, and ensures that returned data is not
209 * invalid (not NULL). Writing back information returned by this
210 * function will give a name "no-name" to pseudonyms that have no
211 * name. This side-effect is unavoidable, but hardly harmful.
213 * @param cfg configuration
214 * @param pseudonym cryptographic ID of the pseudonym
215 * @param ret_meta a location to store metadata pointer. NULL, if metadata
216 * is not needed. Destroy with GNUNET_CONTAINER_meta_data_destroy().
217 * @param ret_rank a location to store rank. NULL, if rank not needed.
218 * @param ret_name a location to store human-readable name. Name is not unique.
219 * NULL, if name is not needed. Free with GNUNET_free().
220 * @param name_is_a_dup is set to GNUNET_YES, if ret_name was filled with
221 * a duplicate of a "no-name" placeholder
222 * @return GNUNET_OK on success. GNUENT_SYSERR if the data was
223 * unobtainable (in that case ret_* are filled with placeholders -
224 * empty metadata container, rank -1 and a "no-name" name).
227 GNUNET_FS_pseudonym_get_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
228 const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
229 struct GNUNET_CONTAINER_MetaData **ret_meta,
236 * Get the pseudonym ID belonging to the given pseudonym name.
238 * @param cfg configuration to use
239 * @param ns_uname unique (!) human-readable name for the pseudonym
240 * @param pseudonym set to pseudonym ID based on 'ns_uname'
241 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
244 GNUNET_FS_pseudonym_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg,
245 const char *ns_uname,
246 struct GNUNET_CRYPTO_EccPublicKey *pseudonym);
250 * Set the pseudonym metadata, rank and name.
252 * @param cfg overall configuration
253 * @param pseudonym id of the pseudonym
254 * @param name name to set. Must be the non-unique version of it.
255 * May be NULL, in which case it erases pseudonym's name!
256 * @param md metadata to set
257 * May be NULL, in which case it erases pseudonym's metadata!
258 * @param rank rank to assign
259 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
262 GNUNET_FS_pseudonym_set_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
263 const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
265 const struct GNUNET_CONTAINER_MetaData *md,
270 * Get a unique key from a URI. This is for putting URIs
271 * into HashMaps. The key may change between FS implementations.
273 * @param uri uri to convert to a unique key
274 * @param key wherer to store the unique key
277 GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
278 struct GNUNET_HashCode *key);
282 * Convert a URI to a UTF-8 String.
284 * @param uri uri to convert to a string
285 * @return the UTF-8 string
288 GNUNET_FS_uri_to_string (const struct GNUNET_FS_Uri *uri);
292 * Convert keyword URI to a human readable format
293 * (i.e. the search query that was used in the first place)
295 * @param uri ksk uri to convert to a string
296 * @return string with the keywords
299 GNUNET_FS_uri_ksk_to_string_fancy (const struct GNUNET_FS_Uri *uri);
303 * Add the given keyword to the set of keywords represented by the URI.
304 * Does nothing if the keyword is already present.
306 * @param uri ksk uri to modify
307 * @param keyword keyword to add
308 * @param is_mandatory is this keyword mandatory?
311 GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri,
317 * Remove the given keyword from the set of keywords represented by the URI.
318 * Does nothing if the keyword is not present.
320 * @param uri ksk uri to modify
321 * @param keyword keyword to add
324 GNUNET_FS_uri_ksk_remove_keyword (struct GNUNET_FS_Uri *uri,
325 const char *keyword);
329 * Convert a UTF-8 String to a URI.
331 * @param uri string to parse
332 * @param emsg where to store the parser error message (if any)
333 * @return NULL on error
335 struct GNUNET_FS_Uri *
336 GNUNET_FS_uri_parse (const char *uri, char **emsg);
342 * @param uri uri to free
345 GNUNET_FS_uri_destroy (struct GNUNET_FS_Uri *uri);
349 * How many keywords are ANDed in this keyword URI?
351 * @param uri ksk uri to get the number of keywords from
352 * @return 0 if this is not a keyword URI
355 GNUNET_FS_uri_ksk_get_keyword_count (const struct GNUNET_FS_Uri *uri);
359 * Iterate over all keywords in this keyword URI.
361 * @param uri ksk uri to get the keywords from
362 * @param iterator function to call on each keyword
363 * @param iterator_cls closure for iterator
364 * @return -1 if this is not a keyword URI, otherwise number of
365 * keywords iterated over until iterator aborted
368 GNUNET_FS_uri_ksk_get_keywords (const struct GNUNET_FS_Uri *uri,
369 GNUNET_FS_KeywordIterator iterator,
374 * Obtain the identity of the peer offering the data
376 * @param uri the location URI to inspect
377 * @param peer where to store the identify of the peer (presumably) offering the content
378 * @return GNUNET_SYSERR if this is not a location URI, otherwise GNUNET_OK
381 GNUNET_FS_uri_loc_get_peer_identity (const struct GNUNET_FS_Uri *uri,
382 struct GNUNET_PeerIdentity *peer);
386 * Obtain the URI of the content itself.
388 * @param uri location URI to get the content URI from
389 * @return NULL if argument is not a location URI
391 struct GNUNET_FS_Uri *
392 GNUNET_FS_uri_loc_get_uri (const struct GNUNET_FS_Uri *uri);
396 * Obtain the expiration of the LOC URI.
398 * @param uri location URI to get the expiration from
399 * @return expiration time of the URI
401 struct GNUNET_TIME_Absolute
402 GNUNET_FS_uri_loc_get_expiration (const struct GNUNET_FS_Uri *uri);
406 * Construct a location URI (this peer will be used for the location).
408 * @param baseUri content offered by the sender
409 * @param cfg configuration information (used to find our hostkey)
410 * @param expiration_time how long will the content be offered?
411 * @return the location URI, NULL on error
413 struct GNUNET_FS_Uri *
414 GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
415 const struct GNUNET_CONFIGURATION_Handle *cfg,
416 struct GNUNET_TIME_Absolute expiration_time);
420 * Merge the sets of keywords from two KSK URIs.
422 * @param u1 first uri
423 * @param u2 second uri
424 * @return merged URI, NULL on error
426 struct GNUNET_FS_Uri *
427 GNUNET_FS_uri_ksk_merge (const struct GNUNET_FS_Uri *u1,
428 const struct GNUNET_FS_Uri *u2);
434 * @param uri the URI to duplicate
435 * @return copy of the URI
437 struct GNUNET_FS_Uri *
438 GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri);
442 * Create an FS URI from a single user-supplied string of keywords.
443 * The string is broken up at spaces into individual keywords.
444 * Keywords that start with "+" are mandatory. Double-quotes can
445 * be used to prevent breaking up strings at spaces (and also
446 * to specify non-mandatory keywords starting with "+").
448 * Keywords must contain a balanced number of double quotes and
449 * double quotes can not be used in the actual keywords (for
450 * example, the string '""foo bar""' will be turned into two
451 * "OR"ed keywords 'foo' and 'bar', not into '"foo bar"'.
453 * @param keywords the keyword string
454 * @param emsg where to store an error message
455 * @return an FS URI for the given keywords, NULL
456 * if keywords is not legal (i.e. empty).
458 struct GNUNET_FS_Uri *
459 GNUNET_FS_uri_ksk_create (const char *keywords, char **emsg);
463 * Create an FS URI from a user-supplied command line of keywords.
464 * Arguments should start with "+" to indicate mandatory
467 * @param argc number of keywords
468 * @param argv keywords (double quotes are not required for
469 * keywords containing spaces; however, double
470 * quotes are required for keywords starting with
471 * "+"); there is no mechanism for having double
472 * quotes in the actual keywords (if the user
473 * did specifically specify double quotes, the
474 * caller should convert each double quote
475 * into two single quotes).
476 * @return an FS URI for the given keywords, NULL
477 * if keywords is not legal (i.e. empty).
479 struct GNUNET_FS_Uri *
480 GNUNET_FS_uri_ksk_create_from_args (unsigned int argc, const char **argv);
484 * Test if two URIs are equal.
486 * @param u1 one of the URIs
487 * @param u2 the other URI
488 * @return GNUNET_YES if the URIs are equal
491 GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
492 const struct GNUNET_FS_Uri *u2);
496 * Is this a namespace URI?
498 * @param uri the uri to check
499 * @return GNUNET_YES if this is an SKS uri
502 GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri);
506 * Create an SKS URI from a namespace ID and an identifier.
508 * @param ns pseudonym to use
509 * @param id identifier
510 * @return an FS URI for the given namespace and identifier
512 struct GNUNET_FS_Uri *
513 GNUNET_FS_uri_sks_create (const struct GNUNET_CRYPTO_EccPublicKey *ns,
518 * Get the public key of a namespace from the given
521 * @param uri the uri to get the namespace ID from
522 * @param pseudonym where to store the public key of the namespace
523 * @return GNUNET_OK on success
526 GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri,
527 struct GNUNET_CRYPTO_EccPublicKey *pseudonym);
531 * Get the content identifier of an SKS URI.
533 * @param uri the sks uri
534 * @return NULL on error (not a valid SKS URI)
537 GNUNET_FS_uri_sks_get_content_id (const struct GNUNET_FS_Uri *uri);
541 * Convert namespace URI to a human readable format
542 * (using the namespace description, if available).
544 * @param cfg configuration to use
545 * @param uri SKS uri to convert
546 * @return NULL on error (not an SKS URI)
549 GNUNET_FS_uri_sks_to_string_fancy (struct GNUNET_CONFIGURATION_Handle *cfg,
550 const struct GNUNET_FS_Uri *uri);
554 * Is this a keyword URI?
557 * @return GNUNET_YES if this is a KSK uri
560 GNUNET_FS_uri_test_ksk (const struct GNUNET_FS_Uri *uri);
564 * Is this a file (or directory) URI?
566 * @param uri the uri to check
567 * @return GNUNET_YES if this is a CHK uri
570 GNUNET_FS_uri_test_chk (const struct GNUNET_FS_Uri *uri);
574 * What is the size of the file that this URI
577 * @param uri the CHK (or LOC) URI to inspect
578 * @return size of the file as specified in the CHK URI
581 GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri *uri);
585 * Is this a location URI?
587 * @param uri the uri to check
588 * @return GNUNET_YES if this is a LOC uri
591 GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri);
595 * Construct a keyword-URI from meta-data (take all entries
596 * in the meta-data and construct one large keyword URI
597 * that lists all keywords that can be found in the meta-data).
599 * @param md metadata to use
600 * @return NULL on error, otherwise a KSK URI
602 struct GNUNET_FS_Uri *
603 GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData
607 /* ******************** command-line option parsing API *********************** */
610 * Command-line option parser function that allows the user
611 * to specify one or more '-k' options with keywords. Each
612 * specified keyword will be added to the URI. A pointer to
613 * the URI must be passed as the "scls" argument.
615 * @param ctx command line processor context
616 * @param scls must be of type "struct GNUNET_FS_Uri **"
617 * @param option name of the option (typically 'k')
618 * @param value command line argument given
619 * @return GNUNET_OK on success
622 GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext
623 *ctx, void *scls, const char *option,
628 * Command-line option parser function that allows the user to specify
629 * one or more '-m' options with metadata. Each specified entry of
630 * the form "type=value" will be added to the metadata. A pointer to
631 * the metadata must be passed as the "scls" argument.
633 * @param ctx command line processor context
634 * @param scls must be of type "struct GNUNET_CONTAINER_MetaData **"
635 * @param option name of the option (typically 'k')
636 * @param value command line argument given
637 * @return GNUNET_OK on success
640 GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext
641 *ctx, void *scls, const char *option,
646 /* ************************* sharing API ***************** */
650 * Possible status codes used in the callback for the
651 * various file-sharing operations. On each file (or search),
652 * the callback is guaranteed to be called once with "START"
653 * and once with STOPPED; calls with PROGRESS, ERROR or COMPLETED
654 * are optional and depend on the circumstances; parent operations
655 * will be STARTED before child-operations and STOPPED after
656 * their respective child-operations. START and STOP signals
657 * are typically generated either due to explicit client requests
658 * or because of suspend/resume operations.
660 enum GNUNET_FS_Status
663 * Notification that we have started to publish a file structure.
665 GNUNET_FS_STATUS_PUBLISH_START = 0,
668 * Notification that we have resumed sharing a file structure.
670 GNUNET_FS_STATUS_PUBLISH_RESUME = 1,
673 * Notification that we have suspended sharing a file structure.
675 GNUNET_FS_STATUS_PUBLISH_SUSPEND = 2,
678 * Notification that we are making progress sharing a file structure.
680 GNUNET_FS_STATUS_PUBLISH_PROGRESS = 3,
683 * Notification that an error was encountered sharing a file structure.
684 * The application will continue to receive resume/suspend events for
685 * this structure until "GNUNET_FS_publish_stop" is called.
687 GNUNET_FS_STATUS_PUBLISH_ERROR = 4,
690 * Notification that we completed sharing a file structure.
691 * The application will continue to receive resume/suspend events for
692 * this structure until "GNUNET_FS_publish_stop" is called.
694 GNUNET_FS_STATUS_PUBLISH_COMPLETED = 5,
697 * Notification that we have stopped
698 * the process of uploading a file structure; no
699 * futher events will be generated for this action.
701 GNUNET_FS_STATUS_PUBLISH_STOPPED = 6,
704 * Notification that we have started this download.
706 GNUNET_FS_STATUS_DOWNLOAD_START = 7,
709 * Notification that this download is being resumed.
711 GNUNET_FS_STATUS_DOWNLOAD_RESUME = 8,
714 * Notification that this download was suspended.
716 GNUNET_FS_STATUS_DOWNLOAD_SUSPEND = 9,
719 * Notification about progress with this download.
721 GNUNET_FS_STATUS_DOWNLOAD_PROGRESS = 10,
724 * Notification that this download encountered an error.
726 GNUNET_FS_STATUS_DOWNLOAD_ERROR = 11,
729 * Notification that this download completed. Note that for
730 * directories, completion does not imply completion of all files in
733 GNUNET_FS_STATUS_DOWNLOAD_COMPLETED = 12,
736 * Notification that this download was stopped
737 * (final event with respect to this action).
739 GNUNET_FS_STATUS_DOWNLOAD_STOPPED = 13,
742 * Notification that this download is now actively being
743 * pursued (as opposed to waiting in the queue).
745 GNUNET_FS_STATUS_DOWNLOAD_ACTIVE = 14,
748 * Notification that this download is no longer actively
749 * being pursued (back in the queue).
751 GNUNET_FS_STATUS_DOWNLOAD_INACTIVE = 15,
754 * Notification that this download is no longer part of a
755 * recursive download or search but now a 'stand-alone'
756 * download (and may thus need to be moved in the GUI
757 * into a different category).
759 GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT = 16,
762 * First event generated when a client requests
763 * a search to begin or when a namespace result
764 * automatically triggers the search for updates.
766 GNUNET_FS_STATUS_SEARCH_START = 17,
769 * Last event when a search is being resumed;
770 * note that "GNUNET_FS_SEARCH_START" will not
771 * be generated in this case.
773 GNUNET_FS_STATUS_SEARCH_RESUME = 18,
776 * Event generated for each search result
777 * when the respective search is resumed.
779 GNUNET_FS_STATUS_SEARCH_RESUME_RESULT = 19,
782 * Last event when a search is being suspended;
783 * note that "GNUNET_FS_SEARCH_STOPPED" will not
784 * be generated in this case.
786 GNUNET_FS_STATUS_SEARCH_SUSPEND = 20,
789 * This search has yielded a result.
791 GNUNET_FS_STATUS_SEARCH_RESULT = 21,
794 * We have discovered a new namespace.
796 GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE = 22,
799 * We have additional data about the quality
800 * or availability of a search result.
802 GNUNET_FS_STATUS_SEARCH_UPDATE = 23,
805 * Signals a problem with this search.
807 GNUNET_FS_STATUS_SEARCH_ERROR = 24,
810 * Signals that this search was paused.
812 GNUNET_FS_STATUS_SEARCH_PAUSED = 25,
815 * Signals that this search was continued (unpaused).
817 GNUNET_FS_STATUS_SEARCH_CONTINUED = 26,
820 * Event generated for each search result
821 * when the respective search is stopped.
823 GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED = 27,
826 * Event generated for each search result
827 * when the respective search is suspended.
829 GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND = 28,
832 * Last message from a search; this signals
833 * that there will be no further events associated
836 GNUNET_FS_STATUS_SEARCH_STOPPED = 29,
839 * Notification that we started to unindex a file.
841 GNUNET_FS_STATUS_UNINDEX_START = 30,
844 * Notification that we resumed unindexing of a file.
846 GNUNET_FS_STATUS_UNINDEX_RESUME = 31,
849 * Notification that we suspended unindexing a file.
851 GNUNET_FS_STATUS_UNINDEX_SUSPEND = 32,
854 * Notification that we made progress unindexing a file.
856 GNUNET_FS_STATUS_UNINDEX_PROGRESS = 33,
859 * Notification that we encountered an error unindexing
862 GNUNET_FS_STATUS_UNINDEX_ERROR = 34,
865 * Notification that the unindexing of this file
868 GNUNET_FS_STATUS_UNINDEX_COMPLETED = 35,
871 * Notification that the unindexing of this file
872 * was stopped (final event for this action).
874 GNUNET_FS_STATUS_UNINDEX_STOPPED = 36
879 * Handle for controlling an upload.
881 struct GNUNET_FS_PublishContext;
885 * Handle for controlling an unindexing operation.
887 struct GNUNET_FS_UnindexContext;
891 * Handle for controlling a search.
893 struct GNUNET_FS_SearchContext;
897 * Result from a search. Opaque handle to refer to the search
898 * (typically used when starting a download associated with the search
901 struct GNUNET_FS_SearchResult;
905 * Context for controlling a download.
907 struct GNUNET_FS_DownloadContext;
911 * Handle for detail information about a file that is being publishd.
912 * Specifies metadata, keywords, how to get the contents of the file
913 * (i.e. data-buffer in memory, filename on disk) and other options.
915 struct GNUNET_FS_FileInformation;
919 * Argument given to the progress callback with
920 * information about what is going on.
922 struct GNUNET_FS_ProgressInfo
926 * Values that depend on the event type.
932 * Values for all "GNUNET_FS_STATUS_PUBLISH_*" events.
938 * Context for controlling the upload.
940 struct GNUNET_FS_PublishContext *pc;
943 * Information about the file that is being publishd.
945 const struct GNUNET_FS_FileInformation *fi;
948 * Client context pointer (set the last time by the client for
949 * this operation; initially NULL on START/RESUME events).
954 * Client context pointer for the parent operation
955 * (if this is a file in a directory or a subdirectory).
960 * Name of the file being published; can be NULL.
962 const char *filename;
965 * How large is the file overall? For directories,
966 * this is only the size of the directory itself,
967 * not of the other files contained within the
973 * At what time do we expect to finish the upload?
974 * (will be a value in the past for completed
977 struct GNUNET_TIME_Relative eta;
980 * How long has this upload been actively running
981 * (excludes times where the upload was suspended).
983 struct GNUNET_TIME_Relative duration;
986 * How many bytes have we completed?
991 * What anonymity level is used for this upload?
996 * Additional values for specific events.
1002 * These values are only valid for
1003 * GNUNET_FS_STATUS_PUBLISH_PROGRESS events.
1009 * Data block we just published.
1014 * At what offset in the file is "data"?
1019 * Length of the data block.
1024 * Depth of the given block in the tree;
1025 * 0 would be the lowest level (DBLOCKs).
1032 * These values are only valid for
1033 * GNUNET_FS_STATUS_PUBLISH_RESUME events.
1039 * Error message, NULL if no error was encountered so far.
1041 const char *message;
1044 * URI of the file (if the download had been completed)
1046 const struct GNUNET_FS_Uri *chk_uri;
1051 * These values are only valid for
1052 * GNUNET_FS_STATUS_PUBLISH_COMPLETED events.
1060 const struct GNUNET_FS_Uri *chk_uri;
1065 * These values are only valid for
1066 * GNUNET_FS_STATUS_PUBLISH_ERROR events.
1072 * Error message, never NULL.
1074 const char *message;
1084 * Values for all "GNUNET_FS_STATUS_DOWNLOAD_*" events.
1090 * Context for controlling the download.
1092 struct GNUNET_FS_DownloadContext *dc;
1095 * Client context pointer (set the last time
1096 * by the client for this operation; initially
1097 * NULL on START/RESUME events).
1102 * Client context pointer for the parent operation
1103 * (if this is a file in a directory or a subdirectory).
1108 * Client context pointer for the associated search operation
1109 * (specifically, context pointer for the specific search
1110 * result, not the overall search); only set if this
1111 * download was started from a search result.
1116 * URI used for this download.
1118 const struct GNUNET_FS_Uri *uri;
1121 * Name of the file that we are downloading.
1123 const char *filename;
1126 * How large is the download overall? This
1127 * is NOT necessarily the size from the
1128 * URI since we may be doing a partial download.
1133 * At what time do we expect to finish the download?
1134 * (will be a value in the past for completed
1137 struct GNUNET_TIME_Relative eta;
1140 * How long has this download been active?
1142 struct GNUNET_TIME_Relative duration;
1145 * How many bytes have we completed?
1150 * What anonymity level is used for this download?
1155 * Is the download currently active.
1160 * Additional values for specific events.
1166 * These values are only valid for
1167 * GNUNET_FS_STATUS_DOWNLOAD_PROGRESS events.
1173 * Data block we just obtained, can be NULL (even if
1174 * data_len > 0) if we found the entire block 'intact' on
1175 * disk. In this case, it is also possible for 'data_len'
1176 * to be larger than an individual (32k) block.
1181 * At what offset in the file is "data"?
1186 * Length of the data block.
1191 * How much time passed between us asking for this block and
1192 * actually getting it? GNUNET_TIME_UNIT_FOREVER_REL if unknown.
1194 struct GNUNET_TIME_Relative block_download_duration;
1197 * Depth of the given block in the tree;
1198 * 0 would be the lowest level (DBLOCKS).
1203 * How much respect did we offer for downloading this block? (estimate,
1204 * because we might have the same request pending for multiple clients,
1205 * and of course because a transmission may have failed at a lower
1208 uint32_t respect_offered;
1211 * How often did we transmit the request? (estimate,
1212 * because we might have the same request pending for multiple clients,
1213 * and of course because a transmission may have failed at a lower
1216 uint32_t num_transmissions;
1221 * These values are only valid for
1222 * GNUNET_FS_STATUS_DOWNLOAD_START events.
1228 * Known metadata for the download.
1230 const struct GNUNET_CONTAINER_MetaData *meta;
1235 * These values are only valid for
1236 * GNUNET_FS_STATUS_DOWNLOAD_RESUME events.
1242 * Known metadata for the download.
1244 const struct GNUNET_CONTAINER_MetaData *meta;
1247 * Error message, NULL if we have not encountered any error yet.
1249 const char *message;
1254 * These values are only valid for
1255 * GNUNET_FS_STATUS_DOWNLOAD_ERROR events.
1263 const char *message;
1272 * Values for all "GNUNET_FS_STATUS_SEARCH_*" events.
1278 * Context for controlling the search, NULL for
1279 * searches that were not explicitly triggered
1280 * by the client (i.e., searches for updates in
1283 struct GNUNET_FS_SearchContext *sc;
1286 * Client context pointer (set the last time by the client for
1287 * this operation; initially NULL on START/RESUME events). Note
1288 * that this value can only be set on START/RESUME; returning
1289 * non-NULL on RESULT/RESUME_RESULT will actually update the
1290 * private context for "UPDATE" events.
1295 * Client parent-context pointer; NULL for top-level searches,
1296 * refers to the client context of the associated search result
1297 * for automatically triggered searches for updates in
1298 * namespaces. In this case, 'presult' refers to that search
1304 * What query is used for this search
1305 * (list of keywords or SKS identifier).
1307 const struct GNUNET_FS_Uri *query;
1310 * How long has this search been actively running
1311 * (excludes times where the search was paused or
1314 struct GNUNET_TIME_Relative duration;
1317 * What anonymity level is used for this search?
1322 * Additional values for specific events.
1328 * These values are only valid for
1329 * GNUNET_FS_STATUS_SEARCH_RESULT events.
1335 * Metadata for the search result.
1337 const struct GNUNET_CONTAINER_MetaData *meta;
1340 * URI for the search result.
1342 const struct GNUNET_FS_Uri *uri;
1345 * Handle to the result (for starting downloads).
1347 struct GNUNET_FS_SearchResult *result;
1350 * Applicability rank (the larger, the better the result
1351 * fits the search criteria).
1353 uint32_t applicability_rank;
1358 * These values are only valid for
1359 * GNUNET_FS_STATUS_SEARCH_RESUME_RESULT events.
1365 * Metadata for the search result.
1367 const struct GNUNET_CONTAINER_MetaData *meta;
1370 * URI for the search result.
1372 const struct GNUNET_FS_Uri *uri;
1375 * Handle to the result (for starting downloads).
1377 struct GNUNET_FS_SearchResult *result;
1380 * Current availability rank (negative:
1381 * unavailable, positive: available)
1383 int32_t availability_rank;
1386 * On how many total queries is the given
1387 * availability_rank based?
1389 uint32_t availability_certainty;
1392 * Updated applicability rank (the larger,
1393 * the better the result fits the search
1396 uint32_t applicability_rank;
1401 * These values are only valid for
1402 * GNUNET_FS_STATUS_SEARCH_UPDATE events.
1408 * Private context set for for this result
1409 * during the "RESULT" event.
1414 * Metadata for the search result.
1416 const struct GNUNET_CONTAINER_MetaData *meta;
1419 * URI for the search result.
1421 const struct GNUNET_FS_Uri *uri;
1424 * Current availability rank (negative:
1425 * unavailable, positive: available)
1427 int32_t availability_rank;
1430 * On how many total queries is the given
1431 * availability_rank based?
1433 uint32_t availability_certainty;
1436 * Updated applicability rank (the larger,
1437 * the better the result fits the search
1440 uint32_t applicability_rank;
1443 * How long has the current probe been active?
1445 struct GNUNET_TIME_Relative current_probe_time;
1450 * These values are only valid for
1451 * GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND events.
1452 * These events are automatically triggered for
1453 * each search result before the
1454 * GNUNET_FS_STATUS_SEARCH_SUSPEND event. This
1455 * happens primarily to give the client a chance
1456 * to clean up the "cctx" (if needed).
1462 * Private context set for for this result
1463 * during the "RESULT" event.
1468 * Metadata for the search result.
1470 const struct GNUNET_CONTAINER_MetaData *meta;
1473 * URI for the search result.
1475 const struct GNUNET_FS_Uri *uri;
1480 * These values are only valid for
1481 * GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED events.
1482 * These events are automatically triggered for
1483 * each search result before the
1484 * GNUNET_FS_STATUS_SEARCH_STOPPED event. This
1485 * happens primarily to give the client a chance
1486 * to clean up the "cctx" (if needed).
1492 * Private context set for for this result
1493 * during the "RESULT" event.
1498 * Metadata for the search result.
1500 const struct GNUNET_CONTAINER_MetaData *meta;
1503 * URI for the search result.
1505 const struct GNUNET_FS_Uri *uri;
1510 * These values are only valid for
1511 * GNUNET_FS_STATUS_SEARCH_RESUME events.
1517 * Error message, NULL if we have not encountered any error yet.
1519 const char *message;
1522 * Is this search currently paused?
1529 * These values are only valid for
1530 * GNUNET_FS_STATUS_SEARCH_ERROR events.
1538 const char *message;
1543 * Values for all "GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE" events.
1549 * Short, human-readable name of the namespace.
1554 * Root identifier for the namespace, can be NULL.
1559 * Metadata for the namespace.
1561 const struct GNUNET_CONTAINER_MetaData *meta;
1564 * Public key of the namespace.
1566 struct GNUNET_CRYPTO_EccPublicKey pseudonym;
1575 * Values for all "GNUNET_FS_STATUS_UNINDEX_*" events.
1581 * Context for controlling the unindexing.
1583 struct GNUNET_FS_UnindexContext *uc;
1586 * Client context pointer (set the last time
1587 * by the client for this operation; initially
1588 * NULL on START/RESUME events).
1593 * Name of the file that is being unindexed.
1595 const char *filename;
1598 * How large is the file overall?
1603 * At what time do we expect to finish unindexing?
1604 * (will be a value in the past for completed
1605 * unindexing opeations).
1607 struct GNUNET_TIME_Relative eta;
1610 * How long has this upload been actively running
1611 * (excludes times where the upload was suspended).
1613 struct GNUNET_TIME_Relative duration;
1616 * How many bytes have we completed?
1621 * Additional values for specific events.
1627 * These values are only valid for
1628 * GNUNET_FS_STATUS_UNINDEX_PROGRESS events.
1634 * Data block we just unindexed.
1639 * At what offset in the file is "data"?
1644 * Length of the data block.
1649 * Depth of the given block in the tree;
1650 * 0 would be the lowest level (DBLOCKS).
1657 * These values are only valid for
1658 * GNUNET_FS_STATUS_UNINDEX_RESUME events.
1664 * Error message, NULL if we have not encountered any error yet.
1666 const char *message;
1671 * These values are only valid for
1672 * GNUNET_FS_STATUS_UNINDEX_ERROR events.
1680 const char *message;
1691 * Specific status code (determines the event type).
1693 enum GNUNET_FS_Status status;
1696 * File-sharing handle that generated the event.
1698 struct GNUNET_FS_Handle *fsh;
1703 * Notification of FS to a client about the progress of an
1704 * operation. Callbacks of this type will be used for uploads,
1705 * downloads and searches. Some of the arguments depend a bit
1706 * in their meaning on the context in which the callback is used.
1708 * @param cls closure
1709 * @param info details about the event, specifying the event type
1710 * and various bits about the event
1711 * @return client-context (for the next progress call
1712 * for this operation; should be set to NULL for
1713 * SUSPEND and STOPPED events). The value returned
1714 * will be passed to future callbacks in the respective
1715 * field in the GNUNET_FS_ProgressInfo struct.
1717 typedef void *(*GNUNET_FS_ProgressCallback) (void *cls,
1718 const struct GNUNET_FS_ProgressInfo *info);
1722 * General (global) option flags for file-sharing.
1724 enum GNUNET_FS_Flags
1727 * No special flags set.
1729 GNUNET_FS_FLAGS_NONE = 0,
1732 * Is persistence of operations desired?
1733 * (will create SUSPEND/RESUME events).
1735 GNUNET_FS_FLAGS_PERSISTENCE = 1,
1738 * Should we automatically trigger probes for search results
1739 * to determine availability?
1740 * (will create GNUNET_FS_STATUS_SEARCH_UPDATE events).
1742 GNUNET_FS_FLAGS_DO_PROBES = 2
1747 * Options specified in the VARARGs portion of GNUNET_FS_start.
1749 enum GNUNET_FS_OPTIONS
1753 * Last option in the VARARG list.
1755 GNUNET_FS_OPTIONS_END = 0,
1758 * Select the desired amount of parallelism (this option should be
1759 * followed by an "unsigned int" giving the desired maximum number
1760 * of parallel downloads).
1762 GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM = 1,
1765 * Maximum number of requests that should be pending at a given
1766 * point in time (invidivual downloads may go above this, but
1767 * if we are above this threshold, we should not activate any
1768 * additional downloads.
1770 GNUNET_FS_OPTIONS_REQUEST_PARALLELISM = 2
1775 * Settings for publishing a block (which may of course also
1776 * apply to an entire directory or file).
1778 struct GNUNET_FS_BlockOptions
1782 * At what time should the block expire? Data blocks (DBLOCKS and
1783 * IBLOCKS) may still be used even if they are expired (however,
1784 * they'd be removed quickly from the datastore if we are short on
1785 * space), all other types of blocks will no longer be returned
1786 * after they expire.
1788 struct GNUNET_TIME_Absolute expiration_time;
1791 * At which anonymity level should the block be shared?
1792 * (0: no anonymity, 1: normal GAP, >1: with cover traffic).
1794 uint32_t anonymity_level;
1797 * How important is it for us to store the block? If we run
1798 * out of space, the highest-priority, non-expired blocks will
1801 uint32_t content_priority;
1804 * How often should we try to migrate the block to other peers?
1805 * Only used if "CONTENT_PUSHING" is set to YES, in which case we
1806 * first push each block to other peers according to their
1807 * replication levels. Once each block has been pushed that many
1808 * times to other peers, blocks are chosen for migration at random.
1809 * Naturally, there is no guarantee that the other peers will keep
1810 * these blocks for any period of time (since they won't have any
1811 * priority or might be too busy to even store the block in the
1814 uint32_t replication_level;
1820 * Return the current year (i.e. '2011').
1823 GNUNET_FS_get_current_year (void);
1827 * Convert a year to an expiration time of January 1st of that year.
1829 * @param year a year (after 1970, please ;-)).
1830 * @return absolute time for January 1st of that year.
1832 struct GNUNET_TIME_Absolute
1833 GNUNET_FS_year_to_time (unsigned int year);
1837 * Convert an expiration time to the respective year (rounds)
1839 * @param at absolute time
1840 * @return year a year (after 1970), 0 on error
1843 GNUNET_FS_time_to_year (struct GNUNET_TIME_Absolute at);
1847 * Handle to the file-sharing service.
1849 struct GNUNET_FS_Handle;
1853 * Setup a connection to the file-sharing service.
1855 * @param cfg configuration to use
1856 * @param client_name unique identifier for this client
1857 * @param upcb function to call to notify about FS actions
1858 * @param upcb_cls closure for upcb
1859 * @param flags specific attributes for fs-operations
1860 * @param ... list of optional options, terminated with GNUNET_FS_OPTIONS_END
1861 * @return NULL on error
1863 struct GNUNET_FS_Handle *
1864 GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1865 const char *client_name, GNUNET_FS_ProgressCallback upcb,
1866 void *upcb_cls, enum GNUNET_FS_Flags flags, ...);
1870 * Close our connection with the file-sharing service.
1871 * The callback given to GNUNET_FS_start will no longer be
1872 * called after this function returns.
1874 * @param h handle that was returned from GNUNET_FS_start
1877 GNUNET_FS_stop (struct GNUNET_FS_Handle *h);
1881 * Function called on entries in a GNUNET_FS_FileInformation publish-structure.
1883 * @param cls closure
1884 * @param fi the entry in the publish-structure
1885 * @param length length of the file or directory
1886 * @param meta metadata for the file or directory (can be modified)
1887 * @param uri pointer to the keywords that will be used for this entry (can be modified)
1888 * @param bo block options (can be modified)
1889 * @param do_index should we index (can be modified)
1890 * @param client_info pointer to client context set upon creation (can be modified)
1891 * @return GNUNET_OK to continue, GNUNET_NO to remove
1892 * this entry from the directory, GNUNET_SYSERR
1893 * to abort the iteration
1895 typedef int (*GNUNET_FS_FileInformationProcessor) (void *cls,
1897 GNUNET_FS_FileInformation *
1898 fi, uint64_t length,
1900 GNUNET_CONTAINER_MetaData *
1902 struct GNUNET_FS_Uri ** uri,
1903 struct GNUNET_FS_BlockOptions
1904 * bo, int *do_index,
1905 void **client_info);
1909 * Obtain the name under which this file information
1910 * structure is stored on disk. Only works for top-level
1911 * file information structures.
1913 * @param s structure to get the filename for
1914 * @return NULL on error, otherwise filename that
1915 * can be passed to "GNUNET_FS_file_information_recover"
1916 * to read this fi-struct from disk.
1919 GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s);
1923 * Obtain the filename from the file information structure.
1925 * @param s structure to get the filename for
1926 * @return "filename" field of the structure (can be NULL)
1929 GNUNET_FS_file_information_get_filename (struct GNUNET_FS_FileInformation *s);
1933 * Set the filename in the file information structure.
1934 * If filename was already set, frees it before setting the new one.
1935 * Makes a copy of the argument.
1937 * @param s structure to get the filename for
1938 * @param filename filename to set
1941 GNUNET_FS_file_information_set_filename (struct GNUNET_FS_FileInformation *s,
1942 const char *filename);
1946 * Create an entry for a file in a publish-structure.
1948 * @param h handle to the file sharing subsystem
1949 * @param client_info initial client-info value for this entry
1950 * @param filename name of the file or directory to publish
1951 * @param keywords under which keywords should this file be available
1952 * directly; can be NULL
1953 * @param meta metadata for the file
1954 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1955 * GNUNET_SYSERR for simulation
1956 * @param bo block options
1957 * @return publish structure entry for the file
1959 struct GNUNET_FS_FileInformation *
1960 GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
1962 const char *filename,
1963 const struct GNUNET_FS_Uri
1966 GNUNET_CONTAINER_MetaData *meta,
1968 const struct GNUNET_FS_BlockOptions
1973 * Create an entry for a file in a publish-structure.
1975 * @param h handle to the file sharing subsystem
1976 * @param client_info initial client-info value for this entry
1977 * @param length length of the file
1978 * @param data data for the file (should not be used afterwards by
1979 * the caller; callee will "free")
1980 * @param keywords under which keywords should this file be available
1981 * directly; can be NULL
1982 * @param meta metadata for the file
1983 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1984 * GNUNET_SYSERR for simulation
1985 * @param bo block options
1986 * @return publish structure entry for the file
1988 struct GNUNET_FS_FileInformation *
1989 GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
1990 void *client_info, uint64_t length,
1992 const struct GNUNET_FS_Uri
1995 GNUNET_CONTAINER_MetaData *meta,
1997 const struct GNUNET_FS_BlockOptions
2002 * Function that provides data.
2004 * @param cls closure
2005 * @param offset offset to read from; it is possible
2006 * that the caller might need to go backwards
2007 * a bit at times; set to UINT64_MAX to tell
2008 * the reader that we won't be reading for a while
2009 * (used to close the file descriptor but NOT fully
2010 * clean up the reader's state); in this case,
2011 * a value of '0' for max should be ignored
2012 * @param max maximum number of bytes that should be
2013 * copied to buf; readers are not allowed
2014 * to provide less data unless there is an error;
2015 * a value of "0" will be used at the end to allow
2016 * the reader to clean up its internal state
2017 * @param buf where the reader should write the data
2018 * @param emsg location for the reader to store an error message
2019 * @return number of bytes written, usually "max", 0 on error
2021 typedef size_t (*GNUNET_FS_DataReader) (void *cls, uint64_t offset, size_t max,
2022 void *buf, char **emsg);
2026 * Create an entry for a file in a publish-structure.
2028 * @param h handle to the file sharing subsystem
2029 * @param client_info initial client-info value for this entry
2030 * @param length length of the file
2031 * @param reader function that can be used to obtain the data for the file
2032 * @param reader_cls closure for "reader"
2033 * @param keywords under which keywords should this file be available
2034 * directly; can be NULL
2035 * @param meta metadata for the file
2036 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
2037 * GNUNET_SYSERR for simulation
2038 * @param bo block options
2039 * @return publish structure entry for the file
2041 struct GNUNET_FS_FileInformation *
2042 GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
2045 GNUNET_FS_DataReader reader,
2047 const struct GNUNET_FS_Uri
2050 GNUNET_CONTAINER_MetaData *meta,
2053 GNUNET_FS_BlockOptions *bo);
2057 * Create an entry for an empty directory in a publish-structure.
2058 * This function should be used by applications for which the
2059 * use of "GNUNET_FS_file_information_create_from_directory"
2060 * is not appropriate.
2062 * @param h handle to the file sharing subsystem
2063 * @param client_info initial client-info value for this entry
2064 * @param keywords under which keywords should this directory be available
2065 * directly; can be NULL
2066 * @param meta metadata for the directory
2067 * @param bo block options
2068 * @param filename name of the directory; can be NULL
2069 * @return publish structure entry for the directory , NULL on error
2071 struct GNUNET_FS_FileInformation *
2072 GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h,
2074 const struct GNUNET_FS_Uri
2077 GNUNET_CONTAINER_MetaData
2080 GNUNET_FS_BlockOptions *bo,
2081 const char *filename);
2085 * Test if a given entry represents a directory.
2087 * @param ent check if this FI represents a directory
2088 * @return GNUNET_YES if so, GNUNET_NO if not
2091 GNUNET_FS_file_information_is_directory (const struct GNUNET_FS_FileInformation
2096 * Add an entry to a directory in a publish-structure. Clients
2097 * should never modify publish structures that were passed to
2098 * "GNUNET_FS_publish_start" already.
2100 * @param dir the directory
2101 * @param ent the entry to add; the entry must not have been
2102 * added to any other directory at this point and
2103 * must not include "dir" in its structure
2104 * @return GNUNET_OK on success, GNUNET_SYSERR on error
2107 GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
2108 struct GNUNET_FS_FileInformation *ent);
2112 * Inspect a file or directory in a publish-structure. Clients
2113 * should never modify publish structures that were passed to
2114 * "GNUNET_FS_publish_start" already. When called on a directory,
2115 * this function will FIRST call "proc" with information about
2116 * the directory itself and then for each of the files in the
2117 * directory (but not for files in subdirectories). When called
2118 * on a file, "proc" will be called exactly once (with information
2119 * about the specific file).
2121 * @param dir the directory
2122 * @param proc function to call on each entry
2123 * @param proc_cls closure for proc
2126 GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
2127 GNUNET_FS_FileInformationProcessor proc,
2132 * Destroy publish-structure. Clients should never destroy publish
2133 * structures that were passed to "GNUNET_FS_publish_start" already.
2135 * @param fi structure to destroy
2136 * @param cleaner function to call on each entry in the structure
2137 * (useful to clean up client_info); can be NULL; return
2138 * values are ignored
2139 * @param cleaner_cls closure for cleaner
2142 GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
2143 GNUNET_FS_FileInformationProcessor cleaner,
2148 * Options for publishing. Compatible options
2149 * can be OR'ed together.
2151 enum GNUNET_FS_PublishOptions
2154 * No options (use defaults for everything).
2156 GNUNET_FS_PUBLISH_OPTION_NONE = 0,
2159 * Simulate publishing. With this option, no data will be stored
2160 * in the datastore. Useful for computing URIs from files.
2162 GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY = 1
2167 * Publish a file or directory.
2169 * @param h handle to the file sharing subsystem
2170 * @param fi information about the file or directory structure to publish
2171 * @param ns namespace to publish the file in, NULL for no namespace
2172 * @param nid identifier to use for the publishd content in the namespace
2173 * (can be NULL, must be NULL if namespace is NULL)
2174 * @param nuid update-identifier that will be used for future updates
2175 * (can be NULL, must be NULL if namespace or nid is NULL)
2176 * @param options options for the publication
2177 * @return context that can be used to control the publish operation
2179 struct GNUNET_FS_PublishContext *
2180 GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
2181 struct GNUNET_FS_FileInformation *fi,
2182 const struct GNUNET_CRYPTO_EccPrivateKey *ns,
2185 enum GNUNET_FS_PublishOptions options);
2189 * Stop a publication. Will abort incomplete publications (but
2190 * not remove blocks that have already been published) or
2191 * simply clean up the state for completed publications.
2192 * Must NOT be called from within the event callback!
2194 * @param pc context for the publication to stop
2197 GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc);
2201 * Signature of a function called as the continuation of a KBlock or
2202 * SBlock publication.
2204 * @param cls closure
2205 * @param uri URI under which the block is now available, NULL on error
2206 * @param emsg error message, NULL on success
2208 typedef void (*GNUNET_FS_PublishContinuation) (void *cls,
2209 const struct GNUNET_FS_Uri *uri,
2214 * Handle to cancel publish KSK operation.
2216 struct GNUNET_FS_PublishKskContext;
2220 * Publish a KBlock on GNUnet.
2222 * @param h handle to the file sharing subsystem
2223 * @param ksk_uri keywords to use
2224 * @param meta metadata to use
2225 * @param uri URI to refer to in the KBlock
2226 * @param bo block options
2227 * @param options publication options
2228 * @param cont continuation
2229 * @param cont_cls closure for cont
2230 * @return NULL on error ('cont' will still be called)
2232 struct GNUNET_FS_PublishKskContext *
2233 GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
2234 const struct GNUNET_FS_Uri *ksk_uri,
2235 const struct GNUNET_CONTAINER_MetaData *meta,
2236 const struct GNUNET_FS_Uri *uri,
2237 const struct GNUNET_FS_BlockOptions *bo,
2238 enum GNUNET_FS_PublishOptions options,
2239 GNUNET_FS_PublishContinuation cont, void *cont_cls);
2243 * Abort the KSK publishing operation.
2245 * @param pkc context of the operation to abort.
2248 GNUNET_FS_publish_ksk_cancel (struct GNUNET_FS_PublishKskContext *pkc);
2252 * Handle to cancel publish SKS operation.
2254 struct GNUNET_FS_PublishSksContext;
2258 * Publish an SBlock on GNUnet.
2260 * @param h handle to the file sharing subsystem
2261 * @param ns namespace to publish in
2262 * @param identifier identifier to use
2263 * @param update update identifier to use
2264 * @param meta metadata to use
2265 * @param uri URI to refer to in the SBlock
2266 * @param bo block options
2267 * @param options publication options
2268 * @param cont continuation
2269 * @param cont_cls closure for cont
2270 * @return NULL on error ('cont' will still be called)
2272 struct GNUNET_FS_PublishSksContext *
2273 GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
2274 const struct GNUNET_CRYPTO_EccPrivateKey *ns,
2275 const char *identifier, const char *update,
2276 const struct GNUNET_CONTAINER_MetaData *meta,
2277 const struct GNUNET_FS_Uri *uri,
2278 const struct GNUNET_FS_BlockOptions *bo,
2279 enum GNUNET_FS_PublishOptions options,
2280 GNUNET_FS_PublishContinuation cont, void *cont_cls);
2284 * Abort the SKS publishing operation.
2286 * @param psc context of the operation to abort.
2289 GNUNET_FS_publish_sks_cancel (struct GNUNET_FS_PublishSksContext *psc);
2293 * Type of a function called by "GNUNET_FS_get_indexed_files".
2295 * @param cls closure
2296 * @param filename the name of the file, NULL for end of list
2297 * @param file_id hash of the contents of the indexed file
2298 * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
2300 typedef int (*GNUNET_FS_IndexedFileProcessor) (void *cls, const char *filename,
2301 const struct GNUNET_HashCode * file_id);
2305 * Handle to cancel 'GNUNET_FS_get_indexed_files'.
2307 struct GNUNET_FS_GetIndexedContext;
2311 * Iterate over all indexed files.
2313 * @param h handle to the file sharing subsystem
2314 * @param iterator function to call on each indexed file
2315 * @param iterator_cls closure for iterator
2316 * @return NULL on error ('iter' is not called)
2318 struct GNUNET_FS_GetIndexedContext *
2319 GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
2320 GNUNET_FS_IndexedFileProcessor iterator,
2321 void *iterator_cls);
2325 * Cancel iteration over all indexed files.
2327 * @param gic operation to cancel
2330 GNUNET_FS_get_indexed_files_cancel (struct GNUNET_FS_GetIndexedContext *gic);
2336 * @param h handle to the file sharing subsystem
2337 * @param filename file to unindex
2338 * @param cctx initial value for the client context
2339 * @return NULL on error, otherwise handle
2341 struct GNUNET_FS_UnindexContext *
2342 GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, const char *filename,
2347 * Clean up after completion of an unindex operation.
2352 GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc);
2356 * Function called on updateable identifiers.
2358 * @param cls closure
2359 * @param last_id last identifier
2360 * @param last_uri uri used for the content published under the last_id
2361 * @param last_meta metadata associated with last_uri
2362 * @param next_id identifier that should be used for updates
2364 typedef void (*GNUNET_FS_IdentifierProcessor) (void *cls, const char *last_id,
2365 const struct GNUNET_FS_Uri *
2368 GNUNET_CONTAINER_MetaData *
2369 last_meta, const char *next_id);
2373 * List all of the identifiers in the namespace for which we could
2374 * produce an update. Namespace updates form a graph where each node
2375 * has a name. Each node can have any number of URI/meta-data entries
2376 * which can each be linked to other nodes. Cycles are possible.
2378 * Calling this function with "next_id" NULL will cause the library to
2379 * call "ip" with a root for each strongly connected component of the
2380 * graph (a root being a node from which all other nodes in the Scc
2383 * Calling this function with "next_id" being the name of a node will
2384 * cause the library to call "ip" with all children of the node. Note
2385 * that cycles within an SCC are possible (including self-loops).
2387 * @param h fs handle to use
2388 * @param ns namespace to inspect for updateable content
2389 * @param next_id ID to look for; use NULL to look for SCC roots
2390 * @param ip function to call on each updateable identifier
2391 * @param ip_cls closure for ip
2394 GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h,
2395 const struct GNUNET_CRYPTO_EccPrivateKey *ns,
2396 const char *next_id,
2397 GNUNET_FS_IdentifierProcessor ip,
2402 * Options for searching. Compatible options
2403 * can be OR'ed together.
2405 enum GNUNET_FS_SearchOptions
2408 * No options (use defaults for everything).
2410 GNUNET_FS_SEARCH_OPTION_NONE = 0,
2413 * Only search the local host, do not search remote systems (no P2P)
2415 GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY = 1
2420 * Start search for content.
2422 * @param h handle to the file sharing subsystem
2423 * @param uri specifies the search parameters; can be
2424 * a KSK URI or an SKS URI.
2425 * @param anonymity desired level of anonymity
2426 * @param options options for the search
2427 * @param cctx initial value for the client context
2428 * @return context that can be used to control the search
2430 struct GNUNET_FS_SearchContext *
2431 GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
2432 const struct GNUNET_FS_Uri *uri, uint32_t anonymity,
2433 enum GNUNET_FS_SearchOptions options, void *cctx);
2439 * @param sc context for the search that should be paused
2442 GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc);
2446 * Continue paused search.
2448 * @param sc context for the search that should be resumed
2451 GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc);
2455 * Stop search for content.
2457 * @param sc context for the search that should be stopped
2460 GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc);
2464 * Start download probes for the given search result.
2466 * @param h file-sharing handle to use for the operation
2467 * @param uri URI to probe
2468 * @param meta meta data associated with the URI
2469 * @param client_info client info pointer to use for associated events
2470 * @param anonymity anonymity level to use for the probes
2471 * @return the search result handle to access the probe activity
2473 struct GNUNET_FS_SearchResult *
2474 GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
2475 const struct GNUNET_FS_Uri *uri,
2476 const struct GNUNET_CONTAINER_MetaData *meta,
2478 uint32_t anonymity);
2482 * Stop probe activity. Must ONLY be used on values
2483 * returned from 'GNUNET_FS_probe'.
2485 * @param sr search result to stop probing for (freed)
2486 * @return the value of the 'client_info' pointer
2489 GNUNET_FS_probe_stop (struct GNUNET_FS_SearchResult *sr);
2493 * Options for downloading. Compatible options
2494 * can be OR'ed together.
2496 enum GNUNET_FS_DownloadOptions
2499 * No options (use defaults for everything).
2501 GNUNET_FS_DOWNLOAD_OPTION_NONE = 0,
2504 * Only download from the local host, do not access remote systems (no P2P)
2506 GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY = 1,
2509 * Do a recursive download (that is, automatically trigger the
2510 * download of files in directories).
2512 GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE = 2,
2515 * Do not append temporary data to
2516 * the target file (for the IBlocks).
2518 GNUNET_FS_DOWNLOAD_NO_TEMPORARIES = 4,
2521 * Internal option used to flag this download as a 'probe' for a
2522 * search result. Impacts the priority with which the download is
2523 * run and causes signalling callbacks to be done differently.
2524 * Also, probe downloads are not serialized on suspension. Normal
2525 * clients should not use this!
2527 GNUNET_FS_DOWNLOAD_IS_PROBE = (1 << 31)
2533 * Download parts of a file. Note that this will store
2534 * the blocks at the respective offset in the given file. Also, the
2535 * download is still using the blocking of the underlying FS
2536 * encoding. As a result, the download may *write* outside of the
2537 * given boundaries (if offset and length do not match the 32k FS
2538 * block boundaries). <p>
2540 * The given range can be used to focus a download towards a
2541 * particular portion of the file (optimization), not to strictly
2542 * limit the download to exactly those bytes.
2544 * @param h handle to the file sharing subsystem
2545 * @param uri the URI of the file (determines what to download); CHK or LOC URI
2546 * @param meta known metadata for the file (can be NULL)
2547 * @param filename where to store the file, maybe NULL (then no file is
2548 * created on disk and data must be grabbed from the callbacks)
2549 * @param tempname where to store temporary file data, not used if filename is non-NULL;
2550 * can be NULL (in which case we will pick a name if needed); the temporary file
2551 * may already exist, in which case we will try to use the data that is there and
2552 * if it is not what is desired, will overwrite it
2553 * @param offset at what offset should we start the download (typically 0)
2554 * @param length how many bytes should be downloaded starting at offset
2555 * @param anonymity anonymity level to use for the download
2556 * @param options various download options
2557 * @param cctx initial value for the client context for this download
2558 * @param parent parent download to associate this download with (use NULL
2559 * for top-level downloads; useful for manually-triggered recursive downloads)
2560 * @return context that can be used to control this download
2562 struct GNUNET_FS_DownloadContext *
2563 GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
2564 const struct GNUNET_FS_Uri *uri,
2565 const struct GNUNET_CONTAINER_MetaData *meta,
2566 const char *filename, const char *tempname,
2567 uint64_t offset, uint64_t length, uint32_t anonymity,
2568 enum GNUNET_FS_DownloadOptions options, void *cctx,
2569 struct GNUNET_FS_DownloadContext *parent);
2573 * Download parts of a file based on a search result. The download
2574 * will be associated with the search result (and the association
2575 * will be preserved when serializing/deserializing the state).
2576 * If the search is stopped, the download will not be aborted but
2577 * be 'promoted' to a stand-alone download.
2579 * As with the other download function, this will store
2580 * the blocks at the respective offset in the given file. Also, the
2581 * download is still using the blocking of the underlying FS
2582 * encoding. As a result, the download may *write* outside of the
2583 * given boundaries (if offset and length do not match the 32k FS
2584 * block boundaries). <p>
2586 * The given range can be used to focus a download towards a
2587 * particular portion of the file (optimization), not to strictly
2588 * limit the download to exactly those bytes.
2590 * @param h handle to the file sharing subsystem
2591 * @param sr the search result to use for the download (determines uri and
2592 * meta data and associations)
2593 * @param filename where to store the file, maybe NULL (then no file is
2594 * created on disk and data must be grabbed from the callbacks)
2595 * @param tempname where to store temporary file data, not used if filename is non-NULL;
2596 * can be NULL (in which case we will pick a name if needed); the temporary file
2597 * may already exist, in which case we will try to use the data that is there and
2598 * if it is not what is desired, will overwrite it
2599 * @param offset at what offset should we start the download (typically 0)
2600 * @param length how many bytes should be downloaded starting at offset
2601 * @param anonymity anonymity level to use for the download
2602 * @param options various download options
2603 * @param cctx initial value for the client context for this download
2604 * @return context that can be used to control this download
2606 struct GNUNET_FS_DownloadContext *
2607 GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
2608 struct GNUNET_FS_SearchResult *sr,
2609 const char *filename,
2610 const char *tempname, uint64_t offset,
2611 uint64_t length, uint32_t anonymity,
2612 enum GNUNET_FS_DownloadOptions options,
2617 * Stop a download (aborts if download is incomplete).
2619 * @param dc handle for the download
2620 * @param do_delete delete files of incomplete downloads
2623 GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete);
2627 /* ******************** Directory API *********************** */
2630 #define GNUNET_FS_DIRECTORY_MIME "application/gnunet-directory"
2631 #define GNUNET_FS_DIRECTORY_MAGIC "\211GND\r\n\032\n"
2632 #define GNUNET_FS_DIRECTORY_EXT ".gnd"
2635 * Does the meta-data claim that this is a directory?
2636 * Checks if the mime-type is that of a GNUnet directory.
2638 * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if
2639 * we have no mime-type information (treat as 'GNUNET_NO')
2642 GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData
2647 * Set the MIMETYPE information for the given
2648 * metadata to "application/gnunet-directory".
2650 * @param md metadata to add mimetype to
2653 GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md);
2657 * Suggest a filename based on given metadata.
2659 * @param md given meta data
2660 * @return NULL if meta data is useless for suggesting a filename
2663 GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData
2668 * Function used to process entries in a directory.
2670 * @param cls closure
2671 * @param filename name of the file in the directory
2672 * @param uri URI of the file
2673 * @param metadata metadata for the file; metadata for
2674 * the directory if everything else is NULL/zero
2675 * @param length length of the available data for the file
2676 * (of type size_t since data must certainly fit
2677 * into memory; if files are larger than size_t
2678 * permits, then they will certainly not be
2679 * embedded with the directory itself).
2680 * @param data data available for the file (length bytes)
2682 typedef void (*GNUNET_FS_DirectoryEntryProcessor) (void *cls,
2683 const char *filename,
2684 const struct GNUNET_FS_Uri *
2687 GNUNET_CONTAINER_MetaData *
2688 meta, size_t length,
2693 * Iterate over all entries in a directory. Note that directories
2694 * are structured such that it is possible to iterate over the
2695 * individual blocks as well as over the entire directory. Thus
2696 * a client can call this function on the buffer in the
2697 * GNUNET_FS_ProgressCallback. Also, directories can optionally
2698 * include the contents of (small) files embedded in the directory
2699 * itself; for those files, the processor may be given the
2700 * contents of the file directly by this function.
2702 * @param size number of bytes in data
2703 * @param data pointer to the beginning of the directory
2704 * @param offset offset of data in the directory
2705 * @param dep function to call on each entry
2706 * @param dep_cls closure for dep
2707 * @return GNUNET_OK if this could be a block in a directory,
2708 * GNUNET_NO if this could be part of a directory (but not 100% OK)
2709 * GNUNET_SYSERR if 'data' does not represent a directory
2712 GNUNET_FS_directory_list_contents (size_t size, const void *data,
2714 GNUNET_FS_DirectoryEntryProcessor dep,
2719 * Opaque handle to a directory builder.
2721 struct GNUNET_FS_DirectoryBuilder;
2724 * Create a directory builder.
2726 * @param mdir metadata for the directory
2728 struct GNUNET_FS_DirectoryBuilder *
2729 GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData
2734 * Add an entry to a directory.
2736 * @param bld directory to extend
2737 * @param uri uri of the entry (must not be a KSK)
2738 * @param md metadata of the entry
2739 * @param data raw data of the entry, can be NULL, otherwise
2740 * data must point to exactly the number of bytes specified
2744 GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
2745 const struct GNUNET_FS_Uri *uri,
2746 const struct GNUNET_CONTAINER_MetaData *md,
2751 * Finish building the directory. Frees the
2752 * builder context and returns the directory
2755 * @param bld directory to finish
2756 * @param rsize set to the number of bytes needed
2757 * @param rdata set to the encoded directory
2758 * @return GNUNET_OK on success
2761 GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
2762 size_t * rsize, void **rdata);
2765 /* ******************** DirScanner API *********************** */
2768 * Progress reasons of the directory scanner.
2770 enum GNUNET_FS_DirScannerProgressUpdateReason
2774 * We've started processing a file or directory.
2776 GNUNET_FS_DIRSCANNER_FILE_START = 0,
2779 * We're having trouble accessing a file (soft-error); it will
2782 GNUNET_FS_DIRSCANNER_FILE_IGNORED,
2785 * We've found all files (in the pre-pass).
2787 GNUNET_FS_DIRSCANNER_ALL_COUNTED,
2790 * We've finished extracting meta data from a file.
2792 GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED,
2795 * Last call to the progress function: we have finished scanning
2798 GNUNET_FS_DIRSCANNER_FINISHED,
2801 * There was an internal error. Application should abort the scan.
2803 GNUNET_FS_DIRSCANNER_INTERNAL_ERROR
2809 * Function called over time as the directory scanner makes
2810 * progress on the job at hand.
2812 * @param cls closure
2813 * @param filename which file we are making progress on
2814 * @param is_directory GNUNET_YES if this is a directory,
2815 * GNUNET_NO if this is a file
2816 * GNUNET_SYSERR if it is neither (or unknown)
2817 * @param reason kind of progress we are making
2819 typedef void (*GNUNET_FS_DirScannerProgressCallback) (void *cls,
2820 const char *filename,
2822 enum GNUNET_FS_DirScannerProgressUpdateReason reason);
2826 * A node of a directory tree (produced by dirscanner)
2828 struct GNUNET_FS_ShareTreeItem
2831 * This is a doubly-linked list
2833 struct GNUNET_FS_ShareTreeItem *prev;
2836 * This is a doubly-linked list
2838 struct GNUNET_FS_ShareTreeItem *next;
2841 * This is a doubly-linked tree
2842 * NULL for top-level entries.
2844 struct GNUNET_FS_ShareTreeItem *parent;
2847 * This is a doubly-linked tree
2848 * NULL for files and empty directories
2850 struct GNUNET_FS_ShareTreeItem *children_head;
2853 * This is a doubly-linked tree
2854 * NULL for files and empty directories
2856 struct GNUNET_FS_ShareTreeItem *children_tail;
2859 * Metadata for this file or directory
2861 struct GNUNET_CONTAINER_MetaData *meta;
2864 * Keywords for this file or directory (derived from metadata).
2866 struct GNUNET_FS_Uri *ksk_uri;
2869 * Name of the file/directory
2874 * Base name of the file/directory.
2876 char *short_filename;
2879 * GNUNET_YES if this is a directory
2887 * Opaqe handle to an asynchronous directory scanning activity.
2889 struct GNUNET_FS_DirScanner;
2893 * Start a directory scanner.
2895 * @param filename name of the directory to scan
2896 * @param disable_extractor GNUNET_YES to not to run libextractor on files (only build a tree)
2897 * @param ex if not NULL, must be a list of extra plugins for extractor
2898 * @param cb the callback to call when there are scanning progress messages
2899 * @param cb_cls closure for 'cb'
2900 * @return directory scanner object to be used for controlling the scanner
2902 struct GNUNET_FS_DirScanner *
2903 GNUNET_FS_directory_scan_start (const char *filename,
2904 int disable_extractor,
2906 GNUNET_FS_DirScannerProgressCallback cb,
2911 * Abort the scan. Must not be called from within the progress_callback
2914 * @param ds directory scanner structure
2917 GNUNET_FS_directory_scan_abort (struct GNUNET_FS_DirScanner *ds);
2921 * Obtain the result of the scan after the scan has signalled
2922 * completion. Must not be called prior to completion. The 'ds' is
2923 * freed as part of this call.
2925 * @param ds directory scanner structure
2926 * @return the results of the scan (a directory tree)
2928 struct GNUNET_FS_ShareTreeItem *
2929 GNUNET_FS_directory_scan_get_result (struct GNUNET_FS_DirScanner *ds);
2933 * Process a share item tree, moving frequent keywords up and
2934 * copying frequent metadata up.
2936 * @param toplevel toplevel directory in the tree, returned by the scanner
2939 GNUNET_FS_share_tree_trim (struct GNUNET_FS_ShareTreeItem *toplevel);
2943 * Release memory of a share item tree.
2945 * @param toplevel toplevel of the tree to be freed
2948 GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel);
2951 #if 0 /* keep Emacsens' auto-indent happy */