add representation of hash, decode dependencies
Dependencies
- [2]
2C2EF2GKmove blake3 files to vendor/blake3 - [3]
LCEKN25Gchange: parse authors - [4]
VKLGQREYchange: add base32 decode, initial deconstruction of hashed - [5]
Y26WT3ZFchange: decode message, description and timestamp - [6]
Q7TKZCJPAdd initial support for reading the offsets from a (fixed) change - [*]
PEUS54XQ - [*]
OBKF6SIIchange: decompress the hashed section too - [*]
B3XLVPNCAdd ani.c and initial Makefile - [*]
X36ICMJNInitial import for blake3
Change contents
- file addition: hash.h[8.1]
#ifndef HASH_H#define HASH_H#define HASH_NONE 0#define HASH_BLAKE3 1#define BLAKE3_BYTES 32struct 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 - file addition: hash.c[8.1]
#include <stdlib.h>#include <stdint.h>#include <stdio.h>#include "hash.h"voidhash_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();}} - replacement in change.h at line 71
void *dependencies; /* array of hashes */void *extra_known; /* another array of hashes */struct hash_list dependencies; /* array of hashes */struct hash_list extra_known; /* another array of hashes */ - edit in change.c at line 13
#include "hash.h" - edit in change.c at line 250
}/* Decode dependencies (Vec<Hash>) */len = bincode_getu64(&binstat);hashed.dependencies.len = len;hashed.dependencies.entries = xmalloc(sizeof(struct hash) * len); - edit in change.c at line 258
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]); - edit in change.c at line 275
dump_buf("buf2", binstat.buf, binstat.avail); - edit in change.c at line 276
/* Decode extra_known (Vec<Hash> again) */len = bincode_getu64(&binstat);hashed.extra_known.len = len;hashed.extra_known.entries = xmalloc(sizeof(struct hash) * len); - edit in change.c at line 281
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]);} - edit in Makefile at line 26[4.3502][11.53469]
OBJS += hash.o