44 lines
883 B
C
44 lines
883 B
C
// SPDX-License-Identifier: ISC
|
|
#pragma once
|
|
#include <inttypes.h>
|
|
#include <stddef.h>
|
|
|
|
typedef int y16t_db_t;
|
|
|
|
// inserts a database entry
|
|
// x, y, z should point to arrays of 16 bytes each
|
|
__attribute__((nonnull))
|
|
int y16t_db_insert(
|
|
y16t_db_t db,
|
|
const uint8_t *x,
|
|
const uint8_t *y,
|
|
const uint8_t *z
|
|
);
|
|
|
|
// lookup a database entry
|
|
// @return 1 means found, 0 means not found, negative is a negated errno value
|
|
// x, y, z should point to arrays of 16 bytes each
|
|
__attribute__((nonnull))
|
|
int y16t_db_lookup(
|
|
y16t_db_t db,
|
|
const uint8_t *x,
|
|
const uint8_t *y,
|
|
const uint8_t *z
|
|
);
|
|
|
|
// iterate over the database
|
|
|
|
int y16t_db_foreach_x(
|
|
y16t_db_t db,
|
|
const uint8_t *y,
|
|
int (*callback)(const uint8_t*, const uint8_t*, void*),
|
|
void *context
|
|
);
|
|
|
|
int y16t_db_foreach_y(
|
|
y16t_db_t db,
|
|
const uint8_t *x,
|
|
int (*callback)(const uint8_t*, const uint8_t*, void*),
|
|
void *context
|
|
);
|