change: parse authors

laumann
Sep 9, 2022, 9:30 PM
LCEKN25G5GFBUWWQAR4REIGPOL6JYNDWLNCDJGZQKOWIDHGIRMZAC

Dependencies

  • [2] Y26WT3ZF change: decode message, description and timestamp
  • [3] VKLGQREY change: add base32 decode, initial deconstruction of hashed
  • [4] Q7TKZCJP Add initial support for reading the offsets from a (fixed) change

Change contents

  • edit in change.h at line 35
    [3.810]
    [3.0]
    /**
    * A list of key-value collections (BTreeMap)
    */
    struct authors {
    size_t len;
    struct author *map;
    };
    /** An "author" is (strangely) a list of key-value pairs */
    struct author {
    size_t len;
    struct author_entry *entries;
    };
    struct author_entry {
    char *key;
    char *value;
    };
  • replacement in change.h at line 58
    [3.173][2.523:573]()
    void *authors; /* a "key"="value" collection */
    [3.173]
    [3.209]
    struct authors authors; /* a list of "key"="value" collections */
  • edit in change.c at line 230
    [2.1639]
    [2.1639]
    len = bincode_getu64(&binstat); /* arrays of authors */
    hashed.header.authors.len = len;
    hashed.header.authors.map = xmalloc(sizeof(struct author) * len);
    printf("[[authors]]\n");
    for (i = 0; i < hashed.header.authors.len; i++) {
    int j;
    len = bincode_getu64(&binstat);
    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++) {
    len = bincode_getu64(&binstat);
    hashed.header.authors.map[i].entries[j].key = bincode_getstr(&binstat, len);
    len = bincode_getu64(&binstat);
    hashed.header.authors.map[i].entries[j].value = bincode_getstr(&binstat, len);
    printf("%s = '%s'\n",
    hashed.header.authors.map[i].entries[j].key,
    hashed.header.authors.map[i].entries[j].value);
    }
    }
    dump_buf("buf2", binstat.buf, binstat.avail);