2 This file is part of GNUnet
3 (C) 2004, 2005, 2006, 2007, 2008, 2009 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 2, 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
56 #define GNUNET_FS_VERSION 0x00090000
59 /* ******************** URI API *********************** */
61 #define GNUNET_FS_URI_PREFIX "gnunet://fs/"
62 #define GNUNET_FS_URI_KSK_INFIX "ksk/"
63 #define GNUNET_FS_URI_SKS_INFIX "sks/"
64 #define GNUNET_FS_URI_CHK_INFIX "chk/"
65 #define GNUNET_FS_URI_LOC_INFIX "loc/"
69 * A Universal Resource Identifier (URI), opaque.
75 * Iterator over keywords
78 * @param keyword the keyword
79 * @param is_mandatory is the keyword mandatory (in a search)
80 * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
82 typedef int (*GNUNET_FS_KeywordIterator) (void *cls,
87 * Get a unique key from a URI. This is for putting URIs
88 * into HashMaps. The key may change between FS implementations.
90 * @param uri uri to convert to a unique key
91 * @param key wherer to store the unique key
94 GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
95 GNUNET_HashCode * key);
98 * Convert a URI to a UTF-8 String.
100 * @param uri uri to convert to a string
101 * @return the UTF-8 string
104 GNUNET_FS_uri_to_string (const struct GNUNET_FS_Uri *uri);
107 * Convert keyword URI to a human readable format
108 * (i.e. the search query that was used in the first place)
110 * @param uri ksk uri to convert to a string
111 * @return string with the keywords
114 GNUNET_FS_uri_ksk_to_string_fancy (const struct GNUNET_FS_Uri *uri);
117 * Convert a UTF-8 String to a URI.
119 * @param uri string to parse
120 * @param emsg where to store the parser error message (if any)
121 * @return NULL on error
123 struct GNUNET_FS_Uri *
124 GNUNET_FS_uri_parse (const char *uri,
130 * @param uri uri to free
133 GNUNET_FS_uri_destroy (struct GNUNET_FS_Uri *uri);
137 * How many keywords are ANDed in this keyword URI?
139 * @param uri ksk uri to get the number of keywords from
140 * @return 0 if this is not a keyword URI
143 GNUNET_FS_uri_ksk_get_keyword_count (const struct GNUNET_FS_Uri *uri);
147 * Iterate over all keywords in this keyword URI.
149 * @param uri ksk uri to get the keywords from
150 * @param iterator function to call on each keyword
151 * @param iterator_cls closure for iterator
152 * @return -1 if this is not a keyword URI, otherwise number of
153 * keywords iterated over until iterator aborted
156 GNUNET_FS_uri_ksk_get_keywords (const struct GNUNET_FS_Uri *uri,
157 GNUNET_FS_KeywordIterator iterator,
162 * Obtain the identity of the peer offering the data
164 * @param uri the location URI to inspect
165 * @param peer where to store the identify of the peer (presumably) offering the content
166 * @return GNUNET_SYSERR if this is not a location URI, otherwise GNUNET_OK
169 GNUNET_FS_uri_loc_get_peer_identity (const struct GNUNET_FS_Uri *uri,
170 struct GNUNET_PeerIdentity * peer);
174 * Obtain the URI of the content itself.
176 * @param uri location URI to get the content URI from
177 * @return NULL if argument is not a location URI
179 struct GNUNET_FS_Uri *
180 GNUNET_FS_uri_loc_get_uri (const struct GNUNET_FS_Uri *uri);
184 * Construct a location URI (this peer will be used for the location).
186 * @param baseURI content offered by the sender
187 * @param cfg configuration information (used to find our hostkey)
188 * @param expiration_time how long will the content be offered?
189 * @return the location URI, NULL on error
191 struct GNUNET_FS_Uri *
192 GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
193 struct GNUNET_CONFIGURATION_Handle *cfg,
194 struct GNUNET_TIME_Absolute expiration_time);
198 * Canonicalize keyword URI. Performs operations such
199 * as decapitalization and removal of certain characters.
200 * (useful for search).
202 * @param uri the URI to canonicalize
203 * @return canonicalized version of the URI, NULL on error
205 struct GNUNET_FS_Uri *
206 GNUNET_FS_uri_ksk_canonicalize (const struct GNUNET_FS_Uri *uri);
210 * Merge the sets of keywords from two KSK URIs.
211 * (useful for merging the canonicalized keywords with
212 * the original keywords for sharing).
214 * @param u1 first uri
215 * @param u2 second uri
216 * @return merged URI, NULL on error
218 struct GNUNET_FS_Uri *
219 GNUNET_FS_uri_ksk_merge (const struct GNUNET_FS_Uri *u1,
220 const struct GNUNET_FS_Uri *u2);
226 * @param uri the URI to duplicate
227 * @return copy of the URI
229 struct GNUNET_FS_Uri *
230 GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri);
234 * Create an FS URI from a single user-supplied string of keywords.
235 * The string is broken up at spaces into individual keywords.
236 * Keywords that start with "+" are mandatory. Double-quotes can
237 * be used to prevent breaking up strings at spaces (and also
238 * to specify non-mandatory keywords starting with "+").
240 * Keywords must contain a balanced number of double quotes and
241 * double quotes can not be used in the actual keywords (for
242 * example, the string '""foo bar""' will be turned into two
243 * "OR"ed keywords 'foo' and 'bar', not into '"foo bar"'.
245 * @param keywords the keyword string
246 * @param emsg where to store an error message
247 * @return an FS URI for the given keywords, NULL
248 * if keywords is not legal (i.e. empty).
250 struct GNUNET_FS_Uri *
251 GNUNET_FS_uri_ksk_create (const char *keywords,
256 * Create an FS URI from a user-supplied command line of keywords.
257 * Arguments should start with "+" to indicate mandatory
260 * @param argc number of keywords
261 * @param argv keywords (double quotes are not required for
262 * keywords containing spaces; however, double
263 * quotes are required for keywords starting with
264 * "+"); there is no mechanism for having double
265 * quotes in the actual keywords (if the user
266 * did specifically specify double quotes, the
267 * caller should convert each double quote
268 * into two single quotes).
269 * @return an FS URI for the given keywords, NULL
270 * if keywords is not legal (i.e. empty).
272 struct GNUNET_FS_Uri *
273 GNUNET_FS_uri_ksk_create_from_args (unsigned int argc,
278 * Test if two URIs are equal.
280 * @param u1 one of the URIs
281 * @param u2 the other URI
282 * @return GNUNET_YES if the URIs are equal
285 GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
286 const struct GNUNET_FS_Uri *u2);
290 * Is this a namespace URI?
292 * @param uri the uri to check
293 * @return GNUNET_YES if this is an SKS uri
296 GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri);
300 * Get the ID of a namespace from the given
303 * @param uri the uri to get the namespace ID from
304 * @param nsid where to store the ID of the namespace
305 * @return GNUNET_OK on success
308 GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri,
309 GNUNET_HashCode * nsid);
313 * Get the content identifier of an SKS URI.
315 * @param uri the sks uri
316 * @return NULL on error (not a valid SKS URI)
319 GNUNET_FS_uri_sks_get_content_id (const struct GNUNET_FS_Uri *uri);
323 * Convert namespace URI to a human readable format
324 * (using the namespace description, if available).
326 * @param cfg configuration to use
327 * @param uri SKS uri to convert
328 * @return NULL on error (not an SKS URI)
331 GNUNET_FS_uri_sks_to_string_fancy (struct GNUNET_CONFIGURATION_Handle *cfg,
332 const struct GNUNET_FS_Uri *uri);
336 * Is this a keyword URI?
339 * @return GNUNET_YES if this is a KSK uri
342 GNUNET_FS_uri_test_ksk (const struct GNUNET_FS_Uri *uri);
346 * Is this a file (or directory) URI?
348 * @param uri the uri to check
349 * @return GNUNET_YES if this is a CHK uri
352 GNUNET_FS_uri_test_chk (const struct GNUNET_FS_Uri *uri);
356 * What is the size of the file that this URI
359 * @param uri the CHK URI to inspect
360 * @return size of the file as specified in the CHK URI
363 GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri *uri);
367 * Is this a location URI?
369 * @param uri the uri to check
370 * @return GNUNET_YES if this is a LOC uri
373 GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri);
377 * Construct a keyword-URI from meta-data (take all entries
378 * in the meta-data and construct one large keyword URI
379 * that lists all keywords that can be found in the meta-data).
382 struct GNUNET_FS_Uri *
383 GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData *md);
386 /* ******************** command-line option parsing API *********************** */
389 * Command-line option parser function that allows the user
390 * to specify one or more '-k' options with keywords. Each
391 * specified keyword will be added to the URI. A pointer to
392 * the URI must be passed as the "scls" argument.
394 * @param ctx command line processor context
395 * @param scls must be of type "struct GNUNET_FS_Uri **"
396 * @param option name of the option (typically 'k')
397 * @param value command line argument given
398 * @return GNUNET_OK on success
401 GNUNET_FS_getopt_configure_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext* ctx,
408 * Command-line option parser function that allows the user to specify
409 * one or more '-m' options with metadata. Each specified entry of
410 * the form "type=value" will be added to the metadata. A pointer to
411 * the metadata must be passed as the "scls" argument.
413 * @param ctx command line processor context
414 * @param scls must be of type "struct GNUNET_MetaData **"
415 * @param option name of the option (typically 'k')
416 * @param value command line argument given
417 * @return GNUNET_OK on success
420 GNUNET_FS_getopt_configure_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext* ctx,
427 /* ************************* sharing API ***************** */
431 * Possible status codes used in the callback for the
432 * various file-sharing operations. On each file (or search),
433 * the callback is guaranteed to be called once with "START"
434 * and once with STOPPED; calls with PROGRESS, ERROR or COMPLETED
435 * are optional and depend on the circumstances; parent operations
436 * will be STARTED before child-operations and STOPPED after
437 * their respective child-operations. START and STOP signals
438 * are typically generated either due to explicit client requests
439 * or because of suspend/resume operations.
441 enum GNUNET_FS_Status
444 * Notification that we have started to publish a file structure.
446 GNUNET_FS_STATUS_PUBLISH_START,
449 * Notification that we have resumed sharing a file structure.
451 GNUNET_FS_STATUS_PUBLISH_RESUME,
454 * Notification that we have suspended sharing a file structure.
456 GNUNET_FS_STATUS_PUBLISH_SUSPEND,
459 * Notification that we are making progress sharing a file structure.
461 GNUNET_FS_STATUS_PUBLISH_PROGRESS,
464 * Notification that an error was encountered sharing a file structure.
465 * The application will continue to receive resume/suspend events for
466 * this structure until "GNUNET_FS_publish_stop" is called.
468 GNUNET_FS_STATUS_PUBLISH_ERROR,
471 * Notification that we completed sharing a file structure.
472 * The application will continue to receive resume/suspend events for
473 * this structure until "GNUNET_FS_publish_stop" is called.
475 GNUNET_FS_STATUS_PUBLISH_COMPLETED,
478 * Notification that we have stopped
479 * the process of uploading a file structure; no
480 * futher events will be generated for this action.
482 GNUNET_FS_STATUS_PUBLISH_STOPPED,
485 * Notification that we have started this download.
487 GNUNET_FS_STATUS_DOWNLOAD_START,
490 * Notification that this download is being resumed.
492 GNUNET_FS_STATUS_DOWNLOAD_RESUME,
495 * Notification that this download was suspended.
497 GNUNET_FS_STATUS_DOWNLOAD_SUSPEND,
500 * Notification about progress with this download.
502 GNUNET_FS_STATUS_DOWNLOAD_PROGRESS,
505 * Notification that this download encountered an error.
507 GNUNET_FS_STATUS_DOWNLOAD_ERROR,
510 * Notification that this download completed. Note that for
511 * directories, completion does not imply completion of all files in
514 GNUNET_FS_STATUS_DOWNLOAD_COMPLETED,
517 * Notification that this download was stopped
518 * (final event with respect to this action).
520 GNUNET_FS_STATUS_DOWNLOAD_STOPPED,
523 * First event generated when a client requests
524 * a search to begin or when a namespace result
525 * automatically triggers the search for updates.
527 GNUNET_FS_STATUS_SEARCH_START,
530 * Last event when a search is being resumed;
531 * note that "GNUNET_FS_SEARCH_START" will not
532 * be generated in this case.
534 GNUNET_FS_STATUS_SEARCH_RESUME,
537 * Event generated for each search result
538 * when the respective search is resumed.
540 GNUNET_FS_STATUS_SEARCH_RESUME_RESULT,
543 * Last event when a search is being suspended;
544 * note that "GNUNET_FS_SEARCH_STOPPED" will not
545 * be generated in this case.
547 GNUNET_FS_STATUS_SEARCH_SUSPEND,
550 * Event generated for each search result
551 * when the respective search is suspended.
553 GNUNET_FS_STATUS_SEARCH_SUSPEND_RESULT,
556 * This search has yielded a result.
558 GNUNET_FS_STATUS_SEARCH_RESULT,
561 * We have discovered a new namespace.
563 GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE,
566 * We have additional data about the quality
567 * or availability of a search result.
569 GNUNET_FS_STATUS_SEARCH_UPDATE,
572 * Signals a problem with this search.
574 GNUNET_FS_STATUS_SEARCH_ERROR,
577 * Signals that this search was paused.
579 GNUNET_FS_STATUS_SEARCH_PAUSED,
582 * Signals that this search was continued (unpaused).
584 GNUNET_FS_STATUS_SEARCH_CONTINUED,
587 * Event generated for each search result
588 * when the respective search is stopped.
590 GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED,
593 * Last message from a search; this signals
594 * that there will be no further events associated
597 GNUNET_FS_STATUS_SEARCH_STOPPED,
600 * Notification that we started to unindex a file.
602 GNUNET_FS_STATUS_UNINDEX_START,
605 * Notification that we resumed unindexing of a file.
607 GNUNET_FS_STATUS_UNINDEX_RESUME,
610 * Notification that we suspended unindexing a file.
612 GNUNET_FS_STATUS_UNINDEX_SUSPEND,
615 * Notification that we made progress unindexing a file.
617 GNUNET_FS_STATUS_UNINDEX_PROGRESS,
620 * Notification that we encountered an error unindexing
623 GNUNET_FS_STATUS_UNINDEX_ERROR,
626 * Notification that the unindexing of this file
627 * was stopped (final event for this action).
629 GNUNET_FS_STATUS_UNINDEX_STOPPED
635 * Handle to one of our namespaces.
637 struct GNUNET_FS_Namespace;
641 * Handle for controlling an upload.
643 struct GNUNET_FS_PublishContext;
647 * Handle for controlling an unindexing operation.
649 struct GNUNET_FS_UnindexContext;
653 * Handle for controlling a search.
655 struct GNUNET_FS_SearchContext;
659 * Context for controlling a download.
661 struct GNUNET_FS_DownloadContext;
665 * Handle for detail information about a file that is being publishd.
666 * Specifies metadata, keywords, how to get the contents of the file
667 * (i.e. data-buffer in memory, filename on disk) and other options.
669 struct GNUNET_FS_FileInformation;
673 * Argument given to the progress callback with
674 * information about what is going on.
676 struct GNUNET_FS_ProgressInfo
680 * Values that depend on the event type.
685 * Values for all "GNUNET_FS_STATUS_PUBLISH_*" events.
690 * Context for controlling the upload.
692 struct GNUNET_FS_PublishContext *sc;
695 * Information about the file that is being publishd.
697 const struct GNUNET_FS_FileInformation *fi;
700 * Client context pointer (set the last time
701 * by the client for this operation; initially
702 * NULL on START/RESUME events).
707 * Client context pointer for the parent operation
708 * (if this is a file in a directory or a subdirectory).
713 * How large is the file overall? For directories,
714 * this is only the size of the directory itself,
715 * not of the other files contained within the
721 * At what time do we expect to finish the upload?
722 * (will be a value in the past for completed
725 struct GNUNET_TIME_Absolute eta;
728 * How long has this upload been actively running
729 * (excludes times where the upload was suspended).
731 struct GNUNET_TIME_Relative duration;
734 * How many bytes have we completed?
739 * What anonymity level is used for this upload?
741 unsigned int anonymity;
744 * Additional values for specific events.
749 * These values are only valid for
750 * GNUNET_FS_STATUS_PUBLISH_PROGRESS events.
755 * Data block we just published.
760 * At what offset in the file is "data"?
765 * Length of the data block.
772 * These values are only valid for
773 * GNUNET_FS_STATUS_PUBLISH_RESUME events.
778 * Error message, NULL if no error was encountered so far.
785 * These values are only valid for
786 * GNUNET_FS_STATUS_PUBLISH_ERROR events.
791 * Error message, never NULL.
803 * Values for all "GNUNET_FS_STATUS_DOWNLOAD_*" events.
808 * Context for controlling the download.
810 struct GNUNET_FS_DownloadContext *dc;
813 * Client context pointer (set the last time
814 * by the client for this operation; initially
815 * NULL on START/RESUME events).
820 * Client context pointer for the parent operation
821 * (if this is a file in a directory or a subdirectory).
826 * URI used for this download.
828 const struct GNUNET_FS_Uri *uri;
831 * How large is the file overall? For directories,
832 * this is only the size of the directory itself,
833 * not of the other files contained within the
839 * At what time do we expect to finish the download?
840 * (will be a value in the past for completed
843 struct GNUNET_TIME_Absolute eta;
846 * How long has this download been active?
848 struct GNUNET_TIME_Relative duration;
851 * How many bytes have we completed?
856 * What anonymity level is used for this download?
858 unsigned int anonymity;
861 * Additional values for specific events.
866 * These values are only valid for
867 * GNUNET_FS_STATUS_DOWNLOAD_PROGRESS events.
872 * Data block we just obtained.
877 * At what offset in the file is "data"?
882 * Length of the data block.
887 * Amount of trust we offered to get the block.
889 unsigned int trust_offered;
894 * These values are only valid for
895 * GNUNET_FS_STATUS_DOWNLOAD_START events.
900 * Known metadata for the download.
902 const struct GNUNET_MetaData *meta;
907 * These values are only valid for
908 * GNUNET_FS_STATUS_DOWNLOAD_RESUME events.
913 * Known metadata for the download.
915 const struct GNUNET_MetaData *meta;
918 * Error message, NULL if we have not encountered any error yet.
925 * These values are only valid for
926 * GNUNET_FS_STATUS_DOWNLOAD_ERROR events.
942 * Values for all "GNUNET_FS_STATUS_SEARCH_*" events.
947 * Context for controlling the search, NULL for
948 * searches that were not explicitly triggered
949 * by the client (i.e., searches for updates in
952 struct GNUNET_FS_SearchContext *sc;
955 * Client context pointer (set the last time by the client for
956 * this operation; initially NULL on START/RESUME events). Note
957 * that this value can only be set on START/RESUME; returning
958 * non-NULL on RESULT/RESUME_RESULT will actually update the
959 * private context for "UPDATE" events.
964 * Client parent-context pointer; NULL for top-level searches,
965 * non-NULL for automatically triggered searches for updates in
971 * What query is used for this search
972 * (list of keywords or SKS identifier).
974 const struct GNUNET_FS_Uri *query;
977 * How long has this search been actively running
978 * (excludes times where the search was paused or
981 struct GNUNET_TIME_Relative duration;
984 * What anonymity level is used for this search?
986 unsigned int anonymity;
989 * How much trust have we been offering for this search
992 unsigned int trust_offered;
995 * Additional values for specific events.
1000 * These values are only valid for
1001 * GNUNET_FS_STATUS_SEARCH_RESULT events.
1006 * Metadata for the search result.
1008 const struct GNUNET_MetaData *meta;
1011 * URI for the search result.
1013 const struct GNUNET_FS_Uri *uri;
1018 * These values are only valid for
1019 * GNUNET_FS_STATUS_SEARCH_RESUME_RESULT events.
1024 * Metadata for the search result.
1026 const struct GNUNET_MetaData *meta;
1029 * URI for the search result.
1031 const struct GNUNET_FS_Uri *uri;
1034 * Current availability rank (negative:
1035 * unavailable, positive: available)
1037 int availability_rank;
1040 * On how many total queries is the given
1041 * availability_rank based?
1043 unsigned int availabiliy_certainty;
1046 * Updated applicability rank (the larger,
1047 * the better the result fits the search
1050 unsigned int applicabiliy_rank;
1055 * These values are only valid for
1056 * GNUNET_FS_STATUS_SEARCH_UPDATE events.
1061 * Private context set for for this result
1062 * during the "RESULT" event.
1067 * Metadata for the search result.
1069 const struct GNUNET_MetaData *meta;
1072 * URI for the search result.
1074 const struct GNUNET_FS_Uri *uri;
1077 * Current availability rank (negative:
1078 * unavailable, positive: available)
1080 int availability_rank;
1083 * On how many total queries is the given
1084 * availability_rank based?
1086 unsigned int availabiliy_certainty;
1089 * Updated applicability rank (the larger,
1090 * the better the result fits the search
1093 unsigned int applicabiliy_rank;
1098 * These values are only valid for
1099 * GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND events.
1100 * These events are automatically triggered for
1101 * each search result before the
1102 * GNUNET_FS_STATUS_SEARCH_SUSPEND event. This
1103 * happens primarily to give the client a chance
1104 * to clean up the "cctx" (if needed).
1109 * Private context set for for this result
1110 * during the "RESULT" event.
1115 * Metadata for the search result.
1117 const struct GNUNET_MetaData *meta;
1120 * URI for the search result.
1122 const struct GNUNET_FS_Uri *uri;
1127 * These values are only valid for
1128 * GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED events.
1129 * These events are automatically triggered for
1130 * each search result before the
1131 * GNUNET_FS_STATUS_SEARCH_STOPPED event. This
1132 * happens primarily to give the client a chance
1133 * to clean up the "cctx" (if needed).
1138 * Private context set for for this result
1139 * during the "RESULT" event.
1144 * Metadata for the search result.
1146 const struct GNUNET_MetaData *meta;
1149 * URI for the search result.
1151 const struct GNUNET_FS_Uri *uri;
1156 * These values are only valid for
1157 * GNUNET_FS_STATUS_SEARCH_RESUME events.
1162 * Error message, NULL if we have not encountered any error yet.
1164 const char *message;
1167 * Is this search currently paused?
1174 * These values are only valid for
1175 * GNUNET_FS_STATUS_SEARCH_ERROR events.
1182 const char *message;
1187 * Values for all "GNUNET_FS_STATUS_RESULT_NAMESPACE" events.
1192 * Handle to the namespace (NULL if it is not a local
1195 struct GNUNET_FS_Namespace *ns;
1198 * Short, human-readable name of the namespace.
1203 * Root identifier for the namespace, can be NULL.
1208 * Metadata for the namespace.
1210 const struct GNUNET_CONTAINER_MetaData *meta;
1213 * Hash-identifier for the namespace.
1224 * Values for all "GNUNET_FS_STATUS_UNINDEX_*" events.
1229 * Context for controlling the unindexing.
1231 struct GNUNET_FS_UnindexContext *uc;
1234 * Client context pointer (set the last time
1235 * by the client for this operation; initially
1236 * NULL on START/RESUME events).
1241 * Name of the file that is being unindexed.
1243 const char *filename;
1246 * How large is the file overall?
1251 * At what time do we expect to finish unindexing?
1252 * (will be a value in the past for completed
1253 * unindexing opeations).
1255 struct GNUNET_TIME_Absolute eta;
1258 * How long has this upload been actively running
1259 * (excludes times where the upload was suspended).
1261 struct GNUNET_TIME_Relative duration;
1264 * How many bytes have we completed?
1269 * Additional values for specific events.
1274 * These values are only valid for
1275 * GNUNET_FS_STATUS_UNINDEX_PROGRESS events.
1280 * Data block we just unindexed.
1285 * At what offset in the file is "data"?
1290 * Length of the data block.
1297 * These values are only valid for
1298 * GNUNET_FS_STATUS_UNINDEX_RESUME events.
1303 * Error message, NULL if we have not encountered any error yet.
1305 const char *message;
1310 * These values are only valid for
1311 * GNUNET_FS_STATUS_UNINDEX_ERROR events.
1318 const char *message;
1329 * Specific status code (determines the event type).
1331 enum GNUNET_FS_Status status;
1337 * Notification of FS to a client about the progress of an
1338 * operation. Callbacks of this type will be used for uploads,
1339 * downloads and searches. Some of the arguments depend a bit
1340 * in their meaning on the context in which the callback is used.
1342 * @param cls closure
1343 * @param info details about the event, specifying the event type
1344 * and various bits about the event
1345 * @return client-context (for the next progress call
1346 * for this operation; should be set to NULL for
1347 * SUSPEND and STOPPED events). The value returned
1348 * will be passed to future callbacks in the respective
1349 * field in the GNUNET_FS_ProgressInfo struct.
1351 typedef void* (*GNUNET_FS_ProgressCallback)
1353 const struct GNUNET_FS_ProgressInfo *info);
1357 * Handle to the file-sharing service.
1359 struct GNUNET_FS_Handle;
1363 * Setup a connection to the file-sharing service.
1365 * @param sched scheduler to use
1366 * @param cfg configuration to use
1367 * @param client_name unique identifier for this client
1368 * @param upcb function to call to notify about FS actions
1369 * @param upcb_cls closure for upcb
1371 struct GNUNET_FS_Handle *
1372 GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched,
1373 const struct GNUNET_CONFIGURATION_Handle *cfg,
1374 const char *client_name,
1375 GNUNET_FS_ProgressCallback upcb,
1380 * Close our connection with the file-sharing service.
1381 * The callback given to GNUNET_FS_start will no longer be
1382 * called after this function returns.
1384 * @param h handle that was returned from GNUNET_FS_start
1387 GNUNET_FS_stop (struct GNUNET_FS_Handle *h);
1391 * Function called on entries in a GNUNET_FS_FileInformation publish-structure.
1393 * @param cls closure
1394 * @param fi the entry in the publish-structure
1395 * @param length length of the file or directory
1396 * @param meta metadata for the file or directory (can be modified)
1397 * @param uri pointer to the keywords that will be used for this entry (can be modified)
1398 * @param anonymity pointer to selected anonymity level (can be modified)
1399 * @param priority pointer to selected priority (can be modified)
1400 * @param expirationTime pointer to selected expiration time (can be modified)
1401 * @param client_info pointer to client context set upon creation (can be modified)
1402 * @return GNUNET_OK to continue, GNUNET_NO to remove
1403 * this entry from the directory, GNUNET_SYSERR
1404 * to abort the iteration
1406 typedef int (*GNUNET_FS_FileInformationProcessor)(void *cls,
1407 struct GNUNET_FS_FileInformation *fi,
1409 struct GNUNET_CONTAINER_MetaData *meta,
1410 struct GNUNET_FS_Uri **uri,
1411 unsigned int *anonymity,
1412 unsigned int *priority,
1413 struct GNUNET_TIME_Absolute *expirationTime,
1414 void **client_info);
1418 * Recover file information structure from disk.
1420 * @param name filename for the structure on disk
1421 * @return NULL on error
1423 struct GNUNET_FS_FileInformation *
1424 GNUNET_FS_file_information_recover (const char *name);
1428 * Obtain the name under which this file information
1429 * structure is stored on disk. Only works for top-level
1430 * file information structures.
1432 * @param s structure to get the filename for
1433 * @return NULL on error, otherwise filename that
1434 * can be passed to "GNUNET_FS_file_information_recover"
1435 * to read this fi-struct from disk.
1438 GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s);
1442 * Synchronize this file-information struct with its mirror
1443 * on disk. Note that all internal FS-operations that change
1444 * file information data should already call "sync" internally,
1445 * so this function is likely not useful for clients.
1447 * @param s the struct to sync
1450 GNUNET_FS_file_information_sync (struct GNUNET_FS_FileInformation *s);
1454 * Create an entry for a file in a publish-structure.
1456 * @param filename name of the file or directory to publish
1457 * @param keywords under which keywords should this file be available
1458 * directly; can be NULL
1459 * @param meta metadata for the file
1460 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1461 * GNUNET_SYSERR for simulation
1462 * @param anonymity what is the desired anonymity level for sharing?
1463 * @param priority what is the priority for OUR node to
1464 * keep this file available? Use 0 for maximum anonymity and
1465 * minimum reliability...
1466 * @param expirationTime when should this content expire?
1467 * @return publish structure entry for the file
1469 struct GNUNET_FS_FileInformation *
1470 GNUNET_FS_file_information_create_from_file (void *client_info,
1471 const char *filename,
1472 const struct GNUNET_FS_Uri *keywords,
1473 const struct GNUNET_CONTAINER_MetaData *meta,
1475 unsigned int anonymity,
1476 unsigned int priority,
1477 struct GNUNET_TIME_Absolute expirationTime);
1481 * Create an entry for a file in a publish-structure.
1483 * @param length length of the file
1484 * @param data data for the file (should not be used afterwards by
1485 * the caller; caller will "free")
1486 * @param keywords under which keywords should this file be available
1487 * directly; can be NULL
1488 * @param meta metadata for the file
1489 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1490 * GNUNET_SYSERR for simulation
1491 * @param anonymity what is the desired anonymity level for sharing?
1492 * @param priority what is the priority for OUR node to
1493 * keep this file available? Use 0 for maximum anonymity and
1494 * minimum reliability...
1495 * @param expirationTime when should this content expire?
1496 * @return publish structure entry for the file
1498 struct GNUNET_FS_FileInformation *
1499 GNUNET_FS_file_information_create_from_data (void *client_info,
1502 const struct GNUNET_FS_Uri *keywords,
1503 const struct GNUNET_CONTAINER_MetaData *meta,
1505 unsigned int anonymity,
1506 unsigned int priority,
1507 struct GNUNET_TIME_Absolute expirationTime);
1511 * Function that provides data.
1513 * @param cls closure
1514 * @param offset offset to read from; it is possible
1515 * that the caller might need to go backwards
1517 * @param max maximum number of bytes that should be
1518 * copied to buf; readers are not allowed
1519 * to provide less data unless there is an error;
1520 * a value of "0" will be used at the end to allow
1521 * the reader to clean up its internal state
1522 * @param buf where the reader should write the data
1523 * @param emsg location for the reader to store an error message
1524 * @return number of bytes written, usually "max", 0 on error
1526 typedef size_t (*GNUNET_FS_DataReader)(void *cls,
1534 * Create an entry for a file in a publish-structure.
1536 * @param length length of the file
1537 * @param reader function that can be used to obtain the data for the file
1538 * @param reader_cls closure for "reader"
1539 * @param keywords under which keywords should this file be available
1540 * directly; can be NULL
1541 * @param meta metadata for the file
1542 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1543 * GNUNET_SYSERR for simulation
1544 * @param anonymity what is the desired anonymity level for sharing?
1545 * @param priority what is the priority for OUR node to
1546 * keep this file available? Use 0 for maximum anonymity and
1547 * minimum reliability...
1548 * @param expirationTime when should this content expire?
1549 * @return publish structure entry for the file
1551 struct GNUNET_FS_FileInformation *
1552 GNUNET_FS_file_information_create_from_reader (void *client_info,
1554 GNUNET_FS_DataReader reader,
1556 const struct GNUNET_FS_Uri *keywords,
1557 const struct GNUNET_CONTAINER_MetaData *meta,
1559 unsigned int anonymity,
1560 unsigned int priority,
1561 struct GNUNET_TIME_Absolute expirationTime);
1565 * Function that a "GNUNET_FS_DirectoryScanner" should call
1566 * for each entry in the directory.
1568 * @param cls closure
1569 * @param filename name of the file (including path); must end
1570 * in a "/" (even on W32) if this is a directory
1571 * @param fi information about the file (should not be
1572 * used henceforth by the caller)
1574 typedef void (*GNUNET_FS_FileProcessor)(void *cls,
1575 const char *filename,
1576 struct GNUNET_FS_FileInformation *fi);
1580 * Type of a function that will be used to scan a directory.
1582 * @param cls closure
1583 * @param dirname name of the directory to scan
1584 * @param do_index should files be indexed or inserted
1585 * @param anonymity desired anonymity level
1586 * @param priority priority for publishing
1587 * @param expirationTime expiration for publication
1588 * @param proc function to call on each entry
1589 * @param proc_cls closure for proc
1590 * @param emsg where to store an error message (on errors)
1591 * @return GNUNET_OK on success
1593 typedef int (*GNUNET_FS_DirectoryScanner)(void *cls,
1594 const char *dirname,
1596 unsigned int anonymity,
1597 unsigned int priority,
1598 struct GNUNET_TIME_Absolute expirationTime,
1599 GNUNET_FS_FileProcessor proc,
1606 * Simple, useful default implementation of a directory scanner
1607 * (GNUNET_FS_DirectoryScanner). This implementation expects to get a
1608 * UNIX filename, will publish all files in the directory except hidden
1609 * files (those starting with a "."). Metadata will be extracted
1610 * using GNU libextractor; the specific list of plugins should be
1611 * specified in "cls", passing NULL will disable (!) metadata
1612 * extraction. Keywords will be derived from the metadata and be
1613 * subject to default canonicalization. This is strictly a
1614 * convenience function.
1616 * @param cls must be of type "struct EXTRACTOR_Extractor*"
1617 * @param dirname name of the directory to scan
1618 * @param do_index should files be indexed or inserted
1619 * @param anonymity desired anonymity level
1620 * @param priority priority for publishing
1621 * @param expirationTime expiration for publication
1622 * @param proc function called on each entry
1623 * @param proc_cls closure for proc
1624 * @param emsg where to store an error message (on errors)
1625 * @return GNUNET_OK on success
1628 GNUNET_FS_directory_scanner_default (void *cls,
1629 const char *dirname,
1631 unsigned int anonymity,
1632 unsigned int priority,
1633 struct GNUNET_TIME_Absolute expirationTime,
1634 GNUNET_FS_FileProcessor proc,
1640 * Create a publish-structure from an existing file hierarchy, inferring
1641 * and organizing keywords and metadata as much as possible. This
1642 * function primarily performs the recursive build and re-organizes
1643 * keywords and metadata; for automatically getting metadata
1644 * extraction, scanning of directories and creation of the respective
1645 * GNUNET_FS_FileInformation entries the default scanner should be
1646 * passed (GNUNET_FS_directory_scanner_default). This is strictly a
1647 * convenience function.
1649 * @param filename name of the top-level file or directory
1650 * @param scanner function used to get a list of files in a directory
1651 * @param scanner_cls closure for scanner
1652 * @param do_index should files in the hierarchy be indexed?
1653 * @param anonymity what is the desired anonymity level for sharing?
1654 * @param priority what is the priority for OUR node to
1655 * keep this file available? Use 0 for maximum anonymity and
1656 * minimum reliability...
1657 * @param expirationTime when should this content expire?
1658 * @param emsg where to store an error message
1659 * @return publish structure entry for the directory, NULL on error
1661 struct GNUNET_FS_FileInformation *
1662 GNUNET_FS_file_information_create_from_directory (void *client_info,
1663 const char *filename,
1664 GNUNET_FS_DirectoryScanner scanner,
1667 unsigned int anonymity,
1668 unsigned int priority,
1669 struct GNUNET_TIME_Absolute expirationTime,
1674 * Create an entry for an empty directory in a publish-structure.
1675 * This function should be used by applications for which the
1676 * use of "GNUNET_FS_file_information_create_from_directory"
1677 * is not appropriate.
1679 * @param meta metadata for the directory
1680 * @param keywords under which keywords should this directory be available
1681 * directly; can be NULL
1682 * @param anonymity what is the desired anonymity level for sharing?
1683 * @param priority what is the priority for OUR node to
1684 * keep this file available? Use 0 for maximum anonymity and
1685 * minimum reliability...
1686 * @param expirationTime when should this content expire?
1687 * @return publish structure entry for the directory , NULL on error
1689 struct GNUNET_FS_FileInformation *
1690 GNUNET_FS_file_information_create_empty_directory (void *client_info,
1691 const struct GNUNET_CONTAINER_MetaData *meta,
1692 const struct GNUNET_FS_Uri *keywords,
1693 unsigned int anonymity,
1694 unsigned int priority,
1695 struct GNUNET_TIME_Absolute expirationTime);
1699 * Add an entry to a directory in a publish-structure. Clients
1700 * should never modify publish structures that were passed to
1701 * "GNUNET_FS_publish_start" already.
1703 * @param dir the directory
1704 * @param end the entry to add; the entry must not have been
1705 * added to any other directory at this point and
1706 * must not include "dir" in its structure
1707 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1710 GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
1711 struct GNUNET_FS_FileInformation *end);
1715 * Inspect a file or directory in a publish-structure. Clients
1716 * should never modify publish structures that were passed to
1717 * "GNUNET_FS_publish_start" already. When called on a directory,
1718 * this function will FIRST call "proc" with information about
1719 * the directory itself and then for each of the files in the
1720 * directory (but not for files in subdirectories). When called
1721 * on a file, "proc" will be called exactly once (with information
1722 * about the specific file).
1724 * @param dir the directory
1725 * @param proc function to call on each entry
1726 * @param proc_cls closure for proc
1729 GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
1730 GNUNET_FS_FileInformationProcessor proc,
1735 * Destroy publish-structure. Clients should never destroy publish
1736 * structures that were passed to "GNUNET_FS_publish_start" already.
1738 * @param fi structure to destroy
1739 * @param cleaner function to call on each entry in the structure
1740 * (useful to clean up client_info); can be NULL; return
1741 * values are ignored
1742 * @param cleaner_cls closure for cleaner
1745 GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
1746 GNUNET_FS_FileInformationProcessor cleaner,
1751 * Publish a file or directory.
1753 * @param h handle to the file sharing subsystem
1754 * @param ctx initial value to use for the '*ctx'
1755 * in the callback (for the GNUNET_FS_STATUS_PUBLISH_START event).
1756 * @param fi information about the file or directory structure to publish
1757 * @param namespace namespace to publish the file in, NULL for no namespace
1758 * @param nid identifier to use for the publishd content in the namespace
1759 * (can be NULL, must be NULL if namespace is NULL)
1760 * @param nuid update-identifier that will be used for future updates
1761 * (can be NULL, must be NULL if namespace or nid is NULL)
1762 * @return context that can be used to control the publish operation
1764 struct GNUNET_FS_PublishContext *
1765 GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1767 const struct GNUNET_FS_FileInformation *fi,
1768 struct GNUNET_FS_Namespace *namespace,
1774 * Stop an upload. Will abort incomplete uploads (but
1775 * not remove blocks that have already been publishd) or
1776 * simply clean up the state for completed uploads.
1778 * @param sc context for the upload to stop
1781 GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *sc);
1785 * Type of a function called by "GNUNET_FS_get_indexed_files".
1787 * @param cls closure
1788 * @param filename the name of the file
1789 * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
1791 typedef int (*GNUNET_FS_IndexedFileProcessor) (void *cls,
1792 const char *filename);
1796 * Iterate over all indexed files.
1798 * @param h handle to the file sharing subsystem
1799 * @param iterator function to call on each indexed file
1800 * @param iterator_cls closure for iterator
1803 GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
1804 GNUNET_FS_IndexedFileProcessor iterator,
1805 void *iterator_cls);
1811 * @param h handle to the file sharing subsystem
1812 * @param filename file to unindex
1813 * @return NULL on error, otherwise handle
1815 struct GNUNET_FS_UnindexContext *
1816 GNUNET_FS_unindex (struct GNUNET_FS_Handle *h,
1817 const char *filename);
1821 * Clean up after completion of an unindex operation.
1826 GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc);
1830 * Publish an advertismement for a namespace.
1832 * @param h handle to the file sharing subsystem
1833 * @param namespace handle for the namespace that should be advertised
1834 * @param meta meta-data for the namespace advertisement
1835 * @param anonymity for the namespace advertismement
1836 * @param priority for the namespace advertisement
1837 * @param expiration for the namespace advertisement
1838 * @param advertisementURI the keyword (!) URI to advertise the
1839 * namespace under (we will create a GNUNET_EC_KNBlock)
1840 * @param rootEntry name of the root entry in the namespace (for
1841 * the namespace advertisement)
1843 * @return uri of the advertisement
1845 struct GNUNET_FS_Uri *
1846 GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
1847 struct GNUNET_FS_Namespace *namespace,
1848 const struct GNUNET_MetaData *meta,
1849 unsigned int anonymity,
1850 unsigned int priority,
1851 struct GNUNET_TIME_Absolute expiration,
1852 const struct GNUNET_FS_Uri *advertisementURI,
1853 const char *rootEntry);
1857 * Create a namespace with the given name; if one already
1858 * exists, return a handle to the existing namespace.
1860 * @param h handle to the file sharing subsystem
1861 * @param name name to use for the namespace
1862 * @return handle to the namespace, NULL on error
1864 struct GNUNET_FS_Namespace *
1865 GNUNET_FS_namespace_create (struct GNUNET_FS_Handle *h,
1870 * Delete a namespace handle. Can be used for a clean shutdown (free
1871 * memory) or also to freeze the namespace to prevent further
1872 * insertions by anyone.
1874 * @param namespace handle to the namespace that should be deleted / freed
1875 * @param freeze prevents future insertions; creating a namespace
1876 * with the same name again will create a fresh namespace instead
1878 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1881 GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *namespace,
1886 * Callback with information about local (!) namespaces.
1887 * Contains the names of the local namespace and the global
1890 * @param cls closure
1891 * @param name human-readable identifier of the namespace
1892 * @param id hash identifier for the namespace
1894 typedef void (*GNUNET_FS_NamespaceInfoProcessor) (void *cls,
1896 const GNUNET_HashCode *id);
1900 * Build a list of all available local (!) namespaces The returned
1901 * names are only the nicknames since we only iterate over the local
1904 * @param h handle to the file sharing subsystem
1905 * @param cb function to call on each known namespace
1906 * @param cb_cls closure for cb
1909 GNUNET_FS_namespace_list (struct GNUNET_FS_Handle *h,
1910 GNUNET_FS_NamespaceInfoProcessor cb,
1915 * Function called on updateable identifiers.
1917 * @param cls closure
1918 * @param last_id last identifier
1919 * @param last_uri uri used for the content published under the last_id
1920 * @param last_meta metadata associated with last_uri
1921 * @param next_id identifier that should be used for updates
1924 (*GNUNET_FS_IdentifierProcessor)(void *cls,
1925 const char *last_id,
1926 const struct GNUNET_FS_Uri *last_uri,
1927 const struct GNUNET_CONTAINER_MetaData *last_meta,
1928 const char *next_id);
1932 * List all of the identifiers in the namespace for
1933 * which we could produce an update.
1935 * @param namespace namespace to inspect for updateable content
1936 * @param ip function to call on each updateable identifier
1937 * @param ip_cls closure for ip
1940 GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1941 GNUNET_FS_IdentifierProcessor ip,
1946 * Start search for content.
1948 * @param h handle to the file sharing subsystem
1949 * @param uri specifies the search parameters; can be
1950 * a KSK URI or an SKS URI.
1951 * @param anonymity desired level of anonymity
1952 * @return context that can be used to control the search
1954 struct GNUNET_FS_SearchContext *
1955 GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
1956 const struct GNUNET_FS_Uri *uri,
1957 unsigned int anonymity);
1963 * @param sc context for the search that should be paused
1966 GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc);
1970 * Continue paused search.
1972 * @param sc context for the search that should be resumed
1975 GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc);
1979 * Stop search for content.
1981 * @param sc context for the search that should be stopped
1984 GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc);
1988 * Download parts of a file. Note that this will store
1989 * the blocks at the respective offset in the given file. Also, the
1990 * download is still using the blocking of the underlying FS
1991 * encoding. As a result, the download may *write* outside of the
1992 * given boundaries (if offset and length do not match the 32k FS
1993 * block boundaries). <p>
1995 * This function should be used to focus a download towards a
1996 * particular portion of the file (optimization), not to strictly
1997 * limit the download to exactly those bytes.
1999 * @param h handle to the file sharing subsystem
2000 * @param uri the URI of the file (determines what to download); CHK or LOC URI
2001 * @param filename where to store the file, maybe NULL (then no file is
2002 * created on disk and data must be grabbed from the callbacks)
2003 * @param offset at what offset should we start the download (typically 0)
2004 * @param length how many bytes should be downloaded starting at offset
2005 * @param anonymity anonymity level to use for the download
2006 * @param no_temporaries set to GNUNET_YES to disallow generation of temporary files
2007 * @param recursive should this be a recursive download (useful for directories
2008 * to automatically trigger download of files in the directories)
2009 * @param parent parent download to associate this download with (use NULL
2010 * for top-level downloads; useful for manually-triggered recursive downloads)
2011 * @return context that can be used to control this download
2013 struct GNUNET_FS_DownloadContext *
2014 GNUNET_FS_file_download_start (struct GNUNET_FS_Handle *h,
2015 const struct GNUNET_FS_Uri *uri,
2016 const char *filename,
2017 unsigned long long offset,
2018 unsigned long long length,
2019 unsigned int anonymity,
2022 struct GNUNET_FS_DownloadContext *parent);
2026 * Stop a download (aborts if download is incomplete).
2028 * @param rm handle for the download
2029 * @param do_delete delete files of incomplete downloads
2032 GNUNET_FS_file_download_stop (struct GNUNET_FS_DownloadContext *rm,
2037 * Initialize collection.
2039 * @param h handle to the file sharing subsystem
2040 * @param namespace namespace to use for the collection
2041 * @return GNUNET_OK on success, GNUNET_SYSERR if another
2042 * namespace is already set for our collection
2045 GNUNET_FS_collection_start (struct GNUNET_FS_Handle *h,
2046 struct GNUNET_FS_Namespace *namespace);
2052 * @param h handle to the file sharing subsystem
2053 * @return GNUNET_OK on success, GNUNET_SYSERR if no collection is active
2056 GNUNET_FS_collection_stop (struct GNUNET_FS_Handle *h);
2060 * Are we using a collection?
2062 * @param h handle to the file sharing subsystem
2063 * @return NULL if there is no collection,
2065 struct GNUNET_FS_Namespace *
2066 GNUNET_FS_collection_get(struct GNUNET_FS_Handle *h);
2070 * Publish an update of the current collection information to the
2071 * network now. The function has no effect if the collection has not
2072 * changed since the last publication. If we are currently not
2073 * collecting, this function does nothing.
2075 * @param h handle to the file sharing subsystem
2077 void GNUNET_FS_collection_publish (struct GNUNET_FS_Handle *h);
2081 * If we are currently building a collection, publish the given file
2082 * information in that collection. If we are currently not
2083 * collecting, this function does nothing.
2085 * @param h handle to the file sharing subsystem
2086 * @param uri uri to add to the collection
2087 * @param meta metadata for the uri
2089 void GNUNET_FS_collection_add (const struct GNUNET_FS_Handle *h,
2090 const struct GNUNET_FS_Uri *uri,
2091 const struct GNUNET_CONTAINER_MetaData *meta);
2097 /* ******************** Directory API *********************** */
2100 #define GNUNET_FS_DIRECTORY_MIME "application/gnunet-directory"
2101 #define GNUNET_FS_DIRECTORY_MAGIC "\211GND\r\n\032\n"
2102 #define GNUNET_FS_DIRECTORY_EXT ".gnd"
2105 * Does the meta-data claim that this is a directory?
2106 * Checks if the mime-type is that of a GNUnet directory.
2108 * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if
2109 * we have no mime-type information (treat as 'GNUNET_NO')
2112 GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData *md);
2116 * Set the MIMETYPE information for the given
2117 * metadata to "application/gnunet-directory".
2119 * @param md metadata to add mimetype to
2122 GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md);
2126 * Function used to process entries in a directory.
2128 * @param cls closure
2129 * @param filename name of the file in the directory
2130 * @param uri URI of the file
2131 * @param metadata metadata for the file; metadata for
2132 * the directory if everything else is NULL/zero
2133 * @param length length of the available data for the file
2134 * (of type size_t since data must certainly fit
2135 * into memory; if files are larger than size_t
2136 * permits, then they will certainly not be
2137 * embedded with the directory itself).
2138 * @param data data available for the file (length bytes)
2140 typedef void (*GNUNET_FS_DirectoryEntryProcessor)(void *cls,
2141 const char *filename,
2142 const struct GNUNET_FS_Uri *uri,
2143 const struct GNUNET_CONTAINER_MetaData *meta,
2149 * Iterate over all entries in a directory. Note that directories
2150 * are structured such that it is possible to iterate over the
2151 * individual blocks as well as over the entire directory. Thus
2152 * a client can call this function on the buffer in the
2153 * GNUNET_FS_ProgressCallback. Also, directories can optionally
2154 * include the contents of (small) files embedded in the directory
2155 * itself; for those files, the processor may be given the
2156 * contents of the file directly by this function.
2158 * @param size number of bytes in data
2159 * @param data pointer to the beginning of the directory
2160 * @param offset offset of data in the directory
2161 * @param dep function to call on each entry
2162 * @param dep_cls closure for dep
2165 GNUNET_FS_directory_list_contents (size_t size,
2168 GNUNET_FS_DirectoryEntryProcessor dep,
2172 #if 0 /* keep Emacsens' auto-indent happy */