summaryrefslogtreecommitdiff
path: root/src/dged/buffers.h
blob: 8add8d8ed857be8f54674394b9211967b47ed67d (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
#include "vec.h"

#include <stdint.h>

struct buffer;

typedef void (*buffers_hook_cb)(struct buffer *buffer, void *userdata);

struct buffers_hook {
  buffers_hook_cb callback;
  void *userdata;
};

struct buffers {
  VEC(struct buffer) buffers;
  VEC(struct buffers_hook) add_hooks;
};

void buffers_init(struct buffers *buffers, uint32_t initial_capacity);

struct buffer *buffers_add(struct buffers *buffers, struct buffer buffer);
struct buffer *buffers_find(struct buffers *buffers, const char *name);
struct buffer *buffers_find_by_filename(struct buffers *buffers, const char *path);

uint32_t buffers_add_add_hook(struct buffers *buffers, buffers_hook_cb callback, void *userdata);
uint32_t buffers_add_remove_hook(struct buffers *buffers, buffers_hook_cb callback, void *userdata);

void buffers_destroy(struct buffers *buffers);