amduat-api/federation/transport_stub.c
Carl Niklas Rydberg a4b501e48d federation
2026-01-21 19:51:26 +01:00

73 lines
2.1 KiB
C

#include "federation/transport_stub.h"
#include <stdlib.h>
#include <string.h>
static int amduat_fed_transport_stub_get_records(void *ctx,
uint32_t domain_id,
uint64_t snapshot_id,
uint64_t log_prefix,
uint64_t from_logseq,
amduat_fed_record_t **out_records,
size_t *out_len) {
(void)ctx;
(void)domain_id;
(void)snapshot_id;
(void)log_prefix;
(void)from_logseq;
if (out_records != NULL) {
*out_records = NULL;
}
if (out_len != NULL) {
*out_len = 0;
}
return 0;
}
static void amduat_fed_transport_stub_free_records(void *ctx,
amduat_fed_record_t *records,
size_t len) {
(void)ctx;
(void)len;
free(records);
}
static int amduat_fed_transport_stub_get_artifact(void *ctx,
amduat_reference_t ref,
amduat_octets_t *out_bytes) {
amduat_fed_transport_stub_t *stub = (amduat_fed_transport_stub_t *)ctx;
(void)ref;
if (out_bytes == NULL || stub == NULL) {
return -1;
}
if (!amduat_octets_clone(stub->artifact_bytes, out_bytes)) {
return -1;
}
return 0;
}
void amduat_fed_transport_stub_init(amduat_fed_transport_stub_t *stub) {
if (stub == NULL) {
return;
}
stub->artifact_bytes = amduat_octets(NULL, 0u);
}
amduat_fed_transport_t amduat_fed_transport_stub_ops(
amduat_fed_transport_stub_t *stub) {
amduat_fed_transport_t ops;
memset(&ops, 0, sizeof(ops));
ops.ctx = stub;
ops.get_records = amduat_fed_transport_stub_get_records;
ops.free_records = amduat_fed_transport_stub_free_records;
ops.get_artifact = amduat_fed_transport_stub_get_artifact;
return ops;
}
void amduat_fed_transport_stub_free(amduat_fed_transport_stub_t *stub) {
if (stub == NULL) {
return;
}
amduat_octets_free(&stub->artifact_bytes);
}