c-ipfs/include/ipfs/importer/exporter.h

57 lines
1.9 KiB
C
Raw Normal View History

2016-12-15 17:38:08 +00:00
#pragma once
2017-09-25 22:56:10 +00:00
#include "ipfs/cmd/cli.h"
#include "ipfs/core/ipfs_node.h"
/**
* Pull bytes from the hashtable
*/
2016-12-15 17:38:08 +00:00
/**
* get a file by its hash, and write the data to a file
* @param hash the base58 multihash of the cid
* @param file_name the file name to write to
* @returns true(1) on success
*/
2017-04-27 16:35:26 +00:00
int ipfs_exporter_to_file(const unsigned char* hash, const char* file_name, struct IpfsNode* local_node);
/***
* Retrieve a protobuf'd Node from the router
* @param local_node the context
* @param hash the hash to retrieve
* @param hash_size the length of the hash
* @param result a place to store the Node
* @returns true(1) on success, otherwise false(0)
*/
int ipfs_exporter_get_node(struct IpfsNode* local_node, const unsigned char* hash, const size_t hash_size, struct HashtableNode** result);
int ipfs_exporter_object_get(int argc, char** argv);
/***
* Called from the command line with ipfs cat [hash]. Retrieves the object pointed to by hash, and displays its block data (links and data elements)
* @param argc number of arguments
* @param argv arguments
* @param output_file where to stream the results
* @returns true(1) on success
*/
int ipfs_exporter_object_cat(struct CliArguments* args, FILE* output_file);
/**
* Retrieves the object pointed to by hash and displays the raw data
* @param local_node the local node
* @param hash the hash to use
* @param hash_size the length of the hash
* @param file the file descrptor to write to
* @returns true(1) on success, false(0) otherwise
*/
int ipfs_exporter_object_cat_to_file(struct IpfsNode *local_node, unsigned char* hash, int hash_size, FILE* file);
2017-09-20 12:53:36 +00:00
/**
* rebuild a file based on this HashtableNode, traversing links
* @param node the HashtableNode to start with
* @param local_node the context
* @param file the filestream to fill
* @returns true(1) on success, false(0) otherwise
*/
int ipfs_exporter_cat_node(struct HashtableNode* node, struct IpfsNode* local_node, FILE *file);