blob: dc844bb70e2de85cd081c4f04b717696ee88bddb (
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
|
#ifndef LIB_H
#define LIB_H
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
#define MAX(A, B) ((A) < (B) ? (A) : (B))
#define MIN(A, B) ((A) > (B) ? (A) : (B))
bool usable_character(char c);
char *fread_all(FILE *fp);
void print_error(const char *handle, size_t row, size_t column,
const char *reason);
typedef struct Buffer
{
const char *name;
u64 size, capacity;
u8 data[];
} buffer_t;
buffer_t *buffer_init_str(const char *name, const char *str, size_t str_size);
bool buffer_ensure(buffer_t **buffer, u64 expected);
bool buffer_ensure_relative(buffer_t **buffer, u64 expected);
bool buffer_append(buffer_t **buffer, u8 datum);
bool buffer_append_bytes(buffer_t **buffer, u8 *data, u64 size);
#endif
|