Initial implementation of namesys/pb

This commit is contained in:
Jose Marcial Vieira Bisneto 2016-12-16 00:28:12 -03:00
parent 87f0cbedbc
commit aa49c7dc35
2 changed files with 50 additions and 0 deletions

31
include/ipfs/namesys/pb.h Normal file
View file

@ -0,0 +1,31 @@
#ifndef IPNS_NAMESYS_PB_H
#define IPNS_NAMESYS_PB_H
typedef int IpnsEntry_ValidityType;
struct ipns_entry {
// TODO
struct routingResolver *cache;
struct stime *eol;
};
struct namesys_pb {
// TODO
struct ipns_entry *IpnsEntry;
};
// setting an EOL says "this record is valid until..."
const IpnsEntry_ValidityType IpnsEntry_EOL = 0;
char *IpnsEntry_ValidityType_name[] = {
"EOL",
NULL
};
int IpnsEntry_ValidityType_value (char *s);
char* ipfs_namesys_pb_get_validity (struct ipns_entry*);
char* ipfs_ipns_entry_data_for_sig(struct ipns_entry*);
char* ipfs_ipns_entry_get_signature(struct ipns_entry*);
int ipfs_namesys_pb_get_value (char**, struct ipns_entry*);
IpnsEntry_ValidityType ipfs_namesys_pb_get_validity_type (struct ipns_entry*);
#endif // IPNS_NAMESYS_PB_H

19
namesys/pb.c Normal file
View file

@ -0,0 +1,19 @@
#include <string.h>
#include "ipfs/namesys/pb.h"
int IpnsEntry_ValidityType_value (char *s)
{
int r;
if (!s) {
return -1; // invalid.
}
for (r = 0 ; IpnsEntry_ValidityType_name[r] ; r++) {
if (strcmp (IpnsEntry_ValidityType_name[r], s) == 0) {
return r; // found
}
}
return -1; // not found.
}