79 lines
2 KiB
C
79 lines
2 KiB
C
#ifndef AMDUAT_ASL_LOG_STORE_H
|
|
#define AMDUAT_ASL_LOG_STORE_H
|
|
|
|
#include "amduat/asl/asl_pointer_fs.h"
|
|
#include "amduat/asl/core.h"
|
|
#include "amduat/asl/store.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
enum { TYPE_TAG_ASL_LOG_CHUNK_1 = 0x00000401u };
|
|
enum { AMDUAT_TYPE_TAG_ASL_LOG_CHUNK_1 = TYPE_TAG_ASL_LOG_CHUNK_1 };
|
|
|
|
typedef struct {
|
|
uint16_t kind;
|
|
bool has_timestamp;
|
|
uint64_t timestamp;
|
|
amduat_reference_t payload_ref;
|
|
bool has_actor;
|
|
amduat_octets_t actor;
|
|
} amduat_asl_log_entry_t;
|
|
|
|
typedef struct {
|
|
bool has_prev;
|
|
amduat_reference_t prev_ref;
|
|
uint64_t base_offset;
|
|
uint32_t entry_count;
|
|
bool has_timestamp;
|
|
bool has_actor;
|
|
amduat_asl_log_entry_t *entries;
|
|
} amduat_asl_log_chunk_t;
|
|
|
|
typedef struct {
|
|
amduat_asl_store_t *store;
|
|
amduat_asl_pointer_store_t pointer_store;
|
|
} amduat_asl_log_store_t;
|
|
|
|
bool amduat_asl_log_store_init(amduat_asl_log_store_t *log_store,
|
|
const char *root_path,
|
|
amduat_asl_store_t *store,
|
|
const amduat_asl_pointer_store_t *pointer_store);
|
|
|
|
amduat_asl_store_error_t amduat_asl_log_append(
|
|
amduat_asl_log_store_t *log_store,
|
|
const char *log_name,
|
|
const amduat_asl_log_entry_t *entries,
|
|
size_t entries_len,
|
|
uint64_t *out_first_offset);
|
|
|
|
amduat_asl_store_error_t amduat_asl_log_read(
|
|
amduat_asl_log_store_t *log_store,
|
|
const char *log_name,
|
|
uint64_t from_offset,
|
|
size_t max_entries,
|
|
amduat_asl_log_entry_t **out_entries,
|
|
size_t *out_len,
|
|
uint64_t *out_next_offset,
|
|
bool *out_end);
|
|
|
|
void amduat_asl_log_entries_free(amduat_asl_log_entry_t *entries,
|
|
size_t entries_len);
|
|
|
|
amduat_asl_store_error_t amduat_asl_log_chunk_decode_v1(
|
|
amduat_octets_t bytes,
|
|
amduat_asl_log_chunk_t *out_chunk);
|
|
|
|
void amduat_asl_log_chunk_free(amduat_asl_log_chunk_t *chunk);
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern "C" */
|
|
#endif
|
|
|
|
#endif /* AMDUAT_ASL_LOG_STORE_H */
|