Created
August 21, 2013 22:22
-
-
Save mtornwall/6301025 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef TC_H | |
#define TC_H | |
#define TC_BLOCK_SIZE 8192 /* Size of a Trenta block in bytes. */ | |
#define TC_HASH_SIZE 40 /* Size of Trenta's block hash in bytes. */ | |
struct tclient; | |
typedef struct tclient TClient; | |
typedef unsigned int TLength; | |
typedef unsigned char TByte; | |
TClient *tc_create(); | |
void tc_free(TClient *client); | |
int tc_connect(TClient *client, const char *host, int port); | |
void tc_disconnect(TClient *client); | |
/* These functions respectively read and write whole blocks. | |
* In both cases, the `block' pointer is assumed to point to at | |
* least TC_BLOCK_SIZE bytes of memory. | |
*/ | |
int tc_read_block(TClient *client, const TByte *hash, TByte *block); | |
int tc_write_block(TClient *client, const TByte *hash, TByte *block); | |
/* These functions respectively read and write indices. | |
* In the read case, hashes and nhashes are populated by the `tc_read_index', | |
* and `*hashes' must be freed by the caller when done. | |
*/ | |
int tc_read_index(TClient *client, const TByte *name, | |
TLength length, TByte **hashes, TLength *nhashes); | |
int tc_write_index(TClient *client, const TByte *name, | |
TLength length, TByte *hashes, TLength nhashes); | |
#endif /* TC_H */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment