YG4DZB3AW3Z3LB5CFBZZ4ORJOLZFN3G4CA2YTAMSUOQX3USVNVEAC
2C2EF2GKTOAT7QI56KKDFGRGSFZRDPKUASNQFB6XQDROAEPPZW4AC
LCEKN25G5GFBUWWQAR4REIGPOL6JYNDWLNCDJGZQKOWIDHGIRMZAC
PEUS54XQ5KJQYAVUYBG5MWLEHIOVPMZ3ANVC7HPQP6JUWWPRDW5AC
VKLGQREYOZDV46F672RFE5XJO3OEOP4EHTCWZYOJY24HVPQX3L6QC
Q7TKZCJP2Z75EICZYKCEZDHKGERSOKZGMTSU3UXETBHTF663T66AC
Y26WT3ZFN7KSVXOZ26B5Y2OR4M4VQYQLPMAHPC4O5VIT3ENBISXAC
OBKF6SIIFFHHY7YWKPPX75N23NAVUD5662DKIHXSSIDPKKXQ5ZDQC
X36ICMJNYKJF35ZUEVCCR33JOZPCPZQ6KSGEQI3RZND2P5EDASLQC
B3XLVPNC4COLLC3FUE34Y7HIKTMF6CJZUASZOU3YM2YGPZKJZP7QC
#ifndef HASH_H
#define HASH_H
#define HASH_NONE 0
#define HASH_BLAKE3 1
#define BLAKE3_BYTES 32
struct hash {
uint8_t variant; /* One of the HASH_* defines */
uint8_t bytes[BLAKE3_BYTES];
};
struct hash_list {
size_t len;
struct hash *entries;
};
void hash_print(struct hash *);
#endif
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include "hash.h"
void
hash_print(struct hash *hash)
{
int i;
switch (hash->variant) {
case HASH_NONE:
printf("(none)\n");
break;
case HASH_BLAKE3:
for (i = 0; i < BLAKE3_BYTES; i++)
printf("%02x", hash->bytes[i]);
printf("\n");
break;
default:
abort();
}
}
printf("[[dependencies]]\n");
for (i = 0; i < hashed.dependencies.len; i++) {
hashed.dependencies.entries[i].variant = bincode_getu32(&binstat);
switch (hashed.dependencies.entries[i].variant) {
case HASH_BLAKE3:
memcpy(hashed.dependencies.entries[i].bytes, binstat.buf, BLAKE3_BYTES);
binstat.buf += BLAKE3_BYTES;
binstat.avail -= BLAKE3_BYTES;
break;
case HASH_NONE:
/* Do nothing, no bytes to consume */
break;
default:
abort();
}
hash_print(&hashed.dependencies.entries[i]);
printf("[[extra_known]]\n");
for (i = 0; i < hashed.extra_known.len; i++) {
hashed.extra_known.entries[i].variant = bincode_getu32(&binstat);
switch (hashed.extra_known.entries[i].variant) {
case HASH_BLAKE3:
memcpy(hashed.extra_known.entries[i].bytes, binstat.buf, BLAKE3_BYTES);
binstat.buf += BLAKE3_BYTES;
binstat.avail -= BLAKE3_BYTES;
break;
case HASH_NONE:
/* Do nothing, no bytes to consume */
break;
default:
abort();
}
hash_print(&hashed.extra_known.entries[i]);
}