y16t/y16t.h
2022-12-18 03:19:25 +01:00

35 lines
1.1 KiB
C

// SPDX-License-Identifier: ISC
#pragma once
#include <inttypes.h>
#include <stddef.h>
typedef struct {
uint8_t *x;
uint8_t *y;
// x and y should have the same length, and xylen = bytescount * 4
uint32_t xylen;
} y16t_location_t;
typedef struct {
// the offset indicates how far the lookup could traverse the tree
uint32_t inpoffset;
// the final data pointer, it doesn't have to be aligned to block boundaries
// if it ends up at the starting point, but the offset isn't 0,
// then a NULL pointer was hit
size_t datoffset;
} y16t_lookup_t;
// @param ret ... the starting point; gets updated to the latest via the given path
// reachable point
// @param data ... a pointer to a mmap-ed file. we convert pointers inside of the file
// from network byte order to host byte order before following them.
// @param datalen ... the length of the block that data points to, in 4 byte units (= file size in bytes / 4)
__attribute__((pure, nonnull))
void y16t_lookup(
y16t_lookup_t * ret,
const uint32_t * data,
const size_t datalen,
const y16t_location_t * loc
);