2023-01-03 11:03:44 +00:00
|
|
|
// SPDX-License-Identifier: ISC
|
|
|
|
#pragma once
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2023-01-03 22:13:32 +00:00
|
|
|
typedef int y16t_db_t;
|
2023-01-03 11:03:44 +00:00
|
|
|
|
|
|
|
// inserts a database entry
|
|
|
|
// x, y, z should point to arrays of 16 bytes each
|
2023-01-03 22:13:32 +00:00
|
|
|
__attribute__((nonnull))
|
2023-01-03 11:03:44 +00:00
|
|
|
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
|
2023-01-03 22:13:32 +00:00
|
|
|
__attribute__((nonnull))
|
2023-01-03 11:03:44 +00:00
|
|
|
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
|
|
|
|
);
|