51 lines
1,020 B
C
51 lines
1,020 B
C
// SPDX-License-Identifier: ISC
|
|
#pragma once
|
|
#include <inttypes.h>
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
// try to lookup the given coordinates,
|
|
// and return the corresponding location via `result`.
|
|
// the file given as `fh` is expected to be at least 256KiB large
|
|
// returns a negative errno number in case of failure
|
|
__attribute__((nonnull))
|
|
int y16t_idx_lookup(
|
|
FILE *fh,
|
|
uint8_t x,
|
|
uint8_t y,
|
|
uint32_t *result
|
|
);
|
|
|
|
// update a table entry.
|
|
__attribute__((nonnull))
|
|
int y16t_idx_update(
|
|
FILE *fh,
|
|
uint8_t x,
|
|
uint8_t y,
|
|
uint32_t newval
|
|
);
|
|
|
|
// insert a table entry if it doesn't already exist
|
|
int y16t_idx_get_or_insert(
|
|
FILE *fh,
|
|
uint8_t x,
|
|
uint8_t y,
|
|
uint32_t *value,
|
|
uint32_t (*palloc)(void*),
|
|
void *context
|
|
);
|
|
|
|
// iterate over columns or rows
|
|
int y16t_idx_foreach_x(
|
|
FILE *fh,
|
|
uint8_t y,
|
|
int (*callback)(uint32_t, void*),
|
|
void *context
|
|
);
|
|
|
|
int y16t_idx_foreach_y(
|
|
FILE *fh,
|
|
uint8_t χ,
|
|
int (*callback)(uint32_t, void*),
|
|
void *context
|
|
);
|