GNUnet 0.22.2

File sharing. More...

Collaboration diagram for FS service:

Modules

 

Data Structures

struct  GNUNET_FS_ProgressInfo
 Argument given to the progress callback with information about what is going on. More...
 
struct  GNUNET_FS_BlockOptions
 Settings for publishing a block (which may of course also apply to an entire directory or file). More...
 
struct  GNUNET_FS_ShareTreeItem
 A node of a directory tree (produced by dirscanner) More...
 

Macros

#define GNUNET_FS_VERSION   0x00090300
 Version number of the implementation. More...
 
#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME   180
 
#define GNUNET_FS_URI_PREFIX   "gnunet://fs/"
 
#define GNUNET_FS_URI_KSK_INFIX   "ksk/"
 
#define GNUNET_FS_URI_SKS_INFIX   "sks/"
 
#define GNUNET_FS_URI_CHK_INFIX   "chk/"
 
#define GNUNET_FS_URI_LOC_INFIX   "loc/"
 
#define GNUNET_FS_PROBE_UPDATE_FREQUENCY
 How often do we signal applications that a probe for a particular search result is running? (used to visualize probes). More...
 
#define GNUNET_FS_DIRECTORY_MIME   "application/gnunet-directory"
 
#define GNUNET_FS_DIRECTORY_MAGIC   "\211GND\r\n\032\n"
 
#define GNUNET_FS_DIRECTORY_EXT   ".gnd"
 

Typedefs

typedef int(* GNUNET_FS_KeywordIterator) (void *cls, const char *keyword, int is_mandatory)
 Iterator over keywords. More...
 
typedef void *(* GNUNET_FS_ProgressCallback) (void *cls, const struct GNUNET_FS_ProgressInfo *info)
 Notification of FS to a client about the progress of an operation. More...
 
typedef int(* GNUNET_FS_FileInformationProcessor) (void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
 Function called on entries in a struct GNUNET_FS_FileInformation iteration. More...
 
typedef size_t(* GNUNET_FS_DataReader) (void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
 Function that provides data. More...
 
typedef void(* GNUNET_FS_PublishContinuation) (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
 Signature of a function called as the continuation of a KBlock or SBlock publication. More...
 
typedef int(* GNUNET_FS_IndexedFileProcessor) (void *cls, const char *filename, const struct GNUNET_HashCode *file_id)
 Type of a function called by GNUNET_FS_get_indexed_files. More...
 
typedef void(* GNUNET_FS_IdentifierProcessor) (void *cls, const char *last_id, const struct GNUNET_FS_Uri *last_uri, const struct GNUNET_FS_MetaData *last_meta, const char *next_id)
 Function called on updateable identifiers. More...
 
typedef void(* GNUNET_FS_DirectoryEntryProcessor) (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, size_t length, const void *data)
 Function used to process entries in a directory. More...
 
typedef void(* GNUNET_FS_DirScannerProgressCallback) (void *cls, const char *filename, int is_directory, enum GNUNET_FS_DirScannerProgressUpdateReason reason)
 Function called over time as the directory scanner makes progress on the job at hand. More...
 

Enumerations

enum  GNUNET_FS_Status {
  GNUNET_FS_STATUS_PUBLISH_START = 0 , GNUNET_FS_STATUS_PUBLISH_RESUME = 1 , GNUNET_FS_STATUS_PUBLISH_SUSPEND = 2 , GNUNET_FS_STATUS_PUBLISH_PROGRESS = 3 ,
  GNUNET_FS_STATUS_PUBLISH_ERROR = 4 , GNUNET_FS_STATUS_PUBLISH_COMPLETED = 5 , GNUNET_FS_STATUS_PUBLISH_STOPPED = 6 , GNUNET_FS_STATUS_DOWNLOAD_START = 7 ,
  GNUNET_FS_STATUS_DOWNLOAD_RESUME = 8 , GNUNET_FS_STATUS_DOWNLOAD_SUSPEND = 9 , GNUNET_FS_STATUS_DOWNLOAD_PROGRESS = 10 , GNUNET_FS_STATUS_DOWNLOAD_ERROR = 11 ,
  GNUNET_FS_STATUS_DOWNLOAD_COMPLETED = 12 , GNUNET_FS_STATUS_DOWNLOAD_STOPPED = 13 , GNUNET_FS_STATUS_DOWNLOAD_ACTIVE = 14 , GNUNET_FS_STATUS_DOWNLOAD_INACTIVE = 15 ,
  GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT = 16 , GNUNET_FS_STATUS_SEARCH_START = 17 , GNUNET_FS_STATUS_SEARCH_RESUME = 18 , GNUNET_FS_STATUS_SEARCH_RESUME_RESULT = 19 ,
  GNUNET_FS_STATUS_SEARCH_SUSPEND = 20 , GNUNET_FS_STATUS_SEARCH_RESULT = 21 , GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE = 22 , GNUNET_FS_STATUS_SEARCH_UPDATE = 23 ,
  GNUNET_FS_STATUS_SEARCH_ERROR = 24 , GNUNET_FS_STATUS_SEARCH_PAUSED = 25 , GNUNET_FS_STATUS_SEARCH_CONTINUED = 26 , GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED = 27 ,
  GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND = 28 , GNUNET_FS_STATUS_SEARCH_STOPPED = 29 , GNUNET_FS_STATUS_UNINDEX_START = 30 , GNUNET_FS_STATUS_UNINDEX_RESUME = 31 ,
  GNUNET_FS_STATUS_UNINDEX_SUSPEND = 32 , GNUNET_FS_STATUS_UNINDEX_PROGRESS = 33 , GNUNET_FS_STATUS_UNINDEX_ERROR = 34 , GNUNET_FS_STATUS_UNINDEX_COMPLETED = 35 ,
  GNUNET_FS_STATUS_UNINDEX_STOPPED = 36 , GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY = 37
}
 Possible status codes used in the callback for the various file-sharing operations. More...
 
enum  GNUNET_FS_Flags { GNUNET_FS_FLAGS_NONE = 0 , GNUNET_FS_FLAGS_PERSISTENCE = 1 , GNUNET_FS_FLAGS_DO_PROBES = 2 }
 General (global) option flags for file-sharing. More...
 
enum  GNUNET_FS_OPTIONS { GNUNET_FS_OPTIONS_END = 0 , GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM = 1 , GNUNET_FS_OPTIONS_REQUEST_PARALLELISM = 2 }
 Options specified in the VARARGs portion of GNUNET_FS_start. More...
 
enum  GNUNET_FS_PublishOptions { GNUNET_FS_PUBLISH_OPTION_NONE = 0 , GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY = 1 }
 Options for publishing. More...
 
enum  GNUNET_FS_SearchOptions { GNUNET_FS_SEARCH_OPTION_NONE = 0 , GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY = 1 }
 Options for searching. More...
 
enum  GNUNET_FS_DownloadOptions {
  GNUNET_FS_DOWNLOAD_OPTION_NONE = 0 , GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY = 1 , GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE = 2 , GNUNET_FS_DOWNLOAD_NO_TEMPORARIES = 4 ,
  GNUNET_FS_DOWNLOAD_IS_PROBE = (UINT32_C(1) << 31)
}
 Options for downloading. More...
 
enum  GNUNET_FS_DirScannerProgressUpdateReason {
  GNUNET_FS_DIRSCANNER_FILE_START = 0 , GNUNET_FS_DIRSCANNER_FILE_IGNORED , GNUNET_FS_DIRSCANNER_ALL_COUNTED , GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED ,
  GNUNET_FS_DIRSCANNER_FINISHED , GNUNET_FS_DIRSCANNER_INTERNAL_ERROR
}
 Progress reasons of the directory scanner. More...
 

Functions

int GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, struct GNUNET_HashCode *key)
 Get a unique key from a URI. More...
 
char * GNUNET_FS_uri_to_string (const struct GNUNET_FS_Uri *uri)
 Convert a URI to a UTF-8 String. More...
 
char * GNUNET_FS_uri_ksk_to_string_fancy (const struct GNUNET_FS_Uri *uri)
 Convert keyword URI to a human readable format (i.e. More...
 
void GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, const char *keyword, int is_mandatory)
 Add the given keyword to the set of keywords represented by the URI. More...
 
void GNUNET_FS_uri_ksk_remove_keyword (struct GNUNET_FS_Uri *uri, const char *keyword)
 Remove the given keyword from the set of keywords represented by the URI. More...
 
struct GNUNET_FS_UriGNUNET_FS_uri_parse (const char *uri, char **emsg)
 Convert a UTF-8 String to a URI. More...
 
void GNUNET_FS_uri_destroy (struct GNUNET_FS_Uri *uri)
 Free URI. More...
 
unsigned int GNUNET_FS_uri_ksk_get_keyword_count (const struct GNUNET_FS_Uri *uri)
 How many keywords are ANDed in this keyword URI? More...
 
int GNUNET_FS_uri_ksk_get_keywords (const struct GNUNET_FS_Uri *uri, GNUNET_FS_KeywordIterator iterator, void *iterator_cls)
 Iterate over all keywords in this keyword URI. More...
 
int GNUNET_FS_uri_loc_get_peer_identity (const struct GNUNET_FS_Uri *uri, struct GNUNET_PeerIdentity *peer)
 Obtain the identity of the peer offering the data. More...
 
struct GNUNET_FS_UriGNUNET_FS_uri_loc_get_uri (const struct GNUNET_FS_Uri *uri)
 Obtain the URI of the content itself. More...
 
struct GNUNET_TIME_Absolute GNUNET_FS_uri_loc_get_expiration (const struct GNUNET_FS_Uri *uri)
 Obtain the expiration of the LOC URI. More...
 
struct GNUNET_FS_UriGNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *base_uri, const struct GNUNET_CRYPTO_EddsaPrivateKey *sign_key, struct GNUNET_TIME_Absolute expiration_time)
 Construct a location URI (this peer will be used for the location). More...
 
struct GNUNET_FS_UriGNUNET_FS_uri_ksk_merge (const struct GNUNET_FS_Uri *u1, const struct GNUNET_FS_Uri *u2)
 Merge the sets of keywords from two KSK URIs. More...
 
struct GNUNET_FS_UriGNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri)
 Duplicate URI. More...
 
struct GNUNET_FS_UriGNUNET_FS_uri_ksk_create (const char *keywords, char **emsg)
 Create an FS URI from a single user-supplied string of keywords. More...
 
struct GNUNET_FS_UriGNUNET_FS_uri_ksk_create_from_args (unsigned int argc, const char **argv)
 Create an FS URI from a user-supplied command line of keywords. More...
 
int GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1, const struct GNUNET_FS_Uri *u2)
 Test if two URIs are equal. More...
 
int GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri)
 Is this a namespace URI? More...
 
struct GNUNET_FS_UriGNUNET_FS_uri_sks_create (const struct GNUNET_CRYPTO_EcdsaPublicKey *ns, const char *id)
 Create an SKS URI from a namespace ID and an identifier. More...
 
int GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri, struct GNUNET_CRYPTO_EcdsaPublicKey *pseudonym)
 Get the public key of a namespace from the given namespace URI. More...
 
char * GNUNET_FS_uri_sks_get_content_id (const struct GNUNET_FS_Uri *uri)
 Get the content identifier of an SKS URI. More...
 
int GNUNET_FS_uri_test_ksk (const struct GNUNET_FS_Uri *uri)
 Is this a keyword URI? More...
 
int GNUNET_FS_uri_test_chk (const struct GNUNET_FS_Uri *uri)
 Is this a file (or directory) URI? More...
 
uint64_t GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri *uri)
 What is the size of the file that this URI refers to? More...
 
const struct GNUNET_HashCodeGNUNET_FS_uri_chk_get_file_hash (const struct GNUNET_FS_Uri *uri)
 What is the hash of the original file's content that this URI refers to? More...
 
int GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri)
 Is this a location URI? More...
 
struct GNUNET_FS_UriGNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_FS_MetaData *md)
 Construct a keyword-URI from meta-data (take all entries in the meta-data and construct one large keyword URI that lists all keywords that can be found in the meta-data). More...
 
struct GNUNET_GETOPT_CommandLineOption GNUNET_FS_GETOPT_KEYWORDS (char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_FS_Uri **topKeywords)
 Allow user to specify keywords. More...
 
struct GNUNET_GETOPT_CommandLineOption GNUNET_FS_GETOPT_METADATA (char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_FS_MetaData **meta)
 Allow user to specify metadata. More...
 
int GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
 Command-line option parser function that allows the user to specify one or more '-m' options with metadata. More...
 
struct GNUNET_FS_HandleGNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, enum GNUNET_FS_Flags flags,...)
 Setup a connection to the file-sharing service. More...
 
void GNUNET_FS_stop (struct GNUNET_FS_Handle *h)
 Close our connection with the file-sharing service. More...
 
const char * GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s)
 Obtain the name under which this file information structure is stored on disk. More...
 
const char * GNUNET_FS_file_information_get_filename (const struct GNUNET_FS_FileInformation *s)
 Obtain the filename from the file information structure. More...
 
void GNUNET_FS_file_information_set_filename (struct GNUNET_FS_FileInformation *s, const char *filename)
 Set the filename in the file information structure. More...
 
struct GNUNET_FS_FileInformationGNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, void *client_info, const char *filename, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
 Create an entry for a file in a publish-structure. More...
 
struct GNUNET_FS_FileInformationGNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h, void *client_info, uint64_t length, void *data, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
 Create an entry for a file in a publish-structure. More...
 
struct GNUNET_FS_FileInformationGNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h, void *client_info, uint64_t length, GNUNET_FS_DataReader reader, void *reader_cls, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
 Create an entry for a file in a publish-structure. More...
 
struct GNUNET_FS_FileInformationGNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h, void *client_info, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_BlockOptions *bo, const char *filename)
 Create an entry for an empty directory in a publish-structure. More...
 
int GNUNET_FS_file_information_is_directory (const struct GNUNET_FS_FileInformation *ent)
 Test if a given entry represents a directory. More...
 
int GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir, struct GNUNET_FS_FileInformation *ent)
 Add an entry to a directory in a publish-structure. More...
 
void GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir, GNUNET_FS_FileInformationProcessor proc, void *proc_cls)
 Inspect a file or directory in a publish-structure. More...
 
void GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
 Destroy publish-structure. More...
 
struct GNUNET_FS_PublishContextGNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, struct GNUNET_FS_FileInformation *fi, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *nid, const char *nuid, enum GNUNET_FS_PublishOptions options)
 Publish a file or directory. More...
 
void GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc)
 Stop a publication. More...
 
struct GNUNET_FS_PublishKskContextGNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *ksk_uri, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
 Publish a KBlock on GNUnet. More...
 
void GNUNET_FS_publish_ksk_cancel (struct GNUNET_FS_PublishKskContext *pkc)
 Abort the KSK publishing operation. More...
 
struct GNUNET_FS_PublishSksContextGNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *identifier, const char *update, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
 Publish an SBlock on GNUnet. More...
 
void GNUNET_FS_publish_sks_cancel (struct GNUNET_FS_PublishSksContext *psc)
 Abort the SKS publishing operation. More...
 
struct GNUNET_FS_GetIndexedContextGNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, GNUNET_FS_IndexedFileProcessor iterator, void *iterator_cls)
 Iterate over all indexed files. More...
 
void GNUNET_FS_get_indexed_files_cancel (struct GNUNET_FS_GetIndexedContext *gic)
 Cancel iteration over all indexed files. More...
 
struct GNUNET_FS_UnindexContextGNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, const char *filename, void *cctx)
 Unindex a file. More...
 
void GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc)
 Clean up after completion of an unindex operation. More...
 
void GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *next_id, GNUNET_FS_IdentifierProcessor ip, void *ip_cls)
 List all of the identifiers in the namespace for which we could produce an update. More...
 
struct GNUNET_FS_SearchContextGNUNET_FS_search_start (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx)
 Start search for content. More...
 
void GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc)
 Pause search. More...
 
void GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc)
 Continue paused search. More...
 
void GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc)
 Stop search for content. More...
 
struct GNUNET_FS_SearchResultGNUNET_FS_probe (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, void *client_info, uint32_t anonymity)
 Start download probes for the given search result. More...
 
void * GNUNET_FS_probe_stop (struct GNUNET_FS_SearchResult *sr)
 Stop probe activity. More...
 
struct GNUNET_FS_DownloadContextGNUNET_FS_download_start (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, const char *filename, const char *tempname, uint64_t offset, uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, void *cctx, struct GNUNET_FS_DownloadContext *parent)
 Download parts of a file. More...
 
struct GNUNET_FS_DownloadContextGNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchResult *sr, const char *filename, const char *tempname, uint64_t offset, uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, void *cctx)
 Download parts of a file based on a search result. More...
 
void GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
 Stop a download (aborts if download is incomplete). More...
 
void GNUNET_FS_download_suspend (struct GNUNET_FS_DownloadContext *dc)
 Suspend a download. More...
 
void GNUNET_FS_download_resume (struct GNUNET_FS_DownloadContext *dc)
 Resume a suspended download. More...
 
int GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_FS_MetaData *md)
 Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet directory. More...
 
void GNUNET_FS_meta_data_make_directory (struct GNUNET_FS_MetaData *md)
 Set the MIMETYPE information for the given metadata to "application/gnunet-directory". More...
 
char * GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_FS_MetaData *md)
 Suggest a filename based on given metadata. More...
 
int GNUNET_FS_directory_list_contents (size_t size, const void *data, uint64_t offset, GNUNET_FS_DirectoryEntryProcessor dep, void *dep_cls)
 Iterate over all entries in a directory. More...
 
struct GNUNET_FS_DirectoryBuilderGNUNET_FS_directory_builder_create (const struct GNUNET_FS_MetaData *mdir)
 Create a directory builder. More...
 
void GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *md, const void *data)
 Add an entry to a directory. More...
 
int GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld, size_t *rsize, void **rdata)
 Finish building the directory. More...
 
struct GNUNET_FS_DirScannerGNUNET_FS_directory_scan_start (const char *filename, int disable_extractor, const char *ex, GNUNET_FS_DirScannerProgressCallback cb, void *cb_cls)
 Start a directory scanner. More...
 
void GNUNET_FS_directory_scan_abort (struct GNUNET_FS_DirScanner *ds)
 Abort the scan. More...
 
struct GNUNET_FS_ShareTreeItemGNUNET_FS_directory_scan_get_result (struct GNUNET_FS_DirScanner *ds)
 Obtain the result of the scan after the scan has signalled completion. More...
 
void GNUNET_FS_share_tree_trim (struct GNUNET_FS_ShareTreeItem *toplevel)
 Process a share item tree, moving frequent keywords up and copying frequent metadata up. More...
 
void GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel)
 Release memory of a share item tree. More...
 
enum GNUNET_GenericReturnValue GNUNET_FS_write_meta_data (struct GNUNET_BIO_WriteHandle *h, const char *what, const struct GNUNET_FS_MetaData *m)
 Write a metadata container. More...
 
struct GNUNET_BIO_ReadSpec GNUNET_FS_read_spec_meta_data (const char *what, struct GNUNET_FS_MetaData **result)
 Create the specification to read a metadata container. More...
 
struct GNUNET_BIO_WriteSpec GNUNET_FS_write_spec_meta_data (const char *what, const struct GNUNET_FS_MetaData *m)
 Create the specification to write a metadata container. More...
 
enum GNUNET_GenericReturnValue GNUNET_FS_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what, struct GNUNET_FS_MetaData **result)
 Read a metadata container. More...
 

Detailed Description

File sharing.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_FS_VERSION

#define GNUNET_FS_VERSION   0x00090300

Version number of the implementation.

History:

1.x.x: initial version with triple GNUNET_hash and merkle tree 2.x.x: root node with mime-type, filename and version number 2.1.x: combined GNUNET_EC_ContentHashKey/3HASH encoding with 25:1 super-nodes 2.2.x: with directories 3.0.x: with namespaces 3.1.x: with namespace meta-data 3.2.x: with collections 4.0.x: with expiration, variable meta-data, kblocks 4.1.x: with new error and configuration handling 5.0.x: with location URIs 6.0.0: with support for OR in KSKs 6.1.x: with simplified namespace support 9.0.0: CPS-style integrated API 9.1.1: asynchronous directory scanning 9.2.0: unified K-Block and S-block format (#2564) 9.3.0: base32crockford encoded URLs

Definition at line 72 of file gnunet_fs_service.h.

◆ EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME

#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME   180

Definition at line 171 of file gnunet_fs_service.h.

◆ GNUNET_FS_URI_PREFIX

#define GNUNET_FS_URI_PREFIX   "gnunet://fs/"

Definition at line 177 of file gnunet_fs_service.h.

◆ GNUNET_FS_URI_KSK_INFIX

#define GNUNET_FS_URI_KSK_INFIX   "ksk/"

Definition at line 178 of file gnunet_fs_service.h.

◆ GNUNET_FS_URI_SKS_INFIX

#define GNUNET_FS_URI_SKS_INFIX   "sks/"

Definition at line 179 of file gnunet_fs_service.h.

◆ GNUNET_FS_URI_CHK_INFIX

#define GNUNET_FS_URI_CHK_INFIX   "chk/"

Definition at line 180 of file gnunet_fs_service.h.

◆ GNUNET_FS_URI_LOC_INFIX

#define GNUNET_FS_URI_LOC_INFIX   "loc/"

Definition at line 181 of file gnunet_fs_service.h.

◆ GNUNET_FS_PROBE_UPDATE_FREQUENCY

#define GNUNET_FS_PROBE_UPDATE_FREQUENCY
Value:
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:486

How often do we signal applications that a probe for a particular search result is running? (used to visualize probes).

Definition at line 188 of file gnunet_fs_service.h.

◆ GNUNET_FS_DIRECTORY_MIME

#define GNUNET_FS_DIRECTORY_MIME   "application/gnunet-directory"

Definition at line 2582 of file gnunet_fs_service.h.

◆ GNUNET_FS_DIRECTORY_MAGIC

#define GNUNET_FS_DIRECTORY_MAGIC   "\211GND\r\n\032\n"

Definition at line 2583 of file gnunet_fs_service.h.

◆ GNUNET_FS_DIRECTORY_EXT

#define GNUNET_FS_DIRECTORY_EXT   ".gnd"

Definition at line 2584 of file gnunet_fs_service.h.

Typedef Documentation

◆ GNUNET_FS_KeywordIterator

typedef int(* GNUNET_FS_KeywordIterator) (void *cls, const char *keyword, int is_mandatory)

Iterator over keywords.

Parameters
clsclosure
keywordthe keyword
is_mandatoryis the keyword mandatory (in a search)
Returns
GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort

Definition at line 211 of file gnunet_fs_service.h.

◆ GNUNET_FS_ProgressCallback

typedef void *(* GNUNET_FS_ProgressCallback) (void *cls, const struct GNUNET_FS_ProgressInfo *info)

Notification of FS to a client about the progress of an operation.

Callbacks of this type will be used for uploads, downloads and searches. Some of the arguments depend a bit in their meaning on the context in which the callback is used.

Parameters
clsclosure
infodetails about the event, specifying the event type and various bits about the event
Returns
client-context (for the next progress call for this operation; should be set to NULL for SUSPEND and STOPPED events). The value returned will be passed to future callbacks in the respective field in the struct GNUNET_FS_ProgressInfo.

Definition at line 1669 of file gnunet_fs_service.h.

◆ GNUNET_FS_FileInformationProcessor

typedef int(* GNUNET_FS_FileInformationProcessor) (void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)

Function called on entries in a struct GNUNET_FS_FileInformation iteration.

Parameters
clsclosure
fithe entry in the publish-structure
lengthlength of the file or directory
metametadata for the file or directory (can be modified)
uripointer to the keywords that will be used for this entry (can be modified)
boblock options (can be modified)
do_indexshould we index (can be modified)
client_infopointer to client context set upon creation (can be modified)
Returns
GNUNET_OK to continue, GNUNET_NO to remove this entry from the directory, GNUNET_SYSERR to abort the iteration

Definition at line 1823 of file gnunet_fs_service.h.

◆ GNUNET_FS_DataReader

typedef size_t(* GNUNET_FS_DataReader) (void *cls, uint64_t offset, size_t max, void *buf, char **emsg)

Function that provides data.

Parameters
clsclosure
offsetoffset to read from; it is possible that the caller might need to go backwards a bit at times; set to UINT64_MAX to tell the reader that we won't be reading for a while (used to close the file descriptor but NOT fully clean up the reader's state); in this case, a value of '0' for max should be ignored
maxmaximum number of bytes that should be copied to buf; readers are not allowed to provide less data unless there is an error; a value of "0" will be used at the end to allow the reader to clean up its internal state
bufwhere the reader should write the data
emsglocation for the reader to store an error message
Returns
number of bytes written, usually max, 0 on error

Definition at line 1948 of file gnunet_fs_service.h.

◆ GNUNET_FS_PublishContinuation

typedef void(* GNUNET_FS_PublishContinuation) (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)

Signature of a function called as the continuation of a KBlock or SBlock publication.

Parameters
clsclosure
uriURI under which the block is now available, NULL on error
emsgerror message, NULL on success

Definition at line 2136 of file gnunet_fs_service.h.

◆ GNUNET_FS_IndexedFileProcessor

typedef int(* GNUNET_FS_IndexedFileProcessor) (void *cls, const char *filename, const struct GNUNET_HashCode *file_id)

Type of a function called by GNUNET_FS_get_indexed_files.

Parameters
clsclosure
filenamethe name of the file, NULL for end of list
file_idhash of the contents of the indexed file
Returns
GNUNET_OK to continue iteration, GNUNET_SYSERR to abort

Definition at line 2230 of file gnunet_fs_service.h.

◆ GNUNET_FS_IdentifierProcessor

typedef void(* GNUNET_FS_IdentifierProcessor) (void *cls, const char *last_id, const struct GNUNET_FS_Uri *last_uri, const struct GNUNET_FS_MetaData *last_meta, const char *next_id)

Function called on updateable identifiers.

Parameters
clsclosure
last_idlast identifier
last_uriuri used for the content published under the last_id
last_metametadata associated with last_uri
next_ididentifier that should be used for updates

Definition at line 2297 of file gnunet_fs_service.h.

◆ GNUNET_FS_DirectoryEntryProcessor

typedef void(* GNUNET_FS_DirectoryEntryProcessor) (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, size_t length, const void *data)

Function used to process entries in a directory.

Parameters
clsclosure
filenamename of the file in the directory
uriURI of the file
metadatametadata for the file; metadata for the directory if everything else is NULL/zero
lengthlength of the available data for the file (of type size_t since data must certainly fit into memory; if files are larger than size_t permits, then they will certainly not be embedded with the directory itself).
datadata available for the file (length bytes)

Definition at line 2634 of file gnunet_fs_service.h.

◆ GNUNET_FS_DirScannerProgressCallback

typedef void(* GNUNET_FS_DirScannerProgressCallback) (void *cls, const char *filename, int is_directory, enum GNUNET_FS_DirScannerProgressUpdateReason reason)

Function called over time as the directory scanner makes progress on the job at hand.

Parameters
clsclosure
filenamewhich file we are making progress on
is_directoryGNUNET_YES if this is a directory, GNUNET_NO if this is a file GNUNET_SYSERR if it is neither (or unknown)
reasonkind of progress we are making

Definition at line 2770 of file gnunet_fs_service.h.

Enumeration Type Documentation

◆ GNUNET_FS_Status

Possible status codes used in the callback for the various file-sharing operations.

On each file (or search), the callback is guaranteed to be called once with "START" and once with STOPPED; calls with PROGRESS, ERROR or COMPLETED are optional and depend on the circumstances; parent operations will be STARTED before child-operations and STOPPED after their respective child-operations. START and STOP signals are typically generated either due to explicit client requests or because of suspend/resume operations.

Enumerator
GNUNET_FS_STATUS_PUBLISH_START 

Notification that we have started to publish a file structure.

GNUNET_FS_STATUS_PUBLISH_RESUME 

Notification that we have resumed sharing a file structure.

GNUNET_FS_STATUS_PUBLISH_SUSPEND 

Notification that we have suspended sharing a file structure.

GNUNET_FS_STATUS_PUBLISH_PROGRESS 

Notification that we are making progress sharing a file structure.

GNUNET_FS_STATUS_PUBLISH_ERROR 

Notification that an error was encountered sharing a file structure.

The application will continue to receive resume/suspend events for this structure until "GNUNET_FS_publish_stop" is called.

GNUNET_FS_STATUS_PUBLISH_COMPLETED 

Notification that we completed sharing a file structure.

The application will continue to receive resume/suspend events for this structure until "GNUNET_FS_publish_stop" is called.

GNUNET_FS_STATUS_PUBLISH_STOPPED 

Notification that we have stopped the process of uploading a file structure; no further events will be generated for this action.

GNUNET_FS_STATUS_DOWNLOAD_START 

Notification that we have started this download.

GNUNET_FS_STATUS_DOWNLOAD_RESUME 

Notification that this download is being resumed.

GNUNET_FS_STATUS_DOWNLOAD_SUSPEND 

Notification that this download was suspended.

GNUNET_FS_STATUS_DOWNLOAD_PROGRESS 

Notification about progress with this download.

GNUNET_FS_STATUS_DOWNLOAD_ERROR 

Notification that this download encountered an error.

GNUNET_FS_STATUS_DOWNLOAD_COMPLETED 

Notification that this download completed.

Note that for directories, completion does not imply completion of all files in the directory.

GNUNET_FS_STATUS_DOWNLOAD_STOPPED 

Notification that this download was stopped (final event with respect to this action).

GNUNET_FS_STATUS_DOWNLOAD_ACTIVE 

Notification that this download is now actively being pursued (as opposed to waiting in the queue).

GNUNET_FS_STATUS_DOWNLOAD_INACTIVE 

Notification that this download is no longer actively being pursued (back in the queue).

GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT 

Notification that this download is no longer part of a recursive download or search but now a 'stand-alone' download (and may thus need to be moved in the GUI into a different category).

GNUNET_FS_STATUS_SEARCH_START 

First event generated when a client requests a search to begin or when a namespace result automatically triggers the search for updates.

GNUNET_FS_STATUS_SEARCH_RESUME 

Last event when a search is being resumed; note that "GNUNET_FS_SEARCH_START" will not be generated in this case.

GNUNET_FS_STATUS_SEARCH_RESUME_RESULT 

Event generated for each search result when the respective search is resumed.

GNUNET_FS_STATUS_SEARCH_SUSPEND 

Last event when a search is being suspended; note that "GNUNET_FS_SEARCH_STOPPED" will not be generated in this case.

GNUNET_FS_STATUS_SEARCH_RESULT 

This search has yielded a result.

GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE 

We have discovered a new namespace.

GNUNET_FS_STATUS_SEARCH_UPDATE 

We have additional data about the quality or availability of a search result.

GNUNET_FS_STATUS_SEARCH_ERROR 

Signals a problem with this search.

GNUNET_FS_STATUS_SEARCH_PAUSED 

Signals that this search was paused.

GNUNET_FS_STATUS_SEARCH_CONTINUED 

Signals that this search was continued (unpaused).

GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED 

Event generated for each search result when the respective search is stopped.

GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND 

Event generated for each search result when the respective search is suspended.

GNUNET_FS_STATUS_SEARCH_STOPPED 

Last message from a search; this signals that there will be no further events associated with this search.

GNUNET_FS_STATUS_UNINDEX_START 

Notification that we started to unindex a file.

GNUNET_FS_STATUS_UNINDEX_RESUME 

Notification that we resumed unindexing of a file.

GNUNET_FS_STATUS_UNINDEX_SUSPEND 

Notification that we suspended unindexing a file.

GNUNET_FS_STATUS_UNINDEX_PROGRESS 

Notification that we made progress unindexing a file.

GNUNET_FS_STATUS_UNINDEX_ERROR 

Notification that we encountered an error unindexing a file.

GNUNET_FS_STATUS_UNINDEX_COMPLETED 

Notification that the unindexing of this file was completed.

GNUNET_FS_STATUS_UNINDEX_STOPPED 

Notification that the unindexing of this file was stopped (final event for this action).

GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY 

Notification that we are making progress sharing a directory.

Definition at line 629 of file gnunet_fs_service.h.

630{
635
640
645
650
657
664
671
676
681
686
691
696
703
709
715
721
729
736
743
749
756
761
766
772
777
782
787
793
799
806
811
816
821
826
832
838
844
849};
@ GNUNET_FS_STATUS_UNINDEX_PROGRESS
Notification that we made progress unindexing a file.
@ GNUNET_FS_STATUS_SEARCH_UPDATE
We have additional data about the quality or availability of a search result.
@ GNUNET_FS_STATUS_DOWNLOAD_INACTIVE
Notification that this download is no longer actively being pursued (back in the queue).
@ GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE
We have discovered a new namespace.
@ GNUNET_FS_STATUS_UNINDEX_RESUME
Notification that we resumed unindexing of a file.
@ GNUNET_FS_STATUS_DOWNLOAD_ERROR
Notification that this download encountered an error.
@ GNUNET_FS_STATUS_SEARCH_ERROR
Signals a problem with this search.
@ GNUNET_FS_STATUS_DOWNLOAD_COMPLETED
Notification that this download completed.
@ GNUNET_FS_STATUS_DOWNLOAD_RESUME
Notification that this download is being resumed.
@ GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED
Event generated for each search result when the respective search is stopped.
@ GNUNET_FS_STATUS_UNINDEX_START
Notification that we started to unindex a file.
@ GNUNET_FS_STATUS_SEARCH_SUSPEND
Last event when a search is being suspended; note that "GNUNET_FS_SEARCH_STOPPED" will not be generat...
@ GNUNET_FS_STATUS_SEARCH_RESUME
Last event when a search is being resumed; note that "GNUNET_FS_SEARCH_START" will not be generated i...
@ GNUNET_FS_STATUS_SEARCH_RESUME_RESULT
Event generated for each search result when the respective search is resumed.
@ GNUNET_FS_STATUS_PUBLISH_STOPPED
Notification that we have stopped the process of uploading a file structure; no further events will b...
@ GNUNET_FS_STATUS_PUBLISH_ERROR
Notification that an error was encountered sharing a file structure.
@ GNUNET_FS_STATUS_UNINDEX_STOPPED
Notification that the unindexing of this file was stopped (final event for this action).
@ GNUNET_FS_STATUS_DOWNLOAD_SUSPEND
Notification that this download was suspended.
@ GNUNET_FS_STATUS_SEARCH_RESULT
This search has yielded a result.
@ GNUNET_FS_STATUS_PUBLISH_SUSPEND
Notification that we have suspended sharing a file structure.
@ GNUNET_FS_STATUS_SEARCH_CONTINUED
Signals that this search was continued (unpaused).
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS
Notification that we are making progress sharing a file structure.
@ GNUNET_FS_STATUS_DOWNLOAD_START
Notification that we have started this download.
@ GNUNET_FS_STATUS_UNINDEX_COMPLETED
Notification that the unindexing of this file was completed.
@ GNUNET_FS_STATUS_SEARCH_PAUSED
Signals that this search was paused.
@ GNUNET_FS_STATUS_DOWNLOAD_PROGRESS
Notification about progress with this download.
@ GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT
Notification that this download is no longer part of a recursive download or search but now a 'stand-...
@ GNUNET_FS_STATUS_UNINDEX_SUSPEND
Notification that we suspended unindexing a file.
@ GNUNET_FS_STATUS_UNINDEX_ERROR
Notification that we encountered an error unindexing a file.
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY
Notification that we are making progress sharing a directory.
@ GNUNET_FS_STATUS_PUBLISH_START
Notification that we have started to publish a file structure.
@ GNUNET_FS_STATUS_PUBLISH_COMPLETED
Notification that we completed sharing a file structure.
@ GNUNET_FS_STATUS_PUBLISH_RESUME
Notification that we have resumed sharing a file structure.
@ GNUNET_FS_STATUS_SEARCH_START
First event generated when a client requests a search to begin or when a namespace result automatical...
@ GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND
Event generated for each search result when the respective search is suspended.
@ GNUNET_FS_STATUS_DOWNLOAD_ACTIVE
Notification that this download is now actively being pursued (as opposed to waiting in the queue).
@ GNUNET_FS_STATUS_DOWNLOAD_STOPPED
Notification that this download was stopped (final event with respect to this action).
@ GNUNET_FS_STATUS_SEARCH_STOPPED
Last message from a search; this signals that there will be no further events associated with this se...

◆ GNUNET_FS_Flags

General (global) option flags for file-sharing.

Enumerator
GNUNET_FS_FLAGS_NONE 

No special flags set.

GNUNET_FS_FLAGS_PERSISTENCE 

Is persistence of operations desired? (will create SUSPEND/RESUME events).

GNUNET_FS_FLAGS_DO_PROBES 

Should we automatically trigger probes for search results to determine availability? (will create GNUNET_FS_STATUS_SEARCH_UPDATE events).

Definition at line 1677 of file gnunet_fs_service.h.

1678{
1683
1689
1696};
@ GNUNET_FS_FLAGS_PERSISTENCE
Is persistence of operations desired? (will create SUSPEND/RESUME events).
@ GNUNET_FS_FLAGS_DO_PROBES
Should we automatically trigger probes for search results to determine availability?...
@ GNUNET_FS_FLAGS_NONE
No special flags set.

◆ GNUNET_FS_OPTIONS

Options specified in the VARARGs portion of GNUNET_FS_start.

Enumerator
GNUNET_FS_OPTIONS_END 

Last option in the VARARG list.

GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM 

Select the desired amount of parallelism (this option should be followed by an "unsigned int" giving the desired maximum number of parallel downloads).

GNUNET_FS_OPTIONS_REQUEST_PARALLELISM 

Maximum number of requests that should be pending at a given point in time (individual downloads may go above this, but if we are above this threshold, we should not activate any additional downloads.

Definition at line 1702 of file gnunet_fs_service.h.

1703{
1708
1715
1723};
@ GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM
Select the desired amount of parallelism (this option should be followed by an "unsigned int" giving ...
@ GNUNET_FS_OPTIONS_END
Last option in the VARARG list.
@ GNUNET_FS_OPTIONS_REQUEST_PARALLELISM
Maximum number of requests that should be pending at a given point in time (individual downloads may ...

◆ GNUNET_FS_PublishOptions

Options for publishing.

Compatible options can be OR'ed together.

Enumerator
GNUNET_FS_PUBLISH_OPTION_NONE 

No options (use defaults for everything).

GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY 

Simulate publishing.

With this option, no data will be stored in the datastore. Useful for computing URIs from files.

Definition at line 2079 of file gnunet_fs_service.h.

2080{
2085
2091};
@ GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY
Simulate publishing.
@ GNUNET_FS_PUBLISH_OPTION_NONE
No options (use defaults for everything).

◆ GNUNET_FS_SearchOptions

Options for searching.

Compatible options can be OR'ed together.

Enumerator
GNUNET_FS_SEARCH_OPTION_NONE 

No options (use defaults for everything).

GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY 

Only search the local host, do not search remote systems (no P2P)

Definition at line 2341 of file gnunet_fs_service.h.

2342{
2347
2352};
@ GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY
Only search the local host, do not search remote systems (no P2P)
@ GNUNET_FS_SEARCH_OPTION_NONE
No options (use defaults for everything).

◆ GNUNET_FS_DownloadOptions

Options for downloading.

Compatible options can be OR'ed together.

Enumerator
GNUNET_FS_DOWNLOAD_OPTION_NONE 

No options (use defaults for everything).

GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY 

Only download from the local host, do not access remote systems (no P2P)

GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE 

Do a recursive download (that is, automatically trigger the download of files in directories).

GNUNET_FS_DOWNLOAD_NO_TEMPORARIES 

Do not append temporary data to the target file (for the IBlocks).

GNUNET_FS_DOWNLOAD_IS_PROBE 

Internal option used to flag this download as a 'probe' for a search result.

Impacts the priority with which the download is run and causes signalling callbacks to be done differently. Also, probe downloads are not serialized on suspension. Normal clients should not use this!

Definition at line 2432 of file gnunet_fs_service.h.

2433{
2438
2443
2449
2455
2463 GNUNET_FS_DOWNLOAD_IS_PROBE = (UINT32_C(1) << 31)
2464};
@ GNUNET_FS_DOWNLOAD_OPTION_NONE
No options (use defaults for everything).
@ GNUNET_FS_DOWNLOAD_IS_PROBE
Internal option used to flag this download as a 'probe' for a search result.
@ GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE
Do a recursive download (that is, automatically trigger the download of files in directories).
@ GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY
Only download from the local host, do not access remote systems (no P2P)
@ GNUNET_FS_DOWNLOAD_NO_TEMPORARIES
Do not append temporary data to the target file (for the IBlocks).

◆ GNUNET_FS_DirScannerProgressUpdateReason

Progress reasons of the directory scanner.

Enumerator
GNUNET_FS_DIRSCANNER_FILE_START 

We've started processing a file or directory.

GNUNET_FS_DIRSCANNER_FILE_IGNORED 

We're having trouble accessing a file (soft-error); it will be ignored.

GNUNET_FS_DIRSCANNER_ALL_COUNTED 

We've found all files (in the pre-pass).

GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED 

We've finished extracting meta data from a file.

GNUNET_FS_DIRSCANNER_FINISHED 

Last call to the progress function: we have finished scanning the directory.

GNUNET_FS_DIRSCANNER_INTERNAL_ERROR 

There was an internal error.

Application should abort the scan.

Definition at line 2723 of file gnunet_fs_service.h.

2724{
2729
2735
2740
2745
2751
2756};
@ GNUNET_FS_DIRSCANNER_INTERNAL_ERROR
There was an internal error.
@ GNUNET_FS_DIRSCANNER_FILE_IGNORED
We're having trouble accessing a file (soft-error); it will be ignored.
@ GNUNET_FS_DIRSCANNER_FINISHED
Last call to the progress function: we have finished scanning the directory.
@ GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED
We've finished extracting meta data from a file.
@ GNUNET_FS_DIRSCANNER_ALL_COUNTED
We've found all files (in the pre-pass).
@ GNUNET_FS_DIRSCANNER_FILE_START
We've started processing a file or directory.

Function Documentation

◆ GNUNET_FS_uri_to_key()

int GNUNET_FS_uri_to_key ( const struct GNUNET_FS_Uri uri,
struct GNUNET_HashCode key 
)

Get a unique key from a URI.

This is for putting URIs into HashMaps. The key may change between FS implementations.

Parameters
uriuri to convert to a unique key
keywhere to store the unique key
Returns
GNUNET_OK on success

Definition at line 96 of file fs_uri.c.

98{
99 switch (uri->type)
100 {
102 *key = uri->data.chk.chk.query;
103 return GNUNET_OK;
104
107 strlen (uri->data.sks.identifier),
108 key);
109 return GNUNET_OK;
110
112 if (uri->data.ksk.keywordCount > 0)
113 {
115 strlen (uri->data.ksk.keywords[0]),
116 key);
117 return GNUNET_OK;
118 }
119 else
120 {
121 memset (key, 0, sizeof(struct GNUNET_HashCode));
122 return GNUNET_SYSERR;
123 }
124 break;
125
128 sizeof(struct FileIdentifier)
129 + sizeof(struct GNUNET_PeerIdentity),
130 key);
131 return GNUNET_OK;
132
133 default:
134 memset (key, 0, sizeof(struct GNUNET_HashCode));
135 return GNUNET_SYSERR;
136 }
137}
@ GNUNET_FS_URI_LOC
Location (chk with identity of hosting peer).
Definition: fs_api.h:159
@ GNUNET_FS_URI_CHK
Content-hash-key (simple file).
Definition: fs_api.h:144
@ GNUNET_FS_URI_SKS
Signed key space (file in namespace).
Definition: fs_api.h:149
@ GNUNET_FS_URI_KSK
Keyword search key (query with keywords).
Definition: fs_api.h:154
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
@ GNUNET_OK
@ GNUNET_SYSERR
struct GNUNET_HashCode query
Hash of the encrypted content, used for querying.
Definition: fs.h:64
complete information needed to download a file.
Definition: fs_api.h:95
struct ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
Definition: fs_api.h:104
char ** keywords
Keywords start with a '+' if they are mandatory (in which case the '+' is NOT part of the keyword) an...
Definition: fs_api.h:186
union GNUNET_FS_Uri::@49 data
struct GNUNET_FS_Uri::@49::@51 sks
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:171
struct GNUNET_FS_Uri::@49::@50 ksk
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content.
Definition: fs_api.h:218
unsigned int keywordCount
Size of the keywords array.
Definition: fs_api.h:191
char * identifier
Human-readable identifier chosen for this entry in the namespace.
Definition: fs_api.h:205
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:212
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).
struct FileIdentifier fi
Information about the shared file.
Definition: fs_api.h:117

References FileIdentifier::chk, GNUNET_FS_Uri::chk, GNUNET_FS_Uri::data, Location::fi, GNUNET_CRYPTO_hash(), GNUNET_FS_URI_CHK, GNUNET_FS_URI_KSK, GNUNET_FS_URI_LOC, GNUNET_FS_URI_SKS, GNUNET_OK, GNUNET_SYSERR, GNUNET_FS_Uri::identifier, key, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, GNUNET_FS_Uri::loc, ContentHashKey::query, GNUNET_FS_Uri::sks, GNUNET_FS_Uri::type, and uri.

Referenced by process_ksk_result(), and process_sks_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_uri_to_string()

char * GNUNET_FS_uri_to_string ( const struct GNUNET_FS_Uri uri)

Convert a URI to a UTF-8 String.

Parameters
uriuri to convert to a string
Returns
the UTF-8 string

Definition at line 2034 of file fs_uri.c.

2035{
2036 if (uri == NULL)
2037 {
2038 GNUNET_break (0);
2039 return NULL;
2040 }
2041 switch (uri->type)
2042 {
2043 case GNUNET_FS_URI_KSK:
2044 return uri_ksk_to_string (uri);
2045
2046 case GNUNET_FS_URI_SKS:
2047 return uri_sks_to_string (uri);
2048
2049 case GNUNET_FS_URI_CHK:
2050 return uri_chk_to_string (uri);
2051
2052 case GNUNET_FS_URI_LOC:
2053 return uri_loc_to_string (uri);
2054
2055 default:
2056 GNUNET_break (0);
2057 return NULL;
2058 }
2059}
static char * uri_chk_to_string(const struct GNUNET_FS_Uri *uri)
Convert a CHK URI to a string.
Definition: fs_uri.c:1960
static char * uri_sks_to_string(const struct GNUNET_FS_Uri *uri)
Convert SKS URI to a string.
Definition: fs_uri.c:1929
static char * uri_loc_to_string(const struct GNUNET_FS_Uri *uri)
Convert a LOC URI to a string.
Definition: fs_uri.c:1991
static char * uri_ksk_to_string(const struct GNUNET_FS_Uri *uri)
Convert a KSK URI to a string.
Definition: fs_uri.c:1859
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

References GNUNET_break, GNUNET_FS_URI_CHK, GNUNET_FS_URI_KSK, GNUNET_FS_URI_LOC, GNUNET_FS_URI_SKS, GNUNET_FS_Uri::type, uri, uri_chk_to_string(), uri_ksk_to_string(), uri_loc_to_string(), and uri_sks_to_string().

Referenced by GNUNET_FS_directory_builder_add(), GNUNET_FS_download_sync_(), GNUNET_FS_file_information_sync_(), GNUNET_FS_publish_ublock_(), GNUNET_FS_search_result_sync_(), GNUNET_FS_search_sync_(), GNUNET_FS_unindex_sync_(), print_entry(), print_search_result(), progress_cb(), run(), trigger_recursive_download(), and write_update_information_graph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_uri_ksk_to_string_fancy()

char * GNUNET_FS_uri_ksk_to_string_fancy ( const struct GNUNET_FS_Uri uri)

Convert keyword URI to a human readable format (i.e.

the search query that was used in the first place)

Parameters
uriksk uri to convert to a string
Returns
string with the keywords

Definition at line 148 of file fs_uri.c.

149{
150 size_t n;
151 char *ret;
152 unsigned int i;
153 const char *keyword;
154 char **keywords;
155 unsigned int keywordCount;
156
157 if ((NULL == uri) || (GNUNET_FS_URI_KSK != uri->type))
158 {
159 GNUNET_break (0);
160 return NULL;
161 }
162 keywords = uri->data.ksk.keywords;
163 keywordCount = uri->data.ksk.keywordCount;
164 n = keywordCount + 1;
165 for (i = 0; i < keywordCount; i++)
166 {
167 keyword = keywords[i];
168 n += strlen (keyword) - 1;
169 if (NULL != strstr (&keyword[1], " "))
170 n += 2;
171 if (keyword[0] == '+')
172 n++;
173 }
174 ret = GNUNET_malloc (n);
175 strcpy (ret, "");
176 for (i = 0; i < keywordCount; i++)
177 {
178 keyword = keywords[i];
179 if (NULL != strstr (&keyword[1], " "))
180 {
181 strcat (ret, "\"");
182 if (keyword[0] == '+')
183 strcat (ret, keyword);
184 else
185 strcat (ret, &keyword[1]);
186 strcat (ret, "\"");
187 }
188 else
189 {
190 if (keyword[0] == '+')
191 strcat (ret, keyword);
192 else
193 strcat (ret, &keyword[1]);
194 }
195 strcat (ret, " ");
196 }
197 return ret;
198}
static int ret
Final status code.
Definition: gnunet-arm.c:93
#define GNUNET_malloc(size)
Wrapper around malloc.

References GNUNET_FS_Uri::data, GNUNET_break, GNUNET_FS_URI_KSK, GNUNET_malloc, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, ret, GNUNET_FS_Uri::type, and uri.

◆ GNUNET_FS_uri_ksk_add_keyword()

void GNUNET_FS_uri_ksk_add_keyword ( struct GNUNET_FS_Uri uri,
const char *  keyword,
int  is_mandatory 
)

Add the given keyword to the set of keywords represented by the URI.

Does nothing if the keyword is already present.

Parameters
uriksk uri to modify
keywordkeyword to add
is_mandatoryis this keyword mandatory?

Definition at line 752 of file fs_uri.c.

755{
756 unsigned int i;
757 const char *old;
758 char *n;
759
761 for (i = 0; i < uri->data.ksk.keywordCount; i++)
762 {
763 old = uri->data.ksk.keywords[i];
764 if (0 == strcmp (&old[1], keyword))
765 return;
766 }
767 GNUNET_asprintf (&n, is_mandatory ? "+%s" : " %s", keyword);
769}
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).

References GNUNET_FS_Uri::data, GNUNET_array_append, GNUNET_asprintf(), GNUNET_assert, GNUNET_FS_URI_KSK, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, GNUNET_FS_Uri::type, and uri.

Referenced by get_file_information(), and migrate_and_drop_keywords().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_uri_ksk_remove_keyword()

void GNUNET_FS_uri_ksk_remove_keyword ( struct GNUNET_FS_Uri uri,
const char *  keyword 
)

Remove the given keyword from the set of keywords represented by the URI.

Does nothing if the keyword is not present.

Parameters
uriksk uri to modify
keywordkeyword to add

Definition at line 780 of file fs_uri.c.

782{
783 unsigned int i;
784 char *old;
785
787 for (i = 0; i < uri->data.ksk.keywordCount; i++)
788 {
789 old = uri->data.ksk.keywords[i];
790 if (0 == strcmp (&old[1], keyword))
791 {
792 uri->data.ksk.keywords[i] =
796 uri->data.ksk.keywordCount - 1);
797 GNUNET_free (old);
798 return;
799 }
800 }
801}
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_FS_Uri::data, GNUNET_array_grow, GNUNET_assert, GNUNET_free, GNUNET_FS_URI_KSK, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, GNUNET_FS_Uri::type, and uri.

Referenced by remove_high_frequency_keywords().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_parse()

struct GNUNET_FS_Uri * GNUNET_FS_uri_parse ( const char *  uri,
char **  emsg 
)

Convert a UTF-8 String to a URI.

Parameters
uristring to parse
emsgwhere to store the parser error message (if any)
Returns
NULL on error

FIXME: Do we want to log this?

Definition at line 637 of file fs_uri.c.

638{
639 struct GNUNET_FS_Uri *ret;
640 char *msg;
641
642 if (NULL == uri)
643 {
644 GNUNET_break (0);
645 if (NULL != emsg)
646 *emsg = GNUNET_strdup (_ ("invalid argument"));
647 return NULL;
648 }
652 msg = NULL;
653 if (NULL != (ret = uri_chk_parse (uri, &msg)))
654 return ret;
656 if (NULL != (ret = uri_ksk_parse (uri, &msg)))
657 return ret;
659 if (NULL != (ret = uri_sks_parse (uri, &msg)))
660 return ret;
662 if (NULL != (ret = uri_loc_parse (uri, &msg)))
663 return ret;
665 if (NULL != emsg)
666 *emsg = GNUNET_strdup (_ ("Unrecognized URI type"));
667 return NULL;
668}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_FS_Uri * uri_sks_parse(const char *s, char **emsg)
Parse an SKS URI.
Definition: fs_uri.c:366
static struct GNUNET_FS_Uri * uri_chk_parse(const char *s, char **emsg)
Parse a CHK URI.
Definition: fs_uri.c:406
static struct GNUNET_FS_Uri * uri_ksk_parse(const char *s, char **emsg)
Parse a KSK URI.
Definition: fs_uri.c:272
static struct GNUNET_FS_Uri * uri_loc_parse(const char *s, char **emsg)
Parse a LOC URI.
Definition: fs_uri.c:496
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:167

References _, GNUNET_break, GNUNET_free, GNUNET_strdup, msg, ret, uri, uri_chk_parse(), uri_ksk_parse(), uri_loc_parse(), and uri_sks_parse().

Referenced by deserialize_download(), deserialize_fi_node(), deserialize_search(), deserialize_search_result(), deserialize_unindex_file(), GNUNET_FS_directory_list_contents(), GNUNET_FS_uri_ksk_create_from_args(), identity_continuation(), process_kblock(), process_kblock_for_unindex(), process_sblock(), read_update_information_graph(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_uri_destroy()

void GNUNET_FS_uri_destroy ( struct GNUNET_FS_Uri uri)

Free URI.

Parameters
uriuri to free

Definition at line 677 of file fs_uri.c.

678{
679 unsigned int i;
680
681 switch (uri->type)
682 {
684 for (i = 0; i < uri->data.ksk.keywordCount; i++)
687 break;
688
691 break;
692
694 break;
695
696 default:
697 /* do nothing */
698 break;
699 }
701}

References GNUNET_FS_Uri::data, GNUNET_array_grow, GNUNET_free, GNUNET_FS_URI_KSK, GNUNET_FS_URI_LOC, GNUNET_FS_URI_SKS, GNUNET_FS_Uri::identifier, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, GNUNET_FS_Uri::sks, GNUNET_FS_Uri::type, and uri.

Referenced by deserialize_search_result(), do_stop_task(), free_download_context(), free_result(), free_search_context(), free_update_information_graph(), GNUNET_FS_directory_builder_add(), GNUNET_FS_directory_list_contents(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_stop(), GNUNET_FS_file_information_destroy(), GNUNET_FS_probe_stop(), GNUNET_FS_publish_ksk_cancel(), GNUNET_FS_publish_sks_cancel(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_stop(), GNUNET_FS_share_tree_free(), GNUNET_FS_tree_encoder_finish(), GNUNET_FS_unindex_signal_suspend_(), GNUNET_FS_unindex_stop(), handle_client_loc_sign(), make_file(), process_kblock(), process_kblock_for_unindex(), process_sblock(), publish_inspector(), run(), search_result_free(), search_result_suspend(), search_start(), and share_tree_trim().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_ksk_get_keyword_count()

unsigned int GNUNET_FS_uri_ksk_get_keyword_count ( const struct GNUNET_FS_Uri uri)

How many keywords are ANDed in this keyword URI?

Parameters
uriksk uri to get the number of keywords from
Returns
0 if this is not a keyword URI

Definition at line 711 of file fs_uri.c.

712{
713 if (uri->type != GNUNET_FS_URI_KSK)
714 return 0;
715 return uri->data.ksk.keywordCount;
716}

References GNUNET_FS_Uri::data, GNUNET_FS_URI_KSK, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::ksk, GNUNET_FS_Uri::type, and uri.

Referenced by fip_signal_start().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_ksk_get_keywords()

int GNUNET_FS_uri_ksk_get_keywords ( const struct GNUNET_FS_Uri uri,
GNUNET_FS_KeywordIterator  iterator,
void *  iterator_cls 
)

Iterate over all keywords in this keyword URI.

Parameters
uriksk uri to get the keywords from
iteratorfunction to call on each keyword
iterator_clsclosure for iterator
Returns
-1 if this is not a keyword URI, otherwise number of keywords iterated over until iterator aborted

Definition at line 720 of file fs_uri.c.

723{
724 unsigned int i;
725 char *keyword;
726
727 if (uri->type != GNUNET_FS_URI_KSK)
728 return -1;
729 if (NULL == iterator)
730 return uri->data.ksk.keywordCount;
731 for (i = 0; i < uri->data.ksk.keywordCount; i++)
732 {
733 keyword = uri->data.ksk.keywords[i];
734 /* first character of keyword indicates
735 * if it is mandatory or not */
736 if (GNUNET_OK != iterator (iterator_cls, &keyword[1],(keyword[0] == '+') ))
737 return i;
738 }
739 return i;
740}

References GNUNET_FS_Uri::data, GNUNET_FS_URI_KSK, GNUNET_OK, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, GNUNET_FS_Uri::type, and uri.

Referenced by publish_inspector(), and share_tree_trim().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_loc_get_peer_identity()

int GNUNET_FS_uri_loc_get_peer_identity ( const struct GNUNET_FS_Uri uri,
struct GNUNET_PeerIdentity peer 
)

Obtain the identity of the peer offering the data.

Parameters
urithe location URI to inspect
peerwhere to store the identify of the peer (presumably) offering the content
Returns
GNUNET_SYSERR if this is not a location URI, otherwise GNUNET_OK

Definition at line 812 of file fs_uri.c.

814{
815 if (uri->type != GNUNET_FS_URI_LOC)
816 return GNUNET_SYSERR;
817 *peer = uri->data.loc.peer;
818 return GNUNET_OK;
819}
struct GNUNET_PeerIdentity peer
Identity of the peer sharing the file.
Definition: fs_api.h:122

References GNUNET_FS_Uri::data, GNUNET_FS_URI_LOC, GNUNET_OK, GNUNET_SYSERR, GNUNET_FS_Uri::loc, Location::peer, GNUNET_FS_Uri::type, and uri.

Referenced by create_download_context(), and deserialize_download().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_loc_get_uri()

struct GNUNET_FS_Uri * GNUNET_FS_uri_loc_get_uri ( const struct GNUNET_FS_Uri uri)

Obtain the URI of the content itself.

Parameters
urilocation URI to get the content URI from
Returns
NULL if argument is not a location URI

Definition at line 843 of file fs_uri.c.

844{
845 struct GNUNET_FS_Uri *ret;
846
847 if (uri->type != GNUNET_FS_URI_LOC)
848 return NULL;
849 ret = GNUNET_new (struct GNUNET_FS_Uri);
850 ret->type = GNUNET_FS_URI_CHK;
851 ret->data.chk = uri->data.loc.fi;
852 return ret;
853}
#define GNUNET_new(type)
Allocate a struct or union of the given type.

References GNUNET_FS_Uri::data, Location::fi, GNUNET_FS_URI_CHK, GNUNET_FS_URI_LOC, GNUNET_new, GNUNET_FS_Uri::loc, ret, GNUNET_FS_Uri::type, and uri.

Referenced by GNUNET_FS_directory_builder_add().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_loc_get_expiration()

struct GNUNET_TIME_Absolute GNUNET_FS_uri_loc_get_expiration ( const struct GNUNET_FS_Uri uri)

Obtain the expiration of the LOC URI.

Parameters
urilocation URI to get the expiration from
Returns
expiration time of the URI

Definition at line 829 of file fs_uri.c.

830{
832 return uri->data.loc.expirationTime;
833}
struct GNUNET_TIME_Absolute expirationTime
Time when this location URI expires.
Definition: fs_api.h:127

References GNUNET_FS_Uri::data, Location::expirationTime, GNUNET_assert, GNUNET_FS_URI_LOC, GNUNET_FS_Uri::loc, GNUNET_FS_Uri::type, and uri.

◆ GNUNET_FS_uri_loc_create()

struct GNUNET_FS_Uri * GNUNET_FS_uri_loc_create ( const struct GNUNET_FS_Uri base_uri,
const struct GNUNET_CRYPTO_EddsaPrivateKey sign_key,
struct GNUNET_TIME_Absolute  expiration_time 
)

Construct a location URI (this peer will be used for the location).

This function should only be called from within gnunet-service-fs, as it requires the peer's private key which is generally unavailable to processes directly under the user's control. However, for testing and as it logically fits under URIs, it is in this API.

Parameters
base_uricontent offered by the sender
sign_keyprivate key of the peer
expiration_timehow long will the content be offered?
Returns
the location URI, NULL on error

Definition at line 869 of file fs_uri.c.

872{
873 struct GNUNET_FS_Uri *uri;
874 struct GNUNET_CRYPTO_EddsaPublicKey my_public_key;
875 struct LocUriAssembly ass;
876 struct GNUNET_TIME_Absolute et;
877
878 if (GNUNET_FS_URI_CHK != base_uri->type)
879 return NULL;
880 /* we round expiration time to full seconds for SKS URIs */
881 et.abs_value_us = (expiration_time.abs_value_us / 1000000LL) * 1000000LL;
882 GNUNET_CRYPTO_eddsa_key_get_public (sign_key, &my_public_key);
883 ass.purpose.size = htonl (sizeof(struct LocUriAssembly));
884 ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT);
885 ass.exptime = GNUNET_TIME_absolute_hton (et);
886 ass.fi = base_uri->data.chk;
887 ass.peer.public_key = my_public_key;
888 uri = GNUNET_new (struct GNUNET_FS_Uri);
890 uri->data.loc.fi = base_uri->data.chk;
892 uri->data.loc.peer.public_key = my_public_key;
893 GNUNET_CRYPTO_eddsa_sign (sign_key,
894 &ass,
896 return uri;
897}
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:201
#define GNUNET_CRYPTO_eddsa_sign(priv, ps, sig)
EdDSA sign a given block.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640
#define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT
Signature by which a peer affirms that it is providing a certain bit of content for use in LOCation U...
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Structure that defines how the contents of a location URI must be assembled in memory to create or ve...
Definition: fs_uri.c:459
struct GNUNET_CRYPTO_EddsaSignature contentSignature
Signature over the GNUNET_EC_FileIdentifier, peer identity and expiration time.
Definition: fs_api.h:133

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_FS_Uri::chk, Location::contentSignature, GNUNET_FS_Uri::data, Location::expirationTime, LocUriAssembly::exptime, Location::fi, LocUriAssembly::fi, GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_CRYPTO_eddsa_sign, GNUNET_FS_URI_CHK, GNUNET_FS_URI_LOC, GNUNET_new, GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT, GNUNET_TIME_absolute_hton(), GNUNET_FS_Uri::loc, Location::peer, LocUriAssembly::peer, GNUNET_PeerIdentity::public_key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, LocUriAssembly::purpose, GNUNET_CRYPTO_EccSignaturePurpose::size, GNUNET_FS_Uri::type, and uri.

Referenced by handle_client_loc_sign().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_uri_ksk_merge()

struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_merge ( const struct GNUNET_FS_Uri u1,
const struct GNUNET_FS_Uri u2 
)

Merge the sets of keywords from two KSK URIs.

Parameters
u1first uri
u2second uri
Returns
merged URI, NULL on error

(useful for merging the canonicalized keywords with the original keywords for sharing).

Parameters
u1first uri
u2second uri
Returns
merged URI, NULL on error

Definition at line 931 of file fs_uri.c.

933{
934 struct GNUNET_FS_Uri *ret;
935 unsigned int kc;
936 unsigned int i;
937 unsigned int j;
938 int found;
939 const char *kp;
940 char **kl;
941
942 if ((u1 == NULL) && (u2 == NULL))
943 return NULL;
944 if (u1 == NULL)
945 return GNUNET_FS_uri_dup (u2);
946 if (u2 == NULL)
947 return GNUNET_FS_uri_dup (u1);
948 if ((u1->type != GNUNET_FS_URI_KSK) || (u2->type != GNUNET_FS_URI_KSK))
949 {
950 GNUNET_break (0);
951 return NULL;
952 }
953 kc = u1->data.ksk.keywordCount;
954 kl = GNUNET_new_array (kc + u2->data.ksk.keywordCount, char *);
955 for (i = 0; i < u1->data.ksk.keywordCount; i++)
956 kl[i] = GNUNET_strdup (u1->data.ksk.keywords[i]);
957 for (i = 0; i < u2->data.ksk.keywordCount; i++)
958 {
959 kp = u2->data.ksk.keywords[i];
960 found = 0;
961 for (j = 0; j < u1->data.ksk.keywordCount; j++)
962 if (0 == strcmp (kp + 1, kl[j] + 1))
963 {
964 found = 1;
965 if (kp[0] == '+')
966 kl[j][0] = '+';
967 break;
968 }
969 if (0 == found)
970 kl[kc++] = GNUNET_strdup (kp);
971 }
972 ret = GNUNET_new (struct GNUNET_FS_Uri);
973 ret->type = GNUNET_FS_URI_KSK;
974 ret->data.ksk.keywordCount = kc;
975 ret->data.ksk.keywords = kl;
976 return ret;
977}
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:987
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.

References GNUNET_FS_Uri::data, GNUNET_break, GNUNET_FS_uri_dup(), GNUNET_FS_URI_KSK, GNUNET_new, GNUNET_new_array, GNUNET_strdup, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, ret, and GNUNET_FS_Uri::type.

Referenced by publish_inspector().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_uri_dup()

struct GNUNET_FS_Uri * GNUNET_FS_uri_dup ( const struct GNUNET_FS_Uri uri)

Duplicate URI.

Parameters
urithe URI to duplicate
Returns
copy of the URI

Definition at line 987 of file fs_uri.c.

988{
989 struct GNUNET_FS_Uri *ret;
990 unsigned int i;
991
992 if (uri == NULL)
993 return NULL;
994 ret = GNUNET_new (struct GNUNET_FS_Uri);
995 GNUNET_memcpy (ret, uri, sizeof(struct GNUNET_FS_Uri));
996 switch (ret->type)
997 {
999 if (ret->data.ksk.keywordCount >=
1000 GNUNET_MAX_MALLOC_CHECKED / sizeof(char *))
1001 {
1002 GNUNET_break (0);
1003 GNUNET_free (ret);
1004 return NULL;
1005 }
1006 if (ret->data.ksk.keywordCount > 0)
1007 {
1008 ret->data.ksk.keywords =
1009 GNUNET_new_array (ret->data.ksk.keywordCount, char *);
1010 for (i = 0; i < ret->data.ksk.keywordCount; i++)
1011 ret->data.ksk.keywords[i] = GNUNET_strdup (uri->data.ksk.keywords[i]);
1012 }
1013 else
1014 ret->data.ksk.keywords = NULL; /* just to be sure */
1015 break;
1016
1017 case GNUNET_FS_URI_SKS:
1018 ret->data.sks.identifier = GNUNET_strdup (uri->data.sks.identifier);
1019 break;
1020
1021 case GNUNET_FS_URI_LOC:
1022 break;
1023
1024 default:
1025 break;
1026 }
1027 return ret;
1028}
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MAX_MALLOC_CHECKED
Maximum allocation with GNUNET_malloc macro.

References GNUNET_FS_Uri::data, GNUNET_break, GNUNET_free, GNUNET_FS_URI_KSK, GNUNET_FS_URI_LOC, GNUNET_FS_URI_SKS, GNUNET_MAX_MALLOC_CHECKED, GNUNET_memcpy, GNUNET_new, GNUNET_new_array, GNUNET_strdup, GNUNET_FS_Uri::identifier, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, ret, GNUNET_FS_Uri::sks, and uri.

Referenced by create_download_context(), GNUNET_FS_file_information_create_empty_directory(), GNUNET_FS_file_information_create_from_reader(), GNUNET_FS_probe(), GNUNET_FS_publish_ksk(), GNUNET_FS_publish_sks(), GNUNET_FS_tree_encoder_get_uri(), GNUNET_FS_uri_ksk_merge(), process_ksk_result(), process_sks_result(), publish_sblocks_cont(), search_start(), share_tree_trim(), and unindex_directory_scan_cb().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_ksk_create()

struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_create ( const char *  keywords,
char **  emsg 
)

Create an FS URI from a single user-supplied string of keywords.

The string is broken up at spaces into individual keywords. Keywords that start with "+" are mandatory. Double-quotes can be used to prevent breaking up strings at spaces (and also to specify non-mandatory keywords starting with "+").

Keywords must contain a balanced number of double quotes and double quotes can not be used in the actual keywords (for example, the string '""foo bar""' will be turned into two "OR"ed keywords 'foo' and 'bar', not into '"foo bar"'.

Parameters
keywordsthe keyword string
emsgwhere to store an error message
Returns
an FS URI for the given keywords, NULL if keywords is not legal (i.e. empty).

Definition at line 1049 of file fs_uri.c.

1050{
1051 char **keywordarr;
1052 unsigned int num_Words;
1053 int inWord;
1054 char *pos;
1055 struct GNUNET_FS_Uri *uri;
1056 char *searchString;
1057 int saw_quote;
1058
1059 if (keywords == NULL)
1060 {
1061 *emsg = GNUNET_strdup (_ ("No keywords specified!\n"));
1062 GNUNET_break (0);
1063 return NULL;
1064 }
1065 searchString = GNUNET_strdup (keywords);
1066 num_Words = 0;
1067 inWord = 0;
1068 saw_quote = 0;
1069 pos = searchString;
1070 while ('\0' != *pos)
1071 {
1072 if ((saw_quote == 0) && (isspace ((unsigned char) *pos)))
1073 {
1074 inWord = 0;
1075 }
1076 else if (0 == inWord)
1077 {
1078 inWord = 1;
1079 ++num_Words;
1080 }
1081 if ('"' == *pos)
1082 saw_quote = (saw_quote + 1) % 2;
1083 pos++;
1084 }
1085 if (num_Words == 0)
1086 {
1087 GNUNET_free (searchString);
1088 *emsg = GNUNET_strdup (_ ("No keywords specified!\n"));
1089 return NULL;
1090 }
1091 if (saw_quote != 0)
1092 {
1093 GNUNET_free (searchString);
1094 *emsg = GNUNET_strdup (_ ("Number of double-quotes not balanced!\n"));
1095 return NULL;
1096 }
1097 keywordarr = GNUNET_new_array (num_Words, char *);
1098 num_Words = 0;
1099 inWord = 0;
1100 pos = searchString;
1101 while ('\0' != *pos)
1102 {
1103 if ((saw_quote == 0) && (isspace ((unsigned char) *pos)))
1104 {
1105 inWord = 0;
1106 *pos = '\0';
1107 }
1108 else if (0 == inWord)
1109 {
1110 keywordarr[num_Words] = pos;
1111 inWord = 1;
1112 ++num_Words;
1113 }
1114 if ('"' == *pos)
1115 saw_quote = (saw_quote + 1) % 2;
1116 pos++;
1117 }
1118 uri =
1119 GNUNET_FS_uri_ksk_create_from_args (num_Words, (const char **) keywordarr);
1120 GNUNET_free (keywordarr);
1121 GNUNET_free (searchString);
1122 return uri;
1123}
struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_create_from_args(unsigned int argc, const char **argv)
Create an FS URI from a user-supplied command line of keywords.
Definition: fs_uri.c:1144

References _, GNUNET_break, GNUNET_free, GNUNET_FS_uri_ksk_create_from_args(), GNUNET_new_array, GNUNET_strdup, GNUNET_FS_Uri::keywords, and uri.

Referenced by make_keywords().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_uri_ksk_create_from_args()

struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_create_from_args ( unsigned int  argc,
const char **  argv 
)

Create an FS URI from a user-supplied command line of keywords.

Arguments should start with "+" to indicate mandatory keywords.

Parameters
argcnumber of keywords
argvkeywords (double quotes are not required for keywords containing spaces; however, double quotes are required for keywords starting with "+"); there is no mechanism for having double quotes in the actual keywords (if the user did specifically specify double quotes, the caller should convert each double quote into two single quotes).
Returns
an FS URI for the given keywords, NULL if keywords is not legal (i.e. empty).

Definition at line 1144 of file fs_uri.c.

1145{
1146 unsigned int i;
1147 struct GNUNET_FS_Uri *uri;
1148 const char *keyword;
1149 char *val;
1150 const char *r;
1151 char *w;
1152 char *emsg;
1153
1154 if (argc == 0)
1155 return NULL;
1156 /* allow URI to be given as one and only keyword and
1157 * handle accordingly */
1158 emsg = NULL;
1159 if ((argc == 1) && (strlen (argv[0]) > strlen (GNUNET_FS_URI_PREFIX)) &&
1160 (0 == strncmp (argv[0],
1162 strlen (GNUNET_FS_URI_PREFIX))) &&
1163 (NULL != (uri = GNUNET_FS_uri_parse (argv[0], &emsg))))
1164 return uri;
1165 GNUNET_free (emsg);
1166 uri = GNUNET_new (struct GNUNET_FS_Uri);
1168 uri->data.ksk.keywordCount = argc;
1169 uri->data.ksk.keywords = GNUNET_new_array (argc, char *);
1170 for (i = 0; i < argc; i++)
1171 {
1172 keyword = argv[i];
1173 if (keyword[0] == '+')
1174 val = GNUNET_strdup (keyword);
1175 else
1176 GNUNET_asprintf (&val, " %s", keyword);
1177 r = val;
1178 w = val;
1179 while ('\0' != *r)
1180 {
1181 if ('"' == *r)
1182 r++;
1183 else
1184 *(w++) = *(r++);
1185 }
1186 *w = '\0';
1187 uri->data.ksk.keywords[i] = val;
1188 }
1189 return uri;
1190}
#define GNUNET_FS_URI_PREFIX
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
Definition: fs_uri.c:637

References GNUNET_FS_Uri::data, GNUNET_asprintf(), GNUNET_free, GNUNET_FS_URI_KSK, GNUNET_FS_uri_parse(), GNUNET_FS_URI_PREFIX, GNUNET_new, GNUNET_new_array, GNUNET_strdup, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, GNUNET_FS_Uri::type, and uri.

Referenced by get_file_information(), GNUNET_FS_uri_ksk_create(), migrate_and_drop_keywords(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_uri_test_equal()

int GNUNET_FS_uri_test_equal ( const struct GNUNET_FS_Uri u1,
const struct GNUNET_FS_Uri u2 
)

Test if two URIs are equal.

Parameters
u1one of the URIs
u2the other URI
Returns
GNUNET_YES if the URIs are equal

Definition at line 1201 of file fs_uri.c.

1203{
1204 int ret;
1205 unsigned int i;
1206 unsigned int j;
1207
1208 GNUNET_assert (u1 != NULL);
1209 GNUNET_assert (u2 != NULL);
1210 if (u1->type != u2->type)
1211 return GNUNET_NO;
1212 switch (u1->type)
1213 {
1214 case GNUNET_FS_URI_CHK:
1215 if (0 ==
1216 memcmp (&u1->data.chk, &u2->data.chk, sizeof(struct FileIdentifier)))
1217 return GNUNET_YES;
1218 return GNUNET_NO;
1219
1220 case GNUNET_FS_URI_SKS:
1221 if ((0 == memcmp (&u1->data.sks.ns,
1222 &u2->data.sks.ns,
1223 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) &&
1224 (0 == strcmp (u1->data.sks.identifier, u2->data.sks.identifier)))
1225
1226 return GNUNET_YES;
1227 return GNUNET_NO;
1228
1229 case GNUNET_FS_URI_KSK:
1230 if (u1->data.ksk.keywordCount != u2->data.ksk.keywordCount)
1231 return GNUNET_NO;
1232 for (i = 0; i < u1->data.ksk.keywordCount; i++)
1233 {
1234 ret = GNUNET_NO;
1235 for (j = 0; j < u2->data.ksk.keywordCount; j++)
1236 {
1237 if (0 == strcmp (u1->data.ksk.keywords[i], u2->data.ksk.keywords[j]))
1238 {
1239 ret = GNUNET_YES;
1240 break;
1241 }
1242 }
1243 if (ret == GNUNET_NO)
1244 return GNUNET_NO;
1245 }
1246 return GNUNET_YES;
1247
1248 case GNUNET_FS_URI_LOC:
1249 if (memcmp (&u1->data.loc,
1250 &u2->data.loc,
1251 sizeof(struct FileIdentifier)
1252 + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)
1253 + sizeof(struct GNUNET_TIME_Absolute)
1254 + sizeof(unsigned short) + sizeof(unsigned short)) != 0)
1255 return GNUNET_NO;
1256 return GNUNET_YES;
1257
1258 default:
1259 return GNUNET_NO;
1260 }
1261}
@ GNUNET_YES
@ GNUNET_NO
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_CRYPTO_EcdsaPublicKey ns
Identifier of the namespace.
Definition: fs_api.h:199

References GNUNET_FS_Uri::chk, GNUNET_FS_Uri::data, GNUNET_assert, GNUNET_FS_URI_CHK, GNUNET_FS_URI_KSK, GNUNET_FS_URI_LOC, GNUNET_FS_URI_SKS, GNUNET_NO, GNUNET_YES, GNUNET_FS_Uri::identifier, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, GNUNET_FS_Uri::loc, GNUNET_FS_Uri::ns, ret, GNUNET_FS_Uri::sks, and GNUNET_FS_Uri::type.

Referenced by get_result_present(), test_result_present(), and trigger_recursive_download().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_test_sks()

int GNUNET_FS_uri_test_sks ( const struct GNUNET_FS_Uri uri)

Is this a namespace URI?

Parameters
urithe uri to check
Returns
GNUNET_YES if this is an SKS uri

Definition at line 1271 of file fs_uri.c.

1272{
1273 return uri->type == GNUNET_FS_URI_SKS;
1274}

References GNUNET_FS_URI_SKS, GNUNET_FS_Uri::type, and uri.

Referenced by deserialize_fi_node(), deserialize_search(), GNUNET_FS_directory_builder_add(), GNUNET_FS_search_sync_(), GNUNET_FS_uri_sks_get_content_id(), GNUNET_FS_uri_sks_get_namespace(), run(), and schedule_transmit_search_request().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_sks_create()

struct GNUNET_FS_Uri * GNUNET_FS_uri_sks_create ( const struct GNUNET_CRYPTO_EcdsaPublicKey ns,
const char *  id 
)

Create an SKS URI from a namespace ID and an identifier.

Parameters
nspseudonym to use
ididentifier
Returns
an FS URI for the given namespace and identifier
Parameters
nsnamespace ID
ididentifier
Returns
an FS URI for the given namespace and identifier

Definition at line 908 of file fs_uri.c.

910{
911 struct GNUNET_FS_Uri *ns_uri;
912
913 ns_uri = GNUNET_new (struct GNUNET_FS_Uri);
914 ns_uri->type = GNUNET_FS_URI_SKS;
915 ns_uri->data.sks.ns = *ns;
916 ns_uri->data.sks.identifier = GNUNET_strdup (id);
917 return ns_uri;
918}
static struct GNUNET_NAMECACHE_Handle * ns
Handle to the namecache.

References GNUNET_FS_Uri::data, GNUNET_FS_URI_SKS, GNUNET_new, GNUNET_strdup, GNUNET_FS_Uri::identifier, ns, GNUNET_FS_Uri::ns, GNUNET_FS_Uri::sks, and GNUNET_FS_Uri::type.

◆ GNUNET_FS_uri_sks_get_namespace()

int GNUNET_FS_uri_sks_get_namespace ( const struct GNUNET_FS_Uri uri,
struct GNUNET_CRYPTO_EcdsaPublicKey pseudonym 
)

Get the public key of a namespace from the given namespace URI.

Parameters
urithe uri to get the namespace ID from
pseudonymwhere to store the public key of the namespace
Returns
GNUNET_OK on success

Get the public key of a namespace from the given namespace URI.

Parameters
urithe uri to get the namespace ID from
pseudonymwhere to store the ID of the namespace
Returns
GNUNET_OK on success

Definition at line 1286 of file fs_uri.c.

1288{
1290 {
1291 GNUNET_break (0);
1292 return GNUNET_SYSERR;
1293 }
1294 *pseudonym = uri->data.sks.ns;
1295 return GNUNET_OK;
1296}
static char * pseudonym
Command-line option identifying the pseudonym to use for the publication.
int GNUNET_FS_uri_test_sks(const struct GNUNET_FS_Uri *uri)
Is this a namespace URI?
Definition: fs_uri.c:1271

References GNUNET_FS_Uri::data, GNUNET_break, GNUNET_FS_uri_test_sks(), GNUNET_OK, GNUNET_SYSERR, GNUNET_FS_Uri::ns, pseudonym, GNUNET_FS_Uri::sks, and uri.

Here is the call graph for this function:

◆ GNUNET_FS_uri_sks_get_content_id()

char * GNUNET_FS_uri_sks_get_content_id ( const struct GNUNET_FS_Uri uri)

Get the content identifier of an SKS URI.

Parameters
urithe sks uri
Returns
NULL on error (not a valid SKS URI)

Definition at line 1306 of file fs_uri.c.

1307{
1309 {
1310 GNUNET_break (0);
1311 return NULL;
1312 }
1314}

References GNUNET_FS_Uri::data, GNUNET_break, GNUNET_FS_uri_test_sks(), GNUNET_strdup, GNUNET_FS_Uri::identifier, GNUNET_FS_Uri::sks, and uri.

Here is the call graph for this function:

◆ GNUNET_FS_uri_test_ksk()

int GNUNET_FS_uri_test_ksk ( const struct GNUNET_FS_Uri uri)

Is this a keyword URI?

Parameters
urithe uri
Returns
GNUNET_YES if this is a KSK uri

Definition at line 1324 of file fs_uri.c.

1325{
1326#if EXTRA_CHECKS
1327 unsigned int i;
1328
1329 if (uri->type == GNUNET_FS_URI_KSK)
1330 {
1331 for (i = 0; i < uri->data.ksk.keywordCount; i++)
1332 GNUNET_assert (uri->data.ksk.keywords[i] != NULL);
1333 }
1334#endif
1335 return uri->type == GNUNET_FS_URI_KSK;
1336}

References GNUNET_FS_Uri::data, GNUNET_assert, GNUNET_FS_URI_KSK, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::keywords, GNUNET_FS_Uri::ksk, GNUNET_FS_Uri::type, and uri.

Referenced by deserialize_fi_node(), deserialize_search(), GNUNET_FS_directory_builder_add(), GNUNET_FS_directory_list_contents(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_start_searching_(), GNUNET_FS_search_stop(), GNUNET_FS_search_sync_(), run(), and schedule_transmit_search_request().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_test_chk()

int GNUNET_FS_uri_test_chk ( const struct GNUNET_FS_Uri uri)

Is this a file (or directory) URI?

Parameters
urithe uri to check
Returns
GNUNET_YES if this is a CHK uri

Definition at line 1346 of file fs_uri.c.

1347{
1348 return uri->type == GNUNET_FS_URI_CHK;
1349}

References GNUNET_FS_URI_CHK, GNUNET_FS_Uri::type, and uri.

Referenced by create_download_context(), deserialize_download(), deserialize_fi_node(), GNUNET_FS_directory_builder_add(), GNUNET_FS_download_sync_(), progress_cb(), and run().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_chk_get_file_size()

uint64_t GNUNET_FS_uri_chk_get_file_size ( const struct GNUNET_FS_Uri uri)

What is the size of the file that this URI refers to?

Parameters
urithe CHK (or LOC) URI to inspect
Returns
size of the file as specified in the CHK URI
Parameters
urithe CHK URI to inspect
Returns
size of the file as specified in the CHK URI

Definition at line 1360 of file fs_uri.c.

1361{
1362 switch (uri->type)
1363 {
1364 case GNUNET_FS_URI_CHK:
1366
1367 case GNUNET_FS_URI_LOC:
1369
1370 default:
1371 GNUNET_assert (0);
1372 }
1373 return 0; /* unreachable */
1374}
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
uint64_t file_length
Total size of the file in bytes.
Definition: fs_api.h:99

References GNUNET_FS_Uri::chk, GNUNET_FS_Uri::data, Location::fi, FileIdentifier::file_length, GNUNET_assert, GNUNET_FS_URI_CHK, GNUNET_FS_URI_LOC, GNUNET_ntohll(), GNUNET_FS_Uri::loc, GNUNET_FS_Uri::type, and uri.

Referenced by create_download_context(), deserialize_download(), encode_cont(), full_recursive_download(), GNUNET_FS_directory_builder_add(), GNUNET_FS_download_start_task_(), GNUNET_FS_search_start_probe_(), match_full_data(), print_search_result(), progress_cb(), run(), trigger_recursive_download(), and try_top_down_reconstruction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_uri_chk_get_file_hash()

const struct GNUNET_HashCode * GNUNET_FS_uri_chk_get_file_hash ( const struct GNUNET_FS_Uri uri)

What is the hash of the original file's content that this URI refers to?

Parameters
urithe CHK URI to inspect
Returns
hash of the file as specified in the CHK URI

Definition at line 1385 of file fs_uri.c.

1386{
1387 if (GNUNET_FS_URI_CHK != uri->type)
1388 GNUNET_assert (0);
1389
1390 return &(uri->data.chk.chk.key);
1391}
struct GNUNET_HashCode key
Hash of the original content, used for encryption.
Definition: fs.h:59

References FileIdentifier::chk, GNUNET_FS_Uri::chk, GNUNET_FS_Uri::data, GNUNET_assert, GNUNET_FS_URI_CHK, ContentHashKey::key, GNUNET_FS_Uri::type, and uri.

◆ GNUNET_FS_uri_test_loc()

int GNUNET_FS_uri_test_loc ( const struct GNUNET_FS_Uri uri)

Is this a location URI?

Parameters
urithe uri to check
Returns
GNUNET_YES if this is a LOC uri

Definition at line 1401 of file fs_uri.c.

1402{
1403 return uri->type == GNUNET_FS_URI_LOC;
1404}

References GNUNET_FS_URI_LOC, GNUNET_FS_Uri::type, and uri.

Referenced by create_download_context(), deserialize_download(), GNUNET_FS_download_sync_(), GNUNET_FS_publish_main_(), and run().

Here is the caller graph for this function:

◆ GNUNET_FS_uri_ksk_create_from_meta_data()

struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_create_from_meta_data ( const struct GNUNET_FS_MetaData md)

Construct a keyword-URI from meta-data (take all entries in the meta-data and construct one large keyword URI that lists all keywords that can be found in the meta-data).

Parameters
mdmetadata to use
Returns
NULL on error, otherwise a KSK URI

Definition at line 1788 of file fs_uri.c.

1790{
1791 struct GNUNET_FS_Uri *ret;
1792 char *filename;
1793 char *full_name = NULL;
1794 char *ss;
1795 int ent;
1796 int tok_keywords = 0;
1797 int paren_keywords = 0;
1798
1799 if (NULL == md)
1800 return NULL;
1801 ret = GNUNET_new (struct GNUNET_FS_Uri);
1802 ret->type = GNUNET_FS_URI_KSK;
1803 ent = GNUNET_FS_meta_data_iterate (md, NULL, NULL);
1804 if (ent > 0)
1805 {
1807 md,
1809 -1);
1810 if (NULL != full_name)
1811 {
1812 filename = full_name;
1813 while (NULL != (ss = strstr (filename, DIR_SEPARATOR_STR)))
1814 filename = ss + 1;
1815 tok_keywords = get_keywords_from_tokens (filename, NULL, 0);
1816 paren_keywords = get_keywords_from_parens (filename, NULL, 0);
1817 }
1818 /* x3 because there might be a normalized variant of every keyword,
1819 plus theoretically one more for mime... */
1820 ret->data.ksk.keywords =
1821 GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3, char *);
1823 }
1824 if (tok_keywords > 0)
1825 ret->data.ksk.keywordCount +=
1827 ret->data.ksk.keywords,
1828 ret->data.ksk.keywordCount);
1829 if (paren_keywords > 0)
1830 ret->data.ksk.keywordCount +=
1832 ret->data.ksk.keywords,
1833 ret->data.ksk.keywordCount);
1834 if (ent > 0)
1835 GNUNET_free (full_name);
1836 return ret;
1837}
static int gather_uri_data(void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_len)
Function called on each value in the meta data.
Definition: fs_uri.c:1713
static int get_keywords_from_parens(const char *s, char **array, int index)
Break the filename up by matching [], () and {} pairs to make keywords.
Definition: fs_uri.c:1540
static int get_keywords_from_tokens(const char *s, char **array, int index)
Break the filename up by TOKENS to make keywords.
Definition: fs_uri.c:1648
static char * filename
#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
int GNUNET_FS_meta_data_iterate(const struct GNUNET_FS_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
Iterate over MD entries.
Definition: meta_data.c:418
char * GNUNET_FS_meta_data_get_first_by_types(const struct GNUNET_FS_MetaData *md,...)
Get the first matching MD entry of the given types.
Definition: meta_data.c:456
#define DIR_SEPARATOR_STR
Definition: platform.h:166

References DIR_SEPARATOR_STR, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, filename, gather_uri_data(), get_keywords_from_parens(), get_keywords_from_tokens(), GNUNET_free, GNUNET_FS_meta_data_get_first_by_types(), GNUNET_FS_meta_data_iterate(), GNUNET_FS_URI_KSK, GNUNET_new, GNUNET_new_array, and ret.

Referenced by process_helper_msgs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_GETOPT_KEYWORDS()

struct GNUNET_GETOPT_CommandLineOption GNUNET_FS_GETOPT_KEYWORDS ( char  shortName,
const char *  name,
const char *  argumentHelp,
const char *  description,
struct GNUNET_FS_Uri **  topKeywords 
)

Allow user to specify keywords.

Parameters
shortNameshort name of the option
namelong name of the option
argumentHelphelp text for the option argument
descriptionlong help text for the option
[out]topKeywordsset to the desired value

Definition at line 129 of file fs_getopt.c.

134{
137 .name = name,
138 .argumentHelp = argumentHelp,
139 .description = description,
140 .require_argument = 1,
141 .processor = &getopt_set_keywords,
142 .scls = (void *) topKeywords
143 };
144
145 return clo;
146}
static int getopt_set_keywords(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Command-line option parser function that allows the user to specify one or more '-k' options with key...
Definition: fs_getopt.c:46
static char * name
Name (label) of the records to list.
static struct GNUNET_FS_Uri * topKeywords
Keywords provided via command-line option.
Definition of a command line option.
const char * description
Help text for the option (description)
const char * argumentHelp
Name of the argument for the user in help text.
const char shortName
Short name of the option.

References GNUNET_GETOPT_CommandLineOption::argumentHelp, GNUNET_GETOPT_CommandLineOption::description, getopt_set_keywords(), name, GNUNET_GETOPT_CommandLineOption::shortName, and topKeywords.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_GETOPT_METADATA()

struct GNUNET_GETOPT_CommandLineOption GNUNET_FS_GETOPT_METADATA ( char  shortName,
const char *  name,
const char *  argumentHelp,
const char *  description,
struct GNUNET_FS_MetaData **  meta 
)

Allow user to specify metadata.

Parameters
shortNameshort name of the option
namelong name of the option
argumentHelphelp text for the option argument
descriptionlong help text for the option
[out]metametadata set to the desired value
shortNameshort name of the option
namelong name of the option
argumentHelphelp text for the option argument
descriptionlong help text for the option
[out]metadataset to the desired value

Definition at line 250 of file fs_getopt.c.

255{
258 .name = name,
259 .argumentHelp = argumentHelp,
260 .description = description,
261 .require_argument = 1,
262 .processor = &getopt_set_metadata,
263 .scls = (void *) meta
264 };
265
266 return clo;
267}
static int getopt_set_metadata(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Command-line option parser function that allows the user to specify one or more '-m' options with met...
Definition: fs_getopt.c:162
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.

References GNUNET_GETOPT_CommandLineOption::argumentHelp, GNUNET_GETOPT_CommandLineOption::description, getopt_set_metadata(), meta, name, and GNUNET_GETOPT_CommandLineOption::shortName.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_getopt_set_metadata()

int GNUNET_FS_getopt_set_metadata ( struct GNUNET_GETOPT_CommandLineProcessorContext ctx,
void *  scls,
const char *  option,
const char *  value 
)

Command-line option parser function that allows the user to specify one or more '-m' options with metadata.

Each specified entry of the form "type=value" will be added to the metadata. A pointer to the metadata must be passed as the "scls" argument.

Parameters
ctxcommand line processor context
sclsmust be of type struct GNUNET_FS_MetaData **
optionname of the option (typically 'k')
valuecommand line argument given
Returns
GNUNET_OK on success

◆ GNUNET_FS_start()

struct GNUNET_FS_Handle * GNUNET_FS_start ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  client_name,
GNUNET_FS_ProgressCallback  upcb,
void *  upcb_cls,
enum GNUNET_FS_Flags  flags,
  ... 
)

Setup a connection to the file-sharing service.

Parameters
cfgconfiguration to use
client_nameunique identifier for this client
upcbfunction to call to notify about FS actions
upcb_clsclosure for upcb
flagsspecific attributes for fs-operations
...list of optional options, terminated with GNUNET_FS_OPTIONS_END
Returns
NULL on error

Definition at line 3264 of file fs_api.c.

3270{
3271 struct GNUNET_FS_Handle *ret;
3272 enum GNUNET_FS_OPTIONS opt;
3273 va_list ap;
3274
3275 ret = GNUNET_new (struct GNUNET_FS_Handle);
3276 ret->cfg = cfg;
3277 ret->client_name = GNUNET_strdup (client_name);
3278 ret->upcb = upcb;
3279 ret->upcb_cls = upcb_cls;
3280 ret->flags = flags;
3281 ret->max_parallel_downloads = DEFAULT_MAX_PARALLEL_DOWNLOADS;
3282 ret->max_parallel_requests = DEFAULT_MAX_PARALLEL_REQUESTS;
3283 ret->avg_block_latency =
3284 GNUNET_TIME_UNIT_MINUTES; /* conservative starting point */
3285 va_start (ap, flags);
3286 while (GNUNET_FS_OPTIONS_END !=
3287 (opt = ((enum GNUNET_FS_OPTIONS) va_arg (ap, int))))
3288 {
3289 switch (opt)
3290 {
3292 ret->max_parallel_downloads = va_arg (ap, unsigned int);
3293
3294 break;
3295
3297 ret->max_parallel_requests = va_arg (ap, unsigned int);
3298
3299 break;
3300
3301 default:
3302 GNUNET_break (0);
3303 GNUNET_free (ret->client_name);
3304 GNUNET_free (ret);
3305 va_end (ap);
3306 return NULL;
3307 }
3308 }
3309 va_end (ap);
3311 {
3314 ret);
3317 ret);
3320 ret);
3323 ret);
3324 }
3325 return ret;
3326}
static int deserialize_download_file(void *cls, const char *filename)
Function called with a filename of serialized download operation to deserialize.
Definition: fs_api.c:3202
#define DEFAULT_MAX_PARALLEL_REQUESTS
How many block requests can we have outstanding in parallel at a time by default?
Definition: fs_api.c:37
static int deserialize_unindex_file(void *cls, const char *filename)
Function called with a filename of serialized unindexing operation to deserialize.
Definition: fs_api.c:2330
static int deserialize_search_file(void *cls, const char *filename)
Function called with a filename of serialized search operation to deserialize.
Definition: fs_api.c:3150
static void deserialization_master(const char *master_path, GNUNET_FileNameCallback proc, struct GNUNET_FS_Handle *h)
Deserialize information about pending operations.
Definition: fs_api.c:3244
#define DEFAULT_MAX_PARALLEL_DOWNLOADS
How many downloads can we have outstanding in parallel at a time by default?
Definition: fs_api.c:42
static int deserialize_publish_file(void *cls, const char *filename)
Function called with a filename of serialized publishing operation to deserialize.
Definition: fs_api.c:1616
#define GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD
Name of the directory with master downloads (not associated with search or part of another download).
Definition: fs_api.h:66
#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH
Name of the directory with top-level searches.
Definition: fs_api.h:55
#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX
Name of the directory with unindex operations.
Definition: fs_api.h:87
#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH
Name of the directory with publishing operations.
Definition: fs_api.h:77
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
GNUNET_FS_OPTIONS
Options specified in the VARARGs portion of GNUNET_FS_start.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
Master context for most FS operations.
Definition: fs_api.h:1070
enum GNUNET_FS_Flags flags
General flags.
Definition: fs_api.h:1162
char * client_name
Name of our client.
Definition: fs_api.h:1079
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1089
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1084

References cfg, GNUNET_FS_Handle::client_name, DEFAULT_MAX_PARALLEL_DOWNLOADS, DEFAULT_MAX_PARALLEL_REQUESTS, deserialization_master(), deserialize_download_file(), deserialize_publish_file(), deserialize_search_file(), deserialize_unindex_file(), GNUNET_FS_Handle::flags, GNUNET_break, GNUNET_free, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, GNUNET_FS_OPTIONS_END, GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, GNUNET_new, GNUNET_strdup, GNUNET_TIME_UNIT_MINUTES, ret, GNUNET_FS_Handle::upcb, and GNUNET_FS_Handle::upcb_cls.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_stop()

void GNUNET_FS_stop ( struct GNUNET_FS_Handle h)

Close our connection with the file-sharing service.

The callback given to GNUNET_FS_start() will no longer be called after this function returns. This function MUST NOT be called from within the callback itself.

Parameters
hhandle that was returned from GNUNET_FS_start()

Definition at line 3330 of file fs_api.c.

3331{
3332 while (NULL != h->top_head)
3333 h->top_head->ssf (h->top_head->ssf_cls);
3334 if (NULL != h->queue_job)
3335 GNUNET_SCHEDULER_cancel (h->queue_job);
3336 GNUNET_free (h->client_name);
3337 GNUNET_free (h);
3338}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980

References GNUNET_free, GNUNET_SCHEDULER_cancel(), and h.

Referenced by clean_task(), cleanup_task(), do_shutdown(), do_stop_task(), run(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_file_information_get_id()

const char * GNUNET_FS_file_information_get_id ( struct GNUNET_FS_FileInformation s)

Obtain the name under which this file information structure is stored on disk.

Only works for top-level file information structures.

Parameters
sstructure to get the filename for
Returns
NULL on error, otherwise filename that can be used to read this fi-struct from disk.

Definition at line 45 of file fs_file_information.c.

46{
47 if (NULL != s->dir)
48 return NULL;
49 return s->serialization;
50}
char * serialization
Under what filename is this struct serialized (for operational persistence).
Definition: fs_api.h:287
struct GNUNET_FS_FileInformation * dir
If this is a file in a directory, "dir" refers to the directory; otherwise NULL.
Definition: fs_api.h:238

References GNUNET_FS_FileInformation::dir, and GNUNET_FS_FileInformation::serialization.

◆ GNUNET_FS_file_information_get_filename()

const char * GNUNET_FS_file_information_get_filename ( const struct GNUNET_FS_FileInformation s)

Obtain the filename from the file information structure.

Parameters
sstructure to get the filename for
Returns
"filename" field of the structure (can be NULL)

Definition at line 60 of file fs_file_information.c.

62{
63 return s->filename;
64}
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:302

References GNUNET_FS_FileInformation::filename.

◆ GNUNET_FS_file_information_set_filename()

void GNUNET_FS_file_information_set_filename ( struct GNUNET_FS_FileInformation s,
const char *  filename 
)

Set the filename in the file information structure.

If filename was already set, frees it before setting the new one. Makes a copy of the argument.

Parameters
sstructure to get the filename for
filenamefilename to set

Definition at line 76 of file fs_file_information.c.

78{
80 if (filename)
82 else
83 s->filename = NULL;
84}

References filename, GNUNET_FS_FileInformation::filename, GNUNET_free, and GNUNET_strdup.

◆ GNUNET_FS_file_information_create_from_file()

struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_from_file ( struct GNUNET_FS_Handle h,
void *  client_info,
const char *  filename,
const struct GNUNET_FS_Uri keywords,
const struct GNUNET_FS_MetaData meta,
int  do_index,
const struct GNUNET_FS_BlockOptions bo 
)

Create an entry for a file in a publish-structure.

Parameters
hhandle to the file sharing subsystem
client_infoinitial client-info value for this entry
filenamename of the file or directory to publish
keywordsunder which keywords should this file be available directly; can be NULL
metametadata for the file
do_indexGNUNET_YES for index, GNUNET_NO for insertion, GNUNET_SYSERR for simulation
boblock options
Returns
publish structure entry for the file

Definition at line 88 of file fs_file_information.c.

96{
97 struct FileInfo *fi;
98 uint64_t fsize;
100 const char *fn;
101 const char *ss;
102
103 /* FIXME: should include_symbolic_links be GNUNET_NO or GNUNET_YES here? */
104 if (GNUNET_OK !=
106 {
108 return NULL;
109 }
111 if (NULL == fi)
112 {
113 GNUNET_break (0);
114 return NULL;
115 }
116 ret =
119 fsize,
121 fi,
122 keywords,
123 meta,
124 do_index,
125 bo);
126 if (ret == NULL)
127 return NULL;
128 ret->h = h;
129 ret->filename = GNUNET_strdup (filename);
130 fn = filename;
131 while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR)))
132 fn = ss + 1;
133/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
134 * this should be changed to EXTRACTOR_METAFORMAT_UTF8
135 */
137 "<gnunet>",
139 EXTRACTOR_METAFORMAT_C_STRING,
140 "text/plain",
141 fn,
142 strlen (fn) + 1);
143 return ret;
144}
void * GNUNET_FS_make_file_reader_context_(const char *filename)
Create the closure for the GNUNET_FS_data_reader_file_() callback.
Definition: fs_api.c:509
size_t GNUNET_FS_data_reader_file_(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function that provides data by reading from a file.
Definition: fs_api.c:447
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:222
struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_from_reader(struct GNUNET_FS_Handle *h, void *client_info, uint64_t length, GNUNET_FS_DataReader reader, void *reader_cls, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
Create an entry for a file in a publish-structure.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
int GNUNET_FS_meta_data_insert(struct GNUNET_FS_MetaData *md, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_size)
Extend metadata.
Definition: meta_data.c:254
Closure for GNUNET_FS_data_reader_file_().
Definition: fs_api.c:413
Information for a file or directory that is about to be published.
Definition: fs_api.h:228
struct GNUNET_FS_Uri * keywords
Keywords to use for KBlocks.
Definition: fs_api.h:258
void * client_info
Pointer kept for the client.
Definition: fs_api.h:248
int do_index
Should the file be indexed or inserted?
Definition: fs_api.h:339

References bo, GNUNET_FS_FileInformation::client_info, DIR_SEPARATOR_STR, GNUNET_FS_FileInformation::do_index, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, filename, GNUNET_break, GNUNET_DISK_file_size(), GNUNET_ERROR_TYPE_WARNING, GNUNET_FS_data_reader_file_(), GNUNET_FS_file_information_create_from_reader(), GNUNET_FS_make_file_reader_context_(), GNUNET_FS_meta_data_insert(), GNUNET_log_strerror_file, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_YES, h, GNUNET_FS_FileInformation::keywords, meta, and ret.

Referenced by get_file_information().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_file_information_create_from_data()

struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_from_data ( struct GNUNET_FS_Handle h,
void *  client_info,
uint64_t  length,
void *  data,
const struct GNUNET_FS_Uri keywords,
const struct GNUNET_FS_MetaData meta,
int  do_index,
const struct GNUNET_FS_BlockOptions bo 
)

Create an entry for a file in a publish-structure.

Parameters
hhandle to the file sharing subsystem
client_infoinitial client-info value for this entry
lengthlength of the file
datadata for the file (should not be used afterwards by the caller; callee will "free")
keywordsunder which keywords should this file be available directly; can be NULL
metametadata for the file
do_indexGNUNET_YES for index, GNUNET_NO for insertion, GNUNET_SYSERR for simulation
boblock options
Returns
publish structure entry for the file

Definition at line 148 of file fs_file_information.c.

157{
158 if (GNUNET_YES == do_index)
159 {
160 GNUNET_break (0);
161 return NULL;
162 }
164 client_info,
165 length,
166 &
168 data,
169 keywords,
170 meta,
171 do_index,
172 bo);
173}
size_t GNUNET_FS_data_reader_copy_(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function that provides data by copying from a buffer.
Definition: fs_api.c:545
static char * data
The data to insert into the dht.

References bo, GNUNET_FS_FileInformation::client_info, data, GNUNET_FS_FileInformation::do_index, GNUNET_break, GNUNET_FS_data_reader_copy_(), GNUNET_FS_file_information_create_from_reader(), GNUNET_YES, h, GNUNET_FS_FileInformation::keywords, and meta.

Referenced by make_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_file_information_create_from_reader()

struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_from_reader ( struct GNUNET_FS_Handle h,
void *  client_info,
uint64_t  length,
GNUNET_FS_DataReader  reader,
void *  reader_cls,
const struct GNUNET_FS_Uri keywords,
const struct GNUNET_FS_MetaData meta,
int  do_index,
const struct GNUNET_FS_BlockOptions bo 
)

Create an entry for a file in a publish-structure.

Parameters
hhandle to the file sharing subsystem
client_infoinitial client-info value for this entry
lengthlength of the file
readerfunction that can be used to obtain the data for the file
reader_clsclosure for reader
keywordsunder which keywords should this file be available directly; can be NULL
metametadata for the file
do_indexGNUNET_YES for index, GNUNET_NO for insertion, GNUNET_SYSERR for simulation
boblock options
Returns
publish structure entry for the file

Definition at line 177 of file fs_file_information.c.

187{
189
191 {
192 GNUNET_break (0);
193 return NULL;
194 }
196 ret->h = h;
197 ret->client_info = client_info;
199 if (ret->meta == NULL)
201 ret->keywords = (keywords == NULL) ? NULL : GNUNET_FS_uri_dup (keywords);
202 ret->data.file.reader = reader;
203 ret->data.file.reader_cls = reader_cls;
204 ret->data.file.do_index = do_index;
205 ret->data.file.file_size = length;
206 ret->bo = *bo;
207 return ret;
208}
struct GNUNET_FS_MetaData * GNUNET_FS_meta_data_create(void)
Create a fresh meta data container.
Definition: meta_data.c:127
struct GNUNET_FS_MetaData * GNUNET_FS_meta_data_duplicate(const struct GNUNET_FS_MetaData *md)
Duplicate a MetaData token.
Definition: meta_data.c:527
GNUNET_FS_DataReader reader
Function that can be used to read the data for the file.
Definition: fs_api.h:317
void * reader_cls
Closure for reader.
Definition: fs_api.h:322

References bo, GNUNET_FS_FileInformation::client_info, GNUNET_FS_FileInformation::do_index, GNUNET_break, GNUNET_FS_data_reader_file_(), GNUNET_FS_meta_data_create(), GNUNET_FS_meta_data_duplicate(), GNUNET_FS_uri_dup(), GNUNET_new, GNUNET_YES, h, GNUNET_FS_FileInformation::keywords, meta, GNUNET_FS_FileInformation::reader, GNUNET_FS_FileInformation::reader_cls, and ret.

Referenced by GNUNET_FS_file_information_create_from_data(), and GNUNET_FS_file_information_create_from_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_file_information_create_empty_directory()

struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_empty_directory ( struct GNUNET_FS_Handle h,
void *  client_info,
const struct GNUNET_FS_Uri keywords,
const struct GNUNET_FS_MetaData meta,
const struct GNUNET_FS_BlockOptions bo,
const char *  filename 
)

Create an entry for an empty directory in a publish-structure.

Parameters
hhandle to the file sharing subsystem
client_infoinitial client-info value for this entry
keywordsunder which keywords should this directory be available directly; can be NULL
metametadata for the directory
boblock options
filenamename of the directory; can be NULL
Returns
publish structure entry for the directory , NULL on error

Definition at line 226 of file fs_file_information.c.

233{
235
237 ret->h = h;
238 ret->client_info = client_info;
240 ret->keywords = GNUNET_FS_uri_dup (keywords);
241 ret->bo = *bo;
242 ret->is_directory = GNUNET_YES;
243 if (filename != NULL)
244 ret->filename = GNUNET_strdup (filename);
245 return ret;
246}

References bo, GNUNET_FS_FileInformation::client_info, filename, GNUNET_FS_meta_data_duplicate(), GNUNET_FS_uri_dup(), GNUNET_new, GNUNET_strdup, GNUNET_YES, h, GNUNET_FS_FileInformation::keywords, meta, and ret.

Referenced by get_file_information().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_file_information_is_directory()

int GNUNET_FS_file_information_is_directory ( const struct GNUNET_FS_FileInformation ent)

Test if a given entry represents a directory.

Parameters
entcheck if this FI represents a directory
Returns
GNUNET_YES if so, GNUNET_NO if not

Definition at line 218 of file fs_file_information.c.

220{
221 return ent->is_directory;
222}
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:391

References GNUNET_FS_FileInformation::is_directory.

◆ GNUNET_FS_file_information_add()

int GNUNET_FS_file_information_add ( struct GNUNET_FS_FileInformation dir,
struct GNUNET_FS_FileInformation ent 
)

Add an entry to a directory in a publish-structure.

Clients should never modify publish structures that were passed to GNUNET_FS_publish_start() already.

Parameters
dirthe directory
entthe entry to add; the entry must not have been added to any other directory at this point and must not include dir in its structure
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 250 of file fs_file_information.c.

252{
253 if ((ent->dir != NULL) || (ent->next != NULL) ||
254 (dir->is_directory != GNUNET_YES))
255 {
256 GNUNET_break (0);
257 return GNUNET_SYSERR;
258 }
259 ent->dir = dir;
260 ent->next = dir->data.dir.entries;
261 dir->data.dir.entries = ent;
262 dir->data.dir.dir_size = 0;
263 return GNUNET_OK;
264}
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:88
struct GNUNET_FS_FileInformation * next
Files in a directory are kept as a linked list.
Definition: fs_api.h:232

References dir, GNUNET_FS_FileInformation::dir, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, and GNUNET_FS_FileInformation::next.

Referenced by get_file_information().

Here is the caller graph for this function:

◆ GNUNET_FS_file_information_inspect()

void GNUNET_FS_file_information_inspect ( struct GNUNET_FS_FileInformation dir,
GNUNET_FS_FileInformationProcessor  proc,
void *  proc_cls 
)

Inspect a file or directory in a publish-structure.

Clients should never modify publish structures that were passed to GNUNET_FS_publish_start already. When called on a directory, this function will FIRST call proc with information about the directory itself and then for each of the files in the directory (but not for files in subdirectories). When called on a file, proc will be called exactly once (with information about the specific file).

Parameters
dirthe directory
procfunction to call on each entry
proc_clsclosure for proc

Definition at line 282 of file fs_file_information.c.

285{
286 struct GNUNET_FS_FileInformation *pos;
287 int no;
288
289 no = GNUNET_NO;
290 if (GNUNET_OK !=
291 proc (proc_cls,
292 dir,
293 (dir->is_directory == GNUNET_YES) ? dir->data.dir.dir_size
294 : dir->data.file.file_size,
295 dir->meta,
296 &dir->keywords,
297 &dir->bo,
298 (dir->is_directory == GNUNET_YES) ? &no : &dir->data.file.do_index,
299 &dir->client_info))
300 return;
301 if (dir->is_directory != GNUNET_YES)
302 return;
303 pos = dir->data.dir.entries;
304 while (pos != NULL)
305 {
306 no = GNUNET_NO;
307 if (GNUNET_OK !=
308 proc (proc_cls,
309 pos,
310 (pos->is_directory == GNUNET_YES) ? pos->data.dir.dir_size
311 : pos->data.file.file_size,
312 pos->meta,
313 &pos->keywords,
314 &pos->bo,
315 (pos->is_directory == GNUNET_YES) ? &no
316 : &pos->data.file.do_index,
317 &pos->client_info))
318 break;
319 pos = pos->next;
320 }
321}
size_t dir_size
Size of the directory itself (in bytes); 0 if the size has not yet been calculated.
Definition: fs_api.h:368
struct GNUNET_FS_FileInformation::@52::@53 file
Data for a file.
uint64_t file_size
Size of the file (in bytes).
Definition: fs_api.h:334
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:275
struct GNUNET_FS_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:253
union GNUNET_FS_FileInformation::@52 data
Data describing either the file or the directory.

References GNUNET_FS_FileInformation::bo, GNUNET_FS_FileInformation::client_info, GNUNET_FS_FileInformation::data, dir, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::dir_size, GNUNET_FS_FileInformation::do_index, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::file_size, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_FS_FileInformation::is_directory, GNUNET_FS_FileInformation::keywords, GNUNET_FS_FileInformation::meta, and GNUNET_FS_FileInformation::next.

Referenced by deserialize_publish_file(), directory_trim_complete(), fip_signal_resume(), fip_signal_start(), fip_signal_stop(), fip_signal_suspend(), GNUNET_FS_publish_signal_suspend_(), GNUNET_FS_publish_start(), GNUNET_FS_publish_stop(), and publish_inspector().

Here is the caller graph for this function:

◆ GNUNET_FS_file_information_destroy()

void GNUNET_FS_file_information_destroy ( struct GNUNET_FS_FileInformation fi,
GNUNET_FS_FileInformationProcessor  cleaner,
void *  cleaner_cls 
)

Destroy publish-structure.

Clients should never destroy publish structures that were passed to GNUNET_FS_publish_start already.

Parameters
fistructure to destroy
cleanerfunction to call on each entry in the structure (useful to clean up client_info); can be NULL; return values are ignored
cleaner_clsclosure for cleaner

Definition at line 335 of file fs_file_information.c.

338{
339 struct GNUNET_FS_FileInformation *pos;
340 int no;
341
342 no = GNUNET_NO;
343 if (GNUNET_YES == fi->is_directory)
344 {
345 /* clean up directory */
346 while (NULL != (pos = fi->data.dir.entries))
347 {
348 fi->data.dir.entries = pos->next;
349 GNUNET_FS_file_information_destroy (pos, cleaner, cleaner_cls);
350 }
351 /* clean up client-info */
352 if (NULL != cleaner)
353 cleaner (cleaner_cls,
354 fi,
355 fi->data.dir.dir_size,
356 fi->meta,
357 &fi->keywords,
358 &fi->bo,
359 &no,
360 &fi->client_info);
362 }
363 else
364 {
365 /* call clean-up function of the reader */
366 if (NULL != fi->data.file.reader)
367 {
368 (void) fi->data.file.reader (fi->data.file.reader_cls, 0, 0, NULL, NULL);
369 fi->data.file.reader = NULL;
370 }
371 /* clean up client-info */
372 if (NULL != cleaner)
373 cleaner (cleaner_cls,
374 fi,
375 fi->data.file.file_size,
376 fi->meta,
377 &fi->keywords,
378 &fi->bo,
379 &fi->data.file.do_index,
380 &fi->client_info);
381 }
382 GNUNET_free (fi->filename);
383 GNUNET_free (fi->emsg);
384 if (NULL != fi->sks_uri)
386 if (NULL != fi->chk_uri)
388 /* clean up serialization */
389 if ((NULL != fi->serialization) && (0 != unlink (fi->serialization)))
391 "unlink",
392 fi->serialization);
393 if (NULL != fi->keywords)
395 if (NULL != fi->meta)
398 if (NULL != fi->te)
399 {
401 fi->te = NULL;
402 }
403 GNUNET_free (fi);
404}
void GNUNET_FS_tree_encoder_finish(struct GNUNET_FS_TreeEncoder *te, char **emsg)
Clean up a tree encoder and return information about possible errors.
Definition: fs_tree.c:432
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:677
void GNUNET_FS_file_information_destroy(struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
Destroy publish-structure.
void GNUNET_FS_meta_data_destroy(struct GNUNET_FS_MetaData *md)
Free meta data.
Definition: meta_data.c:166
struct GNUNET_FS_TreeEncoder * te
Encoder being used to publish this file.
Definition: fs_api.h:292
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:297
struct GNUNET_FS_Uri * sks_uri
SKS URI for this file or directory.
Definition: fs_api.h:270
void * dir_data
Pointer to the data for the directory (or NULL if not available).
Definition: fs_api.h:374
struct GNUNET_FS_FileInformation * entries
Linked list of entries in the directory.
Definition: fs_api.h:362
struct GNUNET_FS_Uri * chk_uri
CHK for this file or directory.
Definition: fs_api.h:264

References GNUNET_FS_FileInformation::bo, GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_FileInformation::client_info, GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::dir_data, GNUNET_FS_FileInformation::dir_size, GNUNET_FS_FileInformation::do_index, GNUNET_FS_FileInformation::emsg, GNUNET_FS_FileInformation::entries, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::file_size, GNUNET_FS_FileInformation::filename, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_file_information_destroy(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_tree_encoder_finish(), GNUNET_FS_uri_destroy(), GNUNET_log_strerror_file, GNUNET_NO, GNUNET_YES, GNUNET_FS_FileInformation::is_directory, GNUNET_FS_FileInformation::keywords, GNUNET_FS_FileInformation::meta, GNUNET_FS_FileInformation::next, GNUNET_FS_FileInformation::reader, GNUNET_FS_FileInformation::reader_cls, GNUNET_FS_FileInformation::serialization, GNUNET_FS_FileInformation::sks_uri, and GNUNET_FS_FileInformation::te.

Referenced by deserialize_fi_node(), deserialize_publish_file(), directory_trim_complete(), GNUNET_FS_file_information_destroy(), and publish_cleanup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_publish_start()

struct GNUNET_FS_PublishContext * GNUNET_FS_publish_start ( struct GNUNET_FS_Handle h,
struct GNUNET_FS_FileInformation fi,
const struct GNUNET_CRYPTO_EcdsaPrivateKey ns,
const char *  nid,
const char *  nuid,
enum GNUNET_FS_PublishOptions  options 
)

Publish a file or directory.

Parameters
hhandle to the file sharing subsystem
fiinformation about the file or directory structure to publish
nsnamespace to publish the file in, NULL for no namespace
nididentifier to use for the published content in the namespace (can be NULL, must be NULL if namespace is NULL)
nuidupdate-identifier that will be used for future updates (can be NULL, must be NULL if namespace or nid is NULL)
optionsoptions for the publication
Returns
context that can be used to control the publish operation

Definition at line 1443 of file fs_publish.c.

1449{
1452
1453 GNUNET_assert (NULL != h);
1456 {
1458 if (NULL == dsh)
1459 return NULL;
1460 }
1461 else
1462 {
1463 dsh = NULL;
1464 }
1466 ret->dsh = dsh;
1467 ret->h = h;
1468 ret->fi = fi;
1469 if (NULL != ns)
1470 {
1472 *ret->ns = *ns;
1473 GNUNET_assert (NULL != nid);
1474 ret->nid = GNUNET_strdup (nid);
1475 if (NULL != nuid)
1476 ret->nuid = GNUNET_strdup (nuid);
1477 }
1478 ret->options = options;
1479 /* signal start */
1481 ret->fi_pos = ret->fi;
1484 if (NULL != ret->dsh)
1485 {
1486 GNUNET_assert (NULL == ret->qre);
1488 _ (
1489 "Reserving space for %u entries and %llu bytes for publication\n"),
1490 (unsigned int) ret->reserve_entries,
1491 (unsigned long long) ret->reserve_space);
1492 ret->qre =
1493 GNUNET_DATASTORE_reserve (ret->dsh, ret->reserve_space,
1494 ret->reserve_entries,
1496 ret);
1497 }
1498 else
1499 {
1500 GNUNET_assert (NULL == ret->upload_task);
1501 ret->upload_task =
1504 }
1505 return ret;
1506}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct TopLevelActivity * GNUNET_FS_make_top(struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, void *ssf_cls)
Create a top-level activity entry.
Definition: fs_api.c:381
void GNUNET_FS_publish_sync_(struct GNUNET_FS_PublishContext *pc)
Synchronize this publishing struct with its mirror on disk.
Definition: fs_api.c:1753
void GNUNET_FS_publish_signal_suspend_(void *cls)
Create SUSPEND event for the given publish operation and then clean up our state (without stop signal...
Definition: fs_publish.c:1355
static int fip_signal_start(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Signal the FS's progress function that we are starting an upload.
Definition: fs_publish.c:1194
static uint64_t compute_contents_size(struct GNUNET_FS_FileInformation *fi)
Calculate the total size of all of the files in the directory structure.
Definition: fs_publish.c:1416
static void finish_reserve(void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
We have gotten a reply for our space reservation request.
Definition: fs_publish.c:1383
void GNUNET_FS_publish_main_(void *cls)
Main function that performs the upload.
Definition: fs_publish.c:1063
static struct GNUNET_DATASTORE_Handle * dsh
Datastore handle.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_reserve(struct GNUNET_DATASTORE_Handle *h, uint64_t amount, uint32_t entries, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Reserve space in the datastore.
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
void GNUNET_FS_file_information_inspect(struct GNUNET_FS_FileInformation *dir, GNUNET_FS_FileInformationProcessor proc, void *proc_cls)
Inspect a file or directory in a publish-structure.
#define GNUNET_log(kind,...)
@ GNUNET_SCHEDULER_PRIORITY_BACKGROUND
Run as background job (higher than idle, lower than default).
@ GNUNET_ERROR_TYPE_INFO
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition: scheduler.c:1231
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
Private ECC key encoded for transmission.
Handle to the datastore service.
Handle for controlling a publication process.
Definition: fs_api.h:1180

References _, GNUNET_ARM_Handle::cfg, compute_contents_size(), dsh, finish_reserve(), fip_signal_start(), GNUNET_assert, GNUNET_DATASTORE_connect(), GNUNET_DATASTORE_reserve(), GNUNET_ERROR_TYPE_INFO, GNUNET_FS_file_information_inspect(), GNUNET_FS_make_top(), GNUNET_FS_publish_main_(), GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY, GNUNET_FS_publish_signal_suspend_(), GNUNET_FS_publish_sync_(), GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, GNUNET_strdup, h, ns, options, and ret.

Referenced by directory_trim_complete(), and start_publish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_publish_stop()

void GNUNET_FS_publish_stop ( struct GNUNET_FS_PublishContext pc)

Stop a publication.

Will abort incomplete publications (but not remove blocks that have already been published) or simply clean up the state for completed publications. Must NOT be called from within the event callback!

Parameters
pccontext for the publication to stop

Stop a publication.

Will abort incomplete uploads (but not remove blocks that have already been published) or simply clean up the state for completed uploads. Must NOT be called from within the event callback!

Parameters
pccontext for the upload to stop

Definition at line 1571 of file fs_publish.c.

1572{
1573 struct GNUNET_FS_ProgressInfo pi;
1574 uint64_t off;
1575
1577 "Publish stop called\n");
1579 if (NULL != pc->ksk_pc)
1580 {
1582 pc->ksk_pc = NULL;
1583 }
1584 if (NULL != pc->sks_pc)
1585 {
1587 pc->sks_pc = NULL;
1588 }
1589 if (NULL != pc->upload_task)
1590 {
1592 pc->upload_task = NULL;
1593 }
1596
1597 if (NULL != pc->fi->serialization)
1598 {
1600 pc->fi->serialization);
1602 pc->fi->serialization = NULL;
1603 }
1604 off = (NULL == pc->fi->chk_uri) ? 0 : GNUNET_ntohll (
1606
1607 if (NULL != pc->serialization)
1608 {
1610 pc->serialization);
1612 pc->serialization = NULL;
1613 }
1614 if (NULL != pc->qre)
1615 {
1617 pc->qre = NULL;
1618 }
1620 GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi, off));
1622}
void GNUNET_FS_remove_sync_file_(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Remove serialization/deserialization file from disk.
Definition: fs_api.c:728
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:402
#define GNUNET_FS_SYNC_PATH_FILE_INFO
Name of the directory with files that are being published.
Definition: fs_api.h:82
static int fip_signal_stop(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Signal the FS's progress function that we are stopping an upload.
Definition: fs_publish.c:1524
static void publish_cleanup(struct GNUNET_FS_PublishContext *pc)
Cleanup the publish context, we're done with it.
Definition: fs_publish.c:79
void * GNUNET_FS_publish_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_PublishContext *pc, const struct GNUNET_FS_FileInformation *p, uint64_t offset)
Fill in all of the generic fields for a publish event and call the callback.
Definition: fs_publish.c:48
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
void GNUNET_FS_publish_ksk_cancel(struct GNUNET_FS_PublishKskContext *pkc)
Abort the KSK publishing operation.
void GNUNET_FS_publish_sks_cancel(struct GNUNET_FS_PublishSksContext *psc)
Abort the SKS publishing operation.
Definition: fs_namespace.c:495
@ GNUNET_ERROR_TYPE_DEBUG
Argument given to the progress callback with information about what is going on.
int skip_next_fi_callback
Flag set to GNUNET_YES if the next callback from GNUNET_FS_file_information_inspect should be skipped...
Definition: fs_api.h:1299
struct GNUNET_FS_PublishKskContext * ksk_pc
Context for KSK publishing operation that is part of this publishing operation (NULL if not active).
Definition: fs_api.h:1253
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1189
struct GNUNET_DATASTORE_QueueEntry * qre
Queue entry for reservation/unreservation.
Definition: fs_api.h:1241
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1194
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1184
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1259
struct GNUNET_FS_PublishSksContext * sks_pc
Context for SKS publishing operation that is part of this publishing operation (NULL if not active).
Definition: fs_api.h:1247
char * serialization
Filename used for serializing information about this operation (should be determined using 'mktemp').
Definition: fs_api.h:1215

References GNUNET_FS_Uri::chk, GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_Uri::data, GNUNET_FS_PublishContext::fi, FileIdentifier::file_length, fip_signal_stop(), GNUNET_break, GNUNET_DATASTORE_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_FS_end_top(), GNUNET_FS_file_information_inspect(), GNUNET_FS_publish_ksk_cancel(), GNUNET_FS_publish_make_status_(), GNUNET_FS_publish_sks_cancel(), GNUNET_FS_remove_sync_file_(), GNUNET_FS_STATUS_PUBLISH_STOPPED, GNUNET_FS_SYNC_PATH_FILE_INFO, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, GNUNET_log, GNUNET_ntohll(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_FS_PublishContext::h, GNUNET_FS_PublishContext::ksk_pc, pc, publish_cleanup(), GNUNET_FS_PublishContext::qre, GNUNET_FS_FileInformation::serialization, GNUNET_FS_PublishContext::serialization, GNUNET_FS_PublishContext::skip_next_fi_callback, GNUNET_FS_PublishContext::sks_pc, GNUNET_FS_ProgressInfo::status, GNUNET_FS_PublishContext::top, and GNUNET_FS_PublishContext::upload_task.

Referenced by do_stop_task(), publish_stop_task(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_publish_ksk()

struct GNUNET_FS_PublishKskContext * GNUNET_FS_publish_ksk ( struct GNUNET_FS_Handle h,
const struct GNUNET_FS_Uri ksk_uri,
const struct GNUNET_FS_MetaData meta,
const struct GNUNET_FS_Uri uri,
const struct GNUNET_FS_BlockOptions bo,
enum GNUNET_FS_PublishOptions  options,
GNUNET_FS_PublishContinuation  cont,
void *  cont_cls 
)

Publish a KBlock on GNUnet.

Parameters
hhandle to the file sharing subsystem
ksk_urikeywords to use
metametadata to use
uriURI to refer to in the KBlock
boblock options
optionspublication options
contcontinuation
cont_clsclosure for cont
Returns
NULL on error (cont will still be called)

Publish a KBlock on GNUnet.

Parameters
hhandle to the file sharing subsystem
ksk_urikeywords to use
metametadata to use
uriURI to refer to in the KBlock
boper-block options
optionspublication options
contcontinuation
cont_clsclosure for cont
Returns
NULL on error ('cont' will still be called)

Definition at line 188 of file fs_publish_ksk.c.

195{
196 struct GNUNET_FS_PublishKskContext *pkc;
197
198 GNUNET_assert (NULL != uri);
200 pkc->h = h;
201 pkc->bo = *bo;
202 pkc->options = options;
203 pkc->cont = cont;
204 pkc->cont_cls = cont_cls;
207 {
209 if (NULL == pkc->dsh)
210 {
211 cont (cont_cls,
212 NULL,
213 _ ("Could not connect to datastore."));
214 GNUNET_free (pkc);
215 return NULL;
216 }
217 }
218 pkc->uri = GNUNET_FS_uri_dup (uri);
221 return pkc;
222}
static void publish_ksk_cont(void *cls)
Continuation of GNUNET_FS_publish_ksk() that performs the actual publishing operation (iterating over...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1304
Context for the KSK publication.
struct GNUNET_FS_Uri * uri
URI to publish.
struct GNUNET_FS_Uri * ksk_uri
Keywords to use.
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore, NULL if we are just simulating.
enum GNUNET_FS_PublishOptions options
Options to use.
struct GNUNET_SCHEDULER_Task * ksk_task
Current task.
struct GNUNET_FS_BlockOptions bo
When should the KBlocks expire?
struct GNUNET_FS_MetaData * meta
Metadata to use.
void * cont_cls
Closure for cont.
struct GNUNET_FS_Handle * h
Global FS context.
GNUNET_FS_PublishContinuation cont
Function to call once we're done.

References _, bo, GNUNET_FS_PublishKskContext::bo, GNUNET_ARM_Handle::cfg, GNUNET_FS_PublishKskContext::cont, GNUNET_FS_PublishKskContext::cont_cls, GNUNET_FS_PublishKskContext::dsh, GNUNET_assert, GNUNET_DATASTORE_connect(), GNUNET_free, GNUNET_FS_meta_data_duplicate(), GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY, GNUNET_FS_uri_dup(), GNUNET_new, GNUNET_SCHEDULER_add_now(), h, GNUNET_FS_PublishKskContext::h, GNUNET_FS_PublishKskContext::ksk_task, GNUNET_FS_PublishKskContext::ksk_uri, meta, GNUNET_FS_PublishKskContext::meta, options, GNUNET_FS_PublishKskContext::options, publish_ksk_cont(), uri, and GNUNET_FS_PublishKskContext::uri.

Referenced by identity_continuation(), and publish_kblocks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_publish_ksk_cancel()

void GNUNET_FS_publish_ksk_cancel ( struct GNUNET_FS_PublishKskContext pkc)

Abort the KSK publishing operation.

Parameters
pkccontext of the operation to abort.

Definition at line 231 of file fs_publish_ksk.c.

232{
233 if (NULL != pkc->ksk_task)
234 {
236 pkc->ksk_task = NULL;
237 }
238 if (NULL != pkc->uc)
239 {
241 pkc->uc = NULL;
242 }
243 if (NULL != pkc->dsh)
244 {
246 pkc->dsh = NULL;
247 }
251 GNUNET_free (pkc);
252}
void GNUNET_FS_publish_ublock_cancel_(struct GNUNET_FS_PublishUblockContext *uc)
Abort UBlock publishing operation.
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
struct GNUNET_FS_PublishUblockContext * uc
UBlock publishing operation that is active.

References GNUNET_FS_PublishKskContext::dsh, GNUNET_DATASTORE_disconnect(), GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_publish_ublock_cancel_(), GNUNET_FS_uri_destroy(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_FS_PublishKskContext::ksk_task, GNUNET_FS_PublishKskContext::ksk_uri, GNUNET_FS_PublishKskContext::meta, GNUNET_FS_PublishKskContext::uc, and GNUNET_FS_PublishKskContext::uri.

Referenced by GNUNET_FS_publish_stop(), kb_put_cont(), publish_ksk_cont(), and suspend_operation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_publish_sks()

struct GNUNET_FS_PublishSksContext * GNUNET_FS_publish_sks ( struct GNUNET_FS_Handle h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey ns,
const char *  identifier,
const char *  update,
const struct GNUNET_FS_MetaData meta,
const struct GNUNET_FS_Uri uri,
const struct GNUNET_FS_BlockOptions bo,
enum GNUNET_FS_PublishOptions  options,
GNUNET_FS_PublishContinuation  cont,
void *  cont_cls 
)

Publish an SBlock on GNUnet.

Parameters
hhandle to the file sharing subsystem
nsnamespace to publish in
identifieridentifier to use
updateupdate identifier to use
metametadata to use
uriURI to refer to in the SBlock
boblock options
optionspublication options
contcontinuation
cont_clsclosure for cont
Returns
NULL on error (cont will still be called)

Definition at line 432 of file fs_namespace.c.

442{
443 struct GNUNET_FS_PublishSksContext *psc;
444 struct GNUNET_FS_Uri *sks_uri;
445
446 sks_uri = GNUNET_new (struct GNUNET_FS_Uri);
447 sks_uri->type = GNUNET_FS_URI_SKS;
450
452 psc->h = h;
453 psc->uri = sks_uri;
454 psc->cont = cont;
455 psc->cont_cls = cont_cls;
456 psc->ns = *ns;
458 {
460 if (NULL == psc->dsh)
461 {
462 sks_publish_cont (psc, _ ("Failed to connect to datastore."));
463 return NULL;
464 }
465 }
466 if (NULL != update)
467 {
468 psc->nsn = GNUNET_new (struct NamespaceUpdateNode);
469 psc->nsn->id = GNUNET_strdup (identifier);
470 psc->nsn->update = GNUNET_strdup (update);
472 psc->nsn->uri = GNUNET_FS_uri_dup (uri);
473 }
475 psc->dsh,
477 update,
478 ns,
479 meta,
480 uri,
481 bo,
482 options,
484 psc);
485 return psc;
486}
static void sks_publish_cont(void *cls, const char *msg)
Function called by the UBlock construction with the result from the PUT (UBlock) request.
Definition: fs_namespace.c:401
struct GNUNET_FS_PublishUblockContext * GNUNET_FS_publish_ublock_(struct GNUNET_FS_Handle *h, struct GNUNET_DATASTORE_Handle *dsh, const char *label, const char *ulabel, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_UBlockContinuation cont, void *cont_cls)
Publish a UBlock.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:190
Context for the SKS publication.
Definition: fs_namespace.c:349
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Namespace we're publishing to.
Definition: fs_namespace.c:364
GNUNET_FS_PublishContinuation cont
Function to call once we're done.
Definition: fs_namespace.c:379
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore.
Definition: fs_namespace.c:369
void * cont_cls
Closure for cont.
Definition: fs_namespace.c:384
struct NamespaceUpdateNode * nsn
Namespace update node to add to namespace on success (or to be deleted if publishing failed).
Definition: fs_namespace.c:359
struct GNUNET_FS_PublishUblockContext * uc
Handle for our UBlock operation request.
Definition: fs_namespace.c:389
struct GNUNET_FS_Handle * h
Handle to FS.
Definition: fs_namespace.c:374
struct GNUNET_FS_Uri * uri
URI of the new entry in the namespace.
Definition: fs_namespace.c:353
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:42
struct GNUNET_FS_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:56
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:61
char * update
Identifier of children of this node.
Definition: fs_namespace.c:51
char * id
Identifier for this node.
Definition: fs_namespace.c:46

References _, bo, GNUNET_ARM_Handle::cfg, GNUNET_FS_PublishSksContext::cont, GNUNET_FS_PublishSksContext::cont_cls, GNUNET_FS_Uri::data, GNUNET_FS_PublishSksContext::dsh, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_DATASTORE_connect(), GNUNET_FS_meta_data_duplicate(), GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY, GNUNET_FS_publish_ublock_(), GNUNET_FS_uri_dup(), GNUNET_FS_URI_SKS, GNUNET_new, GNUNET_strdup, h, GNUNET_FS_PublishSksContext::h, NamespaceUpdateNode::id, GNUNET_FS_Uri::identifier, NamespaceUpdateNode::md, meta, ns, GNUNET_FS_Uri::ns, GNUNET_FS_PublishSksContext::ns, GNUNET_FS_PublishSksContext::nsn, options, GNUNET_FS_Uri::sks, sks_publish_cont(), GNUNET_FS_Uri::type, GNUNET_FS_PublishSksContext::uc, NamespaceUpdateNode::update, uri, NamespaceUpdateNode::uri, and GNUNET_FS_PublishSksContext::uri.

Referenced by publish_sblock(), and uri_ksk_continuation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_publish_sks_cancel()

void GNUNET_FS_publish_sks_cancel ( struct GNUNET_FS_PublishSksContext psc)

Abort the SKS publishing operation.

Parameters
psccontext of the operation to abort.

Definition at line 495 of file fs_namespace.c.

496{
497 if (NULL != psc->uc)
498 {
500 psc->uc = NULL;
501 }
502 if (NULL != psc->dsh)
503 {
505 psc->dsh = NULL;
506 }
508 if (NULL != psc->nsn)
509 {
512 GNUNET_free (psc->nsn->id);
513 GNUNET_free (psc->nsn->update);
514 GNUNET_free (psc->nsn);
515 }
516 GNUNET_free (psc);
517}

References GNUNET_FS_PublishSksContext::dsh, GNUNET_DATASTORE_disconnect(), GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_publish_ublock_cancel_(), GNUNET_FS_uri_destroy(), GNUNET_NO, NamespaceUpdateNode::id, NamespaceUpdateNode::md, GNUNET_FS_PublishSksContext::nsn, GNUNET_FS_PublishSksContext::uc, NamespaceUpdateNode::update, NamespaceUpdateNode::uri, and GNUNET_FS_PublishSksContext::uri.

Referenced by GNUNET_FS_publish_stop(), sks_publish_cont(), and suspend_operation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_get_indexed_files()

struct GNUNET_FS_GetIndexedContext * GNUNET_FS_get_indexed_files ( struct GNUNET_FS_Handle h,
GNUNET_FS_IndexedFileProcessor  iterator,
void *  iterator_cls 
)

Iterate over all indexed files.

Parameters
hhandle to the file sharing subsystem
iteratorfunction to call on each indexed file
iterator_clsclosure for iterator
Returns
NULL on error (iterator is not called)

Definition at line 163 of file fs_list_indexed.c.

166{
170 GNUNET_MQ_hd_fixed_size (index_info_end,
173 gic),
174 GNUNET_MQ_hd_var_size (index_info,
176 struct IndexInfoMessage,
177 gic),
179 };
180 struct GNUNET_MQ_Envelope *env;
182
184 "fs",
185 handlers,
187 h);
188 if (NULL == gic->mq)
189 {
191 _ ("Failed to not connect to `%s' service.\n"),
192 "fs");
194 return NULL;
195 }
196 gic->iterator = iterator;
197 gic->iterator_cls = iterator_cls;
201 env);
202 return gic;
203}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
static struct GNUNET_FS_GetIndexedContext * gic
Handle for the index listing operation.
Definition: gnunet-fs.c:40
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1060
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET
Request from client for list of indexed files.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY
Reply to client with an indexed file name.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END
Reply to client indicating end of list.
Context for GNUNET_FS_get_indexed_files().
void * iterator_cls
Closure for iterator.
GNUNET_FS_IndexedFileProcessor iterator
Function to call for each indexed file.
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Message handler for a specific message type.
Header for all communications.
Message send by FS service in response to a request asking for a list of all indexed files.
Definition: fs.h:197

References _, GNUNET_ARM_Handle::cfg, env, gic, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END, GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY, GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, h, handlers, GNUNET_FS_GetIndexedContext::iterator, GNUNET_FS_GetIndexedContext::iterator_cls, GNUNET_FS_GetIndexedContext::mq, mq_error_handler(), and msg.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_get_indexed_files_cancel()

void GNUNET_FS_get_indexed_files_cancel ( struct GNUNET_FS_GetIndexedContext gic)

Cancel iteration over all indexed files.

Parameters
gicoperation to cancel

Definition at line 212 of file fs_list_indexed.c.

213{
216}
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:700

References gic, GNUNET_free, GNUNET_MQ_destroy(), and GNUNET_FS_GetIndexedContext::mq.

Referenced by do_shutdown(), handle_index_info(), handle_index_info_end(), and mq_error_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_unindex_start()

struct GNUNET_FS_UnindexContext * GNUNET_FS_unindex_start ( struct GNUNET_FS_Handle h,
const char *  filename,
void *  cctx 
)

Unindex a file.

Parameters
hhandle to the file sharing subsystem
filenamefile to unindex
cctxinitial value for the client context
Returns
NULL on error, otherwise handle

Definition at line 796 of file fs_unindex.c.

799{
801 struct GNUNET_FS_ProgressInfo pi;
802 uint64_t size;
803
804 if (GNUNET_OK !=
806 &size,
808 GNUNET_YES))
809 return NULL;
811 uc->h = h;
814 uc->file_size = size;
818 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
820 uc->fhc =
822 filename,
827 uc);
828 return uc;
829}
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Definition: fs.h:48
void GNUNET_FS_unindex_sync_(struct GNUNET_FS_UnindexContext *uc)
Synchronize this unindex struct with its mirror on disk.
Definition: fs_api.c:1831
void GNUNET_FS_unindex_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_UnindexContext *uc, uint64_t offset)
Fill in all of the generic fields for an unindex event and call the callback.
Definition: fs_unindex.c:85
void GNUNET_FS_unindex_signal_suspend_(void *cls)
Create SUSPEND event for the given unindex operation and then clean up our state (without stop signal...
Definition: fs_unindex.c:728
void GNUNET_FS_unindex_process_hash_(void *cls, const struct GNUNET_HashCode *file_id)
Function called once the hash of the file that is being unindexed has been computed.
Definition: fs_unindex.c:695
static struct GNUNET_FS_UnindexContext * uc
struct GNUNET_CRYPTO_FileHashContext * GNUNET_CRYPTO_hash_file(enum GNUNET_SCHEDULER_Priority priority, const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, void *callback_cls)
Compute the hash of an entire file.
@ GNUNET_SCHEDULER_PRIORITY_IDLE
Run when otherwise idle.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
static unsigned int size
Size of the "table".
Definition: peer.c:68
void * cctx
Client context pointer (set the last time by the client for this operation; initially NULL on START/R...
Handle for controlling an unindexing operation.
Definition: fs_api.h:1351
void * client_info
Pointer kept for the client.
Definition: fs_api.h:1408
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1454
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
Definition: fs_api.h:1444
struct TopLevelActivity * top
Our top-level activity entry.
Definition: fs_api.h:1366
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1386
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1361
uint64_t file_size
Overall size of the file.
Definition: fs_api.h:1449

References GNUNET_FS_ProgressInfo::cctx, GNUNET_FS_UnindexContext::client_info, GNUNET_FS_UnindexContext::fhc, GNUNET_FS_UnindexContext::file_size, filename, GNUNET_FS_UnindexContext::filename, GNUNET_CRYPTO_hash_file(), GNUNET_DISK_file_size(), GNUNET_FS_make_top(), GNUNET_FS_STATUS_UNINDEX_START, GNUNET_FS_unindex_make_status_(), GNUNET_FS_unindex_process_hash_(), GNUNET_FS_unindex_signal_suspend_(), GNUNET_FS_unindex_sync_(), GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_strdup, GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, h, GNUNET_FS_UnindexContext::h, HASHING_BLOCKSIZE, size, GNUNET_FS_UnindexContext::start_time, GNUNET_FS_ProgressInfo::status, GNUNET_FS_UnindexContext::top, uc, GNUNET_FS_ProgressInfo::unindex, and GNUNET_FS_ProgressInfo::value.

Referenced by ds_put_cont(), run(), and signal_publish_error().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_unindex_stop()

void GNUNET_FS_unindex_stop ( struct GNUNET_FS_UnindexContext uc)

Clean up after completion of an unindex operation.

Parameters
uchandle

Definition at line 838 of file fs_unindex.c.

839{
840 struct GNUNET_FS_ProgressInfo pi;
841
842 if (NULL != uc->dscan)
843 {
845 uc->dscan = NULL;
846 }
847 if (NULL != uc->dqe)
848 {
850 uc->dqe = NULL;
851 }
852 if (NULL != uc->fhc)
853 {
855 uc->fhc = NULL;
856 }
857 if (NULL != uc->mq)
858 {
860 uc->mq = NULL;
861 }
862 if (NULL != uc->dsh)
863 {
865 uc->dsh = NULL;
866 }
867 if (NULL != uc->ksk_uri)
868 {
870 uc->ksk_uri = NULL;
871 }
872 if (NULL != uc->tc)
873 {
875 uc->tc = NULL;
876 }
877 if (uc->fh != NULL)
878 {
880 uc->fh = NULL;
881 }
883 if (uc->serialization != NULL)
884 {
888 uc->serialization = NULL;
889 }
891 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
893 (uc->state ==
895 GNUNET_break (NULL == uc->client_info);
898 GNUNET_free (uc);
899}
@ UNINDEX_STATE_COMPLETE
We're done.
Definition: fs_api.h:1338
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1289
void GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
Abort the scan.
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_FS_TreeEncoder * tc
Merkle-ish tree encoder context.
Definition: fs_api.h:1413
struct GNUNET_FS_DirScanner * dscan
Directory scanner to find keywords (KBlock removal).
Definition: fs_api.h:1371
enum UnindexState state
Current operatinonal phase.
Definition: fs_api.h:1464
char * emsg
Error message, NULL on success.
Definition: fs_api.h:1439
struct GNUNET_DISK_FileHandle * fh
Handle used to read the file.
Definition: fs_api.h:1418
struct GNUNET_DATASTORE_QueueEntry * dqe
Handle to datastore 'get_key' operation issued for obtaining KBlocks.
Definition: fs_api.h:1424
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service, only valid during the UNINDEX_STATE_DS_NOTIFY phase.
Definition: fs_api.h:1403
char * serialization
Short name under which we are serializing the state of this operation.
Definition: fs_api.h:1391
struct GNUNET_FS_Uri * ksk_uri
Keywords found (telling us which KBlocks to remove).
Definition: fs_api.h:1376
struct GNUNET_MQ_Handle * mq
Connection to the FS service, only valid during the UNINDEX_STATE_FS_NOTIFY phase.
Definition: fs_api.h:1397

References GNUNET_FS_UnindexContext::client_info, GNUNET_FS_UnindexContext::dqe, GNUNET_FS_UnindexContext::dscan, GNUNET_FS_UnindexContext::dsh, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::fh, GNUNET_FS_UnindexContext::fhc, GNUNET_FS_UnindexContext::file_size, GNUNET_FS_UnindexContext::filename, GNUNET_break, GNUNET_CRYPTO_hash_file_cancel(), GNUNET_DATASTORE_cancel(), GNUNET_DATASTORE_disconnect(), GNUNET_DISK_file_close(), GNUNET_free, GNUNET_FS_directory_scan_abort(), GNUNET_FS_end_top(), GNUNET_FS_remove_sync_file_(), GNUNET_FS_STATUS_UNINDEX_STOPPED, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, GNUNET_FS_tree_encoder_finish(), GNUNET_FS_unindex_make_status_(), GNUNET_FS_uri_destroy(), GNUNET_MQ_destroy(), GNUNET_NO, GNUNET_TIME_UNIT_ZERO, GNUNET_FS_UnindexContext::h, GNUNET_FS_UnindexContext::ksk_uri, GNUNET_FS_UnindexContext::mq, GNUNET_FS_UnindexContext::serialization, GNUNET_FS_UnindexContext::state, GNUNET_FS_ProgressInfo::status, GNUNET_FS_UnindexContext::tc, GNUNET_FS_UnindexContext::top, uc, GNUNET_FS_ProgressInfo::unindex, UNINDEX_STATE_COMPLETE, and GNUNET_FS_ProgressInfo::value.

Referenced by GNUNET_FS_unindex_process_hash_(), progress_cb(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_namespace_list_updateable()

void GNUNET_FS_namespace_list_updateable ( struct GNUNET_FS_Handle h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey ns,
const char *  next_id,
GNUNET_FS_IdentifierProcessor  ip,
void *  ip_cls 
)

List all of the identifiers in the namespace for which we could produce an update.

Namespace updates form a graph where each node has a name. Each node can have any number of URI/meta-data entries which can each be linked to other nodes. Cycles are possible.

Calling this function with next_id NULL will cause the library to call ip with a root for each strongly connected component of the graph (a root being a node from which all other nodes in the Scc are reachable).

Calling this function with next_id being the name of a node will cause the library to call ip with all children of the node. Note that cycles within an SCC are possible (including self-loops).

Parameters
hfs handle to use
nsnamespace to inspect for updateable content
next_idID to look for; use NULL to look for SCC roots
ipfunction to call on each updateable identifier
ip_clsclosure for ip

Namespace updates form a graph where each node has a name. Each node can have any number of URI/meta-data entries which can each be linked to other nodes. Cycles are possible.

Calling this function with "next_id" NULL will cause the library to call "ip" with a root for each strongly connected component of the graph (a root being a node from which all other nodes in the Tree are reachable).

Calling this function with "next_id" being the name of a node will cause the library to call "ip" with all children of the node. Note that cycles within the final tree are possible (including self-loops). I know, odd definition of a tree, but the GUI will display an actual tree (GtkTreeView), so that's what counts for the term here.

Parameters
hfs handle to use
nsnamespace to inspect for updateable content
next_idID to look for; use NULL to look for tree roots
ipfunction to call on each updateable identifier
ip_clsclosure for ip

Definition at line 671 of file fs_namespace.c.

677{
678 unsigned int i;
679 unsigned int nug;
680 struct GNUNET_HashCode hc;
681 struct NamespaceUpdateNode *nsn;
683 struct FindTreeClosure fc;
685
687 if (NULL == uig->update_nodes)
688 {
690 "No updateable nodes found for ID `%s'\n",
691 next_id);
693 return; /* no nodes */
694 }
695 uig->update_map =
697 GNUNET_NO);
698 for (i = 0; i < uig->update_node_count; i++)
699 {
700 nsn = uig->update_nodes[i];
701 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
703 uig->update_map,
704 &hc,
705 nsn,
707 }
708 if (NULL != next_id)
709 {
710 GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc);
711 pc.ip = ip;
712 pc.ip_cls = ip_cls;
714 &hc,
716 &pc);
718 return;
719 }
721 "Calculating TREEs to find roots of update trees\n");
722 /* Find heads of TREEs in update graph */
723 nug = ++uig->nug_gen;
724 fc.tree_array = NULL;
725 fc.tree_array_size = 0;
726
727 for (i = 0; i < uig->update_node_count; i++)
728 {
729 nsn = uig->update_nodes[i];
730 if (nsn->nug == nug)
731 {
733 "TREE of node `%s' is %u\n",
734 nsn->id,
735 nsn->nug);
736 continue; /* already placed in TREE */
737 }
738 GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
739 nsn->nug = nug;
740 nsn->tree_id = UINT_MAX;
741 fc.id = UINT_MAX;
742 fc.nug = nug;
743 fc.uig = uig;
745 &hc,
746 &find_trees,
747 &fc);
748 if (UINT_MAX == fc.id)
749 {
750 /* start new TREE */
751 for (fc.id = 0; fc.id < fc.tree_array_size; fc.id++)
752 {
753 if (NULL == fc.tree_array[fc.id])
754 {
755 fc.tree_array[fc.id] = nsn;
756 nsn->tree_id = fc.id;
757 break;
758 }
759 }
760 if (fc.id == fc.tree_array_size)
761 {
762 GNUNET_array_append (fc.tree_array, fc.tree_array_size, nsn);
763 nsn->tree_id = fc.id;
764 }
766 "Starting new TREE %u with node `%s'\n",
767 nsn->tree_id,
768 nsn->id);
769 /* put all nodes with same identifier into this TREE */
770 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
771 fc.id = nsn->tree_id;
772 fc.nug = nug;
773 fc.uig = uig;
775 &hc,
776 &find_trees,
777 &fc);
778 }
779 else
780 {
781 /* make head of TREE "id" */
782 fc.tree_array[fc.id] = nsn;
783 nsn->tree_id = fc.id;
784 }
786 "TREE of node `%s' is %u\n",
787 nsn->id,
788 fc.id);
789 }
790 for (i = 0; i < fc.tree_array_size; i++)
791 {
792 nsn = fc.tree_array[i];
793 if (NULL != nsn)
794 {
796 "Root of TREE %u is node `%s'\n",
797 i,
798 nsn->id);
799 ip (ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
800 }
801 }
802 GNUNET_array_grow (fc.tree_array, fc.tree_array_size, 0);
803 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done processing TREEs\n");
805}
static int process_update_node(void *cls, const struct GNUNET_HashCode *key, void *value)
Call the iterator in the closure for each node.
Definition: fs_namespace.c:548
static void free_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Release memory occupied by UIG datastructure.
Definition: fs_namespace.c:163
static int find_trees(void *cls, const struct GNUNET_HashCode *key, void *value)
Find all nodes reachable from the current node (including the current node itself).
Definition: fs_namespace.c:611
static struct GNUNET_FS_UpdateInformationGraph * read_update_information_graph(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
Read the namespace update node graph from a file.
Definition: fs_namespace.c:251
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
Closure for 'find_trees'.
Definition: fs_namespace.c:562
Handle to update information for a namespace.
Definition: fs_namespace.c:80
unsigned int nug_gen
Generator for unique nug numbers.
Definition: fs_namespace.c:115
unsigned int update_node_count
Size of the update nodes array.
Definition: fs_namespace.c:105
struct GNUNET_CONTAINER_MultiHashMap * update_map
Hash map mapping identifiers of update nodes to the update nodes (initialized on-demand).
Definition: fs_namespace.c:100
struct NamespaceUpdateNode ** update_nodes
Array with information about nodes in the namespace.
Definition: fs_namespace.c:89
unsigned int tree_id
TREE this entry belongs to (if nug is current).
Definition: fs_namespace.c:72
unsigned int nug
Namespace update generation ID.
Definition: fs_namespace.c:67
Closure for 'process_update_node'.
Definition: fs_namespace.c:524

References find_trees(), free_update_information_graph(), GNUNET_array_append, GNUNET_array_grow, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, h, NamespaceUpdateNode::id, FindTreeClosure::id, NamespaceUpdateNode::md, next_id, ns, NamespaceUpdateNode::nug, FindTreeClosure::nug, GNUNET_FS_UpdateInformationGraph::nug_gen, pc, process_update_node(), read_update_information_graph(), FindTreeClosure::tree_array, FindTreeClosure::tree_array_size, NamespaceUpdateNode::tree_id, FindTreeClosure::uig, NamespaceUpdateNode::update, GNUNET_FS_UpdateInformationGraph::update_map, GNUNET_FS_UpdateInformationGraph::update_node_count, GNUNET_FS_UpdateInformationGraph::update_nodes, and NamespaceUpdateNode::uri.

Here is the call graph for this function:

◆ GNUNET_FS_search_start()

struct GNUNET_FS_SearchContext * GNUNET_FS_search_start ( struct GNUNET_FS_Handle h,
const struct GNUNET_FS_Uri uri,
uint32_t  anonymity,
enum GNUNET_FS_SearchOptions  options,
void *  cctx 
)

Start search for content.

Parameters
hhandle to the file sharing subsystem
urispecifies the search parameters; can be a KSK URI or an SKS URI.
anonymitydesired level of anonymity
optionsoptions for the search
cctxinitial value for the client context
Returns
context that can be used to control the search

Definition at line 1607 of file fs_search.c.

1610{
1612
1613 ret = search_start (h, uri, anonymity, options, cctx, NULL);
1614 if (NULL == ret)
1615 return NULL;
1617 return ret;
1618}
static struct GNUNET_FS_SearchContext * search_start(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx, struct GNUNET_FS_SearchResult *psearch)
Start search for content, internal API.
Definition: fs_search.c:1334
void GNUNET_FS_search_signal_suspend_(void *cls)
Create SUSPEND event for the given search operation and then clean up our state (without stop signal)...
Definition: fs_search.c:1555
static unsigned int anonymity
Handle for controlling a search.
Definition: fs_api.h:1511

References anonymity, GNUNET_FS_make_top(), GNUNET_FS_search_signal_suspend_(), h, options, ret, search_start(), and uri.

Referenced by run(), and start_download().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_search_pause()

void GNUNET_FS_search_pause ( struct GNUNET_FS_SearchContext sc)

Pause search.

Parameters
sccontext for the search that should be paused

Definition at line 1627 of file fs_search.c.

1628{
1629 struct GNUNET_FS_ProgressInfo pi;
1630
1631 if (NULL != sc->task)
1632 {
1634 sc->task = NULL;
1635 }
1636 if (NULL != sc->mq)
1637 {
1639 sc->mq = NULL;
1640 }
1644 sc);
1647 sc->h,
1648 sc);
1649}
void GNUNET_FS_search_sync_(struct GNUNET_FS_SearchContext *sc)
Synchronize this search struct with its mirror on disk.
Definition: fs_api.c:2266
void * GNUNET_FS_search_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
Fill in all of the generic fields for a search event and call the callback.
Definition: fs_search.c:49
static int search_result_freeze_probes(void *cls, const struct GNUNET_HashCode *key, void *value)
Freeze probes for the given search result.
Definition: fs_search.c:1462
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiHashMap * master_result_map
Map that contains a struct GNUNET_FS_SearchResult for each result that was found in the search.
Definition: fs_api.h:1559
void * client_info
Pointer we keep for the client.
Definition: fs_api.h:1541
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the search is being stopped (i...
Definition: fs_api.h:1583
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1515
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1536

References GNUNET_FS_SearchContext::client_info, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_FS_search_make_status_(), GNUNET_FS_search_sync_(), GNUNET_FS_STATUS_SEARCH_PAUSED, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_FS_SearchContext::h, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, sc, search_result_freeze_probes(), GNUNET_FS_ProgressInfo::status, and GNUNET_FS_SearchContext::task.

Referenced by search_result_freeze_probes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_search_continue()

void GNUNET_FS_search_continue ( struct GNUNET_FS_SearchContext sc)

Continue paused search.

Parameters
sccontext for the search that should be resumed

Definition at line 1658 of file fs_search.c.

1659{
1660 struct GNUNET_FS_ProgressInfo pi;
1661
1662 GNUNET_assert (NULL == sc->mq);
1663 GNUNET_assert (NULL == sc->task);
1664 do_reconnect (sc);
1670}
static int search_result_resume_probes(void *cls, const struct GNUNET_HashCode *key, void *value)
Resume probes for the given search result.
Definition: fs_search.c:1494
static void do_reconnect(void *cls)
Reconnect to the FS service and transmit our queries NOW.
Definition: fs_search.c:1272

References GNUNET_FS_SearchContext::client_info, do_reconnect(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_FS_search_make_status_(), GNUNET_FS_search_sync_(), GNUNET_FS_STATUS_SEARCH_CONTINUED, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, sc, search_result_resume_probes(), GNUNET_FS_ProgressInfo::status, and GNUNET_FS_SearchContext::task.

Referenced by search_result_resume_probes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_search_stop()

void GNUNET_FS_search_stop ( struct GNUNET_FS_SearchContext sc)

Stop search for content.

Parameters
sccontext for the search that should be stopped

Definition at line 1766 of file fs_search.c.

1767{
1768 struct GNUNET_FS_ProgressInfo pi;
1769 unsigned int i;
1770
1771 if (NULL != sc->top)
1775 sc);
1776 if (NULL != sc->psearch_result)
1778 if (NULL != sc->serialization)
1779 {
1781 (NULL != sc->psearch_result)
1784 sc->serialization);
1786 (NULL != sc->psearch_result)
1789 sc->serialization);
1791 }
1794 sc->h,
1795 sc);
1796 GNUNET_break (NULL == sc->client_info);
1797 if (NULL != sc->task)
1798 {
1800 sc->task = NULL;
1801 }
1802 if (NULL != sc->mq)
1803 {
1805 sc->mq = NULL;
1806 }
1810 if (NULL != sc->requests)
1811 {
1813 for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1814 {
1817 }
1818 }
1820 GNUNET_free (sc->emsg);
1822 GNUNET_free (sc);
1823}
void GNUNET_FS_remove_sync_dir_(struct GNUNET_FS_Handle *h, const char *ext, const char *uni)
Remove serialization/deserialization directory from disk.
Definition: fs_api.c:787
#define GNUNET_FS_SYNC_PATH_CHILD_SEARCH
Name of the directory with sub-searches (namespace-updates).
Definition: fs_api.h:60
static int search_result_stop(void *cls, const struct GNUNET_HashCode *key, void *value)
Signal stop for the given search result.
Definition: fs_search.c:1682
static int search_result_free(void *cls, const struct GNUNET_HashCode *key, void *value)
Free the given search result.
Definition: fs_search.c:1737
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
Definition: fs_uri.c:1324
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:1551
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1565
char * serialization
Name of the file on disk we use for persistence.
Definition: fs_api.h:1546
struct GNUNET_FS_SearchResult * psearch_result
For update-searches, link to the search result that triggered the update search; otherwise NULL.
Definition: fs_api.h:1531
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1520
struct GNUNET_FS_Uri * uri
List of keywords that we're looking for.
Definition: fs_api.h:1525
struct GNUNET_FS_SearchContext * update_search
If this search result triggered an update search, this field links to the update search.
Definition: fs_api.h:552
struct GNUNET_CONTAINER_MultiHashMap * results
Map that contains a "struct GNUNET_FS_SearchResult" for each result that was found under this keyword...
Definition: fs_api.h:1497
char * keyword
The original keyword, used to derive the key (for decrypting the UBlock).
Definition: fs_api.h:1487

References GNUNET_FS_SearchContext::client_info, GNUNET_FS_Uri::data, GNUNET_FS_SearchContext::emsg, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_FS_end_top(), GNUNET_FS_remove_sync_dir_(), GNUNET_FS_remove_sync_file_(), GNUNET_FS_search_make_status_(), GNUNET_FS_STATUS_SEARCH_STOPPED, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, GNUNET_FS_uri_destroy(), GNUNET_FS_uri_test_ksk(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_FS_SearchContext::h, SearchRequestEntry::keyword, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, GNUNET_FS_SearchContext::psearch_result, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, sc, search_result_free(), search_result_stop(), GNUNET_FS_SearchContext::serialization, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchContext::task, GNUNET_FS_SearchContext::top, GNUNET_FS_SearchResult::update_search, and GNUNET_FS_SearchContext::uri.

Referenced by search_result_free(), search_stop_task(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_probe()

struct GNUNET_FS_SearchResult * GNUNET_FS_probe ( struct GNUNET_FS_Handle h,
const struct GNUNET_FS_Uri uri,
const struct GNUNET_FS_MetaData meta,
void *  client_info,
uint32_t  anonymity 
)

Start download probes for the given search result.

Parameters
hfile-sharing handle to use for the operation
uriURI to probe
metameta data associated with the URI
client_infoclient info pointer to use for associated events
anonymityanonymity level to use for the probes
Returns
the search result handle to access the probe activity

Definition at line 489 of file fs_search.c.

494{
495 struct GNUNET_FS_SearchResult *sr;
496
497 GNUNET_assert (NULL != h);
498 GNUNET_assert (NULL != uri);
500 sr->h = h;
501 sr->uri = GNUNET_FS_uri_dup (uri);
504 sr->anonymity = anonymity;
506 return sr;
507}
void GNUNET_FS_search_start_probe_(struct GNUNET_FS_SearchResult *sr)
Start download probes for the given search result.
Definition: fs_search.c:431
Information we store for each search result.
Definition: fs_api.h:499
void * client_info
Client info for this search result.
Definition: fs_api.h:534
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:524
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:503
uint32_t anonymity
Anonymity level to use for probes using this search result.
Definition: fs_api.h:589
struct GNUNET_FS_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:529

References anonymity, GNUNET_FS_SearchResult::anonymity, GNUNET_FS_SearchResult::client_info, GNUNET_assert, GNUNET_FS_meta_data_duplicate(), GNUNET_FS_search_start_probe_(), GNUNET_FS_uri_dup(), GNUNET_new, h, GNUNET_FS_SearchResult::h, meta, GNUNET_FS_SearchResult::meta, uri, and GNUNET_FS_SearchResult::uri.

Here is the call graph for this function:

◆ GNUNET_FS_probe_stop()

void * GNUNET_FS_probe_stop ( struct GNUNET_FS_SearchResult sr)

Stop probe activity.

Must ONLY be used on values returned from GNUNET_FS_probe.

Parameters
srsearch result to stop probing for (freed)
Returns
the value of the 'client_info' pointer

Definition at line 540 of file fs_search.c.

541{
542 void *client_info;
543
544 GNUNET_assert (NULL == sr->sc);
548 client_info = sr->client_info;
549 GNUNET_free (sr);
550 return client_info;
551}
static void GNUNET_FS_search_stop_probe_(struct GNUNET_FS_SearchResult *sr)
Stop probing activity associated with a search result.
Definition: fs_search.c:516
struct GNUNET_FS_SearchContext * sc
Search context this result belongs to; can be NULL for probes that come from a directory result.
Definition: fs_api.h:519

References GNUNET_FS_SearchResult::client_info, GNUNET_assert, GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_search_stop_probe_(), GNUNET_FS_uri_destroy(), GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::sc, and GNUNET_FS_SearchResult::uri.

Here is the call graph for this function:

◆ GNUNET_FS_download_start()

struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start ( struct GNUNET_FS_Handle h,
const struct GNUNET_FS_Uri uri,
const struct GNUNET_FS_MetaData meta,
const char *  filename,
const char *  tempname,
uint64_t  offset,
uint64_t  length,
uint32_t  anonymity,
enum GNUNET_FS_DownloadOptions  options,
void *  cctx,
struct GNUNET_FS_DownloadContext parent 
)

Download parts of a file.

Note that this will store the blocks at the respective offset in the given file. Also, the download is still using the blocking of the underlying FS encoding. As a result, the download may write outside of the given boundaries (if offset and length do not match the 32k FS block boundaries).

The given range can be used to focus a download towards a particular portion of the file (optimization), not to strictly limit the download to exactly those bytes.

Parameters
hhandle to the file sharing subsystem
urithe URI of the file (determines what to download); CHK or LOC URI
metaknown metadata for the file (can be NULL)
filenamewhere to store the file, maybe NULL (then no file is created on disk and data must be grabbed from the callbacks)
tempnamewhere to store temporary file data, not used if filename is non-NULL; can be NULL (in which case we will pick a name if needed); the temporary file may already exist, in which case we will try to use the data that is there and if it is not what is desired, will overwrite it
offsetat what offset should we start the download (typically 0)
lengthhow many bytes should be downloaded starting at offset
anonymityanonymity level to use for the download
optionsvarious download options
cctxinitial value for the client context for this download
parentparent download to associate this download with (use NULL for top-level downloads; useful for manually-triggered recursive downloads)
Returns
context that can be used to control this download

Definition at line 2099 of file fs_download.c.

2110{
2112
2114 uri,
2115 meta,
2116 filename,
2117 tempname,
2118 offset,
2119 length,
2120 anonymity,
2121 options,
2122 cctx);
2123 if (NULL == dc)
2124 return NULL;
2125 dc->parent = parent;
2126 if (NULL != parent)
2128 else if (0 == (GNUNET_FS_DOWNLOAD_IS_PROBE & options))
2129 dc->top =
2131 return dc;
2132}
void GNUNET_FS_download_signal_suspend_(void *cls)
Create SUSPEND event for the given download operation and then clean up our state (without stop signa...
Definition: fs_download.c:1952
static struct GNUNET_FS_DownloadContext * create_download_context(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, const char *filename, const char *tempname, uint64_t offset, uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, void *cctx)
Helper function to setup the download context.
Definition: fs_download.c:2028
static struct GNUNET_FS_DownloadContext * dc
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
Context for controlling a download.
Definition: fs_api.h:1744
uint64_t offset
What is the first offset that we're interested in?
Definition: fs_api.h:1878
struct GNUNET_FS_DownloadContext * child_tail
Tail of list of child downloads.
Definition: fs_api.h:1780
struct GNUNET_FS_DownloadContext * child_head
Head of list of child downloads.
Definition: fs_api.h:1775
uint64_t length
How many bytes starting from offset are desired? This is NOT the overall length of the file!
Definition: fs_api.h:1884
struct GNUNET_FS_DownloadContext * parent
Parent download (used when downloading files in directories).
Definition: fs_api.h:1764
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1748
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1753

References anonymity, GNUNET_FS_DownloadContext::child_head, GNUNET_FS_DownloadContext::child_tail, create_download_context(), dc, filename, GNUNET_CONTAINER_DLL_insert, GNUNET_FS_DOWNLOAD_IS_PROBE, GNUNET_FS_download_signal_suspend_(), GNUNET_FS_make_top(), h, GNUNET_FS_DownloadContext::h, GNUNET_FS_DownloadContext::length, meta, GNUNET_FS_DownloadContext::offset, options, GNUNET_FS_DownloadContext::parent, GNUNET_FS_DownloadContext::top, and uri.

Referenced by GNUNET_FS_search_start_probe_(), progress_cb(), run(), and trigger_recursive_download().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_download_start_from_search()

struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start_from_search ( struct GNUNET_FS_Handle h,
struct GNUNET_FS_SearchResult sr,
const char *  filename,
const char *  tempname,
uint64_t  offset,
uint64_t  length,
uint32_t  anonymity,
enum GNUNET_FS_DownloadOptions  options,
void *  cctx 
)

Download parts of a file based on a search result.

The download will be associated with the search result (and the association will be preserved when serializing/deserializing the state). If the search is stopped, the download will not be aborted but be 'promoted' to a stand-alone download.

As with the other download function, this will store the blocks at the respective offset in the given file. Also, the download is still using the blocking of the underlying FS encoding. As a result, the download may write outside of the given boundaries (if offset and length do not match the 32k FS block boundaries).

The given range can be used to focus a download towards a particular portion of the file (optimization), not to strictly limit the download to exactly those bytes.

Parameters
hhandle to the file sharing subsystem
srthe search result to use for the download (determines uri and meta data and associations)
filenamewhere to store the file, maybe NULL (then no file is created on disk and data must be grabbed from the callbacks)
tempnamewhere to store temporary file data, not used if filename is non-NULL; can be NULL (in which case we will pick a name if needed); the temporary file may already exist, in which case we will try to use the data that is there and if it is not what is desired, will overwrite it
offsetat what offset should we start the download (typically 0)
lengthhow many bytes should be downloaded starting at offset
anonymityanonymity level to use for the download
optionsvarious download options
cctxinitial value for the client context for this download
Returns
context that can be used to control this download

Definition at line 2136 of file fs_download.c.

2145{
2147
2148 if ((NULL == sr) || (NULL != sr->download))
2149 {
2150 GNUNET_break (0);
2151 return NULL;
2152 }
2154 sr->uri,
2155 sr->meta,
2156 filename,
2157 tempname,
2158 offset,
2159 length,
2160 anonymity,
2161 options,
2162 cctx);
2163 if (NULL == dc)
2164 return NULL;
2165 dc->search = sr;
2166 sr->download = dc;
2167 if (NULL != sr->probe_ctx)
2168 {
2170 sr->probe_ctx = NULL;
2172 }
2173 return dc;
2174}
void GNUNET_FS_stop_probe_ping_task_(struct GNUNET_FS_SearchResult *sr)
Stop the ping task for this search result.
Definition: fs_search.c:410
void GNUNET_FS_download_stop(struct GNUNET_FS_DownloadContext *dc, int do_delete)
Stop a download (aborts if download is incomplete).
Definition: fs_download.c:2253
struct GNUNET_FS_SearchResult * search
Associated search (used when downloading files based on search results), or NULL for none.
Definition: fs_api.h:1770
struct GNUNET_FS_DownloadContext * download
ID of an associated download based on this search result (or NULL for none).
Definition: fs_api.h:546
struct GNUNET_FS_DownloadContext * probe_ctx
ID of a job that is currently probing this results' availability (NULL if we are not currently probin...
Definition: fs_api.h:540

References anonymity, create_download_context(), dc, GNUNET_FS_SearchResult::download, filename, GNUNET_break, GNUNET_FS_download_stop(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_YES, h, GNUNET_FS_DownloadContext::length, GNUNET_FS_SearchResult::meta, GNUNET_FS_DownloadContext::offset, options, GNUNET_FS_SearchResult::probe_ctx, GNUNET_FS_DownloadContext::search, and GNUNET_FS_SearchResult::uri.

Here is the call graph for this function:

◆ GNUNET_FS_download_stop()

void GNUNET_FS_download_stop ( struct GNUNET_FS_DownloadContext dc,
int  do_delete 
)

Stop a download (aborts if download is incomplete).

Parameters
dchandle for the download
do_deletedelete files of incomplete downloads

Definition at line 2253 of file fs_download.c.

2254{
2255 struct GNUNET_FS_ProgressInfo pi;
2256 int have_children;
2257 int search_was_null;
2258
2259 if (NULL != dc->top)
2261 if (NULL != dc->task)
2262 {
2264 dc->task = NULL;
2265 }
2266 search_was_null = (NULL == dc->search);
2267 if (NULL != dc->search)
2268 {
2269 dc->search->download = NULL;
2271 dc->search = NULL;
2272 }
2273 if (NULL != dc->job_queue)
2274 {
2276 dc->job_queue = NULL;
2277 }
2278 if (NULL != dc->te)
2279 {
2281 dc->te = NULL;
2282 }
2283 have_children = (NULL != dc->child_head) ? GNUNET_YES : GNUNET_NO;
2284 while (NULL != dc->child_head)
2286 if (NULL != dc->parent)
2289 dc);
2290 if (NULL != dc->serialization)
2292 ((NULL != dc->parent) || (! search_was_null))
2295 dc->serialization);
2296 if ((GNUNET_YES == have_children) && (NULL == dc->parent))
2298 (! search_was_null)
2301 dc->serialization);
2305 dc->top_request = NULL;
2306 if (NULL != dc->active)
2307 {
2309 dc->active = NULL;
2310 }
2311 if (NULL != dc->filename)
2312 {
2313 if ((dc->completed != dc->length) && (GNUNET_YES == do_delete))
2314 {
2315 if ((0 != unlink (dc->filename)) && (ENOENT != errno))
2317 "unlink",
2318 dc->filename);
2319 }
2321 }
2324 if (NULL != dc->temp_filename)
2325 {
2326 if (0 != unlink (dc->temp_filename))
2328 "unlink",
2329 dc->temp_filename);
2331 }
2333 GNUNET_assert (NULL == dc->job_queue);
2334 GNUNET_free (dc);
2335}
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
Definition: fs_api.c:2165
void GNUNET_FS_dequeue_(struct GNUNET_FS_QueueEntry *qe)
Dequeue a job from the queue.
Definition: fs_api.c:356
#define GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD
Name of the directory with downloads that are part of another download or a search.
Definition: fs_api.h:72
void GNUNET_FS_free_download_request_(struct DownloadRequest *dr)
(recursively) free download request structure
Definition: fs_download.c:997
void GNUNET_FS_download_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_DownloadContext *dc)
Fill in all of the generic fields for a download event and call the callback.
Definition: fs_download.c:104
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
@ GNUNET_ERROR_TYPE_ERROR
char * filename
Where are we writing the data (name of the file, can be NULL!).
Definition: fs_api.h:1822
struct GNUNET_FS_Uri * uri
URI that identifies the file that we are downloading.
Definition: fs_api.h:1800
struct GNUNET_FS_MetaData * meta
Known meta-data for the file (can be NULL).
Definition: fs_api.h:1805
uint64_t completed
How many bytes have we already received within the specified range (DBlocks only).
Definition: fs_api.h:1890
struct GNUNET_FS_QueueEntry * job_queue
Our entry in the job queue.
Definition: fs_api.h:1834
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the download is being stopped ...
Definition: fs_api.h:1872
struct GNUNET_FS_TreeEncoder * te
Tree encoder used for the reconstruction.
Definition: fs_api.h:1839
struct GNUNET_CONTAINER_MultiHashMap * active
Map of active requests (those waiting for a response).
Definition: fs_api.h:1851
char * serialization
Random portion of filename we use for syncing state of this download.
Definition: fs_api.h:1816
char * temp_filename
Where are we writing the data temporarily (name of the file, can be NULL!); used if we do not have a ...
Definition: fs_api.h:1829
struct DownloadRequest * top_request
Top-level download request.
Definition: fs_api.h:1856

References GNUNET_FS_DownloadContext::active, GNUNET_FS_DownloadContext::child_head, GNUNET_FS_DownloadContext::child_tail, GNUNET_FS_DownloadContext::completed, dc, GNUNET_FS_SearchResult::download, GNUNET_FS_DownloadContext::filename, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_dequeue_(), GNUNET_FS_download_make_status_(), GNUNET_FS_download_stop(), GNUNET_FS_end_top(), GNUNET_FS_free_download_request_(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_remove_sync_dir_(), GNUNET_FS_remove_sync_file_(), GNUNET_FS_search_result_sync_(), GNUNET_FS_STATUS_DOWNLOAD_STOPPED, GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, GNUNET_FS_tree_encoder_finish(), GNUNET_FS_uri_destroy(), GNUNET_log_strerror_file, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_FS_DownloadContext::h, GNUNET_FS_DownloadContext::job_queue, GNUNET_FS_DownloadContext::length, GNUNET_FS_DownloadContext::meta, GNUNET_FS_DownloadContext::parent, GNUNET_FS_DownloadContext::search, GNUNET_FS_DownloadContext::serialization, GNUNET_FS_ProgressInfo::status, GNUNET_FS_DownloadContext::task, GNUNET_FS_DownloadContext::te, GNUNET_FS_DownloadContext::temp_filename, GNUNET_FS_DownloadContext::top, GNUNET_FS_DownloadContext::top_request, and GNUNET_FS_DownloadContext::uri.

Referenced by download_stop_task(), GNUNET_FS_download_start_from_search(), GNUNET_FS_download_stop(), GNUNET_FS_search_stop_probe_(), probe_failure_handler(), probe_success_handler(), search_result_freeze_probes(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_download_suspend()

void GNUNET_FS_download_suspend ( struct GNUNET_FS_DownloadContext dc)

Suspend a download.

Parameters
dchandle for the download

Definition at line 2214 of file fs_download.c.

2215{
2217}
static void deactivate_fs_download(void *cls)
We must stop to ask the FS service for our blocks.
Definition: fs_download.c:1448

References dc, and deactivate_fs_download().

Here is the call graph for this function:

◆ GNUNET_FS_download_resume()

void GNUNET_FS_download_resume ( struct GNUNET_FS_DownloadContext dc)

Resume a suspended download.

Parameters
dchandle for the download

Definition at line 2226 of file fs_download.c.

2227{
2228 struct GNUNET_FS_ProgressInfo pi;
2229
2232
2233 GNUNET_assert (NULL == dc->task);
2234 dc->job_queue =
2238 dc,
2239 (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE,
2243}
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
Definition: fs.h:41
struct GNUNET_FS_QueueEntry * GNUNET_FS_queue_(struct GNUNET_FS_Handle *h, GNUNET_SCHEDULER_TaskCallback start, GNUNET_SCHEDULER_TaskCallback stop, void *cls, unsigned int blocks, enum GNUNET_FS_QueuePriority priority)
Add a job to the queue.
Definition: fs_api.c:321
@ GNUNET_FS_QUEUE_PRIORITY_NORMAL
Default priority.
Definition: fs_api.h:413
@ GNUNET_FS_QUEUE_PRIORITY_PROBE
This is a probe (low priority).
Definition: fs_api.h:408
static void activate_fs_download(void *cls)
We're allowed to ask the FS service for our blocks.
Definition: fs_download.c:1427
enum GNUNET_FS_DownloadOptions options
Options for the download.
Definition: fs_api.h:1923
enum GNUNET_FS_Status status
Specific status code (determines the event type).

References activate_fs_download(), DBLOCK_SIZE, dc, deactivate_fs_download(), GNUNET_assert, GNUNET_FS_DOWNLOAD_IS_PROBE, GNUNET_FS_download_make_status_(), GNUNET_FS_queue_(), GNUNET_FS_QUEUE_PRIORITY_NORMAL, GNUNET_FS_QUEUE_PRIORITY_PROBE, GNUNET_FS_STATUS_DOWNLOAD_ACTIVE, GNUNET_FS_DownloadContext::h, GNUNET_FS_DownloadContext::job_queue, GNUNET_FS_DownloadContext::length, GNUNET_FS_DownloadContext::options, GNUNET_FS_ProgressInfo::status, and GNUNET_FS_DownloadContext::task.

Here is the call graph for this function:

◆ GNUNET_FS_meta_data_test_for_directory()

int GNUNET_FS_meta_data_test_for_directory ( const struct GNUNET_FS_MetaData md)

Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet directory.

Returns
GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if we have no mime-type information (treat as GNUNET_NO)

Definition at line 55 of file fs_directory.c.

57{
58 char *mime;
59 int ret;
60
61 if (NULL == md)
62 return GNUNET_SYSERR;
64 EXTRACTOR_METATYPE_MIMETYPE);
65 if (NULL == mime)
66 return GNUNET_SYSERR;
67 ret = (0 == strcasecmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES :
69 GNUNET_free (mime);
70 return ret;
71}
#define GNUNET_FS_DIRECTORY_MIME
char * GNUNET_FS_meta_data_get_by_type(const struct GNUNET_FS_MetaData *md, enum EXTRACTOR_MetaType type)
Get the first MD entry of the given type.
Definition: meta_data.c:438

References GNUNET_free, GNUNET_FS_DIRECTORY_MIME, GNUNET_FS_meta_data_get_by_type(), GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, and ret.

Referenced by fip_signal_resume(), fip_signal_stop(), fip_signal_suspend(), is_recursive_download(), progress_cb(), publish_inspector(), and trigger_recursive_download().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_meta_data_make_directory()

void GNUNET_FS_meta_data_make_directory ( struct GNUNET_FS_MetaData md)

Set the MIMETYPE information for the given metadata to "application/gnunet-directory".

Parameters
mdmetadata to add mimetype to

Definition at line 81 of file fs_directory.c.

82{
83 char *mime;
84
85 mime =
86 GNUNET_FS_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
87 if (mime != NULL)
88 {
89 GNUNET_break (0 == strcmp (mime, GNUNET_FS_DIRECTORY_MIME));
90 GNUNET_free (mime);
91 return;
92 }
93 GNUNET_FS_meta_data_insert (md, "<gnunet>",
94 EXTRACTOR_METATYPE_MIMETYPE,
95 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
97 strlen (GNUNET_FS_DIRECTORY_MIME) + 1);
98}

References GNUNET_break, GNUNET_free, GNUNET_FS_DIRECTORY_MIME, GNUNET_FS_meta_data_get_by_type(), and GNUNET_FS_meta_data_insert().

Referenced by get_file_information(), and GNUNET_FS_directory_builder_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_meta_data_suggest_filename()

char * GNUNET_FS_meta_data_suggest_filename ( const struct GNUNET_FS_MetaData md)

Suggest a filename based on given metadata.

Parameters
mdgiven meta data
Returns
NULL if meta data is useless for suggesting a filename

Definition at line 39 of file fs_misc.c.

41{
42 static const char *mimeMap[][2] = {
43 { "application/bz2", ".bz2" },
44 { "application/gnunet-directory", ".gnd" },
45 { "application/java", ".class" },
46 { "application/msword", ".doc" },
47 { "application/nar", ".nar" },
48 { "application/narinfo", ".narinfo" },
49 { "application/ogg", ".ogg" },
50 { "application/pdf", ".pdf" },
51 { "application/pgp-keys", ".key" },
52 { "application/pgp-signature", ".pgp" },
53 { "application/postscript", ".ps" },
54 { "application/rar", ".rar" },
55 { "application/rtf", ".rtf" },
56 { "application/xml", ".xml" },
57 { "application/x-debian-package", ".deb" },
58 { "application/x-dvi", ".dvi" },
59 { "application/x-flac", ".flac" },
60 { "application/x-gzip", ".gz" },
61 { "application/x-java-archive", ".jar" },
62 { "application/x-java-vm", ".class" },
63 { "application/x-python-code", ".pyc" },
64 { "application/x-redhat-package-manager", ".rpm" },
65 { "application/x-rpm", ".rpm" },
66 { "application/x-tar", ".tar" },
67 { "application/x-tex-pk", ".pk" },
68 { "application/x-texinfo", ".texinfo" },
69 { "application/x-xcf", ".xcf" },
70 { "application/x-xfig", ".xfig" },
71 { "application/zip", ".zip" },
72
73 { "audio/midi", ".midi" },
74 { "audio/mpeg", ".mp3" },
75 { "audio/real", ".rm" },
76 { "audio/x-wav", ".wav" },
77
78 { "image/gif", ".gif" },
79 { "image/jpeg", ".jpg" },
80 { "image/pcx", ".pcx" },
81 { "image/png", ".png" },
82 { "image/tiff", ".tiff" },
83 { "image/x-ms-bmp", ".bmp" },
84 { "image/x-xpixmap", ".xpm" },
85
86 { "text/css", ".css" },
87 { "text/html", ".html" },
88 { "text/plain", ".txt" },
89 { "text/rtf", ".rtf" },
90 { "text/x-c++hdr", ".h++" },
91 { "text/x-c++src", ".c++" },
92 { "text/x-chdr", ".h" },
93 { "text/x-csrc", ".c" },
94 { "text/x-java", ".java" },
95 { "text/x-moc", ".moc" },
96 { "text/x-pascal", ".pas" },
97 { "text/x-perl", ".pl" },
98 { "text/x-python", ".py" },
99 { "text/x-tex", ".tex" },
100
101 { "video/avi", ".avi" },
102 { "video/mpeg", ".mpeg" },
103 { "video/quicktime", ".qt" },
104 { "video/real", ".rm" },
105 { "video/x-msvideo", ".avi" },
106 { NULL, NULL },
107 };
108 char *ret;
109 unsigned int i;
110 char *mime;
111 char *base;
112 const char *ext;
113
114 ret =
117 if (ret != NULL)
118 return ret;
119 ext = NULL;
120 mime =
121 GNUNET_FS_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
122 if (mime != NULL)
123 {
124 i = 0;
125 while ((mimeMap[i][0] != NULL) && (0 != strcmp (mime, mimeMap[i][0])))
126 i++;
127 if (mimeMap[i][1] == NULL)
129 _ ("Did not find mime type `%s' in extension list.\n"), mime);
130 else
131 ext = mimeMap[i][1];
132 GNUNET_free (mime);
133 }
134 base =
136 EXTRACTOR_METATYPE_TITLE,
137 EXTRACTOR_METATYPE_BOOK_TITLE,
138 EXTRACTOR_METATYPE_ORIGINAL_TITLE,
139 EXTRACTOR_METATYPE_PACKAGE_NAME,
140 EXTRACTOR_METATYPE_URL,
141 EXTRACTOR_METATYPE_URI,
142 EXTRACTOR_METATYPE_DESCRIPTION,
143 EXTRACTOR_METATYPE_ISRC,
144 EXTRACTOR_METATYPE_JOURNAL_NAME,
145 EXTRACTOR_METATYPE_AUTHOR_NAME,
146 EXTRACTOR_METATYPE_SUBJECT,
147 EXTRACTOR_METATYPE_ALBUM,
148 EXTRACTOR_METATYPE_ARTIST,
149 EXTRACTOR_METATYPE_KEYWORDS,
150 EXTRACTOR_METATYPE_COMMENT,
151 EXTRACTOR_METATYPE_UNKNOWN,
152 -1);
153 if ((base == NULL) && (ext == NULL))
154 return NULL;
155 if (base == NULL)
156 return GNUNET_strdup (ext);
157 if (ext == NULL)
158 return base;
159 GNUNET_asprintf (&ret, "%s%s", base, ext);
160 GNUNET_free (base);
161 return ret;
162}
@ GNUNET_ERROR_TYPE_BULK

References _, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, GNUNET_asprintf(), GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_FS_meta_data_get_by_type(), GNUNET_FS_meta_data_get_first_by_types(), GNUNET_log, GNUNET_strdup, and ret.

Referenced by trigger_recursive_download().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_directory_list_contents()

int GNUNET_FS_directory_list_contents ( size_t  size,
const void *  data,
uint64_t  offset,
GNUNET_FS_DirectoryEntryProcessor  dep,
void *  dep_cls 
)

Iterate over all entries in a directory.

Note that directories are structured such that it is possible to iterate over the individual blocks as well as over the entire directory. Thus a client can call this function on the buffer in the GNUNET_FS_ProgressCallback. Also, directories can optionally include the contents of (small) files embedded in the directory itself; for those files, the processor may be given the contents of the file directly by this function.

Parameters
sizenumber of bytes in data
datapointer to the beginning of the directory
offsetoffset of data in the directory
depfunction to call on each entry
dep_clsclosure for dep
Returns
GNUNET_OK if this could be a block in a directory, GNUNET_NO if this could be part of a directory (but not 100% OK) GNUNET_SYSERR if 'data' does not represent a directory

Note that directories are structured such that it is possible to iterate over the individual blocks as well as over the entire directory. Thus a client can call this function on the buffer in the GNUNET_FS_ProgressCallback. Also, directories can optionally include the contents of (small) files embedded in the directory itself; for those files, the processor may be given the contents of the file directly by this function.

Note that this function maybe called on parts of directories. Thus parser errors should not be reported at all (with GNUNET_break). Still, if some entries can be recovered despite these parsing errors, the function should try to do this.

Parameters
sizenumber of bytes in data
datapointer to the beginning of the directory
offsetoffset of data in the directory
depfunction to call on each entry
dep_clsclosure for dep
Returns
GNUNET_OK if this could be a block in a directory, GNUNET_NO if this could be part of a directory (but not 100% OK) GNUNET_SYSERR if data does not represent a directory

Definition at line 182 of file fs_directory.c.

187{
188 struct GetFullDataClosure full_data;
189 const char *cdata = data;
190 char *emsg;
191 uint64_t pos;
192 uint64_t align;
193 uint32_t mdSize;
194 uint64_t epos;
195 struct GNUNET_FS_Uri *uri;
196 struct GNUNET_FS_MetaData *md;
197 char *filename;
198
199 if ((offset == 0) &&
200 ((size < 8 + sizeof(uint32_t)) ||
201 (0 != memcmp (cdata,
203 8))))
204 return GNUNET_SYSERR;
205 pos = offset;
206 if (offset == 0)
207 {
208 GNUNET_memcpy (&mdSize,
209 &cdata[8],
210 sizeof(uint32_t));
211 mdSize = ntohl (mdSize);
212 if (mdSize > size - 8 - sizeof(uint32_t))
213 {
214 /* invalid size */
216 _ ("MAGIC mismatch. This is not a GNUnet directory.\n"));
217 return GNUNET_SYSERR;
218 }
219 md = GNUNET_FS_meta_data_deserialize (&cdata[8 + sizeof(uint32_t)],
220 mdSize);
221 if (md == NULL)
222 {
223 GNUNET_break (0);
224 return GNUNET_SYSERR; /* malformed ! */
225 }
226 dep (dep_cls,
227 NULL,
228 NULL,
229 md,
230 0,
231 NULL);
233 pos = 8 + sizeof(uint32_t) + mdSize;
234 }
235 while (pos < size)
236 {
237 /* find end of URI */
238 if (cdata[pos] == '\0')
239 {
240 /* URI is never empty, must be end of block,
241 * skip to next alignment */
242 align = ((pos / DBLOCK_SIZE) + 1) * DBLOCK_SIZE;
243 if (align == pos)
244 {
245 /* if we were already aligned, still skip a block! */
246 align += DBLOCK_SIZE;
247 }
248 pos = align;
249 if (pos >= size)
250 {
251 /* malformed - or partial download... */
252 break;
253 }
254 }
255 epos = pos;
256 while ((epos < size) && (cdata[epos] != '\0'))
257 epos++;
258 if (epos >= size)
259 return GNUNET_NO; /* malformed - or partial download */
260
261 uri = GNUNET_FS_uri_parse (&cdata[pos], &emsg);
262 pos = epos + 1;
263 if (NULL == uri)
264 {
265 GNUNET_free (emsg);
266 pos--; /* go back to '\0' to force going to next alignment */
267 continue;
268 }
270 {
272 GNUNET_break (0);
273 return GNUNET_NO; /* illegal in directory! */
274 }
275
276 GNUNET_memcpy (&mdSize,
277 &cdata[pos],
278 sizeof(uint32_t));
279 mdSize = ntohl (mdSize);
280 pos += sizeof(uint32_t);
281 if (pos + mdSize > size)
282 {
284 return GNUNET_NO; /* malformed - or partial download */
285 }
286
287 md = GNUNET_FS_meta_data_deserialize (&cdata[pos],
288 mdSize);
289 if (NULL == md)
290 {
292 GNUNET_break (0);
293 return GNUNET_NO; /* malformed ! */
294 }
295 pos += mdSize;
296 filename =
299 full_data.size = 0;
300 full_data.data = NULL;
303 &full_data);
304 if (NULL != dep)
305 {
306 dep (dep_cls,
307 filename,
308 uri,
309 md,
310 full_data.size,
311 full_data.data);
312 }
313 GNUNET_free (full_data.data);
317 }
318 return GNUNET_OK;
319}
static int find_full_data(void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_len)
Type of a function that libextractor calls for each meta data item found.
Definition: fs_directory.c:136
#define GNUNET_FS_DIRECTORY_MAGIC
struct GNUNET_FS_MetaData * GNUNET_FS_meta_data_deserialize(const char *input, size_t size)
Deserialize meta-data.
Definition: meta_data.c:885
Meta data to associate with a file, directory or namespace.
Definition: meta_data.c:92
Closure for 'find_full_data'.
Definition: fs_directory.c:105

References _, data, GetFullDataClosure::data, DBLOCK_SIZE, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, filename, find_full_data(), GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_DIRECTORY_MAGIC, GNUNET_FS_meta_data_deserialize(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_meta_data_get_by_type(), GNUNET_FS_meta_data_iterate(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_parse(), GNUNET_FS_uri_test_ksk(), GNUNET_log, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, size, GetFullDataClosure::size, and uri.

Referenced by full_recursive_download(), process_result_with_request(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_directory_builder_create()

struct GNUNET_FS_DirectoryBuilder * GNUNET_FS_directory_builder_create ( const struct GNUNET_FS_MetaData mdir)

Create a directory builder.

Parameters
mdirmetadata for the directory

Definition at line 366 of file fs_directory.c.

368{
370
372 if (mdir != NULL)
373 ret->meta = GNUNET_FS_meta_data_duplicate (mdir);
374 else
377 return ret;
378}
void GNUNET_FS_meta_data_make_directory(struct GNUNET_FS_MetaData *md)
Set the MIMETYPE information for the given metadata to "application/gnunet-directory".
Definition: fs_directory.c:81
Internal state of a directory builder.
Definition: fs_directory.c:342

References GNUNET_FS_meta_data_create(), GNUNET_FS_meta_data_duplicate(), GNUNET_FS_meta_data_make_directory(), GNUNET_new, and ret.

Referenced by publish_content(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_directory_builder_add()

void GNUNET_FS_directory_builder_add ( struct GNUNET_FS_DirectoryBuilder bld,
const struct GNUNET_FS_Uri uri,
const struct GNUNET_FS_MetaData md,
const void *  data 
)

Add an entry to a directory.

Parameters
blddirectory to extend
uriuri of the entry (must not be a KSK)
mdmetadata of the entry
dataraw data of the entry, can be NULL, otherwise data must point to exactly the number of bytes specified by the uri
blddirectory to extend
uriuri of the entry (must not be a KSK)
mdmetadata of the entry
dataraw data of the entry, can be NULL, otherwise data must point to exactly the number of bytes specified by the uri which must be of type LOC or CHK

Definition at line 392 of file fs_directory.c.

396{
397 struct GNUNET_FS_Uri *curi;
398 struct BuilderEntry *e;
399 uint64_t fsize;
400 uint32_t big;
401 ssize_t ret;
402 size_t mds;
403 size_t mdxs;
404 char *uris;
405 char *serialized;
406 char *sptr;
407 size_t slen;
408 struct GNUNET_FS_MetaData *meta;
409 const struct GNUNET_FS_MetaData *meta_use;
410
412 if (NULL != data)
413 {
416 {
418 }
419 else
420 {
422 GNUNET_assert (NULL != curi);
423 fsize = GNUNET_FS_uri_chk_get_file_size (curi);
425 }
426 }
427 else
428 {
429 fsize = 0; /* not given */
430 }
431 if (fsize > MAX_INLINE_SIZE)
432 fsize = 0; /* too large */
434 slen = strlen (uris) + 1;
436 meta_use = md;
437 meta = NULL;
438 if (fsize > 0)
439 {
441 GNUNET_FS_meta_data_insert (meta, "<gnunet>",
442 EXTRACTOR_METATYPE_GNUNET_FULL_DATA,
443 EXTRACTOR_METAFORMAT_BINARY, NULL, data,
444 fsize);
446 if ((slen + sizeof(uint32_t) + mdxs - 1) / DBLOCK_SIZE ==
447 (slen + sizeof(uint32_t) + mds - 1) / DBLOCK_SIZE)
448 {
449 /* adding full data would not cause us to cross
450 * additional blocks, so add it! */
451 meta_use = meta;
452 mds = mdxs;
453 }
454 }
455
456 if (mds > GNUNET_MAX_MALLOC_CHECKED / 2)
458 e = GNUNET_malloc (sizeof(struct BuilderEntry) + slen + mds
459 + sizeof(uint32_t));
460 serialized = (char *) &e[1];
461 GNUNET_memcpy (serialized, uris, slen);
462 GNUNET_free (uris);
463 sptr = &serialized[slen + sizeof(uint32_t)];
464 ret =
465 GNUNET_FS_meta_data_serialize (meta_use, &sptr, mds,
467 if (NULL != meta)
469 if (ret == -1)
470 mds = 0;
471 else
472 mds = ret;
473 big = htonl (mds);
474 GNUNET_memcpy (&serialized[slen], &big, sizeof(uint32_t));
475 e->len = slen + sizeof(uint32_t) + mds;
476 e->next = bld->head;
477 bld->head = e;
478 bld->count++;
479}
#define MAX_INLINE_SIZE
Maximum size for a file to be considered for inlining in a directory.
Definition: fs_api.h:50
uint64_t GNUNET_FS_uri_chk_get_file_size(const struct GNUNET_FS_Uri *uri)
What is the size of the file that this URI refers to?
Definition: fs_uri.c:1360
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2034
int GNUNET_FS_uri_test_chk(const struct GNUNET_FS_Uri *uri)
Is this a file (or directory) URI?
Definition: fs_uri.c:1346
struct GNUNET_FS_Uri * GNUNET_FS_uri_loc_get_uri(const struct GNUNET_FS_Uri *uri)
Obtain the URI of the content itself.
Definition: fs_uri.c:843
ssize_t GNUNET_FS_meta_data_get_serialized_size(const struct GNUNET_FS_MetaData *md)
Get the size of the full meta-data in serialized form.
Definition: meta_data.c:858
ssize_t GNUNET_FS_meta_data_serialize(const struct GNUNET_FS_MetaData *md, char **target, size_t max, enum GNUNET_FS_MetaDataSerializationOptions opt)
Serialize meta-data to target.
Definition: meta_data.c:637
@ GNUNET_FS_META_DATA_SERIALIZE_PART
If not enough space is available, it is acceptable to only serialize some of the metadata.
Entries in the directory (builder).
Definition: fs_directory.c:326
size_t len
Length of this entry.
Definition: fs_directory.c:335
struct BuilderEntry * next
This is a linked list.
Definition: fs_directory.c:330
struct BuilderEntry * head
Head of linked list of entries.
Definition: fs_directory.c:351
unsigned int count
Number of entries in the directory.
Definition: fs_directory.c:356

References GNUNET_FS_DirectoryBuilder::count, data, DBLOCK_SIZE, GNUNET_assert, GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_meta_data_duplicate(), GNUNET_FS_meta_data_get_serialized_size(), GNUNET_FS_meta_data_insert(), GNUNET_FS_meta_data_serialize(), GNUNET_FS_META_DATA_SERIALIZE_PART, GNUNET_FS_uri_chk_get_file_size(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_loc_get_uri(), GNUNET_FS_uri_test_chk(), GNUNET_FS_uri_test_ksk(), GNUNET_FS_uri_test_sks(), GNUNET_FS_uri_to_string(), GNUNET_malloc, GNUNET_MAX_MALLOC_CHECKED, GNUNET_memcpy, GNUNET_FS_DirectoryBuilder::head, BuilderEntry::len, MAX_INLINE_SIZE, meta, BuilderEntry::next, ret, and uri.

Referenced by progress_cb(), and publish_content().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_directory_builder_finish()

int GNUNET_FS_directory_builder_finish ( struct GNUNET_FS_DirectoryBuilder bld,
size_t *  rsize,
void **  rdata 
)

Finish building the directory.

Frees the builder context and returns the directory in-memory.

Parameters
blddirectory to finish
rsizeset to the number of bytes needed
rdataset to the encoded directory
Returns
GNUNET_OK on success

Definition at line 578 of file fs_directory.c.

581{
582 char *data;
583 char *sptr;
584 size_t *sizes;
585 unsigned int *perm;
586 unsigned int i;
587 unsigned int j;
588 struct BuilderEntry *pos;
589 struct BuilderEntry **bes;
590 size_t size;
591 size_t psize;
592 size_t off;
593 ssize_t ret;
594 uint32_t big;
595
596 size = strlen (GNUNET_DIRECTORY_MAGIC) + sizeof(uint32_t);
598 sizes = NULL;
599 perm = NULL;
600 bes = NULL;
601 if (0 < bld->count)
602 {
603 sizes = GNUNET_new_array (bld->count,
604 size_t);
605 perm = GNUNET_new_array (bld->count,
606 unsigned int);
607 bes = GNUNET_new_array (bld->count,
608 struct BuilderEntry *);
609 pos = bld->head;
610 for (i = 0; i < bld->count; i++)
611 {
612 perm[i] = i;
613 bes[i] = pos;
614 sizes[i] = pos->len;
615 pos = pos->next;
616 }
617 block_align (size, bld->count, sizes, perm);
618 /* compute final size with alignment */
619 for (i = 0; i < bld->count; i++)
620 {
621 psize = size;
622 size += sizes[perm[i]];
623 size = do_align (psize, size);
624 }
625 }
626 *rsize = size;
628 if (data == NULL)
629 {
631 "malloc");
632 *rsize = 0;
633 *rdata = NULL;
634 GNUNET_free (sizes);
635 GNUNET_free (perm);
636 GNUNET_free (bes);
637 return GNUNET_SYSERR;
638 }
639 *rdata = data;
642 strlen (GNUNET_DIRECTORY_MAGIC));
643 off = strlen (GNUNET_DIRECTORY_MAGIC);
644
645 sptr = &data[off + sizeof(uint32_t)];
646 ret =
648 &sptr,
649 size - off - sizeof(uint32_t),
651 GNUNET_assert (ret != -1);
652 big = htonl (ret);
653 GNUNET_memcpy (&data[off],
654 &big,
655 sizeof(uint32_t));
656 off += sizeof(uint32_t) + ret;
657 for (j = 0; j < bld->count; j++)
658 {
659 i = perm[j];
660 psize = off;
661 off += sizes[i];
662 off = do_align (psize, off);
663 GNUNET_memcpy (&data[off - sizes[i]], &(bes[i])[1], sizes[i]);
664 GNUNET_free (bes[i]);
665 }
666 GNUNET_free (sizes);
667 GNUNET_free (perm);
668 GNUNET_free (bes);
669 GNUNET_assert (off == size);
671 GNUNET_free (bld);
672 return GNUNET_OK;
673}
static size_t do_align(size_t start_position, size_t end_position)
Given the start and end position of a block of data, return the end position of that data after align...
Definition: fs_directory.c:488
#define GNUNET_DIRECTORY_MAGIC
String that is used to indicate that a file is a GNUnet directory.
Definition: fs_directory.c:44
static void block_align(size_t start, unsigned int count, const size_t *sizes, unsigned int *perm)
Compute a permutation of the blocks to minimize the cost of alignment.
Definition: fs_directory.c:509
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
#define GNUNET_malloc_large(size)
Wrapper around malloc.
@ GNUNET_FS_META_DATA_SERIALIZE_FULL
Serialize all of the data.
struct GNUNET_FS_MetaData * meta
Meta-data for the directory itself.
Definition: fs_directory.c:346

References block_align(), GNUNET_FS_DirectoryBuilder::count, data, do_align(), GNUNET_assert, GNUNET_DIRECTORY_MAGIC, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_meta_data_get_serialized_size(), GNUNET_FS_meta_data_serialize(), GNUNET_FS_META_DATA_SERIALIZE_FULL, GNUNET_log_strerror, GNUNET_malloc_large, GNUNET_memcpy, GNUNET_new_array, GNUNET_OK, GNUNET_SYSERR, GNUNET_FS_DirectoryBuilder::head, BuilderEntry::len, GNUNET_FS_DirectoryBuilder::meta, BuilderEntry::next, ret, and size.

Referenced by clean_task(), and publish_content().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_directory_scan_start()

struct GNUNET_FS_DirScanner * GNUNET_FS_directory_scan_start ( const char *  filename,
int  disable_extractor,
const char *  ex,
GNUNET_FS_DirScannerProgressCallback  cb,
void *  cb_cls 
)

Start a directory scanner.

Parameters
filenamename of the directory to scan
disable_extractorGNUNET_YES to not run libextractor on files (only build a tree)
exif not NULL, must be a list of extra plugins for extractor
cbthe callback to call when there are scanning progress messages
cb_clsclosure for cb
Returns
directory scanner object to be used for controlling the scanner

Start a directory scanner.

Parameters
filenamename of the directory to scan
disable_extractorGNUNET_YES to not run libextractor on files (only build a tree)
exif not NULL, must be a list of extra plugins for extractor
cbthe callback to call when there are scanning progress messages
cb_clsclosure for 'cb'
Returns
directory scanner object to be used for controlling the scanner

Definition at line 450 of file fs_dirmetascan.c.

455{
456 struct stat sbuf;
457 char *filename_expanded;
458 struct GNUNET_FS_DirScanner *ds;
459
460 if (0 != stat (filename, &sbuf))
461 return NULL;
463 if (NULL == filename_expanded)
464 return NULL;
466 "Starting to scan directory `%s'\n",
469 ds->progress_callback = cb;
470 ds->progress_callback_cls = cb_cls;
473 ds->ex_arg = GNUNET_strdup ("-");
474 else
475 ds->ex_arg = (NULL != ex) ? GNUNET_strdup (ex) : NULL;
476 ds->args[0] = (char*) "gnunet-helper-fs-publish";
478 ds->args[2] = ds->ex_arg;
479 ds->args[3] = NULL;
481 GNUNET_NO,
482 "gnunet-helper-fs-publish",
483 ds->args,
486 ds);
487 if (NULL == ds->helper)
488 {
490 GNUNET_free (ds);
491 return NULL;
492 }
493 return ds;
494}
static void helper_died_cb(void *cls)
Function called if our helper process died.
static int process_helper_msgs(void *cls, const struct GNUNET_MessageHeader *msg)
Called every time there is data to read from the scanner.
static int disable_extractor
Disable extractor option to use for publishing.
static struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
struct GNUNET_HELPER_Handle * GNUNET_HELPER_start(const struct GNUNET_OS_ProjectData *pd, int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls)
Starts a helper and begins reading from it.
Definition: helper.c:460
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:504
An opaque structure a pointer to which is returned to the caller to be used to control the scanner.
GNUNET_FS_DirScannerProgressCallback progress_callback
The function that will be called every time there's a progress message.
char * args[4]
Arguments for helper.
char * ex_arg
Second argument to helper process.
void * progress_callback_cls
A closure for progress_callback.
struct GNUNET_HELPER_Handle * helper
Helper process.
char * filename_expanded
Expanded filename (as given by the scan initiator).

References GNUNET_FS_DirScanner::args, disable_extractor, ds, GNUNET_FS_DirScanner::ex_arg, filename, GNUNET_FS_DirScanner::filename_expanded, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELPER_start(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OS_project_data_gnunet(), GNUNET_strdup, GNUNET_STRINGS_filename_expand(), GNUNET_FS_DirScanner::helper, helper_died_cb(), process_helper_msgs(), GNUNET_FS_DirScanner::progress_callback, and GNUNET_FS_DirScanner::progress_callback_cls.

Referenced by GNUNET_FS_unindex_do_extract_keywords_(), and identity_continuation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_directory_scan_abort()

void GNUNET_FS_directory_scan_abort ( struct GNUNET_FS_DirScanner ds)

Abort the scan.

Must not be called from within the progress_callback function.

Parameters
dsdirectory scanner structure

Definition at line 99 of file fs_dirmetascan.c.

100{
101 /* terminate helper */
102 if (NULL != ds->helper)
104
105 /* free resources */
106 if (NULL != ds->toplevel)
108 if (NULL != ds->stop_task)
112 GNUNET_free (ds);
113}
void GNUNET_FS_share_tree_free(struct GNUNET_FS_ShareTreeItem *toplevel)
Release memory of a share item tree.
Definition: fs_sharetree.c:437
void GNUNET_HELPER_stop(struct GNUNET_HELPER_Handle *h, int soft_kill)
Kills the helper, closes the pipe, frees the handle and calls wait() on the helper process.
Definition: helper.c:538
struct GNUNET_FS_ShareTreeItem * toplevel
After the scan is finished, it will contain a pointer to the top-level directory entry in the directo...
struct GNUNET_SCHEDULER_Task * stop_task
Task scheduled when we are done.

References ds, GNUNET_FS_DirScanner::ex_arg, GNUNET_FS_DirScanner::filename_expanded, GNUNET_free, GNUNET_FS_share_tree_free(), GNUNET_HELPER_stop(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_FS_DirScanner::helper, GNUNET_FS_DirScanner::stop_task, and GNUNET_FS_DirScanner::toplevel.

Referenced by do_stop_task(), GNUNET_FS_directory_scan_get_result(), GNUNET_FS_unindex_signal_suspend_(), GNUNET_FS_unindex_stop(), and unindex_directory_scan_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_directory_scan_get_result()

struct GNUNET_FS_ShareTreeItem * GNUNET_FS_directory_scan_get_result ( struct GNUNET_FS_DirScanner ds)

Obtain the result of the scan after the scan has signalled completion.

Must not be called prior to completion. The ds is freed as part of this call.

Parameters
dsdirectory scanner structure
Returns
the results of the scan (a directory tree)

Definition at line 117 of file fs_dirmetascan.c.

118{
120
121 /* check that we're actually done */
122 GNUNET_assert (NULL == ds->helper);
123 /* preserve result */
124 result = ds->toplevel;
125 ds->toplevel = NULL;
127 return result;
128}
static int result
Global testing status.
A node of a directory tree (produced by dirscanner)

References ds, GNUNET_assert, GNUNET_FS_directory_scan_abort(), GNUNET_FS_DirScanner::helper, result, and GNUNET_FS_DirScanner::toplevel.

Referenced by directory_scan_cb(), and unindex_directory_scan_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_share_tree_trim()

void GNUNET_FS_share_tree_trim ( struct GNUNET_FS_ShareTreeItem toplevel)

Process a share item tree, moving frequent keywords up and copying frequent metadata up.

Parameters
topleveltoplevel directory in the tree, returned by the scanner

Definition at line 417 of file fs_sharetree.c.

418{
419 struct TrimContext tc;
420
421 if (toplevel == NULL)
422 return;
423 tc.keywordcounter = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO);
425 share_tree_trim (&tc, toplevel);
428}
static void share_tree_trim(struct TrimContext *tc, struct GNUNET_FS_ShareTreeItem *tree)
Process a share item tree, moving frequent keywords up and copying frequent metadata up.
Definition: fs_sharetree.c:337
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:431
A structure that forms a singly-linked list that serves as a stack for metadata-processing function.
Definition: fs_sharetree.c:120

References GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_NO, share_tree_trim(), and tc.

Referenced by directory_scan_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_share_tree_free()

void GNUNET_FS_share_tree_free ( struct GNUNET_FS_ShareTreeItem toplevel)

Release memory of a share item tree.

Parameters
topleveltoplevel of the tree to be freed

Definition at line 437 of file fs_sharetree.c.

438{
439 struct GNUNET_FS_ShareTreeItem *pos;
440
441 while (NULL != (pos = toplevel->children_head))
443 if (NULL != toplevel->parent)
445 toplevel->parent->children_tail,
446 toplevel);
447 if (NULL != toplevel->meta)
449 if (NULL != toplevel->ksk_uri)
450 GNUNET_FS_uri_destroy (toplevel->ksk_uri);
451 GNUNET_free (toplevel->filename);
452 GNUNET_free (toplevel->short_filename);
453 GNUNET_free (toplevel);
454}
struct GNUNET_FS_ShareTreeItem * parent
This is a doubly-linked tree NULL for top-level entries.
struct GNUNET_FS_Uri * ksk_uri
Keywords for this file or directory (derived from metadata).
char * short_filename
Base name of the file/directory.
struct GNUNET_FS_ShareTreeItem * children_head
This is a doubly-linked tree NULL for files and empty directories.
struct GNUNET_FS_MetaData * meta
Metadata for this file or directory.
char * filename
Name of the file/directory.
struct GNUNET_FS_ShareTreeItem * children_tail
This is a doubly-linked tree NULL for files and empty directories.

References GNUNET_FS_ShareTreeItem::children_head, GNUNET_FS_ShareTreeItem::children_tail, GNUNET_FS_ShareTreeItem::filename, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_share_tree_free(), GNUNET_FS_uri_destroy(), GNUNET_FS_ShareTreeItem::ksk_uri, GNUNET_FS_ShareTreeItem::meta, GNUNET_FS_ShareTreeItem::parent, and GNUNET_FS_ShareTreeItem::short_filename.

Referenced by directory_trim_complete(), GNUNET_FS_directory_scan_abort(), GNUNET_FS_share_tree_free(), and unindex_directory_scan_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_write_meta_data()

enum GNUNET_GenericReturnValue GNUNET_FS_write_meta_data ( struct GNUNET_BIO_WriteHandle h,
const char *  what,
const struct GNUNET_FS_MetaData m 
)

Write a metadata container.

Parameters
hthe IO handle to write to
whatwhat is being written (for error message creation)
mmetadata to write
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 1110 of file meta_data.c.

1113{
1114 ssize_t size;
1115 char *buf;
1116
1117 if (m == NULL)
1118 return GNUNET_BIO_write_int32 (h, _ ("metadata length"), 0);
1119 buf = NULL;
1121 &buf,
1125 "Serialized %lld bytes of metadata",
1126 (long long) size);
1127
1128 if (-1 == size)
1129 {
1130 GNUNET_free (buf);
1132 "Failed to serialize metadata `%s'",
1133 what);
1134 return GNUNET_SYSERR;
1135 }
1136 if ( (GNUNET_OK !=
1138 "metadata length",
1139 (uint32_t) size)) ||
1140 (GNUNET_OK !=
1142 what,
1143 buf,
1144 size)) )
1145 {
1146 GNUNET_free (buf);
1147 return GNUNET_SYSERR;
1148 }
1149 GNUNET_free (buf);
1150 return GNUNET_OK;
1151}
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:103
enum GNUNET_GenericReturnValue GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
Write an (u)int32_t.
Definition: bio.c:845
enum GNUNET_GenericReturnValue GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const char *what, const void *buffer, size_t n)
Write a buffer to a handle.
Definition: bio.c:750
#define MAX_META_DATA
Maximum size allowed for meta data written/read from disk.
Definition: meta_data.c:35

References _, GNUNET_BIO_write(), GNUNET_BIO_write_int32(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_FS_meta_data_serialize(), GNUNET_FS_META_DATA_SERIALIZE_PART, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, h, m, MAX_META_DATA, and size.

Referenced by write_spec_handler_meta_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_read_spec_meta_data()

struct GNUNET_BIO_ReadSpec GNUNET_FS_read_spec_meta_data ( const char *  what,
struct GNUNET_FS_MetaData **  result 
)

Create the specification to read a metadata container.

Parameters
whatdescribes what is being read (for error message creation)
resultthe buffer to store a pointer to the (allocated) metadata
Returns
the read spec

Definition at line 1185 of file meta_data.c.

1187{
1188 struct GNUNET_BIO_ReadSpec rs = {
1190 .cls = NULL,
1191 .target = result,
1192 .size = 0,
1193 };
1194
1195 return rs;
1196}
static int read_spec_handler_meta_data(void *cls, struct GNUNET_BIO_ReadHandle *h, const char *what, void *target, size_t target_size)
Function used internally to read a metadata container from within a read spec.
Definition: meta_data.c:1166
Structure specifying a reading operation on an IO handle.
GNUNET_BIO_ReadHandler rh
Function performing data deserialization.

References read_spec_handler_meta_data(), result, and GNUNET_BIO_ReadSpec::rh.

Referenced by deserialize_download(), and read_update_information_graph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_write_spec_meta_data()

struct GNUNET_BIO_WriteSpec GNUNET_FS_write_spec_meta_data ( const char *  what,
const struct GNUNET_FS_MetaData m 
)

Create the specification to write a metadata container.

Parameters
whatwhat is being written (for error message creation)
mmetadata to write
Returns
the write spec

Definition at line 1223 of file meta_data.c.

1225{
1226 struct GNUNET_BIO_WriteSpec ws = {
1228 .cls = NULL,
1229 .what = what,
1230 .source = (void *) m,
1231 .source_size = 0,
1232 };
1233
1234 return ws;
1235}
static int write_spec_handler_meta_data(void *cls, struct GNUNET_BIO_WriteHandle *h, const char *what, void *source, size_t source_size)
Function used internally to write a metadata container from within a write spec.
Definition: meta_data.c:1211
Structure specifying a writing operation on an IO handle.
GNUNET_BIO_WriteHandler wh
Function performing data serialization.
size_t source_size
Size of source.
const char * what
What is being read (for error message creation)

References m, GNUNET_BIO_WriteSpec::source_size, GNUNET_BIO_WriteSpec::wh, GNUNET_BIO_WriteSpec::what, and write_spec_handler_meta_data().

Referenced by GNUNET_FS_download_sync_(), GNUNET_FS_file_information_sync_(), GNUNET_FS_search_result_sync_(), and write_update_information_graph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_read_meta_data()

enum GNUNET_GenericReturnValue GNUNET_FS_read_meta_data ( struct GNUNET_BIO_ReadHandle h,
const char *  what,
struct GNUNET_FS_MetaData **  result 
)

Read a metadata container.

Parameters
hhandle to an open file
whatdescribes what is being read (for error message creation)
resultthe buffer to store a pointer to the (allocated) metadata
Returns
GNUNET_OK on success, GNUNET_SYSERR on failure

Definition at line 1051 of file meta_data.c.

1054{
1055 uint32_t size;
1056 char *buf;
1057 char *emsg;
1058 struct GNUNET_FS_MetaData *meta;
1059
1061 _ ("metadata length"),
1062 (int32_t *) &size))
1063 return GNUNET_SYSERR;
1064 if (0 == size)
1065 {
1066 *result = NULL;
1067 return GNUNET_OK;
1068 }
1069 if (MAX_META_DATA < size)
1070 {
1071 GNUNET_asprintf (&emsg,
1072 _ (
1073 "Serialized metadata `%s' larger than allowed (%u > %u)\n"),
1074 what,
1075 size,
1078 GNUNET_free (emsg);
1079 return GNUNET_SYSERR;
1080 }
1081 buf = GNUNET_malloc (size);
1082 if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, size))
1083 {
1084 GNUNET_free (buf);
1085 return GNUNET_SYSERR;
1086 }
1088 if (NULL == meta)
1089 {
1090 GNUNET_free (buf);
1092 _ ("Failed to deserialize metadata `%s'"), what);
1093 return GNUNET_SYSERR;
1094 }
1095 GNUNET_free (buf);
1096 *result = meta;
1097 return GNUNET_OK;
1098}
enum GNUNET_GenericReturnValue GNUNET_BIO_read(struct GNUNET_BIO_ReadHandle *h, const char *what, void *result, size_t len)
Read some contents into a buffer.
Definition: bio.c:291
void GNUNET_BIO_read_set_error(struct GNUNET_BIO_ReadHandle *h, const char *emsg)
Set read error to handle.
Definition: bio.c:187
enum GNUNET_GenericReturnValue GNUNET_BIO_read_int32(struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
Read an (u)int32_t.
Definition: bio.c:427

References _, GNUNET_asprintf(), GNUNET_BIO_read(), GNUNET_BIO_read_int32(), GNUNET_BIO_read_set_error(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_meta_data_deserialize(), GNUNET_log, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, h, MAX_META_DATA, meta, result, and size.

Referenced by deserialize_fi_node(), deserialize_search_result(), and read_spec_handler_meta_data().

Here is the call graph for this function:
Here is the caller graph for this function: