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 * Create an entry for a file in a publish-structure.
1420 * @param filename name of the file or directory to publish
1421 * @param meta metadata for the file
1422 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1423 * GNUNET_SYSERR for simulation
1424 * @param anonymity what is the desired anonymity level for sharing?
1425 * @param priority what is the priority for OUR node to
1426 * keep this file available? Use 0 for maximum anonymity and
1427 * minimum reliability...
1428 * @param expirationTime when should this content expire?
1429 * @return publish structure entry for the file
1431 struct GNUNET_FS_FileInformation *
1432 GNUNET_FS_file_information_create_from_file (void *client_info,
1433 const char *filename,
1434 const struct GNUNET_CONTAINER_MetaData *meta,
1436 unsigned int anonymity,
1437 unsigned int priority,
1438 struct GNUNET_TIME_Absolute expirationTime);
1442 * Create an entry for a file in a publish-structure.
1444 * @param length length of the file
1445 * @param data data for the file (should not be used afterwards by
1446 * the caller; caller will "free")
1447 * @param meta metadata for the file
1448 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1449 * GNUNET_SYSERR for simulation
1450 * @param anonymity what is the desired anonymity level for sharing?
1451 * @param priority what is the priority for OUR node to
1452 * keep this file available? Use 0 for maximum anonymity and
1453 * minimum reliability...
1454 * @param expirationTime when should this content expire?
1455 * @return publish structure entry for the file
1457 struct GNUNET_FS_FileInformation *
1458 GNUNET_FS_file_information_create_from_data (void *client_info,
1461 const struct GNUNET_CONTAINER_MetaData *meta,
1463 unsigned int anonymity,
1464 unsigned int priority,
1465 struct GNUNET_TIME_Absolute expirationTime);
1469 * Function that provides data.
1471 * @param cls closure
1472 * @param offset offset to read from; it is possible
1473 * that the caller might need to go backwards
1475 * @param max maximum number of bytes that should be
1476 * copied to buf; readers are not allowed
1477 * to provide less data unless there is an error;
1478 * a value of "0" will be used at the end to allow
1479 * the reader to clean up its internal state
1480 * @param buf where the reader should write the data
1481 * @param emsg location for the reader to store an error message
1482 * @return number of bytes written, usually "max", 0 on error
1484 typedef size_t (*GNUNET_FS_DataReader)(void *cls,
1492 * Create an entry for a file in a publish-structure.
1494 * @param length length of the file
1495 * @param reader function that can be used to obtain the data for the file
1496 * @param reader_cls closure for "reader"
1497 * @param keywords under which keywords should this file be available
1498 * directly; can be NULL
1499 * @param meta metadata for the file
1500 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1501 * GNUNET_SYSERR for simulation
1502 * @param anonymity what is the desired anonymity level for sharing?
1503 * @param priority what is the priority for OUR node to
1504 * keep this file available? Use 0 for maximum anonymity and
1505 * minimum reliability...
1506 * @param expirationTime when should this content expire?
1507 * @return publish structure entry for the file
1509 struct GNUNET_FS_FileInformation *
1510 GNUNET_FS_file_information_create_from_reader (void *client_info,
1512 GNUNET_FS_DataReader reader,
1514 const struct GNUNET_FS_Uri *keywords,
1515 const struct GNUNET_CONTAINER_MetaData *meta,
1517 unsigned int anonymity,
1518 unsigned int priority,
1519 struct GNUNET_TIME_Absolute expirationTime);
1523 * Function that a "GNUNET_FS_DirectoryScanner" should call
1524 * for each entry in the directory.
1526 * @param cls closure
1527 * @param filename name of the file (including path); must end
1528 * in a "/" (even on W32) if this is a directory
1529 * @param fi information about the file (should not be
1530 * used henceforth by the caller)
1532 typedef void (*GNUNET_FS_FileProcessor)(void *cls,
1533 const char *filename,
1534 struct GNUNET_FS_FileInformation *fi);
1538 * Type of a function that will be used to scan a directory.
1540 * @param cls closure
1541 * @param dirname name of the directory to scan
1542 * @param proc function to call on each entry
1543 * @param proc_cls closure for proc
1544 * @param emsg where to store an error message (on errors)
1545 * @return GNUNET_OK on success
1547 typedef int (*GNUNET_FS_DirectoryScanner)(void *cls,
1548 const char *dirname,
1549 GNUNET_FS_FileProcessor proc,
1556 * Simple, useful default implementation of a directory scanner
1557 * (GNUNET_FS_DirectoryScanner). This implementation expects to get a
1558 * UNIX filename, will publish all files in the directory except hidden
1559 * files (those starting with a "."). Metadata will be extracted
1560 * using GNU libextractor; the specific list of plugins should be
1561 * specified in "cls", passing NULL will disable (!) metadata
1562 * extraction. Keywords will be derived from the metadata and be
1563 * subject to default canonicalization. This is strictly a
1564 * convenience function.
1566 * @param cls must be of type "struct EXTRACTOR_Extractor*"
1567 * @param dirname name of the directory to scan
1568 * @param proc function called on each entry
1569 * @param proc_cls closure for proc
1570 * @param emsg where to store an error message (on errors)
1571 * @return GNUNET_OK on success
1574 GNUNET_FS_directory_scanner_default (void *cls,
1575 const char *dirname,
1576 GNUNET_FS_FileProcessor proc,
1581 * Create a publish-structure from an existing file hierarchy, inferring
1582 * and organizing keywords and metadata as much as possible. This
1583 * function primarily performs the recursive build and re-organizes
1584 * keywords and metadata; for automatically getting metadata
1585 * extraction, scanning of directories and creation of the respective
1586 * GNUNET_FS_FileInformation entries the default scanner should be
1587 * passed (GNUNET_FS_directory_scanner_default). This is strictly a
1588 * convenience function.
1590 * @param filename name of the top-level file or directory
1591 * @param scanner function used to get a list of files in a directory
1592 * @param scanner_cls closure for scanner
1593 * @param anonymity what is the desired anonymity level for sharing?
1594 * @param priority what is the priority for OUR node to
1595 * keep this file available? Use 0 for maximum anonymity and
1596 * minimum reliability...
1597 * @param expirationTime when should this content expire?
1598 * @return publish structure entry for the directory, NULL on error
1600 struct GNUNET_FS_FileInformation *
1601 GNUNET_FS_file_information_create_from_directory (void *client_info,
1602 GNUNET_FS_DirectoryScanner scanner,
1604 unsigned int anonymity,
1605 unsigned int priority,
1606 struct GNUNET_TIME_Absolute expirationTime);
1610 * Create an entry for an empty directory in a publish-structure.
1611 * This function should be used by applications for which the
1612 * use of "GNUNET_FS_file_information_create_from_directory"
1613 * is not appropriate.
1615 * @param meta metadata for the directory
1616 * @param keywords under which keywords should this directory be available
1617 * directly; can be NULL
1618 * @param anonymity what is the desired anonymity level for sharing?
1619 * @param priority what is the priority for OUR node to
1620 * keep this file available? Use 0 for maximum anonymity and
1621 * minimum reliability...
1622 * @param expirationTime when should this content expire?
1623 * @return publish structure entry for the directory , NULL on error
1625 struct GNUNET_FS_FileInformation *
1626 GNUNET_FS_file_information_create_empty_directory (void *client_info,
1627 const struct GNUNET_CONTAINER_MetaData *meta,
1628 const struct GNUNET_FS_Uri *keywords,
1629 unsigned int anonymity,
1630 unsigned int priority,
1631 struct GNUNET_TIME_Absolute expirationTime);
1635 * Add an entry to a directory in a publish-structure. Clients
1636 * should never modify publish structures that were passed to
1637 * "GNUNET_FS_publish_start" already.
1639 * @param dir the directory
1640 * @param end the entry to add; the entry must not have been
1641 * added to any other directory at this point and
1642 * must not include "dir" in its structure
1643 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1646 GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
1647 struct GNUNET_FS_FileInformation *end);
1651 * Inspect a file or directory in a publish-structure. Clients
1652 * should never modify publish structures that were passed to
1653 * "GNUNET_FS_publish_start" already. When called on a directory,
1654 * this function will FIRST call "proc" with information about
1655 * the directory itself and then for each of the files in the
1656 * directory (but not for files in subdirectories). When called
1657 * on a file, "proc" will be called exactly once (with information
1658 * about the specific file).
1660 * @param dir the directory
1661 * @param proc function to call on each entry
1662 * @param proc_cls closure for proc
1665 GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
1666 GNUNET_FS_FileInformationProcessor proc,
1671 * Destroy publish-structure. Clients should never destroy publish
1672 * structures that were passed to "GNUNET_FS_publish_start" already.
1674 * @param fi structure to destroy
1675 * @param cleaner function to call on each entry in the structure
1676 * (useful to clean up client_info); can be NULL; return
1677 * values are ignored
1678 * @param cleaner_cls closure for cleaner
1681 GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
1682 GNUNET_FS_FileInformationProcessor cleaner,
1687 * Publish a file or directory.
1689 * @param h handle to the file sharing subsystem
1690 * @param ctx initial value to use for the '*ctx'
1691 * in the callback (for the GNUNET_FS_STATUS_PUBLISH_START event).
1692 * @param fi information about the file or directory structure to publish
1693 * @param namespace namespace to publish the file in, NULL for no namespace
1694 * @param nid identifier to use for the publishd content in the namespace
1695 * (can be NULL, must be NULL if namespace is NULL)
1696 * @param nuid update-identifier that will be used for future updates
1697 * (can be NULL, must be NULL if namespace or nid is NULL)
1698 * @return context that can be used to control the publish operation
1700 struct GNUNET_FS_PublishContext *
1701 GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1703 const struct GNUNET_FS_FileInformation *fi,
1704 struct GNUNET_FS_Namespace *namespace,
1710 * Stop an upload. Will abort incomplete uploads (but
1711 * not remove blocks that have already been publishd) or
1712 * simply clean up the state for completed uploads.
1714 * @param sc context for the upload to stop
1717 GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *sc);
1721 * Type of a function called by "GNUNET_FS_get_indexed_files".
1723 * @param cls closure
1724 * @param filename the name of the file
1725 * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
1727 typedef int (*GNUNET_FS_IndexedFileProcessor) (void *cls,
1728 const char *filename);
1732 * Iterate over all indexed files.
1734 * @param h handle to the file sharing subsystem
1735 * @param iterator function to call on each indexed file
1736 * @param iterator_cls closure for iterator
1739 GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
1740 GNUNET_FS_IndexedFileProcessor iterator,
1741 void *iterator_cls);
1747 * @param h handle to the file sharing subsystem
1748 * @param filename file to unindex
1749 * @return NULL on error, otherwise handle
1751 struct GNUNET_FS_UnindexContext *
1752 GNUNET_FS_unindex (struct GNUNET_FS_Handle *h,
1753 const char *filename);
1757 * Clean up after completion of an unindex operation.
1762 GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc);
1766 * Publish an advertismement for a namespace.
1768 * @param h handle to the file sharing subsystem
1769 * @param namespace handle for the namespace that should be advertised
1770 * @param meta meta-data for the namespace advertisement
1771 * @param anonymity for the namespace advertismement
1772 * @param priority for the namespace advertisement
1773 * @param expiration for the namespace advertisement
1774 * @param advertisementURI the keyword (!) URI to advertise the
1775 * namespace under (we will create a GNUNET_EC_KNBlock)
1776 * @param rootEntry name of the root entry in the namespace (for
1777 * the namespace advertisement)
1779 * @return uri of the advertisement
1781 struct GNUNET_FS_Uri *
1782 GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
1783 struct GNUNET_FS_Namespace *namespace,
1784 const struct GNUNET_MetaData *meta,
1785 unsigned int anonymity,
1786 unsigned int priority,
1787 struct GNUNET_TIME_Absolute expiration,
1788 const struct GNUNET_FS_Uri *advertisementURI,
1789 const char *rootEntry);
1793 * Create a namespace with the given name; if one already
1794 * exists, return a handle to the existing namespace.
1796 * @param h handle to the file sharing subsystem
1797 * @param name name to use for the namespace
1798 * @return handle to the namespace, NULL on error
1800 struct GNUNET_FS_Namespace *
1801 GNUNET_FS_namespace_create (struct GNUNET_FS_Handle *h,
1806 * Delete a namespace handle. Can be used for a clean shutdown (free
1807 * memory) or also to freeze the namespace to prevent further
1808 * insertions by anyone.
1810 * @param namespace handle to the namespace that should be deleted / freed
1811 * @param freeze prevents future insertions; creating a namespace
1812 * with the same name again will create a fresh namespace instead
1814 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1817 GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *namespace,
1822 * Callback with information about local (!) namespaces.
1823 * Contains the names of the local namespace and the global
1826 * @param cls closure
1827 * @param name human-readable identifier of the namespace
1828 * @param id hash identifier for the namespace
1830 typedef void (*GNUNET_FS_NamespaceInfoProcessor) (void *cls,
1832 const GNUNET_HashCode *id);
1836 * Build a list of all available local (!) namespaces The returned
1837 * names are only the nicknames since we only iterate over the local
1840 * @param h handle to the file sharing subsystem
1841 * @param cb function to call on each known namespace
1842 * @param cb_cls closure for cb
1845 GNUNET_FS_namespace_list (struct GNUNET_FS_Handle *h,
1846 GNUNET_FS_NamespaceInfoProcessor cb,
1851 * Function called on updateable identifiers.
1853 * @param cls closure
1854 * @param last_id last identifier
1855 * @param last_uri uri used for the content published under the last_id
1856 * @param last_meta metadata associated with last_uri
1857 * @param next_id identifier that should be used for updates
1860 (*GNUNET_FS_IdentifierProcessor)(void *cls,
1861 const char *last_id,
1862 const struct GNUNET_FS_Uri *last_uri,
1863 const struct GNUNET_CONTAINER_MetaData *last_meta,
1864 const char *next_id);
1868 * List all of the identifiers in the namespace for
1869 * which we could produce an update.
1871 * @param namespace namespace to inspect for updateable content
1872 * @param ip function to call on each updateable identifier
1873 * @param ip_cls closure for ip
1876 GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1877 GNUNET_FS_IdentifierProcessor ip,
1882 * Start search for content.
1884 * @param h handle to the file sharing subsystem
1885 * @param uri specifies the search parameters; can be
1886 * a KSK URI or an SKS URI.
1887 * @param anonymity desired level of anonymity
1888 * @return context that can be used to control the search
1890 struct GNUNET_FS_SearchContext *
1891 GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
1892 const struct GNUNET_FS_Uri *uri,
1893 unsigned int anonymity);
1899 * @param sc context for the search that should be paused
1902 GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc);
1906 * Continue paused search.
1908 * @param sc context for the search that should be resumed
1911 GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc);
1915 * Stop search for content.
1917 * @param sc context for the search that should be stopped
1920 GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc);
1924 * Download parts of a file. Note that this will store
1925 * the blocks at the respective offset in the given file. Also, the
1926 * download is still using the blocking of the underlying FS
1927 * encoding. As a result, the download may *write* outside of the
1928 * given boundaries (if offset and length do not match the 32k FS
1929 * block boundaries). <p>
1931 * This function should be used to focus a download towards a
1932 * particular portion of the file (optimization), not to strictly
1933 * limit the download to exactly those bytes.
1935 * @param h handle to the file sharing subsystem
1936 * @param uri the URI of the file (determines what to download); CHK or LOC URI
1937 * @param filename where to store the file, maybe NULL (then no file is
1938 * created on disk and data must be grabbed from the callbacks)
1939 * @param offset at what offset should we start the download (typically 0)
1940 * @param length how many bytes should be downloaded starting at offset
1941 * @param anonymity anonymity level to use for the download
1942 * @param no_temporaries set to GNUNET_YES to disallow generation of temporary files
1943 * @param recursive should this be a recursive download (useful for directories
1944 * to automatically trigger download of files in the directories)
1945 * @param parent parent download to associate this download with (use NULL
1946 * for top-level downloads; useful for manually-triggered recursive downloads)
1947 * @return context that can be used to control this download
1949 struct GNUNET_FS_DownloadContext *
1950 GNUNET_FS_file_download_start (struct GNUNET_FS_Handle *h,
1951 const struct GNUNET_FS_Uri *uri,
1952 const char *filename,
1953 unsigned long long offset,
1954 unsigned long long length,
1955 unsigned int anonymity,
1958 struct GNUNET_FS_DownloadContext *parent);
1962 * Stop a download (aborts if download is incomplete).
1964 * @param rm handle for the download
1965 * @param do_delete delete files of incomplete downloads
1968 GNUNET_FS_file_download_stop (struct GNUNET_FS_DownloadContext *rm,
1973 * Initialize collection.
1975 * @param h handle to the file sharing subsystem
1976 * @param namespace namespace to use for the collection
1977 * @return GNUNET_OK on success, GNUNET_SYSERR if another
1978 * namespace is already set for our collection
1981 GNUNET_FS_collection_start (struct GNUNET_FS_Handle *h,
1982 struct GNUNET_FS_Namespace *namespace);
1988 * @param h handle to the file sharing subsystem
1989 * @return GNUNET_OK on success, GNUNET_SYSERR if no collection is active
1992 GNUNET_FS_collection_stop (struct GNUNET_FS_Handle *h);
1996 * Are we using a collection?
1998 * @param h handle to the file sharing subsystem
1999 * @return NULL if there is no collection,
2001 struct GNUNET_FS_Namespace *
2002 GNUNET_FS_collection_get(struct GNUNET_FS_Handle *h);
2006 * Publish an update of the current collection information to the
2007 * network now. The function has no effect if the collection has not
2008 * changed since the last publication. If we are currently not
2009 * collecting, this function does nothing.
2011 * @param h handle to the file sharing subsystem
2013 void GNUNET_FS_collection_publish (struct GNUNET_FS_Handle *h);
2017 * If we are currently building a collection, publish the given file
2018 * information in that collection. If we are currently not
2019 * collecting, this function does nothing.
2021 * @param h handle to the file sharing subsystem
2022 * @param uri uri to add to the collection
2023 * @param meta metadata for the uri
2025 void GNUNET_FS_collection_add (const struct GNUNET_FS_Handle *h,
2026 const struct GNUNET_FS_Uri *uri,
2027 const struct GNUNET_CONTAINER_MetaData *meta);
2033 /* ******************** Directory API *********************** */
2036 #define GNUNET_FS_DIRECTORY_MIME "application/gnunet-directory"
2037 #define GNUNET_FS_DIRECTORY_MAGIC "\211GND\r\n\032\n"
2038 #define GNUNET_FS_DIRECTORY_EXT ".gnd"
2041 * Does the meta-data claim that this is a directory?
2042 * Checks if the mime-type is that of a GNUnet directory.
2044 * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if
2045 * we have no mime-type information (treat as 'GNUNET_NO')
2048 GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData *md);
2052 * Set the MIMETYPE information for the given
2053 * metadata to "application/gnunet-directory".
2055 * @param md metadata to add mimetype to
2058 GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md);
2062 * Function used to process entries in a directory.
2064 * @param cls closure
2065 * @param filename name of the file in the directory
2066 * @param uri URI of the file
2067 * @param metadata metadata for the file; metadata for
2068 * the directory if everything else is NULL/zero
2069 * @param length length of the available data for the file
2070 * (of type size_t since data must certainly fit
2071 * into memory; if files are larger than size_t
2072 * permits, then they will certainly not be
2073 * embedded with the directory itself).
2074 * @param data data available for the file (length bytes)
2076 typedef void (*GNUNET_FS_DirectoryEntryProcessor)(void *cls,
2077 const char *filename,
2078 const struct GNUNET_FS_Uri *uri,
2079 const struct GNUNET_CONTAINER_MetaData *meta,
2085 * Iterate over all entries in a directory. Note that directories
2086 * are structured such that it is possible to iterate over the
2087 * individual blocks as well as over the entire directory. Thus
2088 * a client can call this function on the buffer in the
2089 * GNUNET_FS_ProgressCallback. Also, directories can optionally
2090 * include the contents of (small) files embedded in the directory
2091 * itself; for those files, the processor may be given the
2092 * contents of the file directly by this function.
2094 * @param size number of bytes in data
2095 * @param data pointer to the beginning of the directory
2096 * @param offset offset of data in the directory
2097 * @param dep function to call on each entry
2098 * @param dep_cls closure for dep
2101 GNUNET_FS_directory_list_contents (size_t size,
2104 GNUNET_FS_DirectoryEntryProcessor dep,
2108 #if 0 /* keep Emacsens' auto-indent happy */