-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.h
58 lines (51 loc) · 1.2 KB
/
config.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
/* intercept layer that parses config files as they are read by Unison */
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <pthread.h>
#include <sys/types.h>
struct string_s {
char *string;
size_t length;
};
extern struct config_s {
pthread_mutex_t lock;
char *search_path;
struct string_s root[2];
char *pre_command;
char *post_command;
struct post_s {
struct string_s pattern;
char *command;
struct post_s *next;
} *post;
struct symlink_s {
struct string_s path;
char *target;
struct symlink_s *next;
} *symlink;
struct encrypt_s {
struct string_s path;
struct string_s prefixed_path;
struct string_s suffixed_path;
unsigned char key[256 / CHAR_BIT];
struct encrypt_s *next;
} *encrypt;
struct buffer_s {
char *buffer;
size_t size;
} scratchpad;
} config;
static inline void buffer_alloc(struct buffer_s * restrict buffer, size_t size)
{
if (buffer->size < size) {
size = (size + 1024) & ~1023U;
buffer->buffer = realloc(buffer->buffer, size);
assert(buffer->buffer);
buffer->size = size;
}
}
int config_open(const char *path, int flags, ...);
int config_close(int fd);
ssize_t config_read(int fd, void *buf, size_t bytes);
void config_reset(void);