Files
blobchain/inc/blobchain/stream.h
T
2026-04-30 21:28:09 -04:00

42 lines
772 B
C

/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause
*/
#ifndef BLOBCHAIN_STREAM_H
#define BLOBCHAIN_STREAM_H 1
#include <stdint.h>
#include <stddef.h>
#include "blobchain/common.h"
/*
* Represents a data stream
*
* @data: Data buffer
* @length: Number of bytes in data buffer
* @hash: SHA256 hash of file contents
*/
struct data_stream {
void *data;
size_t length;
uint8_t hash[SHA256_N_BYTES];
};
/*
* Obtain a stream from a file
*
* @stmp: Stream pointer result
* @path: Path of file to obtain stream from
*
* Returns zero on success
*/
int stream_from_file(struct data_stream *stmp, const char *path);
/*
* Destroy a data stream
*/
void stream_destroy(struct data_stream *stmp);
#endif /* !BLOBCHAIN_STREAM_H */