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3PORNDR35I2P5GQC
XTVLIC243WZF52NVTNRA3SV3WLE2ZZ5GTFQOK45IOLMXYQMTLOSAC
LPGHALLKCQRJUB7BNHABAG2VEEAFTUSN3WAPASM5B3V6JJ54GXJQC
OBKF6SIIFFHHY7YWKPPX75N23NAVUD5662DKIHXSSIDPKKXQ5ZDQC
len = bincode_getu64(&bc);
hashed->header.authors.map[i].entries =
xmalloc(sizeof(struct author) * len);
hashed->header.authors.map[i].len = len;
for (j = 0; j < hashed->header.authors.map[i].len; j++) {
// In VERSION_NOENC, the authors are a struct { name: str, full_name: maybe str, email: maybe str } instead of a more generic map
char scratch[4096] = { 0 };
if (hashed->version == VERSION) {
len = bincode_getu64(&bc);
hashed->header.authors.map[i].entries =
xmalloc(sizeof(struct author) * len);
hashed->header.authors.map[i].len = len;
for (j = 0; j < hashed->header.authors.map[i].len;
j++) {
// In VERSION_NOENC, the authors are a struct { name: str, full_name: maybe str, email: maybe str } instead of a more generic map
// TODO switch on offsets.version to figure
// out how to decode the authors here
len = bincode_getu64(&bc);
hashed->header.authors.map[i].entries[j].key =
xmalloc(len + 1);
bincode_getstr(
&bc,
hashed->header.authors.map[i]
.entries[j]
.key,
len
);
len = bincode_getu64(&bc);
hashed->header.authors.map[i].entries[j].value =
xmalloc(len + 1);
bincode_getstr(
&bc,
hashed->header.authors.map[i]
.entries[j]
.value,
len
);
}
} else {
char *name = NULL;
char *full_name = NULL;
char *email = NULL;
size_t n = 1, j = 0;
name = xmalloc(len + 1);
bincode_getstr(&bc, name, len);
/* optional full_name field */
if (bincode_getu8(&bc)) {
len = bincode_getu64(&bc);
full_name = xmalloc(len + 1);
bincode_getstr(&bc, full_name, len);
n++;
}
/* optional email field */
if (bincode_getu8(&bc)) {
len = bincode_getu64(&bc);
email = xmalloc(len + 1);
bincode_getstr(&bc, email, len);
n++;
}
hashed->header.authors.map[i].len = n;
hashed->header.authors.map[i].entries =
xmalloc(sizeof(struct author) * n);
/* decode "name", then two optional fields, making the total length between 1 and 3 */
xmalloc(len + 1);
bincode_getstr(
&bc,
hashed->header.authors.map[i].entries[j].key,
len
);
len = bincode_getu64(&bc);
hashed->header.authors.map[i].entries[j].value =
xmalloc(len + 1);
bincode_getstr(
&bc,
hashed->header.authors.map[i].entries[j].value,
len
);
xmalloc(5);
memcpy(hashed->header.authors.map[i].entries[j].key,
"name", 4);
hashed->header.authors.map[i].entries[j].value = name;
if (full_name) {
j++;
hashed->header.authors.map[i].entries[j].key =
xmalloc(10);
memcpy(hashed->header.authors.map[i]
.entries[j]
.key,
"full_name", 9);
hashed->header.authors.map[i].entries[j].value =
full_name;
}
if (email) {
j++;
hashed->header.authors.map[i].entries[j].key =
xmalloc(6);
memcpy(hashed->header.authors.map[i]
.entries[j]
.key,
"email", 5);
hashed->header.authors.map[i].entries[j].value =
email;
}
}
/**
* In the VERSION_NOENC file metadata (for file additions), the
* filemetadata contains *only* the inodemetadata directly followed by
* the basename. The basename is not bincode-encoded, so we assume the
* length of the string is the given content length minus 2 (for the
* first two bytes used by the inodemetadata).
*/
static void
read_filemetadata_noenc(
struct filemetadata *m, uint8_t *contents, size_t contents_len
)
{
size_t len;
struct bincode bc = { .avail = contents_len, .buf = contents };
m->inodemetadata = bincode_getu16(&bc);
len = contents_len - 2;
m->basename = xmalloc(len + 1);
memcpy(m->basename, &contents[2], len);
m->basename[len] = '\0';
if (off->version != VERSION) {
if (off->version == VERSION_NOENC) {
printf("The NOENC version (%lu) is not yet supported, sorry (but it's planned)\n",
off->version);
} else {
printf("Version %lu is not yet supported, sorry.\n",
off->version);
}
if (off->version != VERSION && off->version != VERSION_NOENC) {
printf("Version %lu is not yet supported, sorry.\n",
off->version);
err = off->version;