2016-12-16 03:28:12 +00:00
|
|
|
#include <string.h>
|
2016-12-21 00:08:51 +00:00
|
|
|
#include "ipfs/namesys/routing.h"
|
2016-12-16 03:28:12 +00:00
|
|
|
#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.
|
|
|
|
}
|
2016-12-21 00:08:51 +00:00
|
|
|
|
|
|
|
struct ipns_entry* ipfs_namesys_pb_new_ipns_entry ()
|
|
|
|
{
|
|
|
|
return calloc(1, sizeof (struct ipns_entry));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ipfs_namesys_ipnsentry_reset (struct ipns_entry *m)
|
|
|
|
{
|
|
|
|
if (m) {
|
|
|
|
// ipns_entry is an struct of pointers,
|
|
|
|
// so we can access as an array of pointers.
|
|
|
|
char **a = (char **)m;
|
|
|
|
int i, l = (sizeof (struct ipns_entry) / sizeof (void*)) - 2; // avoid last 2 pointers, cache and eol.
|
|
|
|
for (i = 0 ; i < l ; i++) {
|
|
|
|
if (a[i]) {
|
|
|
|
free (a[i]); // free allocated pointers,
|
|
|
|
a[i] = NULL; // and mark as free.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|