summaryrefslogtreecommitdiff
path: root/src/io/read_file.h
blob: 201ae5ba9a2deb6303f9bbf308b5e080a708d5cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma once

#include <stddef.h>
#include <stdio.h>

enum mapping_type {
  MT_MMAP,
  MT_OWNED,
};

struct filebuf {
  char *buf;
  size_t sz;
  enum mapping_type mapping_type;
};

struct filebuf *stream_to_filebuf(FILE *restrict stream);
struct filebuf *file_to_filebuf(char *fname);
void free_filebuf(struct filebuf *filebuf);