GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
FS service

File sharing. More...

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 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_CONTAINER_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_CONTAINER_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_CONTAINER_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 = (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...
 
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_CONTAINER_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_CONTAINER_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 (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_CONTAINER_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_CONTAINER_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_CONTAINER_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_CONTAINER_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_CONTAINER_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_CONTAINER_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_CONTAINER_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_CONTAINER_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_CONTAINER_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_CONTAINER_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_CONTAINER_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_CONTAINER_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_CONTAINER_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...
 

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 67 of file gnunet_fs_service.h.

Referenced by process_kblock().

◆ GNUNET_FS_URI_PREFIX

#define GNUNET_FS_URI_PREFIX   "gnunet://fs/"

◆ GNUNET_FS_URI_KSK_INFIX

#define GNUNET_FS_URI_KSK_INFIX   "ksk/"

Definition at line 73 of file gnunet_fs_service.h.

Referenced by uri_ksk_to_string().

◆ GNUNET_FS_URI_SKS_INFIX

#define GNUNET_FS_URI_SKS_INFIX   "sks/"

Definition at line 74 of file gnunet_fs_service.h.

Referenced by uri_sks_to_string().

◆ GNUNET_FS_URI_CHK_INFIX

#define GNUNET_FS_URI_CHK_INFIX   "chk/"

Definition at line 75 of file gnunet_fs_service.h.

Referenced by uri_chk_to_string().

◆ GNUNET_FS_URI_LOC_INFIX

#define GNUNET_FS_URI_LOC_INFIX   "loc/"

Definition at line 76 of file gnunet_fs_service.h.

Referenced by uri_loc_to_string().

◆ GNUNET_FS_PROBE_UPDATE_FREQUENCY

#define GNUNET_FS_PROBE_UPDATE_FREQUENCY
Value:
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:442
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.

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

Definition at line 83 of file gnunet_fs_service.h.

Referenced by probe_ping_task_cb().

◆ GNUNET_FS_DIRECTORY_MIME

#define GNUNET_FS_DIRECTORY_MIME   "application/gnunet-directory"

◆ GNUNET_FS_DIRECTORY_MAGIC

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

Definition at line 2460 of file gnunet_fs_service.h.

Referenced by GNUNET_FS_directory_list_contents().

◆ GNUNET_FS_DIRECTORY_EXT

#define GNUNET_FS_DIRECTORY_EXT   ".gnd"

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 101 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 1548 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_CONTAINER_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 1702 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 1826 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 2014 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 2108 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_CONTAINER_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 2174 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_CONTAINER_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 2511 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 2647 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 futher 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 507 of file gnunet_fs_service.h.

508 {
513 
518 
523 
528 
535 
542 
549 
554 
559 
564 
569 
574 
581 
587 
593 
599 
607 
614 
621 
627 
634 
639 
644 
650 
655 
660 
665 
671 
677 
684 
689 
694 
699 
704 
710 
716 
722 
727 };
Notification that we have started this download.
This search has yielded a result.
Notification that we started to unindex a file.
Last message from a search; this signals that there will be no further events associated with this se...
Notification that we are making progress sharing a file structure.
Notification that this download was suspended.
Event generated for each search result when the respective search is stopped.
Notification that we made progress unindexing a file.
First event generated when a client requests a search to begin or when a namespace result automatical...
Notification that we suspended unindexing a file.
We have discovered a new namespace.
Notification that we have stopped the process of uploading a file structure; no futher events will be...
Notification that we have started to publish a file structure.
Notification that this download completed.
Notification that we are making progress sharing a directory.
Last event when a search is being resumed; note that "GNUNET_FS_SEARCH_START" will not be generated i...
Signals that this search was continued (unpaused).
Notification that this download is no longer actively being pursued (back in the queue).
Last event when a search is being suspended; note that "GNUNET_FS_SEARCH_STOPPED" will not be generat...
Notification that the unindexing of this file was stopped (final event for this action).
Notification about progress with this download.
Notification that this download is now actively being pursued (as opposed to waiting in the queue)...
Notification that the unindexing of this file was completed.
Notification that we completed sharing a file structure.
Notification that this download is being resumed.
Notification that this download is no longer part of a recursive download or search but now a &#39;stand-...
Event generated for each search result when the respective search is resumed.
Notification that we have resumed sharing a file structure.
Event generated for each search result when the respective search is suspended.
Notification that an error was encountered sharing a file structure.
Notification that we have suspended sharing a file structure.
Signals a problem with this search.
We have additional data about the quality or availability of a search result.
Notification that we resumed unindexing of a file.
Notification that this download was stopped (final event with respect to this action).
Signals that this search was paused.
Notification that we encountered an error unindexing a file.
Notification that this download encountered an error.

◆ 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 1555 of file gnunet_fs_service.h.

1556 {
1561 
1567 
1574 };
No special flags set.
Should we automatically trigger probes for search results to determine availability? (will create GNUNET_FS_STATUS_SEARCH_UPDATE events).
Is persistence of operations desired? (will create SUSPEND/RESUME events).

◆ 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 (invidivual downloads may go above this, but if we are above this threshold, we should not activate any additional downloads.

Definition at line 1580 of file gnunet_fs_service.h.

1581 {
1586 
1593 
1601 };
Last option in the VARARG list.
Select the desired amount of parallelism (this option should be followed by an "unsigned int" giving ...
Maximum number of requests that should be pending at a given point in time (invidivual 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 1956 of file gnunet_fs_service.h.

1957 {
1962 
1968 };
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 2218 of file gnunet_fs_service.h.

2219 {
2224 
2229 };
No options (use defaults for everything).
Only search the local host, do not search remote systems (no P2P)

◆ 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 2309 of file gnunet_fs_service.h.

2310 {
2315 
2320 
2326 
2332 
2340  GNUNET_FS_DOWNLOAD_IS_PROBE = (1 << 31)
2341 };
Do not append temporary data to the target file (for the IBlocks).
Only download from the local host, do not access remote systems (no P2P)
Internal option used to flag this download as a &#39;probe&#39; for a search result.
No options (use defaults for everything).
Do a recursive download (that is, automatically trigger the download of files in directories).

◆ 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 2600 of file gnunet_fs_service.h.

2601 {
2606 
2612 
2617 
2622 
2628 
2633 };
We&#39;ve found all files (in the pre-pass).
There was an internal error.
Last call to the progress function: we have finished scanning the directory.
We&#39;ve started processing a file or directory.
We&#39;ve finished extracting meta data from a file.
We&#39;re having trouble accessing a file (soft-error); it will be ignored.

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
keywherer to store the unique key
Returns
GNUNET_OK on success

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 103 of file fs_uri.c.

References GNUNET_FS_Uri::chk, FileIdentifier::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::ksk, GNUNET_FS_Uri::loc, ContentHashKey::query, GNUNET_FS_Uri::sks, and GNUNET_FS_Uri::type.

Referenced by process_ksk_result(), and process_sks_result().

105 {
106  switch (uri->type)
107  {
108  case GNUNET_FS_URI_CHK:
109  *key = uri->data.chk.chk.query;
110  return GNUNET_OK;
111 
112  case GNUNET_FS_URI_SKS:
113  GNUNET_CRYPTO_hash (uri->data.sks.identifier,
114  strlen (uri->data.sks.identifier),
115  key);
116  return GNUNET_OK;
117 
118  case GNUNET_FS_URI_KSK:
119  if (uri->data.ksk.keywordCount > 0)
120  {
121  GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0],
122  strlen (uri->data.ksk.keywords[0]),
123  key);
124  return GNUNET_OK;
125  }
126  else
127  {
128  memset (key, 0, sizeof(struct GNUNET_HashCode));
129  return GNUNET_SYSERR;
130  }
131  break;
132 
133  case GNUNET_FS_URI_LOC:
134  GNUNET_CRYPTO_hash (&uri->data.loc.fi,
135  sizeof(struct FileIdentifier)
136  + sizeof(struct GNUNET_PeerIdentity),
137  key);
138  return GNUNET_OK;
139 
140  default:
141  memset (key, 0, sizeof(struct GNUNET_HashCode));
142  return GNUNET_SYSERR;
143  }
144 }
struct ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
Definition: fs_api.h:103
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:211
struct GNUNET_FS_Uri::@13::@15 sks
Keyword search key (query with keywords).
Definition: fs_api.h:153
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
struct GNUNET_HashCode query
Hash of the encrypted content, used for querying.
Definition: fs.h:63
complete information needed to download a file.
Definition: fs_api.h:93
A 512-bit hashcode.
Content-hash-key (simple file).
Definition: fs_api.h:143
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
Signed key space (file in namespace).
Definition: fs_api.h:148
The identity of the host (wraps the signing key of the peer).
struct GNUNET_FS_Uri::@13::@14 ksk
struct FileIdentifier fi
Information about the shared file.
Definition: fs_api.h:116
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content...
Definition: fs_api.h:217
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 2028 of file fs_uri.c.

References GNUNET_break, GNUNET_FS_URI_CHK, GNUNET_FS_URI_KSK, GNUNET_FS_URI_LOC, GNUNET_FS_URI_SKS, GNUNET_FS_Uri::type, 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(), progress_cb(), trigger_recursive_download(), and write_update_information_graph().

2029 {
2030  if (uri == NULL)
2031  {
2032  GNUNET_break (0);
2033  return NULL;
2034  }
2035  switch (uri->type)
2036  {
2037  case GNUNET_FS_URI_KSK:
2038  return uri_ksk_to_string (uri);
2039 
2040  case GNUNET_FS_URI_SKS:
2041  return uri_sks_to_string (uri);
2042 
2043  case GNUNET_FS_URI_CHK:
2044  return uri_chk_to_string (uri);
2045 
2046  case GNUNET_FS_URI_LOC:
2047  return uri_loc_to_string (uri);
2048 
2049  default:
2050  GNUNET_break (0);
2051  return NULL;
2052  }
2053 }
static char * uri_chk_to_string(const struct GNUNET_FS_Uri *uri)
Convert a CHK URI to a string.
Definition: fs_uri.c:1954
static char * uri_ksk_to_string(const struct GNUNET_FS_Uri *uri)
Convert a KSK URI to a string.
Definition: fs_uri.c:1853
Keyword search key (query with keywords).
Definition: fs_api.h:153
static char * uri_sks_to_string(const struct GNUNET_FS_Uri *uri)
Convert SKS URI to a string.
Definition: fs_uri.c:1923
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Content-hash-key (simple file).
Definition: fs_api.h:143
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
Signed key space (file in namespace).
Definition: fs_api.h:148
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
static char * uri_loc_to_string(const struct GNUNET_FS_Uri *uri)
Convert a LOC URI to a string.
Definition: fs_uri.c:1985
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 155 of file fs_uri.c.

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

156 {
157  size_t n;
158  char *ret;
159  unsigned int i;
160  const char *keyword;
161  char **keywords;
162  unsigned int keywordCount;
163 
164  if ((NULL == uri) || (GNUNET_FS_URI_KSK != uri->type))
165  {
166  GNUNET_break (0);
167  return NULL;
168  }
169  keywords = uri->data.ksk.keywords;
170  keywordCount = uri->data.ksk.keywordCount;
171  n = keywordCount + 1;
172  for (i = 0; i < keywordCount; i++)
173  {
174  keyword = keywords[i];
175  n += strlen (keyword) - 1;
176  if (NULL != strstr (&keyword[1], " "))
177  n += 2;
178  if (keyword[0] == '+')
179  n++;
180  }
181  ret = GNUNET_malloc (n);
182  strcpy (ret, "");
183  for (i = 0; i < keywordCount; i++)
184  {
185  keyword = keywords[i];
186  if (NULL != strstr (&keyword[1], " "))
187  {
188  strcat (ret, "\"");
189  if (keyword[0] == '+')
190  strcat (ret, keyword);
191  else
192  strcat (ret, &keyword[1]);
193  strcat (ret, "\"");
194  }
195  else
196  {
197  if (keyword[0] == '+')
198  strcat (ret, keyword);
199  else
200  strcat (ret, &keyword[1]);
201  }
202  strcat (ret, " ");
203  }
204  return ret;
205 }
Keyword search key (query with keywords).
Definition: fs_api.h:153
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
struct GNUNET_FS_Uri::@13::@14 ksk
#define GNUNET_malloc(size)
Wrapper around malloc.

◆ 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 762 of file fs_uri.c.

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

Referenced by get_file_information(), and migrate_and_drop_keywords().

765 {
766  unsigned int i;
767  const char *old;
768  char *n;
769 
771  for (i = 0; i < uri->data.ksk.keywordCount; i++)
772  {
773  old = uri->data.ksk.keywords[i];
774  if (0 == strcmp (&old[1], keyword))
775  return;
776  }
777  GNUNET_asprintf (&n, is_mandatory ? "+%s" : " %s", keyword);
778  GNUNET_array_append (uri->data.ksk.keywords, uri->data.ksk.keywordCount, n);
779 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Keyword search key (query with keywords).
Definition: fs_api.h:153
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
struct GNUNET_FS_Uri::@13::@14 ksk
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 790 of file fs_uri.c.

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

Referenced by remove_high_frequency_keywords().

792 {
793  unsigned int i;
794  char *old;
795 
797  for (i = 0; i < uri->data.ksk.keywordCount; i++)
798  {
799  old = uri->data.ksk.keywords[i];
800  if (0 == strcmp (&old[1], keyword))
801  {
802  uri->data.ksk.keywords[i] =
803  uri->data.ksk.keywords[uri->data.ksk.keywordCount - 1];
804  GNUNET_array_grow (uri->data.ksk.keywords,
805  uri->data.ksk.keywordCount,
806  uri->data.ksk.keywordCount - 1);
807  GNUNET_free (old);
808  return;
809  }
810  }
811 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Keyword search key (query with keywords).
Definition: fs_api.h:153
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
struct GNUNET_FS_Uri::@13::@14 ksk
#define GNUNET_free(ptr)
Wrapper around free.
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

Definition at line 644 of file fs_uri.c.

References _, GNUNET_break, GNUNET_free, GNUNET_strdup, msg, ret, 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().

645 {
646  struct GNUNET_FS_Uri *ret;
647  char *msg;
648 
649  if (NULL == uri)
650  {
651  GNUNET_break (0);
652  if (NULL != emsg)
653  *emsg = GNUNET_strdup (_ ("invalid argument"));
654  return NULL;
655  }
656  if (NULL == emsg)
657  emsg = &msg;
658  *emsg = NULL;
659  if ((NULL != (ret = uri_chk_parse (uri, emsg))) ||
660  (NULL != (ret = uri_ksk_parse (uri, emsg))) ||
661  (NULL != (ret = uri_sks_parse (uri, emsg))) ||
662  (NULL != (ret = uri_loc_parse (uri, emsg))))
663  return ret;
664  if (NULL == *emsg)
665  *emsg = GNUNET_strdup (_ ("Unrecognized URI type"));
666  if (emsg == &msg)
667  GNUNET_free (msg);
668  return NULL;
669 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_FS_Uri * uri_loc_parse(const char *s, char **emsg)
Parse a LOC URI.
Definition: fs_uri.c:503
static struct GNUNET_FS_Uri * uri_ksk_parse(const char *s, char **emsg)
Parse a KSK URI.
Definition: fs_uri.c:279
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_FS_Uri * uri_sks_parse(const char *s, char **emsg)
Parse an SKS URI.
Definition: fs_uri.c:373
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_FS_Uri * uri_chk_parse(const char *s, char **emsg)
Parse a CHK URI.
Definition: fs_uri.c:413
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
#define GNUNET_free(ptr)
Wrapper around free.
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 678 of file fs_uri.c.

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::ksk, GNUNET_FS_Uri::sks, and GNUNET_FS_Uri::type.

Referenced by deserialize_search_result(), do_stop_task(), download_timeout(), 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(), report_success(), report_uri(), run(), search_result_free(), search_result_suspend(), search_start(), and share_tree_trim().

679 {
680  unsigned int i;
681 
682  switch (uri->type)
683  {
684  case GNUNET_FS_URI_KSK:
685  for (i = 0; i < uri->data.ksk.keywordCount; i++)
686  GNUNET_free (uri->data.ksk.keywords[i]);
687  GNUNET_array_grow (uri->data.ksk.keywords, uri->data.ksk.keywordCount, 0);
688  break;
689 
690  case GNUNET_FS_URI_SKS:
691  GNUNET_free (uri->data.sks.identifier);
692  break;
693 
694  case GNUNET_FS_URI_LOC:
695  break;
696 
697  default:
698  /* do nothing */
699  break;
700  }
701  GNUNET_free (uri);
702 }
struct GNUNET_FS_Uri::@13::@15 sks
Keyword search key (query with keywords).
Definition: fs_api.h:153
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
Signed key space (file in namespace).
Definition: fs_api.h:148
struct GNUNET_FS_Uri::@13::@14 ksk
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
#define GNUNET_free(ptr)
Wrapper around free.
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 712 of file fs_uri.c.

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

Referenced by fip_signal_start().

713 {
714  if (uri->type != GNUNET_FS_URI_KSK)
715  return 0;
716  return uri->data.ksk.keywordCount;
717 }
Keyword search key (query with keywords).
Definition: fs_api.h:153
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
struct GNUNET_FS_Uri::@13::@14 ksk
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
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 730 of file fs_uri.c.

References GNUNET_FS_Uri::data, GNUNET_FS_URI_KSK, GNUNET_OK, GNUNET_FS_Uri::ksk, and GNUNET_FS_Uri::type.

Referenced by publish_inspector(), and share_tree_trim().

733 {
734  unsigned int i;
735  char *keyword;
736 
737  if (uri->type != GNUNET_FS_URI_KSK)
738  return -1;
739  if (NULL == iterator)
740  return uri->data.ksk.keywordCount;
741  for (i = 0; i < uri->data.ksk.keywordCount; i++)
742  {
743  keyword = uri->data.ksk.keywords[i];
744  /* first character of keyword indicates
745  * if it is mandatory or not */
746  if (GNUNET_OK != iterator (iterator_cls, &keyword[1],(keyword[0] == '+') ))
747  return i;
748  }
749  return i;
750 }
static int iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
Keyword search key (query with keywords).
Definition: fs_api.h:153
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
struct GNUNET_FS_Uri::@13::@14 ksk
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 822 of file fs_uri.c.

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

Referenced by create_download_context(), and deserialize_download().

824 {
825  if (uri->type != GNUNET_FS_URI_LOC)
826  return GNUNET_SYSERR;
827  *peer = uri->data.loc.peer;
828  return GNUNET_OK;
829 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_PeerIdentity peer
Identity of the peer sharing the file.
Definition: fs_api.h:121
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content...
Definition: fs_api.h:217
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 853 of file fs_uri.c.

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

Referenced by GNUNET_FS_directory_builder_add().

854 {
855  struct GNUNET_FS_Uri *ret;
856 
857  if (uri->type != GNUNET_FS_URI_LOC)
858  return NULL;
859  ret = GNUNET_new (struct GNUNET_FS_Uri);
860  ret->type = GNUNET_FS_URI_CHK;
861  ret->data.chk = uri->data.loc.fi;
862  return ret;
863 }
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:211
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Content-hash-key (simple file).
Definition: fs_api.h:143
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
struct FileIdentifier fi
Information about the shared file.
Definition: fs_api.h:116
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content...
Definition: fs_api.h:217
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 839 of file fs_uri.c.

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

840 {
842  return uri->data.loc.expirationTime;
843 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TIME_Absolute expirationTime
Time when this location URI expires.
Definition: fs_api.h:126
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content...
Definition: fs_api.h:217

◆ 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 879 of file fs_uri.c.

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_assert, GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_CRYPTO_eddsa_sign(), GNUNET_FS_URI_CHK, GNUNET_FS_URI_LOC, GNUNET_new, GNUNET_OK, 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().

882 {
883  struct GNUNET_FS_Uri *uri;
884  struct GNUNET_CRYPTO_EddsaPublicKey my_public_key;
885  struct LocUriAssembly ass;
886  struct GNUNET_TIME_Absolute et;
887 
888  if (GNUNET_FS_URI_CHK != base_uri->type)
889  return NULL;
890  /* we round expiration time to full seconds for SKS URIs */
891  et.abs_value_us = (expiration_time.abs_value_us / 1000000LL) * 1000000LL;
892  GNUNET_CRYPTO_eddsa_key_get_public (sign_key, &my_public_key);
893  ass.purpose.size = htonl (sizeof(struct LocUriAssembly));
894  ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT);
895  ass.exptime = GNUNET_TIME_absolute_hton (et);
896  ass.fi = base_uri->data.chk;
897  ass.peer.public_key = my_public_key;
898  uri = GNUNET_new (struct GNUNET_FS_Uri);
899  uri->type = GNUNET_FS_URI_LOC;
900  uri->data.loc.fi = base_uri->data.chk;
901  uri->data.loc.expirationTime = et;
902  uri->data.loc.peer.public_key = my_public_key;
904  GNUNET_CRYPTO_eddsa_sign (sign_key,
905  &ass.purpose,
906  &uri->data.loc.contentSignature));
907  return uri;
908 }
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:211
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_CRYPTO_eddsa_sign(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition: crypto_ecc.c:987
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_PeerIdentity peer
Identity of the peer sharing the file.
Definition: fs_api.h:121
uint64_t abs_value_us
The actual value.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
#define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT
Signature by which a peer affirms that it is providing a certain bit of content (used in LOCation URI...
Content-hash-key (simple file).
Definition: fs_api.h:143
struct GNUNET_TIME_Absolute expirationTime
Time when this location URI expires.
Definition: fs_api.h:126
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
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:270
union GNUNET_FS_Uri::@13 data
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
struct GNUNET_CRYPTO_EddsaSignature contentSignature
Signature over the GNUNET_EC_FileIdentifier, peer identity and expiration time.
Definition: fs_api.h:132
struct FileIdentifier fi
Information about the shared file.
Definition: fs_api.h:116
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content...
Definition: fs_api.h:217
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:657
Structure that defines how the contents of a location URI must be assembled in memory to create or ve...
Definition: fs_uri.c:465
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
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 942 of file fs_uri.c.

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::ksk, ret, and GNUNET_FS_Uri::type.

Referenced by publish_inspector().

944 {
945  struct GNUNET_FS_Uri *ret;
946  unsigned int kc;
947  unsigned int i;
948  unsigned int j;
949  int found;
950  const char *kp;
951  char **kl;
952 
953  if ((u1 == NULL) && (u2 == NULL))
954  return NULL;
955  if (u1 == NULL)
956  return GNUNET_FS_uri_dup (u2);
957  if (u2 == NULL)
958  return GNUNET_FS_uri_dup (u1);
959  if ((u1->type != GNUNET_FS_URI_KSK) || (u2->type != GNUNET_FS_URI_KSK))
960  {
961  GNUNET_break (0);
962  return NULL;
963  }
964  kc = u1->data.ksk.keywordCount;
965  kl = GNUNET_new_array (kc + u2->data.ksk.keywordCount, char *);
966  for (i = 0; i < u1->data.ksk.keywordCount; i++)
967  kl[i] = GNUNET_strdup (u1->data.ksk.keywords[i]);
968  for (i = 0; i < u2->data.ksk.keywordCount; i++)
969  {
970  kp = u2->data.ksk.keywords[i];
971  found = 0;
972  for (j = 0; j < u1->data.ksk.keywordCount; j++)
973  if (0 == strcmp (kp + 1, kl[j] + 1))
974  {
975  found = 1;
976  if (kp[0] == '+')
977  kl[j][0] = '+';
978  break;
979  }
980  if (0 == found)
981  kl[kc++] = GNUNET_strdup (kp);
982  }
983  ret = GNUNET_new (struct GNUNET_FS_Uri);
984  ret->type = GNUNET_FS_URI_KSK;
985  ret->data.ksk.keywordCount = kc;
986  ret->data.ksk.keywords = kl;
987  return ret;
988 }
Keyword search key (query with keywords).
Definition: fs_api.h:153
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
struct GNUNET_FS_Uri::@13::@14 ksk
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 998 of file fs_uri.c.

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::ksk, ret, GNUNET_FS_Uri::sks, and GNUNET_FS_Uri::type.

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_TEST_download(), GNUNET_FS_tree_encoder_get_uri(), GNUNET_FS_uri_ksk_merge(), process_ksk_result(), process_sks_result(), publish_progress_cb(), publish_sblocks_cont(), search_start(), share_tree_trim(), and unindex_directory_scan_cb().

999 {
1000  struct GNUNET_FS_Uri *ret;
1001  unsigned int i;
1002 
1003  if (uri == NULL)
1004  return NULL;
1005  ret = GNUNET_new (struct GNUNET_FS_Uri);
1006  GNUNET_memcpy (ret, uri, sizeof(struct GNUNET_FS_Uri));
1007  switch (ret->type)
1008  {
1009  case GNUNET_FS_URI_KSK:
1010  if (ret->data.ksk.keywordCount >=
1011  GNUNET_MAX_MALLOC_CHECKED / sizeof(char *))
1012  {
1013  GNUNET_break (0);
1014  GNUNET_free (ret);
1015  return NULL;
1016  }
1017  if (ret->data.ksk.keywordCount > 0)
1018  {
1019  ret->data.ksk.keywords =
1020  GNUNET_new_array (ret->data.ksk.keywordCount, char *);
1021  for (i = 0; i < ret->data.ksk.keywordCount; i++)
1022  ret->data.ksk.keywords[i] = GNUNET_strdup (uri->data.ksk.keywords[i]);
1023  }
1024  else
1025  ret->data.ksk.keywords = NULL; /* just to be sure */
1026  break;
1027 
1028  case GNUNET_FS_URI_SKS:
1029  ret->data.sks.identifier = GNUNET_strdup (uri->data.sks.identifier);
1030  break;
1031 
1032  case GNUNET_FS_URI_LOC:
1033  break;
1034 
1035  default:
1036  break;
1037  }
1038  return ret;
1039 }
struct GNUNET_FS_Uri::@13::@15 sks
Keyword search key (query with keywords).
Definition: fs_api.h:153
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
#define GNUNET_MAX_MALLOC_CHECKED
Maximum allocation with GNUNET_malloc macro.
union GNUNET_FS_Uri::@13 data
Signed key space (file in namespace).
Definition: fs_api.h:148
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
struct GNUNET_FS_Uri::@13::@14 ksk
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
#define GNUNET_free(ptr)
Wrapper around free.
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 1060 of file fs_uri.c.

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

Referenced by make_keywords().

1061 {
1062  char **keywordarr;
1063  unsigned int num_Words;
1064  int inWord;
1065  char *pos;
1066  struct GNUNET_FS_Uri *uri;
1067  char *searchString;
1068  int saw_quote;
1069 
1070  if (keywords == NULL)
1071  {
1072  *emsg = GNUNET_strdup (_ ("No keywords specified!\n"));
1073  GNUNET_break (0);
1074  return NULL;
1075  }
1076  searchString = GNUNET_strdup (keywords);
1077  num_Words = 0;
1078  inWord = 0;
1079  saw_quote = 0;
1080  pos = searchString;
1081  while ('\0' != *pos)
1082  {
1083  if ((saw_quote == 0) && (isspace ((unsigned char) *pos)))
1084  {
1085  inWord = 0;
1086  }
1087  else if (0 == inWord)
1088  {
1089  inWord = 1;
1090  ++num_Words;
1091  }
1092  if ('"' == *pos)
1093  saw_quote = (saw_quote + 1) % 2;
1094  pos++;
1095  }
1096  if (num_Words == 0)
1097  {
1098  GNUNET_free (searchString);
1099  *emsg = GNUNET_strdup (_ ("No keywords specified!\n"));
1100  return NULL;
1101  }
1102  if (saw_quote != 0)
1103  {
1104  GNUNET_free (searchString);
1105  *emsg = GNUNET_strdup (_ ("Number of double-quotes not balanced!\n"));
1106  return NULL;
1107  }
1108  keywordarr = GNUNET_new_array (num_Words, char *);
1109  num_Words = 0;
1110  inWord = 0;
1111  pos = searchString;
1112  while ('\0' != *pos)
1113  {
1114  if ((saw_quote == 0) && (isspace ((unsigned char) *pos)))
1115  {
1116  inWord = 0;
1117  *pos = '\0';
1118  }
1119  else if (0 == inWord)
1120  {
1121  keywordarr[num_Words] = pos;
1122  inWord = 1;
1123  ++num_Words;
1124  }
1125  if ('"' == *pos)
1126  saw_quote = (saw_quote + 1) % 2;
1127  pos++;
1128  }
1129  uri =
1130  GNUNET_FS_uri_ksk_create_from_args (num_Words, (const char **) keywordarr);
1131  GNUNET_free (keywordarr);
1132  GNUNET_free (searchString);
1133  return uri;
1134 }
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:1155
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
char ** keywords
Keywords start with a &#39;+&#39; if they are mandatory (in which case the &#39;+&#39; is NOT part of the keyword) an...
Definition: fs_api.h:185
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
#define GNUNET_free(ptr)
Wrapper around free.
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 1155 of file fs_uri.c.

References GNUNET_FS_Uri::data, GNUNET_asprintf(), GNUNET_free_non_null, GNUNET_FS_URI_KSK, GNUNET_FS_uri_parse(), GNUNET_FS_URI_PREFIX, GNUNET_new, GNUNET_new_array, GNUNET_strdup, 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().

1156 {
1157  unsigned int i;
1158  struct GNUNET_FS_Uri *uri;
1159  const char *keyword;
1160  char *val;
1161  const char *r;
1162  char *w;
1163  char *emsg;
1164 
1165  if (argc == 0)
1166  return NULL;
1167  /* allow URI to be given as one and only keyword and
1168  * handle accordingly */
1169  emsg = NULL;
1170  if ((argc == 1) && (strlen (argv[0]) > strlen (GNUNET_FS_URI_PREFIX)) &&
1171  (0 == strncmp (argv[0],
1173  strlen (GNUNET_FS_URI_PREFIX))) &&
1174  (NULL != (uri = GNUNET_FS_uri_parse (argv[0], &emsg))))
1175  return uri;
1176  GNUNET_free_non_null (emsg);
1177  uri = GNUNET_new (struct GNUNET_FS_Uri);
1178  uri->type = GNUNET_FS_URI_KSK;
1179  uri->data.ksk.keywordCount = argc;
1180  uri->data.ksk.keywords = GNUNET_new_array (argc, char *);
1181  for (i = 0; i < argc; i++)
1182  {
1183  keyword = argv[i];
1184  if (keyword[0] == '+')
1185  val = GNUNET_strdup (keyword);
1186  else
1187  GNUNET_asprintf (&val, " %s", keyword);
1188  r = val;
1189  w = val;
1190  while ('\0' != *r)
1191  {
1192  if ('"' == *r)
1193  r++;
1194  else
1195  *(w++) = *(r++);
1196  }
1197  *w = '\0';
1198  uri->data.ksk.keywords[i] = val;
1199  }
1200  return uri;
1201 }
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:644
Keyword search key (query with keywords).
Definition: fs_api.h:153
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
#define GNUNET_FS_URI_PREFIX
struct GNUNET_FS_Uri::@13::@14 ksk
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 1212 of file fs_uri.c.

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::ksk, GNUNET_FS_Uri::loc, ret, GNUNET_FS_Uri::sks, and GNUNET_FS_Uri::type.

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

1214 {
1215  int ret;
1216  unsigned int i;
1217  unsigned int j;
1218 
1219  GNUNET_assert (u1 != NULL);
1220  GNUNET_assert (u2 != NULL);
1221  if (u1->type != u2->type)
1222  return GNUNET_NO;
1223  switch (u1->type)
1224  {
1225  case GNUNET_FS_URI_CHK:
1226  if (0 ==
1227  memcmp (&u1->data.chk, &u2->data.chk, sizeof(struct FileIdentifier)))
1228  return GNUNET_YES;
1229  return GNUNET_NO;
1230 
1231  case GNUNET_FS_URI_SKS:
1232  if ((0 == memcmp (&u1->data.sks.ns,
1233  &u2->data.sks.ns,
1234  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) &&
1235  (0 == strcmp (u1->data.sks.identifier, u2->data.sks.identifier)))
1236 
1237  return GNUNET_YES;
1238  return GNUNET_NO;
1239 
1240  case GNUNET_FS_URI_KSK:
1241  if (u1->data.ksk.keywordCount != u2->data.ksk.keywordCount)
1242  return GNUNET_NO;
1243  for (i = 0; i < u1->data.ksk.keywordCount; i++)
1244  {
1245  ret = GNUNET_NO;
1246  for (j = 0; j < u2->data.ksk.keywordCount; j++)
1247  {
1248  if (0 == strcmp (u1->data.ksk.keywords[i], u2->data.ksk.keywords[j]))
1249  {
1250  ret = GNUNET_YES;
1251  break;
1252  }
1253  }
1254  if (ret == GNUNET_NO)
1255  return GNUNET_NO;
1256  }
1257  return GNUNET_YES;
1258 
1259  case GNUNET_FS_URI_LOC:
1260  if (memcmp (&u1->data.loc,
1261  &u2->data.loc,
1262  sizeof(struct FileIdentifier)
1263  + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)
1264  + sizeof(struct GNUNET_TIME_Absolute)
1265  + sizeof(unsigned short) + sizeof(unsigned short)) != 0)
1266  return GNUNET_NO;
1267  return GNUNET_YES;
1268 
1269  default:
1270  return GNUNET_NO;
1271  }
1272 }
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:211
struct GNUNET_FS_Uri::@13::@15 sks
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Keyword search key (query with keywords).
Definition: fs_api.h:153
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_NO
Definition: gnunet_common.h:78
complete information needed to download a file.
Definition: fs_api.h:93
Content-hash-key (simple file).
Definition: fs_api.h:143
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
Signed key space (file in namespace).
Definition: fs_api.h:148
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_FS_Uri::@13::@14 ksk
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content...
Definition: fs_api.h:217
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
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 1282 of file fs_uri.c.

References GNUNET_FS_URI_SKS, and GNUNET_FS_Uri::type.

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(), and schedule_transmit_search_request().

1283 {
1284  return uri->type == GNUNET_FS_URI_SKS;
1285 }
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
Signed key space (file in namespace).
Definition: fs_api.h:148
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 919 of file fs_uri.c.

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

921 {
922  struct GNUNET_FS_Uri *ns_uri;
923 
924  ns_uri = GNUNET_new (struct GNUNET_FS_Uri);
925  ns_uri->type = GNUNET_FS_URI_SKS;
926  ns_uri->data.sks.ns = *ns;
927  ns_uri->data.sks.identifier = GNUNET_strdup (id);
928  return ns_uri;
929 }
struct GNUNET_FS_Uri::@13::@15 sks
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
Signed key space (file in namespace).
Definition: fs_api.h:148
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165

◆ 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 1297 of file fs_uri.c.

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

1299 {
1300  if (! GNUNET_FS_uri_test_sks (uri))
1301  {
1302  GNUNET_break (0);
1303  return GNUNET_SYSERR;
1304  }
1305  *pseudonym = uri->data.sks.ns;
1306  return GNUNET_OK;
1307 }
struct GNUNET_FS_Uri::@13::@15 sks
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int GNUNET_FS_uri_test_sks(const struct GNUNET_FS_Uri *uri)
Is this a namespace URI?
Definition: fs_uri.c:1282
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
union GNUNET_FS_Uri::@13 data
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 1317 of file fs_uri.c.

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

1318 {
1319  if (! GNUNET_FS_uri_test_sks (uri))
1320  {
1321  GNUNET_break (0);
1322  return NULL;
1323  }
1324  return GNUNET_strdup (uri->data.sks.identifier);
1325 }
struct GNUNET_FS_Uri::@13::@15 sks
int GNUNET_FS_uri_test_sks(const struct GNUNET_FS_Uri *uri)
Is this a namespace URI?
Definition: fs_uri.c:1282
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
union GNUNET_FS_Uri::@13 data
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 1335 of file fs_uri.c.

References GNUNET_FS_Uri::data, GNUNET_assert, GNUNET_FS_URI_KSK, GNUNET_FS_Uri::ksk, and GNUNET_FS_Uri::type.

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_(), and schedule_transmit_search_request().

1336 {
1337 #if EXTRA_CHECKS
1338  unsigned int i;
1339 
1340  if (uri->type == GNUNET_FS_URI_KSK)
1341  {
1342  for (i = 0; i < uri->data.ksk.keywordCount; i++)
1343  GNUNET_assert (uri->data.ksk.keywords[i] != NULL);
1344  }
1345 #endif
1346  return uri->type == GNUNET_FS_URI_KSK;
1347 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Keyword search key (query with keywords).
Definition: fs_api.h:153
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
struct GNUNET_FS_Uri::@13::@14 ksk
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 1357 of file fs_uri.c.

References GNUNET_FS_URI_CHK, and GNUNET_FS_Uri::type.

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

1358 {
1359  return uri->type == GNUNET_FS_URI_CHK;
1360 }
Content-hash-key (simple file).
Definition: fs_api.h:143
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
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 1371 of file fs_uri.c.

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, and GNUNET_FS_Uri::type.

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_(), GNUNET_FS_TEST_download(), match_full_data(), progress_cb(), run(), trigger_recursive_download(), and try_top_down_reconstruction().

1372 {
1373  switch (uri->type)
1374  {
1375  case GNUNET_FS_URI_CHK:
1376  return GNUNET_ntohll (uri->data.chk.file_length);
1377 
1378  case GNUNET_FS_URI_LOC:
1379  return GNUNET_ntohll (uri->data.loc.fi.file_length);
1380 
1381  default:
1382  GNUNET_assert (0);
1383  }
1384  return 0; /* unreachable */
1385 }
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:211
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Content-hash-key (simple file).
Definition: fs_api.h:143
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
uint64_t file_length
Total size of the file in bytes.
Definition: fs_api.h:98
struct FileIdentifier fi
Information about the shared file.
Definition: fs_api.h:116
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content...
Definition: fs_api.h:217
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 1395 of file fs_uri.c.

References GNUNET_FS_URI_LOC, and GNUNET_FS_Uri::type.

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

1396 {
1397  return uri->type == GNUNET_FS_URI_LOC;
1398 }
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
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_CONTAINER_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 1782 of file fs_uri.c.

References GNUNET_FS_Uri::data, DIR_SEPARATOR_STR, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, filename, gather_uri_data(), get_keywords_from_parens(), get_keywords_from_tokens(), GNUNET_CONTAINER_meta_data_get_first_by_types(), GNUNET_CONTAINER_meta_data_iterate(), GNUNET_free_non_null, GNUNET_FS_URI_KSK, GNUNET_new, GNUNET_new_array, GNUNET_FS_Uri::ksk, ret, and GNUNET_FS_Uri::type.

Referenced by process_helper_msgs().

1784 {
1785  struct GNUNET_FS_Uri *ret;
1786  char *filename;
1787  char *full_name = NULL;
1788  char *ss;
1789  int ent;
1790  int tok_keywords = 0;
1791  int paren_keywords = 0;
1792 
1793  if (NULL == md)
1794  return NULL;
1795  ret = GNUNET_new (struct GNUNET_FS_Uri);
1796  ret->type = GNUNET_FS_URI_KSK;
1797  ent = GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL);
1798  if (ent > 0)
1799  {
1801  md,
1803  -1);
1804  if (NULL != full_name)
1805  {
1806  filename = full_name;
1807  while (NULL != (ss = strstr (filename, DIR_SEPARATOR_STR)))
1808  filename = ss + 1;
1809  tok_keywords = get_keywords_from_tokens (filename, NULL, 0);
1810  paren_keywords = get_keywords_from_parens (filename, NULL, 0);
1811  }
1812  /* x3 because there might be a normalized variant of every keyword,
1813  plus theoretically one more for mime... */
1814  ret->data.ksk.keywords =
1815  GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3, char *);
1817  }
1818  if (tok_keywords > 0)
1819  ret->data.ksk.keywordCount +=
1820  get_keywords_from_tokens (filename,
1821  ret->data.ksk.keywords,
1822  ret->data.ksk.keywordCount);
1823  if (paren_keywords > 0)
1824  ret->data.ksk.keywordCount +=
1825  get_keywords_from_parens (filename,
1826  ret->data.ksk.keywords,
1827  ret->data.ksk.keywordCount);
1828  if (ent > 0)
1829  GNUNET_free_non_null (full_name);
1830  return ret;
1831 }
Keyword search key (query with keywords).
Definition: fs_api.h:153
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
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:1642
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
char * GNUNET_CONTAINER_meta_data_get_first_by_types(const struct GNUNET_CONTAINER_MetaData *md,...)
Get the first matching MD entry of the given types.
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:1707
#define DIR_SEPARATOR_STR
Definition: platform.h:168
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
static char * filename
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:1534
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
struct GNUNET_FS_Uri::@13::@14 ksk
int GNUNET_CONTAINER_meta_data_iterate(const struct GNUNET_CONTAINER_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
Iterate over MD entries.
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.

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

Referenced by main().

134 {
135  struct GNUNET_GETOPT_CommandLineOption clo = {
136  .shortName = shortName,
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 }
const char * argumentHelp
Name of the argument for the user in help text.
const char * description
Help text for the option (description)
Definition of a command line option.
const char shortName
Short name of the option.
const char * name
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 &#39;-k&#39; options with key...
Definition: fs_getopt.c:46
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_CONTAINER_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]metadataset to the desired value

Definition at line 254 of file fs_getopt.c.

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

Referenced by main().

259 {
260  struct GNUNET_GETOPT_CommandLineOption clo = {
261  .shortName = shortName,
262  .name = name,
263  .argumentHelp = argumentHelp,
264  .description = description,
265  .require_argument = 1,
266  .processor = &getopt_set_metadata,
267  .scls = (void *) meta
268  };
269 
270  return clo;
271 }
const char * argumentHelp
Name of the argument for the user in help text.
const char * description
Help text for the option (description)
Definition of a command line option.
const char shortName
Short name of the option.
const char * name
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 &#39;-m&#39; options with met...
Definition: fs_getopt.c:162
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_CONTAINER_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 3141 of file fs_api.c.

References GNUNET_FS_Handle::avg_block_latency, cfg, GNUNET_FS_Handle::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, GNUNET_VA_ARG_ENUM, GNUNET_FS_Handle::max_parallel_downloads, GNUNET_FS_Handle::max_parallel_requests, ret, GNUNET_FS_Handle::upcb, and GNUNET_FS_Handle::upcb_cls.

Referenced by download_connect_adapter(), publish_connect_adapter(), and run().

3147 {
3148  struct GNUNET_FS_Handle *ret;
3149  enum GNUNET_FS_OPTIONS opt;
3150  va_list ap;
3151 
3152  ret = GNUNET_new (struct GNUNET_FS_Handle);
3153  ret->cfg = cfg;
3155  ret->upcb = upcb;
3156  ret->upcb_cls = upcb_cls;
3157  ret->flags = flags;
3160  ret->avg_block_latency =
3161  GNUNET_TIME_UNIT_MINUTES; /* conservative starting point */
3162  va_start (ap, flags);
3163  while (GNUNET_FS_OPTIONS_END !=
3164  (opt = GNUNET_VA_ARG_ENUM (ap, GNUNET_FS_OPTIONS)))
3165  {
3166  switch (opt)
3167  {
3169  ret->max_parallel_downloads = va_arg (ap, unsigned int);
3170 
3171  break;
3172 
3174  ret->max_parallel_requests = va_arg (ap, unsigned int);
3175 
3176  break;
3177 
3178  default:
3179  GNUNET_break (0);
3180  GNUNET_free (ret->client_name);
3181  GNUNET_free (ret);
3182  va_end (ap);
3183  return NULL;
3184  }
3185  }
3186  va_end (ap);
3187  if (0 != (GNUNET_FS_FLAGS_PERSISTENCE & flags))
3188  {
3191  ret);
3194  ret);
3197  ret);
3200  ret);
3201  }
3202  return ret;
3203 }
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:3076
static void deserialization_master(const char *master_path, GNUNET_FileNameCallback proc, struct GNUNET_FS_Handle *h)
Deserialize informatin about pending operations.
Definition: fs_api.c:3114
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_TIME_Relative avg_block_latency
Average time we take for a single request to be satisfied.
Definition: fs_api.h:1146
#define DEFAULT_MAX_PARALLEL_DOWNLOADS
How many downloads can we have outstanding in parallel at a time by default?
Definition: fs_api.c:41
Master context for most FS operations.
Definition: fs_api.h:1068
#define GNUNET_TIME_UNIT_MINUTES
One minute.
Last option in the VARARG list.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
unsigned int max_parallel_requests
Maximum number of parallel requests.
Definition: fs_api.h:1171
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#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:65
#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX
Name of the directory with unindex operations.
Definition: fs_api.h:86
char * client_name
Name of our client.
Definition: fs_api.h:1078
#define DEFAULT_MAX_PARALLEL_REQUESTS
How many block requests can we have outstanding in parallel at a time by default? ...
Definition: fs_api.c:36
GNUNET_FS_OPTIONS
Options specified in the VARARGs portion of GNUNET_FS_start.
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:3024
Select the desired amount of parallelism (this option should be followed by an "unsigned int" giving ...
Maximum number of requests that should be pending at a given point in time (invidivual downloads may ...
#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH
Name of the directory with top-level searches.
Definition: fs_api.h:54
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1083
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1088
#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH
Name of the directory with publishing operations.
Definition: fs_api.h:76
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:2229
unsigned int max_parallel_downloads
Maximum number of parallel downloads.
Definition: fs_api.h:1166
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:1571
#define GNUNET_free(ptr)
Wrapper around free.
Is persistence of operations desired? (will create SUSPEND/RESUME events).
enum GNUNET_FS_Flags flags
General flags.
Definition: fs_api.h:1161
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073
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 3216 of file fs_api.c.

References GNUNET_FS_Handle::client_name, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_FS_Handle::queue_job, TopLevelActivity::ssf, TopLevelActivity::ssf_cls, and GNUNET_FS_Handle::top_head.

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

3217 {
3218  while (NULL != h->top_head)
3219  h->top_head->ssf (h->top_head->ssf_cls);
3220  if (NULL != h->queue_job)
3222  GNUNET_free (h->client_name);
3223  GNUNET_free (h);
3224 }
struct GNUNET_SCHEDULER_Task * queue_job
Task that processes the jobs in the running and pending queues (and moves jobs around as needed)...
Definition: fs_api.h:1134
char * client_name
Name of our client.
Definition: fs_api.h:1078
struct TopLevelActivity * top_head
Head of DLL of top-level activities.
Definition: fs_api.h:1093
void * ssf_cls
Closure for &#39;ssf&#39; (some struct GNUNET_FS_XXXHandle*)
Definition: fs_api.h:1036
SuspendSignalFunction ssf
Function to call for suspend-signalling and clean up.
Definition: fs_api.h:1031
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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.

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

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

◆ GNUNET_FS_file_information_get_filename()

const char* GNUNET_FS_file_information_get_filename ( 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.

References GNUNET_FS_FileInformation::filename.

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

◆ 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 75 of file fs_file_information.c.

References GNUNET_FS_FileInformation::filename, GNUNET_free_non_null, and GNUNET_strdup.

77 {
79  if (filename)
81  else
82  s->filename = NULL;
83 }
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:301
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * filename

◆ 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_CONTAINER_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
Parameters
hhandle to the file sharing subsystem
client_infoinitial value for the 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 101 of file fs_file_information.c.

References DIR_SEPARATOR_STR, EXTRACTOR_METAFORMAT_C_STRING, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, filename, GNUNET_FS_FileInformation::filename, fn, GNUNET_break, GNUNET_CONTAINER_meta_data_insert(), 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_log_strerror_file, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_YES, h, GNUNET_FS_FileInformation::h, GNUNET_FS_FileInformation::meta, and ret.

Referenced by get_file_information(), and publish_fs_connect_complete_cb().

109 {
110  struct FileInfo *fi;
111  uint64_t fsize;
113  const char *fn;
114  const char *ss;
115 
116  /* FIXME: should include_symbolic_links be GNUNET_NO or GNUNET_YES here? */
117  if (GNUNET_OK !=
119  {
121  return NULL;
122  }
124  if (NULL == fi)
125  {
126  GNUNET_break (0);
127  return NULL;
128  }
129  ret =
131  client_info,
132  fsize,
134  fi,
135  keywords,
136  meta,
137  do_index,
138  bo);
139  if (ret == NULL)
140  return NULL;
141  ret->h = h;
143  fn = filename;
144  while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR)))
145  fn = ss + 1;
146 /* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
147  * this should be changed to EXTRACTOR_METAFORMAT_UTF8
148  */
150  "<gnunet>",
153  "text/plain",
154  fn,
155  strlen (fn) + 1);
156  return ret;
157 }
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:252
void * client_info
Pointer kept for the client.
Definition: fs_api.h:247
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:301
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:457
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
struct GNUNET_FS_Handle * h
Handle to the master context.
Definition: fs_api.h:242
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * fn
Filename of the unique file.
#define DIR_SEPARATOR_STR
Definition: platform.h:168
static char * filename
int GNUNET_CONTAINER_meta_data_insert(struct GNUNET_CONTAINER_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.
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:525
int 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:257
int do_index
Should the file be indexed or inserted?
Definition: fs_api.h:338
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_CONTAINER_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
Create an entry for a file in a publish-structure.
#define GNUNET_YES
Definition: gnunet_common.h:77
Closure for GNUNET_FS_data_reader_file_().
Definition: fs_api.c:422
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_CONTAINER_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
Parameters
hhandle to the file sharing subsystem
client_infoinitial value for the 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 177 of file fs_file_information.c.

References GNUNET_break, GNUNET_FS_data_reader_copy_(), GNUNET_FS_file_information_create_from_reader(), and GNUNET_YES.

Referenced by make_file().

186 {
187  if (GNUNET_YES == do_index)
188  {
189  GNUNET_break (0);
190  return NULL;
191  }
193  client_info,
194  length,
195  &
197  data,
198  keywords,
199  meta,
200  do_index,
201  bo);
202 }
void * client_info
Pointer kept for the client.
Definition: fs_api.h:247
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:561
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int do_index
Should the file be indexed or inserted?
Definition: fs_api.h:338
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_CONTAINER_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
Create an entry for a file in a publish-structure.
#define GNUNET_YES
Definition: gnunet_common.h:77
uint32_t data
The data value.
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_CONTAINER_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
Parameters
hhandle to the file sharing subsystem
client_infoinitial value for the 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 222 of file fs_file_information.c.

References bo, GNUNET_FS_FileInformation::bo, GNUNET_FS_FileInformation::client_info, GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::do_index, GNUNET_FS_FileInformation::file, GNUNET_break, GNUNET_CONTAINER_meta_data_create(), GNUNET_CONTAINER_meta_data_duplicate(), GNUNET_FS_data_reader_file_(), GNUNET_FS_uri_dup(), GNUNET_new, GNUNET_YES, h, GNUNET_FS_FileInformation::h, GNUNET_FS_FileInformation::keywords, GNUNET_FS_FileInformation::meta, GNUNET_FS_FileInformation::reader, GNUNET_FS_FileInformation::reader_cls, and ret.

Referenced by GNUNET_FS_file_information_create_from_data(), GNUNET_FS_file_information_create_from_file(), and publish_fs_connect_complete_cb().

232 {
234 
236  {
237  GNUNET_break (0);
238  return NULL;
239  }
240  ret = GNUNET_new (struct GNUNET_FS_FileInformation);
241  ret->h = h;
242  ret->client_info = client_info;
244  if (ret->meta == NULL)
246  ret->keywords = (keywords == NULL) ? NULL : GNUNET_FS_uri_dup (keywords);
247  ret->data.file.reader = reader;
248  ret->data.file.reader_cls = reader_cls;
249  ret->data.file.do_index = do_index;
250  ret->data.file.file_size = length;
251  ret->bo = *bo;
252  return ret;
253 }
void * reader_cls
Closure for reader.
Definition: fs_api.h:321
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:252
void * client_info
Pointer kept for the client.
Definition: fs_api.h:247
GNUNET_FS_DataReader reader
Function that can be used to read the data for the file.
Definition: fs_api.h:316
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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:457
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
struct GNUNET_FS_Handle * h
Handle to the master context.
Definition: fs_api.h:242
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_create(void)
Create a fresh meta data container.
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:274
int do_index
Should the file be indexed or inserted?
Definition: fs_api.h:338
struct GNUNET_FS_Uri * keywords
Keywords to use for KBlocks.
Definition: fs_api.h:257
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_duplicate(const struct GNUNET_CONTAINER_MetaData *md)
Duplicate a MetaData token.
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_CONTAINER_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
Parameters
hhandle to the file sharing subsystem
client_infoinitial value for the client-info value for this entry
metametadata for the directory
keywordsunder which keywords should this directory be available directly; can be NULL
boblock options
filenamename of the directory; can be NULL
Returns
publish structure entry for the directory , NULL on error

Definition at line 283 of file fs_file_information.c.

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

Referenced by get_file_information().

290 {
292 
293  ret = GNUNET_new (struct GNUNET_FS_FileInformation);
294  ret->h = h;
295  ret->client_info = client_info;
297  ret->keywords = GNUNET_FS_uri_dup (keywords);
298  ret->bo = *bo;
299  ret->is_directory = GNUNET_YES;
300  if (filename != NULL)
302  return ret;
303 }
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:252
void * client_info
Pointer kept for the client.
Definition: fs_api.h:247
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:301
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
struct GNUNET_FS_Handle * h
Handle to the master context.
Definition: fs_api.h:242
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:390
static char * filename
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:274
struct GNUNET_FS_Uri * keywords
Keywords to use for KBlocks.
Definition: fs_api.h:257
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_duplicate(const struct GNUNET_CONTAINER_MetaData *md)
Duplicate a MetaData token.
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 263 of file fs_file_information.c.

References GNUNET_FS_FileInformation::is_directory.

265 {
266  return ent->is_directory;
267 }
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:390

◆ 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

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 318 of file fs_file_information.c.

References GNUNET_FS_FileInformation::data, dir, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::dir_size, GNUNET_FS_FileInformation::entries, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_FS_FileInformation::is_directory, and GNUNET_FS_FileInformation::next.

Referenced by get_file_information().

320 {
321  if ((ent->dir != NULL) || (ent->next != NULL) ||
322  (dir->is_directory != GNUNET_YES))
323  {
324  GNUNET_break (0);
325  return GNUNET_SYSERR;
326  }
327  ent->dir = dir;
328  ent->next = dir->data.dir.entries;
329  dir->data.dir.entries = ent;
330  dir->data.dir.dir_size = 0;
331  return GNUNET_OK;
332 }
struct GNUNET_FS_FileInformation * entries
Linked list of entries in the directory.
Definition: fs_api.h:361
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:89
struct GNUNET_FS_FileInformation * dir
If this is a file in a directory, "dir" refers to the directory; otherwise NULL.
Definition: fs_api.h:237
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:390
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_FS_FileInformation * next
Files in a directory are kept as a linked list.
Definition: fs_api.h:231
#define GNUNET_YES
Definition: gnunet_common.h:77
size_t dir_size
Size of the directory itself (in bytes); 0 if the size has not yet been calculated.
Definition: fs_api.h:367
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 350 of file fs_file_information.c.

References GNUNET_FS_FileInformation::bo, GNUNET_FS_FileInformation::client_info, GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::dir_size, GNUNET_FS_FileInformation::entries, GNUNET_FS_FileInformation::file, 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().

353 {
354  struct GNUNET_FS_FileInformation *pos;
355  int no;
356 
357  no = GNUNET_NO;
358  if (GNUNET_OK !=
359  proc (proc_cls,
360  dir,
361  (dir->is_directory == GNUNET_YES) ? dir->data.dir.dir_size
362  : dir->data.file.file_size,
363  dir->meta,
364  &dir->keywords,
365  &dir->bo,
366  (dir->is_directory == GNUNET_YES) ? &no : &dir->data.file.do_index,
367  &dir->client_info))
368  return;
369  if (dir->is_directory != GNUNET_YES)
370  return;
371  pos = dir->data.dir.entries;
372  while (pos != NULL)
373  {
374  no = GNUNET_NO;
375  if (GNUNET_OK !=
376  proc (proc_cls,
377  pos,
378  (pos->is_directory == GNUNET_YES) ? pos->data.dir.dir_size
379  : pos->data.file.file_size,
380  pos->meta,
381  &pos->keywords,
382  &pos->bo,
383  (pos->is_directory == GNUNET_YES) ? &no
384  : &pos->data.file.do_index,
385  &pos->client_info))
386  break;
387  pos = pos->next;
388  }
389 }
struct GNUNET_FS_FileInformation * entries
Linked list of entries in the directory.
Definition: fs_api.h:361
struct GNUNET_FS_FileInformation * dir
If this is a file in a directory, "dir" refers to the directory; otherwise NULL.
Definition: fs_api.h:237
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:252
void * client_info
Pointer kept for the client.
Definition: fs_api.h:247
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:390
struct GNUNET_FS_FileInformation * next
Files in a directory are kept as a linked list.
Definition: fs_api.h:231
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:274
struct GNUNET_FS_Uri * keywords
Keywords to use for KBlocks.
Definition: fs_api.h:257
#define GNUNET_YES
Definition: gnunet_common.h:77
size_t dir_size
Size of the directory itself (in bytes); 0 if the size has not yet been calculated.
Definition: fs_api.h:367
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 403 of file fs_file_information.c.

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::emsg, GNUNET_FS_FileInformation::entries, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::filename, GNUNET_CONTAINER_meta_data_destroy(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_free_non_null, GNUNET_FS_file_information_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::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().

406 {
407  struct GNUNET_FS_FileInformation *pos;
408  int no;
409 
410  no = GNUNET_NO;
411  if (GNUNET_YES == fi->is_directory)
412  {
413  /* clean up directory */
414  while (NULL != (pos = fi->data.dir.entries))
415  {
416  fi->data.dir.entries = pos->next;
417  GNUNET_FS_file_information_destroy (pos, cleaner, cleaner_cls);
418  }
419  /* clean up client-info */
420  if (NULL != cleaner)
421  cleaner (cleaner_cls,
422  fi,
423  fi->data.dir.dir_size,
424  fi->meta,
425  &fi->keywords,
426  &fi->bo,
427  &no,
428  &fi->client_info);
430  }
431  else
432  {
433  /* call clean-up function of the reader */
434  if (NULL != fi->data.file.reader)
435  {
436  (void) fi->data.file.reader (fi->data.file.reader_cls, 0, 0, NULL, NULL);
437  fi->data.file.reader = NULL;
438  }
439  /* clean up client-info */
440  if (NULL != cleaner)
441  cleaner (cleaner_cls,
442  fi,
443  fi->data.file.file_size,
444  fi->meta,
445  &fi->keywords,
446  &fi->bo,
447  &fi->data.file.do_index,
448  &fi->client_info);
449  }
452  if (NULL != fi->sks_uri)
454  if (NULL != fi->chk_uri)
456  /* clean up serialization */
457  if ((NULL != fi->serialization) && (0 != unlink (fi->serialization)))
459  "unlink",
460  fi->serialization);
461  if (NULL != fi->keywords)
463  if (NULL != fi->meta)
466  if (NULL != fi->te)
467  {
468  GNUNET_FS_tree_encoder_finish (fi->te, NULL);
469  fi->te = NULL;
470  }
471  GNUNET_free (fi);
472 }
struct GNUNET_FS_FileInformation * entries
Linked list of entries in the directory.
Definition: fs_api.h:361
struct GNUNET_FS_FileInformation * dir
If this is a file in a directory, "dir" refers to the directory; otherwise NULL.
Definition: fs_api.h:237
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:252
void * client_info
Pointer kept for the client.
Definition: fs_api.h:247
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:296
char * serialization
Under what filename is this struct serialized (for operational persistence).
Definition: fs_api.h:286
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:301
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
void * dir_data
Pointer to the data for the directory (or NULL if not available).
Definition: fs_api.h:373
struct GNUNET_FS_TreeEncoder * te
Encoder being used to publish this file.
Definition: fs_api.h:291
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:390
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
struct GNUNET_FS_Uri * chk_uri
CHK for this file or directory.
Definition: fs_api.h:263
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
struct GNUNET_FS_FileInformation * next
Files in a directory are kept as a linked list.
Definition: fs_api.h:231
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:274
struct GNUNET_FS_Uri * keywords
Keywords to use for KBlocks.
Definition: fs_api.h:257
void GNUNET_FS_file_information_destroy(struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
Destroy publish-structure.
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:443
#define GNUNET_YES
Definition: gnunet_common.h:77
size_t dir_size
Size of the directory itself (in bytes); 0 if the size has not yet been calculated.
Definition: fs_api.h:367
struct GNUNET_FS_Uri * sks_uri
SKS URI for this file or directory.
Definition: fs_api.h:269
#define GNUNET_free(ptr)
Wrapper around free.
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 publishd 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 1442 of file fs_publish.c.

References _, GNUNET_FS_Handle::cfg, compute_contents_size(), dsh, GNUNET_FS_PublishContext::dsh, GNUNET_FS_PublishContext::fi, GNUNET_FS_PublishContext::fi_pos, 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, GNUNET_FS_PublishContext::h, GNUNET_FS_PublishContext::nid, ns, GNUNET_FS_PublishContext::ns, GNUNET_FS_PublishContext::nuid, options, GNUNET_FS_PublishContext::options, GNUNET_FS_PublishContext::qre, GNUNET_FS_PublishContext::reserve_entries, GNUNET_FS_PublishContext::reserve_space, ret, GNUNET_FS_PublishContext::top, and GNUNET_FS_PublishContext::upload_task.

Referenced by directory_trim_complete(), publish_fs_connect_complete_cb(), and start_publish().

1448 {
1449  struct GNUNET_FS_PublishContext *ret;
1450  struct GNUNET_DATASTORE_Handle *dsh;
1451 
1452  GNUNET_assert (NULL != h);
1453  compute_contents_size (fi);
1455  {
1456  dsh = GNUNET_DATASTORE_connect (h->cfg);
1457  if (NULL == dsh)
1458  return NULL;
1459  }
1460  else
1461  {
1462  dsh = NULL;
1463  }
1464  ret = GNUNET_new (struct GNUNET_FS_PublishContext);
1465  ret->dsh = dsh;
1466  ret->h = h;
1467  ret->fi = fi;
1468  if (NULL != ns)
1469  {
1471  *ret->ns = *ns;
1472  GNUNET_assert (NULL != nid);
1473  ret->nid = GNUNET_strdup (nid);
1474  if (NULL != nuid)
1475  ret->nuid = GNUNET_strdup (nuid);
1476  }
1477  ret->options = options;
1478  /* signal start */
1480  ret->fi_pos = ret->fi;
1483  if (NULL != ret->dsh)
1484  {
1485  GNUNET_assert (NULL == ret->qre);
1487  _ (
1488  "Reserving space for %u entries and %llu bytes for publication\n"),
1489  (unsigned int) ret->reserve_entries,
1490  (unsigned long long) ret->reserve_space);
1491  ret->qre =
1493  ret->reserve_entries,
1494  &finish_reserve,
1495  ret);
1496  }
1497  else
1498  {
1499  GNUNET_assert (NULL == ret->upload_task);
1500  ret->upload_task =
1503  }
1504  return ret;
1505 }
char * nid
ID of the content in the namespace, NULL if we have no namespace.
Definition: fs_api.h:1203
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1258
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
uint64_t reserve_space
Storage space to reserve for the operation.
Definition: fs_api.h:1263
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
enum GNUNET_FS_PublishOptions options
Options for publishing.
Definition: fs_api.h:1274
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service.
Definition: fs_api.h:1235
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1183
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Private ECC key encoded for transmission.
Run as background job (higher than idle, lower than default).
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
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:1415
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
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:1382
void GNUNET_FS_publish_main_(void *cls)
Main function that performs the upload.
Definition: fs_publish.c:1062
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
void GNUNET_FS_publish_sync_(struct GNUNET_FS_PublishContext *pc)
Synchronize this publishing struct with its mirror on disk.
Definition: fs_api.c:1706
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:1207
char * nuid
ID for future updates, NULL if we have no namespace or no updates.
Definition: fs_api.h:1208
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
Handle for controlling a publication process.
Definition: fs_api.h:1178
uint32_t reserve_entries
Overall number of entries to reserve for the publish operation.
Definition: fs_api.h:1269
struct GNUNET_DATASTORE_QueueEntry * qre
Queue entry for reservation/unreservation.
Definition: fs_api.h:1240
static int fip_signal_start(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Signal the FS&#39;s progress function that we are starting an upload.
Definition: fs_publish.c:1193
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:391
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1188
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1193
struct GNUNET_CRYPTO_EcdsaPrivateKey * ns
Namespace that we are publishing in, NULL if we have no namespace.
Definition: fs_api.h:1198
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.
Handle to the datastore service.
static struct GNUNET_DATASTORE_Handle * dsh
Datastore handle.
#define GNUNET_log(kind,...)
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:1354
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073
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 publishd) 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 1570 of file fs_publish.c.

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, 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(), publish_timeout(), report_uri(), and shutdown_task().

1571 {
1572  struct GNUNET_FS_ProgressInfo pi;
1573  uint64_t off;
1574 
1576  "Publish stop called\n");
1577  GNUNET_FS_end_top (pc->h, pc->top);
1578  if (NULL != pc->ksk_pc)
1579  {
1581  pc->ksk_pc = NULL;
1582  }
1583  if (NULL != pc->sks_pc)
1584  {
1586  pc->sks_pc = NULL;
1587  }
1588  if (NULL != pc->upload_task)
1589  {
1591  pc->upload_task = NULL;
1592  }
1595 
1596  if (NULL != pc->fi->serialization)
1597  {
1599  pc->fi->serialization);
1600  GNUNET_free (pc->fi->serialization);
1601  pc->fi->serialization = NULL;
1602  }
1603  off = (NULL == pc->fi->chk_uri) ? 0 : GNUNET_ntohll (
1604  pc->fi->chk_uri->data.chk.file_length);
1605 
1606  if (NULL != pc->serialization)
1607  {
1609  pc->serialization);
1610  GNUNET_free (pc->serialization);
1611  pc->serialization = NULL;
1612  }
1613  if (NULL != pc->qre)
1614  {
1616  pc->qre = NULL;
1617  }
1619  GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi, off));
1620  publish_cleanup (pc);
1621 }
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1258
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:211
char * serialization
Under what filename is this struct serialized (for operational persistence).
Definition: fs_api.h:286
void GNUNET_FS_publish_ksk_cancel(struct GNUNET_FS_PublishKskContext *pkc)
Abort the KSK publishing operation.
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1183
char * serialization
Filename used for serializing information about this operation (should be determined using &#39;mktemp&#39;)...
Definition: fs_api.h:1214
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Notification that we have stopped the process of uploading a file structure; no futher events will be...
static int fip_signal_stop(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Signal the FS&#39;s progress function that we are stopping an upload.
Definition: fs_publish.c:1523
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:412
void GNUNET_FS_publish_sks_cancel(struct GNUNET_FS_PublishSksContext *psc)
Abort the SKS publishing operation.
Definition: fs_namespace.c:496
struct GNUNET_FS_Uri * chk_uri
CHK for this file or directory.
Definition: fs_api.h:263
static void publish_cleanup(struct GNUNET_FS_PublishContext *pc)
Cleanup the publish context, we&#39;re done with it.
Definition: fs_publish.c:78
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:1252
#define GNUNET_FS_SYNC_PATH_FILE_INFO
Name of the directory with files that are being published.
Definition: fs_api.h:81
struct GNUNET_DATASTORE_QueueEntry * qre
Queue entry for reservation/unreservation.
Definition: fs_api.h:1240
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:1246
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:47
union GNUNET_FS_Uri::@13 data
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1188
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1193
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.
uint64_t file_length
Total size of the file in bytes.
Definition: fs_api.h:98
#define GNUNET_log(kind,...)
#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH
Name of the directory with publishing operations.
Definition: fs_api.h:76
#define GNUNET_YES
Definition: gnunet_common.h:77
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:1298
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:744
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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_CONTAINER_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 193 of file fs_publish_ksk.c.

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

Referenced by identity_continuation(), and publish_kblocks().

200 {
201  struct GNUNET_FS_PublishKskContext *pkc;
202 
203  GNUNET_assert (NULL != uri);
205  pkc->h = h;
206  pkc->bo = *bo;
207  pkc->options = options;
208  pkc->cont = cont;
209  pkc->cont_cls = cont_cls;
212  {
213  pkc->dsh = GNUNET_DATASTORE_connect (h->cfg);
214  if (NULL == pkc->dsh)
215  {
216  cont (cont_cls,
217  NULL,
218  _ ("Could not connect to datastore."));
219  GNUNET_free (pkc);
220  return NULL;
221  }
222  }
223  pkc->uri = GNUNET_FS_uri_dup (uri);
224  pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
226  return pkc;
227 }
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
GNUNET_FS_PublishContinuation cont
Function to call once we&#39;re done.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore, NULL if we are just simulating.
struct GNUNET_SCHEDULER_Task * ksk_task
Current task.
struct GNUNET_FS_Uri * uri
URI to publish.
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:1280
Context for the KSK publication.
enum GNUNET_FS_PublishOptions options
Options to use.
struct GNUNET_FS_Handle * h
Global FS context.
static void publish_ksk_cont(void *cls)
Continuation of GNUNET_FS_publish_ksk() that performs the actual publishing operation (iterating over...
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
struct GNUNET_FS_Uri * ksk_uri
Keywords to use.
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_FS_BlockOptions bo
When should the KBlocks expire?
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_duplicate(const struct GNUNET_CONTAINER_MetaData *md)
Duplicate a MetaData token.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073
void * cont_cls
Closure for cont.
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 236 of file fs_publish_ksk.c.

References GNUNET_FS_PublishKskContext::dsh, GNUNET_CONTAINER_meta_data_destroy(), GNUNET_DATASTORE_disconnect(), GNUNET_free, 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().

237 {
238  if (NULL != pkc->ksk_task)
239  {
241  pkc->ksk_task = NULL;
242  }
243  if (NULL != pkc->uc)
244  {
246  pkc->uc = NULL;
247  }
248  if (NULL != pkc->dsh)
249  {
251  pkc->dsh = NULL;
252  }
255  GNUNET_FS_uri_destroy (pkc->uri);
256  GNUNET_free (pkc);
257 }
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore, NULL if we are just simulating.
struct GNUNET_SCHEDULER_Task * ksk_task
Current task.
struct GNUNET_FS_PublishUblockContext * uc
UBlock publishing operation that is active.
struct GNUNET_FS_Uri * uri
URI to publish.
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
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_Uri * ksk_uri
Keywords to use.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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_CONTAINER_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)
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 433 of file fs_namespace.c.

References _, GNUNET_FS_Handle::cfg, GNUNET_FS_PublishSksContext::cont, GNUNET_FS_PublishSksContext::cont_cls, GNUNET_FS_Uri::data, GNUNET_FS_PublishSksContext::dsh, GNUNET_CONTAINER_meta_data_duplicate(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_DATASTORE_connect(), 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, NamespaceUpdateNode::md, ns, GNUNET_FS_PublishSksContext::ns, GNUNET_FS_PublishSksContext::nsn, GNUNET_FS_Uri::sks, sks_publish_cont(), GNUNET_FS_Uri::type, GNUNET_FS_PublishSksContext::uc, NamespaceUpdateNode::update, NamespaceUpdateNode::uri, and GNUNET_FS_PublishSksContext::uri.

Referenced by publish_sblock(), and uri_ksk_continuation().

443 {
444  struct GNUNET_FS_PublishSksContext *psc;
445  struct GNUNET_FS_Uri *sks_uri;
446 
447  sks_uri = GNUNET_new (struct GNUNET_FS_Uri);
448  sks_uri->type = GNUNET_FS_URI_SKS;
449  sks_uri->data.sks.identifier = GNUNET_strdup (identifier);
450  GNUNET_CRYPTO_ecdsa_key_get_public (ns, &sks_uri->data.sks.ns);
451 
453  psc->h = h;
454  psc->uri = sks_uri;
455  psc->cont = cont;
456  psc->cont_cls = cont_cls;
457  psc->ns = *ns;
459  {
460  psc->dsh = GNUNET_DATASTORE_connect (h->cfg);
461  if (NULL == psc->dsh)
462  {
463  sks_publish_cont (psc, _ ("Failed to connect to datastore."));
464  return NULL;
465  }
466  }
467  if (NULL != update)
468  {
469  psc->nsn = GNUNET_new (struct NamespaceUpdateNode);
470  psc->nsn->id = GNUNET_strdup (identifier);
471  psc->nsn->update = GNUNET_strdup (update);
473  psc->nsn->uri = GNUNET_FS_uri_dup (uri);
474  }
475  psc->uc = GNUNET_FS_publish_ublock_ (h,
476  psc->dsh,
477  identifier,
478  update,
479  ns,
480  meta,
481  uri,
482  bo,
483  options,
485  psc);
486  return psc;
487 }
GNUNET_FS_PublishContinuation cont
Function to call once we&#39;re done.
Definition: fs_namespace.c:365
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_FS_Uri * uri
URI of the new entry in the namespace.
Definition: fs_namespace.c:339
struct GNUNET_FS_Uri::@13::@15 sks
Context for the SKS publication.
Definition: fs_namespace.c:334
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:60
struct GNUNET_FS_Handle * h
Handle to FS.
Definition: fs_namespace.c:360
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
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:387
char * identifier
Human-readable identifier chosen for this entry in the namespace.
Definition: fs_api.h:204
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
char * id
Identifier for this node.
Definition: fs_namespace.c:45
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Namespace we&#39;re publishing to.
Definition: fs_namespace.c:350
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
char * update
Identifier of children of this node.
Definition: fs_namespace.c:50
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:239
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_CONTAINER_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.
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:40
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
Signed key space (file in namespace).
Definition: fs_api.h:148
struct GNUNET_CONTAINER_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:55
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
struct NamespaceUpdateNode * nsn
Namespace update node to add to namespace on success (or to be deleted if publishing failed)...
Definition: fs_namespace.c:345
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore.
Definition: fs_namespace.c:355
void * cont_cls
Closure for cont.
Definition: fs_namespace.c:370
struct GNUNET_FS_PublishUblockContext * uc
Handle for our UBlock operation request.
Definition: fs_namespace.c:375
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_duplicate(const struct GNUNET_CONTAINER_MetaData *md)
Duplicate a MetaData token.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073
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 496 of file fs_namespace.c.

References GNUNET_FS_PublishSksContext::dsh, GNUNET_CONTAINER_meta_data_destroy(), GNUNET_DATASTORE_disconnect(), GNUNET_free, 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().

497 {
498  if (NULL != psc->uc)
499  {
501  psc->uc = NULL;
502  }
503  if (NULL != psc->dsh)
504  {
506  psc->dsh = NULL;
507  }
508  GNUNET_FS_uri_destroy (psc->uri);
509  if (NULL != psc->nsn)
510  {
512  GNUNET_FS_uri_destroy (psc->nsn->uri);
513  GNUNET_free (psc->nsn->id);
514  GNUNET_free (psc->nsn->update);
515  GNUNET_free (psc->nsn);
516  }
517  GNUNET_free (psc);
518 }
struct GNUNET_FS_Uri * uri
URI of the new entry in the namespace.
Definition: fs_namespace.c:339
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:60
#define GNUNET_NO
Definition: gnunet_common.h:78
char * id
Identifier for this node.
Definition: fs_namespace.c:45
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
char * update
Identifier of children of this node.
Definition: fs_namespace.c:50
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
void GNUNET_FS_publish_ublock_cancel_(struct GNUNET_FS_PublishUblockContext *uc)
Abort UBlock publishing operation.
struct GNUNET_CONTAINER_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:55
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
struct NamespaceUpdateNode * nsn
Namespace update node to add to namespace on success (or to be deleted if publishing failed)...
Definition: fs_namespace.c:345
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore.
Definition: fs_namespace.c:355
struct GNUNET_FS_PublishUblockContext * uc
Handle for our UBlock operation request.
Definition: fs_namespace.c:375
#define GNUNET_free(ptr)
Wrapper around free.
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)
Parameters
hhandle to the file sharing subsystem
iteratorfunction to call on each indexed file
iterator_clsclosure for iterator
Returns
NULL on error ('iter' is not called)

Definition at line 167 of file fs_list_indexed.c.

References _, GNUNET_FS_Handle::cfg, env, 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, GNUNET_FS_GetIndexedContext::iterator, GNUNET_FS_GetIndexedContext::iterator_cls, GNUNET_FS_GetIndexedContext::mq, mq_error_handler(), and msg.

Referenced by run().

170 {
171  struct GNUNET_FS_GetIndexedContext *gic
174  GNUNET_MQ_hd_fixed_size (index_info_end,
176  struct GNUNET_MessageHeader,
177  gic),
178  GNUNET_MQ_hd_var_size (index_info,
180  struct IndexInfoMessage,
181  gic),
183  };
184  struct GNUNET_MQ_Envelope *env;
185  struct GNUNET_MessageHeader *msg;
186 
187  gic->mq = GNUNET_CLIENT_connect (h->cfg,
188  "fs",
189  handlers,
191  h);
192  if (NULL == gic->mq)
193  {
195  _ ("Failed to not connect to `%s' service.\n"),
196  "fs");
197  GNUNET_free (gic);
198  return NULL;
199  }
200  gic->iterator = iterator;
201  gic->iterator_cls = iterator_cls;
202  env = GNUNET_MQ_msg (msg,
204  GNUNET_MQ_send (gic->mq,
205  env);
206  return gic;
207 }
static int iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
void * iterator_cls
Closure for iterator.
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:1057
#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET
Request from client for list of indexed files.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
Message send by FS service in response to a request asking for a list of all indexed files...
Definition: fs.h:195
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY
Reply to client with an indexed file name.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
Message handler for a specific message type.
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
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...
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END
Reply to client indicating end of list.
#define GNUNET_log(kind,...)
Context for GNUNET_FS_get_indexed_files().
Header for all communications.
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:353
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
GNUNET_FS_IndexedFileProcessor iterator
Function to call for each indexed file.
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073
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 216 of file fs_list_indexed.c.

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

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

217 {
218  GNUNET_MQ_destroy (gic->mq);
219  GNUNET_free (gic);
220 }
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
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 795 of file fs_unindex.c.

References GNUNET_FS_ProgressInfo::cctx, GNUNET_FS_UnindexContext::client_info, GNUNET_FS_UnindexContext::fhc, GNUNET_FS_UnindexContext::file_size, 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().

798 {
800  struct GNUNET_FS_ProgressInfo pi;
801  uint64_t size;
802 
803  if (GNUNET_OK !=
805  &size,
806  GNUNET_YES,
807  GNUNET_YES))
808  return NULL;
809  uc = GNUNET_new (struct GNUNET_FS_UnindexContext);
810  uc->h = h;
813  uc->file_size = size;
814  uc->client_info = cctx;
817  pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
819  uc->fhc =
821  filename,
824  uc->top = GNUNET_FS_make_top (h,
826  uc);
827  return uc;
828 }
Notification that we started to unindex a file.
static struct GNUNET_FS_UnindexContext * uc
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Handle for controlling an unindexing operation.
Definition: fs_api.h:1349
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
Definition: fs_api.h:1443
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct TopLevelActivity * top
Our top-level activity entry.
Definition: fs_api.h:1365
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1453
static char * filename
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1385
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Run when otherwise idle.
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:84
void GNUNET_FS_unindex_sync_(struct GNUNET_FS_UnindexContext *uc)
Synchronize this unindex struct with its mirror on disk.
Definition: fs_api.c:1778
int 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:257
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:391
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Definition: fs.h:47
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:694
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:727
#define GNUNET_YES
Definition: gnunet_common.h:77
void * client_info
Pointer kept for the client.
Definition: fs_api.h:1407
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1360
Argument given to the progress callback with information about what is going on.
void * cctx
Client context pointer (set the last time by the client for this operation; initially NULL on START/R...
uint64_t file_size
Overall size of the file.
Definition: fs_api.h:1448
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 837 of file fs_unindex.c.

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_free_non_null, 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, GNUNET_FS_ProgressInfo::unindex, UNINDEX_STATE_COMPLETE, and GNUNET_FS_ProgressInfo::value.

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

838 {
839  struct GNUNET_FS_ProgressInfo pi;
840 
841  if (NULL != uc->dscan)
842  {
844  uc->dscan = NULL;
845  }
846  if (NULL != uc->dqe)
847  {
849  uc->dqe = NULL;
850  }
851  if (NULL != uc->fhc)
852  {
854  uc->fhc = NULL;
855  }
856  if (NULL != uc->mq)
857  {
858  GNUNET_MQ_destroy (uc->mq);
859  uc->mq = NULL;
860  }
861  if (NULL != uc->dsh)
862  {
864  uc->dsh = NULL;
865  }
866  if (NULL != uc->ksk_uri)
867  {
869  uc->ksk_uri = NULL;
870  }
871  if (NULL != uc->tc)
872  {
873  GNUNET_FS_tree_encoder_finish (uc->tc, NULL);
874  uc->tc = NULL;
875  }
876  if (uc->fh != NULL)
877  {
879  uc->fh = NULL;
880  }
881  GNUNET_FS_end_top (uc->h, uc->top);
882  if (uc->serialization != NULL)
883  {
885  uc->serialization);
887  uc->serialization = NULL;
888  }
890  pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
892  (uc->state ==
893  UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
894  GNUNET_break (NULL == uc->client_info);
896  GNUNET_free (uc->filename);
897  GNUNET_free (uc);
898 }
char * serialization
Short name under which we are serializing the state of this operation.
Definition: fs_api.h:1390
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1345
struct GNUNET_FS_TreeEncoder * tc
Merkle-ish tree encoder context.
Definition: fs_api.h:1412
We&#39;re done.
Definition: fs_api.h:1337
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
enum UnindexState state
Current operatinonal phase.
Definition: fs_api.h:1463
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service, only valid during the UNINDEX_STATE_DS_NOTIFY phase...
Definition: fs_api.h:1402
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
Definition: fs_api.h:1443
struct TopLevelActivity * top
Our top-level activity entry.
Definition: fs_api.h:1365
struct GNUNET_DISK_FileHandle * fh
Handle used to read the file.
Definition: fs_api.h:1417
#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX
Name of the directory with unindex operations.
Definition: fs_api.h:86
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:412
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
void GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
Abort the scan.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
struct GNUNET_FS_Uri * ksk_uri
Keywords found (telling us which KBlocks to remove).
Definition: fs_api.h:1375
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1385
struct GNUNET_DATASTORE_QueueEntry * dqe
Handle to datastore &#39;get_key&#39; operation issued for obtaining KBlocks.
Definition: fs_api.h:1423
struct GNUNET_MQ_Handle * mq
Connection to the FS service, only valid during the UNINDEX_STATE_FS_NOTIFY phase.
Definition: fs_api.h:1396
Notification that the unindexing of this file was stopped (final event for this action).
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:84
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
struct GNUNET_FS_DirScanner * dscan
Directory scanner to find keywords (KBlock removal).
Definition: fs_api.h:1370
char * emsg
Error message, NULL on success.
Definition: fs_api.h:1438
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:443
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
void * client_info
Pointer kept for the client.
Definition: fs_api.h:1407
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1360
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:744
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
uint64_t file_size
Overall size of the file.
Definition: fs_api.h:1448
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,