#ifndef IPLD_HEADER_H #define IPLD_HEADER_H #include #include #include #include "base58.h" #include "varhexutils.h" //Predefined values: #define IDKey "@id" #define TypeKey "@type" #define ValueKey "@value" #define CtxKey "@/home/xethyrion/Desktop/Bak/varint.hcontext" #define CodecKey "@codec" #define LinkKey "mlink" int NODE_H_DEBUG = 0; //Turn this on if you want to debug the program /* Node struct * obj = json_t A jansson json object. * node_size = size of the node */ struct NODE { json_t * obj; size_t node_size; }; /* LOAD_NODE(@param1) * Creates a new node from a string. * @Param1 a json string(char *) * returns a json_t /home/xethyrion/Desktop/Bak/varint.hobject! (jansson.h) */ struct NODE LOAD_NODE(char * str) { struct NODE X; json_error_t error; X.obj = json_loads(str, 0, &error); X.node_size = strlen(str); return X; } /* Unload_Node(@pa for(int i=0; iField1<:{}} * @param1: LINK.name //Storing in type from LINK struct. * @param2: LINK // The link structure we are using. */ void lName(char * str, struct LINK O) { json_t * value; const char * key; json_object_foreach(O.obj, key, value) { if(NODE_H_DEBUG == 1) { printf("lName: %s\n", key); } strcat(str, key); } } /*B58Hash(@param1, @parunsigned char** binary_dataam2) *Decodes the hash, and stores it into a char from your link struct */ void lb58Hash(char * str, struct LINK X) //Need to find out if prefixed or not! { char * hash = X.hash; size_t hash_length = strlen(hash); size_t result_buffer_length = libp2p_crypto_encoding_base58_decode_max_size(hash); unsigned char result_buffer[result_buffer_length]; unsigned char * ptr_2_result = result_buffer; memset(result_buffer, 0, result_buffer_length); int valid = libp2p_crypto_encoding_base58_decode(hash,hash_length,&ptr_2_result, &result_buffer_length); printf("IS_VALID: %d\n",valid); char HReadable[1000]; bzero(HReadable,1000); int ilen = 0; for(int i = 0; i