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_SEARCH_INFIX "ksk/"
63 #define GNUNET_FS_SUBSPACE_INFIX "sks/"
64 #define GNUNET_FS_FILE_INFIX "chk/"
65 #define GNUNET_FS_LOCATION_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 * @return an FS URI for the given keywords, NULL
247 * if keywords is not legal (i.e. empty).
249 struct GNUNET_FS_Uri *
250 GNUNET_FS_uri_ksk_create (const char *keywords);
254 * Create an FS URI from a user-supplied command line of keywords.
255 * Arguments should start with "+" to indicate mandatory
258 * @param argc number of keywords
259 * @param argv keywords (double quotes are not required for
260 * keywords containing spaces; however, double
261 * quotes are required for keywords starting with
262 * "+"); there is no mechanism for having double
263 * quotes in the actual keywords (if the user
264 * did specifically specify double quotes, the
265 * caller should convert each double quote
266 * into two single quotes).
267 * @return an FS URI for the given keywords, NULL
268 * if keywords is not legal (i.e. empty).
270 struct GNUNET_FS_Uri *
271 GNUNET_FS_uri_ksk_create_from_args (unsigned int argc,
276 * Test if two URIs are equal.
278 * @param u1 one of the URIs
279 * @param u2 the other URI
280 * @return GNUNET_YES if the URIs are equal
283 GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
284 const struct GNUNET_FS_Uri *u2);
288 * Is this a namespace URI?
290 * @param uri the uri to check
291 * @return GNUNET_YES if this is an SKS uri
294 GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri);
298 * Get the ID of a namespace from the given
301 * @param uri the uri to get the namespace ID from
302 * @param nsid where to store the ID of the namespace
303 * @return GNUNET_OK on success
306 GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri,
307 GNUNET_HashCode * nsid);
311 * Get the content identifier of an SKS URI.
313 * @param uri the sks uri
314 * @return NULL on error (not a valid SKS URI)
317 GNUNET_FS_uri_sks_get_content_id (const struct GNUNET_FS_Uri *uri);
321 * Convert namespace URI to a human readable format
322 * (using the namespace description, if available).
324 * @param cfg configuration to use
325 * @param uri SKS uri to convert
326 * @return NULL on error (not an SKS URI)
329 GNUNET_FS_uri_sks_to_string_fancy (struct GNUNET_CONFIGURATION_Handle *cfg,
330 const struct GNUNET_FS_Uri *uri);
334 * Is this a keyword URI?
337 * @return GNUNET_YES if this is a KSK uri
340 GNUNET_FS_uri_test_ksk (const struct GNUNET_FS_Uri *uri);
344 * Is this a file (or directory) URI?
346 * @param uri the uri to check
347 * @return GNUNET_YES if this is a CHK uri
350 GNUNET_FS_uri_test_chk (const struct GNUNET_FS_Uri *uri);
354 * What is the size of the file that this URI
357 * @param uri the CHK URI to inspect
358 * @return size of the file as specified in the CHK URI
361 GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri *uri);
365 * Is this a location URI?
367 * @param uri the uri to check
368 * @return GNUNET_YES if this is a LOC uri
371 GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri);
375 * Construct a keyword-URI from meta-data (take all entries
376 * in the meta-data and construct one large keyword URI
377 * that lists all keywords that can be found in the meta-data).
380 struct GNUNET_FS_Uri *
381 GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_MetaData *md);
384 /* ******************** command-line option parsing API *********************** */
387 * Command-line option parser function that allows the user
388 * to specify one or more '-k' options with keywords. Each
389 * specified keyword will be added to the URI. A pointer to
390 * the URI must be passed as the "scls" argument.
392 * @param ctx command line processor context
393 * @param scls must be of type "struct GNUNET_FS_Uri **"
394 * @param option name of the option (typically 'k')
395 * @param value command line argument given
396 * @return GNUNET_OK on success
399 GNUNET_FS_getopt_configure_set_keywords (GNUNET_GETOPT_CommandLineProcessorContext* ctx,
406 * Command-line option parser function that allows the user to specify
407 * one or more '-m' options with metadata. Each specified entry of
408 * the form "type=value" will be added to the metadata. A pointer to
409 * the metadata must be passed as the "scls" argument.
411 * @param ctx command line processor context
412 * @param scls must be of type "struct GNUNET_MetaData **"
413 * @param option name of the option (typically 'k')
414 * @param value command line argument given
415 * @return GNUNET_OK on success
418 GNUNET_FS_getopt_configure_set_metadata (GNUNET_GETOPT_CommandLineProcessorContext* ctx,
425 /* ************************* sharing API ***************** */
429 * Possible status codes used in the callback for the
430 * various file-sharing operations. On each file (or search),
431 * the callback is guaranteed to be called once with "START"
432 * and once with STOPPED; calls with PROGRESS, ERROR or COMPLETED
433 * are optional and depend on the circumstances; parent operations
434 * will be STARTED before child-operations and STOPPED after
435 * their respective child-operations. START and STOP signals
436 * are typically generated either due to explicit client requests
437 * or because of suspend/resume operations.
439 enum GNUNET_FS_Status
442 * Notification that we have started to share a file structure.
444 GNUNET_FS_STATUS_SHARE_START,
447 * Notification that we have resumed sharing a file structure.
449 GNUNET_FS_STATUS_SHARE_RESUME,
452 * Notification that we have suspended sharing a file structure.
454 GNUNET_FS_STATUS_SHARE_SUSPEND,
457 * Notification that we are making progress sharing a file structure.
459 GNUNET_FS_STATUS_SHARE_PROGRESS,
462 * Notification that an error was encountered sharing a file structure.
463 * The application will continue to receive resume/suspend events for
464 * this structure until "GNUNET_FS_share_stop" is called.
466 GNUNET_FS_STATUS_SHARE_ERROR,
469 * Notification that we completed sharing a file structure.
470 * The application will continue to receive resume/suspend events for
471 * this structure until "GNUNET_FS_share_stop" is called.
473 GNUNET_FS_STATUS_SHARE_COMPLETED,
476 * Notification that we have stopped
477 * the process of uploading a file structure; no
478 * futher events will be generated for this action.
480 GNUNET_FS_STATUS_SHARE_STOPPED,
483 * Notification that we have started this download.
485 GNUNET_FS_STATUS_DOWNLOAD_START,
488 * Notification that this download is being resumed.
490 GNUNET_FS_STATUS_DOWNLOAD_RESUME,
493 * Notification that this download was suspended.
495 GNUNET_FS_STATUS_DOWNLOAD_SUSPEND,
498 * Notification about progress with this download.
500 GNUNET_FS_STATUS_DOWNLOAD_PROGRESS,
503 * Notification that this download encountered an error.
505 GNUNET_FS_STATUS_DOWNLOAD_ERROR,
508 * Notification that this download completed. Note that for
509 * directories, completion does not imply completion of all files in
512 GNUNET_FS_STATUS_DOWNLOAD_COMPLETED,
515 * Notification that this download was stopped
516 * (final event with respect to this action).
518 GNUNET_FS_STATUS_DOWNLOAD_STOPPED,
521 * First event generated when a client requests
522 * a search to begin or when a namespace result
523 * automatically triggers the search for updates.
525 GNUNET_FS_STATUS_SEARCH_START,
528 * Last event when a search is being resumed;
529 * note that "GNUNET_FS_SEARCH_START" will not
530 * be generated in this case.
532 GNUNET_FS_STATUS_SEARCH_RESUME,
535 * Event generated for each search result
536 * when the respective search is resumed.
538 GNUNET_FS_STATUS_SEARCH_RESUME_RESULT,
541 * Last event when a search is being suspended;
542 * note that "GNUNET_FS_SEARCH_STOPPED" will not
543 * be generated in this case.
545 GNUNET_FS_STATUS_SEARCH_SUSPEND,
548 * Event generated for each search result
549 * when the respective search is suspended.
551 GNUNET_FS_STATUS_SEARCH_SUSPEND_RESULT,
554 * This search has yielded a result.
556 GNUNET_FS_STATUS_SEARCH_RESULT,
559 * We have discovered a new namespace.
561 GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE,
564 * We have additional data about the quality
565 * or availability of a search result.
567 GNUNET_FS_STATUS_SEARCH_UPDATE,
570 * Signals a problem with this search.
572 GNUNET_FS_STATUS_SEARCH_ERROR,
575 * Signals that this search was paused.
577 GNUNET_FS_STATUS_SEARCH_PAUSED,
580 * Signals that this search was continued (unpaused).
582 GNUNET_FS_STATUS_SEARCH_CONTINUED,
585 * Event generated for each search result
586 * when the respective search is stopped.
588 GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED,
591 * Last message from a search; this signals
592 * that there will be no further events associated
595 GNUNET_FS_STATUS_SEARCH_STOPPED,
598 * Notification that we started to unindex a file.
600 GNUNET_FS_STATUS_UNINDEX_START,
603 * Notification that we resumed unindexing of a file.
605 GNUNET_FS_STATUS_UNINDEX_RESUME,
608 * Notification that we suspended unindexing a file.
610 GNUNET_FS_STATUS_UNINDEX_SUSPEND,
613 * Notification that we made progress unindexing a file.
615 GNUNET_FS_STATUS_UNINDEX_PROGRESS,
618 * Notification that we encountered an error unindexing
621 GNUNET_FS_STATUS_UNINDEX_ERROR,
624 * Notification that the unindexing of this file
625 * was stopped (final event for this action).
627 GNUNET_FS_STATUS_UNINDEX_STOPPED
633 * Notification of FS to a client about the progress of an
634 * operation. Callbacks of this type will be used for uploads,
635 * downloads and searches. Some of the arguments depend a bit
636 * in their meaning on the context in which the callback is used.
639 * @param info details about the event, specifying the event type
640 * and various bits about the event
641 * @return client-context (for the next progress call
642 * for this operation; should be set to NULL for
643 * SUSPEND and STOPPED events). The value returned
644 * will be passed to future callbacks in the respective
645 * field in the GNUNET_FS_ProgressInfo struct.
647 typedef int (*GNUNET_FS_ProgressCallback)
649 const struct GNUNET_FS_ProgressInfo *info);
653 * Handle to one of our namespaces.
655 struct GNUNET_FS_Namespace;
659 * Handle for controlling an upload.
661 struct GNUNET_FS_ShareContext;
665 * Handle for controlling an unindexing operation.
667 struct GNUNET_FS_UnindexContext;
671 * Handle for controlling a search.
673 struct GNUNET_FS_SearchContext;
677 * Context for controlling a download.
679 struct GNUNET_FS_DownloadContext;
683 * Handle for detail information about a file that is being shared.
684 * Specifies metadata, keywords, how to get the contents of the file
685 * (i.e. data-buffer in memory, filename on disk) and other options.
687 struct GNUNET_FS_FileInformation;
691 * Argument given to the progress callback with
692 * information about what is going on.
694 struct GNUNET_FS_ProgressInfo
698 * Values that depend on the event type.
703 * Values for all "GNUNET_FS_STATUS_SHARE_*" events.
708 * Context for controlling the upload.
710 struct GNUNET_FS_ShareContext *sc;
713 * Information about the file that is being shared.
715 const struct GNUNET_FS_FileInformation *fi;
718 * Client context pointer (set the last time
719 * by the client for this operation; initially
720 * NULL on START/RESUME events).
725 * Client context pointer for the parent operation
726 * (if this is a file in a directory or a subdirectory).
731 * How large is the file overall? For directories,
732 * this is only the size of the directory itself,
733 * not of the other files contained within the
739 * At what time do we expect to finish the upload?
740 * (will be a value in the past for completed
743 struct GNUNET_TIME_Absolute eta;
746 * How long has this upload been actively running
747 * (excludes times where the upload was suspended).
749 struct GNUNET_TIME_Relative duration;
752 * How many bytes have we completed?
757 * What anonymity level is used for this upload?
759 unsigned int anonymity;
762 * Additional values for specific events.
767 * These values are only valid for
768 * GNUNET_FS_STATUS_SHARE_PROGRESS events.
773 * Data block we just published.
778 * At what offset in the file is "data"?
783 * Length of the data block.
790 * These values are only valid for
791 * GNUNET_FS_STATUS_SHARE_RESUME events.
796 * Error message, NULL if no error was encountered so far.
803 * These values are only valid for
804 * GNUNET_FS_STATUS_SHARE_ERROR events.
809 * Error message, never NULL.
821 * Values for all "GNUNET_FS_STATUS_DOWNLOAD_*" events.
826 * Context for controlling the download.
828 struct GNUNET_FS_DownloadContext *dc;
831 * Client context pointer (set the last time
832 * by the client for this operation; initially
833 * NULL on START/RESUME events).
838 * Client context pointer for the parent operation
839 * (if this is a file in a directory or a subdirectory).
844 * URI used for this download.
846 const struct GNUNET_FS_Uri *uri;
849 * How large is the file overall? For directories,
850 * this is only the size of the directory itself,
851 * not of the other files contained within the
857 * At what time do we expect to finish the download?
858 * (will be a value in the past for completed
861 struct GNUNET_TIME_Absolute eta;
864 * How long has this download been active?
866 struct GNUNET_TIME_Relative duration;
869 * How many bytes have we completed?
874 * What anonymity level is used for this download?
876 unsigned int anonymity;
879 * Additional values for specific events.
884 * These values are only valid for
885 * GNUNET_FS_STATUS_DOWNLOAD_PROGRESS events.
890 * Data block we just obtained.
895 * At what offset in the file is "data"?
900 * Length of the data block.
905 * Amount of trust we offered to get the block.
907 unsigned int trust_offered;
912 * These values are only valid for
913 * GNUNET_FS_STATUS_DOWNLOAD_START events.
918 * Known metadata for the download.
920 const struct GNUNET_MetaData *meta;
925 * These values are only valid for
926 * GNUNET_FS_STATUS_DOWNLOAD_RESUME events.
931 * Known metadata for the download.
933 const struct GNUNET_MetaData *meta;
936 * Error message, NULL if we have not encountered any error yet.
943 * These values are only valid for
944 * GNUNET_FS_STATUS_DOWNLOAD_ERROR events.
960 * Values for all "GNUNET_FS_STATUS_SEARCH_*" events.
965 * Context for controlling the search, NULL for
966 * searches that were not explicitly triggered
967 * by the client (i.e., searches for updates in
970 struct GNUNET_FS_SearchContext *sc;
973 * Client context pointer (set the last time by the client for
974 * this operation; initially NULL on START/RESUME events). Note
975 * that this value can only be set on START/RESUME; returning
976 * non-NULL on RESULT/RESUME_RESULT will actually update the
977 * private context for "UPDATE" events.
982 * Client parent-context pointer; NULL for top-level searches,
983 * non-NULL for automatically triggered searches for updates in
989 * What query is used for this search
990 * (list of keywords or SKS identifier).
992 const struct GNUNET_FS_Uri *query;
995 * How long has this search been actively running
996 * (excludes times where the search was paused or
999 struct GNUNET_TIME_Relative duration;
1002 * What anonymity level is used for this search?
1004 unsigned int anonymity;
1007 * How much trust have we been offering for this search
1010 unsigned int trust_offered;
1013 * Additional values for specific events.
1018 * These values are only valid for
1019 * GNUNET_FS_STATUS_SEARCH_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;
1036 * These values are only valid for
1037 * GNUNET_FS_STATUS_SEARCH_RESUME_RESULT events.
1042 * Metadata for the search result.
1044 const struct GNUNET_MetaData *meta;
1047 * URI for the search result.
1049 const struct GNUNET_FS_Uri *uri;
1052 * Current availability rank (negative:
1053 * unavailable, positive: available)
1055 int availability_rank;
1058 * On how many total queries is the given
1059 * availability_rank based?
1061 unsigned int availabiliy_certainty;
1064 * Updated applicability rank (the larger,
1065 * the better the result fits the search
1068 unsigned int applicabiliy_rank;
1073 * These values are only valid for
1074 * GNUNET_FS_STATUS_SEARCH_UPDATE events.
1079 * Private context set for for this result
1080 * during the "RESULT" event.
1085 * Metadata for the search result.
1087 const struct GNUNET_MetaData *meta;
1090 * URI for the search result.
1092 const struct GNUNET_FS_Uri *uri;
1095 * Current availability rank (negative:
1096 * unavailable, positive: available)
1098 int availability_rank;
1101 * On how many total queries is the given
1102 * availability_rank based?
1104 unsigned int availabiliy_certainty;
1107 * Updated applicability rank (the larger,
1108 * the better the result fits the search
1111 unsigned int applicabiliy_rank;
1116 * These values are only valid for
1117 * GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND events.
1118 * These events are automatically triggered for
1119 * each search result before the
1120 * GNUNET_FS_STATUS_SEARCH_SUSPEND event. This
1121 * happens primarily to give the client a chance
1122 * to clean up the "cctx" (if needed).
1127 * Private context set for for this result
1128 * during the "RESULT" event.
1133 * Metadata for the search result.
1135 const struct GNUNET_MetaData *meta;
1138 * URI for the search result.
1140 const struct GNUNET_FS_Uri *uri;
1145 * These values are only valid for
1146 * GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED events.
1147 * These events are automatically triggered for
1148 * each search result before the
1149 * GNUNET_FS_STATUS_SEARCH_STOPPED event. This
1150 * happens primarily to give the client a chance
1151 * to clean up the "cctx" (if needed).
1156 * Private context set for for this result
1157 * during the "RESULT" event.
1162 * Metadata for the search result.
1164 const struct GNUNET_MetaData *meta;
1167 * URI for the search result.
1169 const struct GNUNET_FS_Uri *uri;
1174 * These values are only valid for
1175 * GNUNET_FS_STATUS_SEARCH_RESUME events.
1180 * Error message, NULL if we have not encountered any error yet.
1182 const char *message;
1185 * Is this search currently paused?
1192 * These values are only valid for
1193 * GNUNET_FS_STATUS_SEARCH_ERROR events.
1200 const char *message;
1205 * Values for all "GNUNET_FS_STATUS_RESULT_NAMESPACE" events.
1210 * Handle to the namespace (NULL if it is not a local
1213 struct GNUNET_FS_Namespace *ns;
1216 * Short, human-readable name of the namespace.
1221 * Root identifier for the namespace, can be NULL.
1226 * Metadata for the namespace.
1228 const struct GNUNET_CONTAINER_MetaData *meta;
1231 * Hash-identifier for the namespace.
1233 struct GNUNET_HashCode id;
1242 * Values for all "GNUNET_FS_STATUS_UNINDEX_*" events.
1247 * Context for controlling the unindexing.
1249 struct GNUNET_FS_UnindexContext *uc;
1252 * Client context pointer (set the last time
1253 * by the client for this operation; initially
1254 * NULL on START/RESUME events).
1259 * Name of the file that is being unindexed.
1261 const char *filename;
1264 * How large is the file overall?
1269 * At what time do we expect to finish unindexing?
1270 * (will be a value in the past for completed
1271 * unindexing opeations).
1273 struct GNUNET_TIME_Absolute eta;
1276 * How long has this upload been actively running
1277 * (excludes times where the upload was suspended).
1279 struct GNUNET_TIME_Relative duration;
1282 * How many bytes have we completed?
1287 * Additional values for specific events.
1292 * These values are only valid for
1293 * GNUNET_FS_STATUS_UNINDEX_PROGRESS events.
1298 * Data block we just unindexed.
1303 * At what offset in the file is "data"?
1308 * Length of the data block.
1315 * These values are only valid for
1316 * GNUNET_FS_STATUS_UNINDEX_RESUME events.
1321 * Error message, NULL if we have not encountered any error yet.
1323 const char *message;
1328 * These values are only valid for
1329 * GNUNET_FS_STATUS_UNINDEX_ERROR events.
1336 const char *message;
1347 * Specific status code (determines the event type).
1349 enum GNUNET_FS_Status status;
1355 * Handle to the file-sharing service.
1357 struct GNUNET_FS_Handle;
1361 * Setup a connection to the file-sharing service.
1363 * @param sched scheduler to use
1364 * @param cfg configuration to use
1365 * @param client_name unique identifier for this client
1366 * @param upcb function to call to notify about FS actions
1367 * @param upcb_cls closure for upcb
1369 struct GNUNET_FS_Handle *
1370 GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched,
1371 struct GNUNET_CONFIGURATION_Handle *cfg,
1372 const char *client_name,
1373 GNUNET_FS_ProgressCallback upcb,
1378 * Close our connection with the file-sharing service.
1379 * The callback given to GNUNET_FS_start will no longer be
1380 * called after this function returns.
1382 * @param h handle that was returned from GNUNET_FS_start
1385 GNUNET_FS_stop (struct GNUNET_FS_Handle *h);
1389 * Function called on entries in a GNUNET_FS_FileInformation share-structure.
1391 * @param cls closure
1392 * @param fi the entry in the share-structure
1393 * @param length length of the file or directory
1394 * @param meta metadata for the file or directory (can be modified)
1395 * @param uri pointer to the keywords that will be used for this entry (can be modified)
1396 * @param anonymity pointer to selected anonymity level (can be modified)
1397 * @param priority pointer to selected priority (can be modified)
1398 * @param expirationTime pointer to selected expiration time (can be modified)
1399 * @param client_info pointer to client context set upon creation (can be modified)
1400 * @return GNUNET_OK to continue, GNUNET_NO to remove
1401 * this entry from the directory, GNUNET_SYSERR
1402 * to abort the iteration
1404 typedef int (*GNUNET_FS_FileInformationProcessor)(void *cls,
1405 struct GNUNET_FS_FileInformation *fi,
1407 struct GNUNET_CONTAINER_MetaData *meta,
1408 struct GNUNET_FS_Uri **uri,
1409 unsigned int *anonymity,
1410 unsigned int *priority,
1411 struct GNUNET_TIME_Absolute *expirationTime,
1412 void **client_info);
1416 * Create an entry for a file in a share-structure.
1418 * @param filename name of the file or directory to share
1419 * @param meta metadata for the file
1420 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1421 * GNUNET_SYSERR for simulation
1422 * @param anonymity what is the desired anonymity level for sharing?
1423 * @param priority what is the priority for OUR node to
1424 * keep this file available? Use 0 for maximum anonymity and
1425 * minimum reliability...
1426 * @param expirationTime when should this content expire?
1427 * @return share structure entry for the file
1429 struct GNUNET_FS_FileInformation *
1430 GNUNET_FS_file_information_create_from_file (void *client_info,
1431 const char *filename,
1432 const struct GNUNET_CONTAINER_MetaData *meta,
1434 unsigned int anonymity,
1435 unsigned int priority,
1436 struct GNUNET_TIME_Absolute expirationTime);
1440 * Create an entry for a file in a share-structure.
1442 * @param length length of the file
1443 * @param data data for the file (should not be used afterwards by
1444 * the caller; caller will "free")
1445 * @param meta metadata for the file
1446 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1447 * GNUNET_SYSERR for simulation
1448 * @param anonymity what is the desired anonymity level for sharing?
1449 * @param priority what is the priority for OUR node to
1450 * keep this file available? Use 0 for maximum anonymity and
1451 * minimum reliability...
1452 * @param expirationTime when should this content expire?
1453 * @return share structure entry for the file
1455 struct GNUNET_FS_FileInformation *
1456 GNUNET_FS_file_information_create_from_data (void *client_info,
1459 const struct GNUNET_CONTAINER_MetaData *meta,
1461 unsigned int anonymity,
1462 unsigned int priority,
1463 struct GNUNET_TIME_Absolute expirationTime);
1467 * Function that provides data.
1469 * @param cls closure
1470 * @param offset offset to read from; it is possible
1471 * that the caller might need to go backwards
1473 * @param max maximum number of bytes that should be
1474 * copied to buf; readers are not allowed
1475 * to provide less data unless there is an error;
1476 * a value of "0" will be used at the end to allow
1477 * the reader to clean up its internal state
1478 * @param buf where the reader should write the data
1479 * @param emsg location for the reader to store an error message
1480 * @return number of bytes written, usually "max", 0 on error
1482 typedef size_t (*GNUNET_FS_DataReader)(void *cls,
1490 * Create an entry for a file in a share-structure.
1492 * @param length length of the file
1493 * @param reader function that can be used to obtain the data for the file
1494 * @param reader_cls closure for "reader"
1495 * @param keywords under which keywords should this file be available
1496 * directly; can be NULL
1497 * @param meta metadata for the file
1498 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1499 * GNUNET_SYSERR for simulation
1500 * @param anonymity what is the desired anonymity level for sharing?
1501 * @param priority what is the priority for OUR node to
1502 * keep this file available? Use 0 for maximum anonymity and
1503 * minimum reliability...
1504 * @param expirationTime when should this content expire?
1505 * @return share structure entry for the file
1507 struct GNUNET_FS_FileInformation *
1508 GNUNET_FS_file_information_create_from_reader (void *client_info,
1510 GNUNET_FS_DataReader reader,
1512 const struct GNUNET_FS_Uri *keywords,
1513 const struct GNUNET_CONTAINER_MetaData *meta,
1515 unsigned int anonymity,
1516 unsigned int priority,
1517 struct GNUNET_TIME_Absolute expirationTime);
1521 * Function that a "GNUNET_FS_DirectoryScanner" should call
1522 * for each entry in the directory.
1524 * @param cls closure
1525 * @param filename name of the file (including path); must end
1526 * in a "/" (even on W32) if this is a directory
1527 * @param fi information about the file (should not be
1528 * used henceforth by the caller)
1530 typedef void (*GNUNET_FS_FileInformationProcessor)(void *cls,
1531 const char *filename,
1532 struct GNUNET_FS_FileInformation *fi);
1536 * Type of a function that will be used to scan a directory.
1538 * @param cls closure
1539 * @param dirname name of the directory to scan
1540 * @param proc function to call on each entry
1541 * @param proc_cls closure for proc
1542 * @param emsg where to store an error message (on errors)
1543 * @return GNUNET_OK on success
1545 typedef int (*GNUNET_FS_DirectoryScanner)(void *cls,
1546 const char *dirname,
1547 GNUNET_FS_FileProcessor proc,
1554 * Simple, useful default implementation of a directory scanner
1555 * (GNUNET_FS_DirectoryScanner). This implementation expects to get a
1556 * UNIX filename, will share all files in the directory except hidden
1557 * files (those starting with a "."). Metadata will be extracted
1558 * using GNU libextractor; the specific list of plugins should be
1559 * specified in "cls", passing NULL will disable (!) metadata
1560 * extraction. Keywords will be derived from the metadata and be
1561 * subject to default canonicalization. This is strictly a
1562 * convenience function.
1564 * @param cls must be of type "struct EXTRACTOR_Extractor*"
1565 * @param dirname name of the directory to scan
1566 * @param proc function called on each entry
1567 * @param proc_cls closure for proc
1568 * @param emsg where to store an error message (on errors)
1569 * @return GNUNET_OK on success
1572 GNUNET_FS_directory_scanner_default (void *cls,
1573 const char *dirname,
1574 GNUNET_FS_FileProcessor proc,
1579 * Create a share-structure from an existing file hierarchy, inferring
1580 * and organizing keywords and metadata as much as possible. This
1581 * function primarily performs the recursive build and re-organizes
1582 * keywords and metadata; for automatically getting metadata
1583 * extraction, scanning of directories and creation of the respective
1584 * GNUNET_FS_FileInformation entries the default scanner should be
1585 * passed (GNUNET_FS_directory_scanner_default). This is strictly a
1586 * convenience function.
1588 * @param filename name of the top-level file or directory
1589 * @param scanner function used to get a list of files in a directory
1590 * @param scanner_cls closure for scanner
1591 * @param anonymity what is the desired anonymity level for sharing?
1592 * @param priority what is the priority for OUR node to
1593 * keep this file available? Use 0 for maximum anonymity and
1594 * minimum reliability...
1595 * @param expirationTime when should this content expire?
1596 * @return share structure entry for the directory, NULL on error
1598 struct GNUNET_FS_FileInformation *
1599 GNUNET_FS_file_information_create_from_directory (void *client_info,
1600 GNUNET_FS_DirectoryScanner scanner,
1602 unsigned int anonymity,
1603 unsigned int priority,
1604 struct GNUNET_TIME_Absolute expirationTime);
1608 * Create an entry for an empty directory in a share-structure.
1609 * This function should be used by applications for which the
1610 * use of "GNUNET_FS_file_information_create_from_directory"
1611 * is not appropriate.
1613 * @param meta metadata for the directory
1614 * @param keywords under which keywords should this directory be available
1615 * directly; can be NULL
1616 * @param anonymity what is the desired anonymity level for sharing?
1617 * @param priority what is the priority for OUR node to
1618 * keep this file available? Use 0 for maximum anonymity and
1619 * minimum reliability...
1620 * @param expirationTime when should this content expire?
1621 * @return share structure entry for the directory , NULL on error
1623 struct GNUNET_FS_FileInformation *
1624 GNUNET_FS_file_information_create_empty_directory (void *client_info,
1625 const struct GNUNET_CONTAINER_MetaData *meta,
1626 const struct GNUNET_FS_Uri *keywords,
1627 unsigned int anonymity,
1628 unsigned int priority,
1629 struct GNUNET_TIME_Absolute expirationTime);
1633 * Add an entry to a directory in a share-structure. Clients
1634 * should never modify share structures that were passed to
1635 * "GNUNET_FS_share_start" already.
1637 * @param dir the directory
1638 * @param end the entry to add; the entry must not have been
1639 * added to any other directory at this point and
1640 * must not include "dir" in its structure
1641 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1644 GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
1645 struct GNUNET_FS_FileInformation *end);
1649 * Inspect a file or directory in a share-structure. Clients
1650 * should never modify share structures that were passed to
1651 * "GNUNET_FS_share_start" already. When called on a directory,
1652 * this function will FIRST call "proc" with information about
1653 * the directory itself and then for each of the files in the
1654 * directory (but not for files in subdirectories). When called
1655 * on a file, "proc" will be called exactly once (with information
1656 * about the specific file).
1658 * @param dir the directory
1659 * @param proc function to call on each entry
1660 * @param proc_cls closure for proc
1663 GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
1664 struct GNUNET_FS_FileInformationProcessor proc,
1669 * Destroy share-structure. Clients should never destroy share
1670 * structures that were passed to "GNUNET_FS_share_start" already.
1672 * @param fi structure to destroy
1673 * @param cleaner function to call on each entry in the structure
1674 * (useful to clean up client_info); can be NULL; return
1675 * values are ignored
1676 * @param cleaner_cls closure for cleaner
1679 GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
1680 GNUNET_FS_FileInformationProcessor cleaner,
1685 * Share a file or directory.
1687 * @param h handle to the file sharing subsystem
1688 * @param ctx initial value to use for the '*ctx'
1689 * in the callback (for the GNUNET_FS_STATUS_SHARE_START event).
1690 * @param fi information about the file or directory structure to share
1691 * @param namespace namespace to share the file in, NULL for no namespace
1692 * @param nid identifier to use for the shared content in the namespace
1693 * (can be NULL, must be NULL if namespace is NULL)
1694 * @param nuid update-identifier that will be used for future updates
1695 * (can be NULL, must be NULL if namespace or nid is NULL)
1696 * @return context that can be used to control the share operation
1698 struct GNUNET_FS_ShareContext *
1699 GNUNET_FS_share_start (struct GNUNET_FS_Handle *h,
1701 const struct GNUNET_FS_FileInformation *fi,
1702 struct GNUNET_FS_Namespace *namespace
1708 * Stop an upload. Will abort incomplete uploads (but
1709 * not remove blocks that have already been shared) or
1710 * simply clean up the state for completed uploads.
1712 * @param sc context for the upload to stop
1715 GNUNET_FS_share_stop (struct GNUNET_FS_ShareContext *sc);
1719 * Type of a function called by "GNUNET_FS_get_indexed_files".
1721 * @param cls closure
1722 * @param filename the name of the file
1723 * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
1725 typedef int (*GNUNET_FS_FileProcessor) (void *cls,
1726 const char *filename);
1730 * Iterate over all indexed files.
1732 * @param h handle to the file sharing subsystem
1733 * @param iterator function to call on each indexed file
1734 * @param iterator_cls closure for iterator
1737 GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
1738 GNUNET_FS_FileProcessor iterator,
1739 void *iterator_cls);
1745 * @param h handle to the file sharing subsystem
1746 * @param filename file to unindex
1747 * @return NULL on error, otherwise handle
1749 struct GNUNET_FS_UnindexContext *
1750 GNUNET_FS_unindex (struct GNUNET_FS_Handle *h,
1751 const char *filename);
1755 * Clean up after completion of an unindex operation.
1760 GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc);
1764 * Publish an advertismement for a namespace.
1766 * @param h handle to the file sharing subsystem
1767 * @param namespace handle for the namespace that should be advertised
1768 * @param meta meta-data for the namespace advertisement
1769 * @param anonymity for the namespace advertismement
1770 * @param priority for the namespace advertisement
1771 * @param expiration for the namespace advertisement
1772 * @param advertisementURI the keyword (!) URI to advertise the
1773 * namespace under (we will create a GNUNET_EC_KNBlock)
1774 * @param rootEntry name of the root entry in the namespace (for
1775 * the namespace advertisement)
1777 * @return uri of the advertisement
1779 struct GNUNET_FS_Uri *
1780 GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
1781 struct GNUNET_FS_Namespace *namespace,
1782 const struct GNUNET_MetaData *meta,
1783 unsigned int anonymity,
1784 unsigned int priority,
1785 struct GNUNET_TIME_Absolute expiration,
1786 const struct GNUNET_FS_Uri *advertisementURI,
1787 const char *rootEntry);
1791 * Create a namespace with the given name; if one already
1792 * exists, return a handle to the existing namespace.
1794 * @param h handle to the file sharing subsystem
1795 * @param name name to use for the namespace
1796 * @return handle to the namespace, NULL on error
1798 struct GNUNET_FS_Namespace *
1799 GNUNET_FS_namespace_create (struct GNUNET_FS_Handle *h,
1804 * Delete a namespace handle. Can be used for a clean shutdown (free
1805 * memory) or also to freeze the namespace to prevent further
1806 * insertions by anyone.
1808 * @param namespace handle to the namespace that should be deleted / freed
1809 * @param freeze prevents future insertions; creating a namespace
1810 * with the same name again will create a fresh namespace instead
1812 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1815 GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *namespace,
1820 * Callback with information about local (!) namespaces.
1821 * Contains the names of the local namespace and the global
1824 * @param cls closure
1825 * @param name human-readable identifier of the namespace
1826 * @param id hash identifier for the namespace
1828 typedef void (*GNUNET_FS_NamespaceInfoProcessor) (void *cls,
1830 const GNUNET_HashCode *id);
1834 * Build a list of all available local (!) namespaces The returned
1835 * names are only the nicknames since we only iterate over the local
1838 * @param h handle to the file sharing subsystem
1839 * @param cb function to call on each known namespace
1840 * @param cb_cls closure for cb
1841 * @return GNUNET_SYSERR on error, otherwise the number of pseudonyms in list
1844 GNUNET_FS_namespace_list (struct GNUNET_FS_Handle *h,
1845 GNUNET_FS_NamespaceProcessor cb,
1850 * Function called on updateable identifiers.
1852 * @param cls closure
1853 * @param last_id last identifier
1854 * @param last_uri uri used for the content published under the last_id
1855 * @param last_meta metadata associated with last_uri
1856 * @param next_id identifier that should be used for updates
1859 (*GNUNET_FS_IdentifierProcessor)(void *cls,
1860 const char *last_id,
1861 const struct GNUNET_FS_Uri *last_uri,
1862 const struct GNUNET_CONTAINER_MetaData *last_meta,
1863 const char *next_id);
1867 * List all of the identifiers in the namespace for
1868 * which we could produce an update.
1870 * @param namespace namespace to inspect for updateable content
1871 * @param ip function to call on each updateable identifier
1872 * @param ip_cls closure for ip
1875 GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1876 GNUNET_FS_IdentifierProcessor ip,
1881 * Start search for content.
1883 * @param h handle to the file sharing subsystem
1884 * @param uri specifies the search parameters; can be
1885 * a KSK URI or an SKS URI.
1886 * @param anonymity desired level of anonymity
1887 * @return context that can be used to control the search
1889 struct GNUNET_FS_SearchContext *
1890 GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
1891 const struct GNUNET_FS_Uri *uri,
1892 unsigned int anonymity);
1898 * @param sc context for the search that should be paused
1901 GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc);
1905 * Continue paused search.
1907 * @param sc context for the search that should be resumed
1910 GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc);
1914 * Stop search for content.
1916 * @param sc context for the search that should be stopped
1919 GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc);
1923 * Download parts of a file. Note that this will store
1924 * the blocks at the respective offset in the given file. Also, the
1925 * download is still using the blocking of the underlying FS
1926 * encoding. As a result, the download may *write* outside of the
1927 * given boundaries (if offset and length do not match the 32k FS
1928 * block boundaries). <p>
1930 * This function should be used to focus a download towards a
1931 * particular portion of the file (optimization), not to strictly
1932 * limit the download to exactly those bytes.
1934 * @param h handle to the file sharing subsystem
1935 * @param uri the URI of the file (determines what to download); CHK or LOC URI
1936 * @param filename where to store the file, maybe NULL (then no file is
1937 * created on disk and data must be grabbed from the callbacks)
1938 * @param offset at what offset should we start the download (typically 0)
1939 * @param length how many bytes should be downloaded starting at offset
1940 * @param anonymity anonymity level to use for the download
1941 * @param no_temporaries set to GNUNET_YES to disallow generation of temporary files
1942 * @param recursive should this be a recursive download (useful for directories
1943 * to automatically trigger download of files in the directories)
1944 * @param parent parent download to associate this download with (use NULL
1945 * for top-level downloads; useful for manually-triggered recursive downloads)
1946 * @return context that can be used to control this download
1948 struct GNUNET_FS_DownloadContext *
1949 GNUNET_FS_file_download_start (struct GNUNET_FS_Handle *h,
1950 const struct GNUNET_FS_Uri *uri,
1951 const char *filename,
1952 unsigned long long offset,
1953 unsigned long long length,
1954 unsigned int anonymity,
1957 struct GNUNET_FS_DownloadContext *parent);
1961 * Stop a download (aborts if download is incomplete).
1963 * @param rm handle for the download
1964 * @param do_delete delete files of incomplete downloads
1967 GNUNET_FS_file_download_stop (struct GNUNET_FS_DownloadContext *rm,
1972 * Initialize collection.
1974 * @param h handle to the file sharing subsystem
1975 * @param namespace namespace to use for the collection
1976 * @return GNUNET_OK on success, GNUNET_SYSERR if another
1977 * namespace is already set for our collection
1980 GNUNET_FS_collection_start (struct GNUNET_FS_Handle *h,
1981 struct GNUNET_FS_Namespace *namespace);
1987 * @param h handle to the file sharing subsystem
1988 * @return GNUNET_OK on success, GNUNET_SYSERR if no collection is active
1991 GNUNET_FS_collection_stop (struct GNUNET_FS_Handle *h);
1995 * Are we using a collection?
1997 * @param h handle to the file sharing subsystem
1998 * @return NULL if there is no collection,
2000 struct GNUNET_FS_Namespace *
2001 GNUNET_FS_collection_get(struct GNUNET_FS_Handle *h);
2005 * Publish an update of the current collection information to the
2006 * network now. The function has no effect if the collection has not
2007 * changed since the last publication. If we are currently not
2008 * collecting, this function does nothing.
2010 * @param h handle to the file sharing subsystem
2012 void GNUNET_FS_collection_publish (struct GNUNET_FS_Handle *h);
2016 * If we are currently building a collection, publish the given file
2017 * information in that collection. If we are currently not
2018 * collecting, this function does nothing.
2020 * @param h handle to the file sharing subsystem
2021 * @param uri uri to add to the collection
2022 * @param meta metadata for the uri
2024 void GNUNET_FS_collection_add (const struct GNUNET_FS_Handle *h,
2025 const struct GNUNET_FS_Uri *uri,
2026 const struct GNUNET_CONTAINER_MetaData *meta);
2032 /* ******************** Directory API *********************** */
2035 #define GNUNET_DIRECTORY_MIME "application/gnunet-directory"
2036 #define GNUNET_DIRECTORY_MAGIC "\211GND\r\n\032\n"
2037 #define GNUNET_DIRECTORY_EXT ".gnd"
2040 * Does the meta-data claim that this is a directory?
2041 * Checks if the mime-type is that of a GNUnet directory.
2043 * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if
2044 * we have no mime-type information (treat as 'GNUNET_NO')
2047 GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData *md);
2051 * Set the MIMETYPE information for the given
2052 * metadata to "application/gnunet-directory".
2054 * @param md metadata to add mimetype to
2057 GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md);
2061 * Function used to process entries in a directory.
2063 * @param cls closure
2064 * @param filename name of the file in the directory
2065 * @param uri URI of the file
2066 * @param metadata metadata for the file
2067 * @param length length of the available data for the file
2068 * (of type size_t since data must certainly fit
2069 * into memory; if files are larger than size_t
2070 * permits, then they will certainly not be
2071 * embedded with the directory itself).
2072 * @param data data available for the file (length bytes)
2074 typedef void (*GNUNET_FS_DirectoryEntryProcessor)(void *cls,
2075 const char *filename,
2076 const struct GNUNET_FS_Uri *uri,
2077 const struct GNUNET_FS_MetaData *meta,
2083 * Iterate over all entries in a directory. Note that directories
2084 * are structured such that it is possible to iterate over the
2085 * individual blocks as well as over the entire directory. Thus
2086 * a client can call this function on the buffer in the
2087 * GNUNET_FS_ProgressCallback. Also, directories can optionally
2088 * include the contents of (small) files embedded in the directory
2089 * itself; for those files, the processor may be given the
2090 * contents of the file directly by this function.
2092 * @param size number of bytes in data
2093 * @param data pointer to the beginning of the directory
2094 * @param offset offset of data in the directory
2095 * @param dep function to call on each entry
2096 * @param dep_cls closure for spcb
2099 GNUNET_FS_directory_list_contents (size_t size,
2102 GNUNET_FS_DirectoryEntryProcessor dep,
2106 #if 0 /* keep Emacsens' auto-indent happy */