2016-12-15 17:38:08 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-09-25 22:56:10 +00:00
|
|
|
#include "ipfs/cmd/cli.h"
|
2017-04-20 22:56:03 +00:00
|
|
|
#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);
|
2016-12-22 15:21:18 +00:00
|
|
|
|
2017-04-20 22:56:03 +00:00
|
|
|
/***
|
|
|
|
* 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);
|
|
|
|
|
2016-12-22 15:21:18 +00:00
|
|
|
int ipfs_exporter_object_get(int argc, char** argv);
|
|
|
|
|
2016-12-23 17:53:03 +00:00
|
|
|
/***
|
|
|
|
* 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
|
2017-10-05 18:08:36 +00:00
|
|
|
* @param output_file where to stream the results
|
2016-12-23 17:53:03 +00:00
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
2017-10-05 18:08:36 +00:00
|
|
|
int ipfs_exporter_object_cat(struct CliArguments* args, FILE* output_file);
|
2017-04-24 21:33:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|