summaryrefslogtreecommitdiffstats
path: root/src/storage.h
blob: 00826d82c1eff1edebb97bf92e9eabb1771d06a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef STORAGE_H
#define STORAGE_H

#include <stdlib.h>
#include <stdint.h>

struct tsnif_storage_handle;
struct tsnif_storage_opts;

enum {
	TSNIF_STORAGE_TYPE_MMAP,
};

#define TSNIF_HEADER_MAGIC	0xdeadfeed

struct tsnif_storage_header {
	uint32_t magic;
	uint32_t type;
};

enum {
	TSNIF_STORAGE_OPT_CREATE = 0x1,
	TSNIF_STORAGE_OPT_OPEN   = 0x2,
	TSNIF_STORAGE_OPT_READ   = 0x4,
	TSNIF_STORAGE_OPT_WRITE  = 0x8,
};

struct tsnif_storage_rec {
	void *ptr;
	int len;
	uint flags;
};

int tsnif_storage_init(struct tsnif_storage_handle *h,
		       struct tsnif_storage_opts *ops, char *name);
int tsnif_storage_close(struct tsnif_storage_handle *h);
int tsnif_storage_write(struct tsnif_storage_handle *h,
			struct tsnif_storage_rec *rec);
int tsnif_storage_read(struct tsnif_storage_handle *h, int idx,
			struct tsnif_storage_rec *rec);

/* TODO make CONFIG option and ifdef this place */
#include "storage-mmap.h"

#endif /* STORAGE_H */