2025-01-30 18:10:38 +00:00
|
|
|
#ifndef PIPELINE_H_
|
|
|
|
|
#define PIPELINE_H_
|
|
|
|
|
|
2025-02-15 12:36:37 +00:00
|
|
|
#include "cluster.h"
|
2025-01-30 18:10:38 +00:00
|
|
|
#include "status.h"
|
|
|
|
|
|
|
|
|
|
#include <blue/core/queue.h>
|
|
|
|
|
#include <stddef.h>
|
2025-02-15 12:36:37 +00:00
|
|
|
#include <stdio.h>
|
2025-01-30 18:10:38 +00:00
|
|
|
|
|
|
|
|
enum ec3_pipeline_stage_type_id {
|
|
|
|
|
EC3_PIPELINE_NONE = 0,
|
|
|
|
|
EC3_PIPELINE_AES256,
|
|
|
|
|
EC3_PIPELINE_ZSTD,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ec3_pipeline_stage_type_flags {
|
|
|
|
|
EC3_PIPELINE_F_NONE = 0x00u,
|
|
|
|
|
EC3_PIPELINE_F_BUFFERED = 0x01u,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ec3_pipeline_stage;
|
|
|
|
|
|
|
|
|
|
struct ec3_pipeline_stage_type {
|
|
|
|
|
enum ec3_pipeline_stage_type_id t_id;
|
|
|
|
|
enum ec3_pipeline_stage_type_flags t_flags;
|
|
|
|
|
|
2025-02-15 12:36:37 +00:00
|
|
|
enum ec3_status (*t_cluster_in)(
|
2025-01-30 18:10:38 +00:00
|
|
|
struct ec3_pipeline_stage *,
|
|
|
|
|
const void *,
|
2025-02-15 12:36:37 +00:00
|
|
|
size_t,
|
2025-01-30 18:10:38 +00:00
|
|
|
void *,
|
2025-02-15 12:36:37 +00:00
|
|
|
size_t,
|
2025-01-30 18:10:38 +00:00
|
|
|
size_t *);
|
2025-02-15 12:36:37 +00:00
|
|
|
enum ec3_status (*t_cluster_out)(
|
2025-01-30 18:10:38 +00:00
|
|
|
struct ec3_pipeline_stage *,
|
|
|
|
|
const void *,
|
|
|
|
|
size_t,
|
|
|
|
|
void *,
|
2025-02-15 12:36:37 +00:00
|
|
|
size_t,
|
2025-01-30 18:10:38 +00:00
|
|
|
size_t *);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ec3_pipeline_stage {
|
|
|
|
|
const struct ec3_pipeline_stage_type *s_type;
|
|
|
|
|
void *s_buf;
|
|
|
|
|
void *s_arg;
|
|
|
|
|
b_queue_entry s_entry;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ec3_pipeline_stage_args {
|
|
|
|
|
enum ec3_pipeline_stage_type_id type;
|
|
|
|
|
void *arg;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ec3_pipeline {
|
2025-02-15 12:36:37 +00:00
|
|
|
FILE *p_target;
|
|
|
|
|
size_t p_target_base_offset;
|
|
|
|
|
|
|
|
|
|
size_t p_cluster_size;
|
|
|
|
|
unsigned int p_cluster_flags;
|
|
|
|
|
struct cluster_table p_cluster_table;
|
|
|
|
|
|
|
|
|
|
size_t p_next_cluster_id;
|
|
|
|
|
size_t p_data_offset;
|
|
|
|
|
|
|
|
|
|
void *p_read_buf;
|
2025-01-30 18:10:38 +00:00
|
|
|
b_queue p_stages;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern enum ec3_status ec3_pipeline_create(
|
|
|
|
|
struct ec3_pipeline_stage_args stages[],
|
|
|
|
|
size_t nr_stages,
|
|
|
|
|
size_t cluster_size,
|
2025-02-15 12:36:37 +00:00
|
|
|
FILE *target,
|
|
|
|
|
size_t target_base_offset,
|
|
|
|
|
FILE *cluster_table,
|
|
|
|
|
size_t cluster_table_base_offset,
|
2025-01-30 18:10:38 +00:00
|
|
|
struct ec3_pipeline **out);
|
|
|
|
|
extern void ec3_pipeline_destroy(struct ec3_pipeline *p);
|
|
|
|
|
|
2025-02-15 12:36:37 +00:00
|
|
|
extern enum ec3_status ec3_pipeline_write_cluster(
|
2025-01-30 18:10:38 +00:00
|
|
|
struct ec3_pipeline *pipeline,
|
|
|
|
|
void *p,
|
|
|
|
|
size_t len,
|
2025-02-15 12:36:37 +00:00
|
|
|
size_t *bytes_written);
|
|
|
|
|
extern enum ec3_status ec3_pipeline_read_cluster(
|
2025-01-30 18:10:38 +00:00
|
|
|
struct ec3_pipeline *pipeline,
|
|
|
|
|
void *p,
|
2025-02-15 12:36:37 +00:00
|
|
|
size_t cluster_id,
|
2025-01-30 18:10:38 +00:00
|
|
|
size_t *nr_read);
|
|
|
|
|
|
2025-02-16 08:46:22 +00:00
|
|
|
extern enum ec3_status ec3_pipeline_copy_all(
|
|
|
|
|
struct ec3_pipeline *dest,
|
|
|
|
|
struct cluster_table *clusters,
|
|
|
|
|
FILE *data);
|
|
|
|
|
|
2025-02-02 20:56:29 +00:00
|
|
|
extern size_t ec3_get_cluster_size(unsigned int v);
|
2025-02-15 12:36:37 +00:00
|
|
|
extern enum ec3_pipeline_stage_type_id
|
|
|
|
|
ec3_get_pipeline_stage_for_encryption_func(unsigned int func);
|
|
|
|
|
extern enum ec3_pipeline_stage_type_id
|
|
|
|
|
ec3_get_pipeline_stage_for_compression_func(unsigned int func);
|
2025-02-02 20:56:29 +00:00
|
|
|
|
2025-01-30 18:10:38 +00:00
|
|
|
#endif
|