aboutsummaryrefslogtreecommitdiff
path: root/vcal.h
blob: 6b3667bf37b66662e69c24a7ea070c3128581089 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef VCAL_H
#define VCAL_H

#include <stdlib.h>

#include "strbuf.h"

#define TYPE strbuf
#include "linked_list.h"
#undef TYPE

typedef struct {
	strbuf key;
	strbuf value;
	strbuf* vals;
	int val_count;
} parameter;

typedef struct {
	strbuf key;

	LLIST(strbuf) vals;

	parameter* params;
	int param_count;
} content_line;

INIT_F(content_line);
INIT_F(content_line, int keylen, int vallen);
FREE_F(content_line);

/*
 * Resolves a collision in some form of structure (probably a hash-map
 * or a trie). If dest is NULL just return new. Otherwise mutates dest
 * to have the correct form, and returns it. Destroying new in the
 * process.
 */
content_line* RESOLVE(content_line)
	(content_line* dest, content_line* new);

#define TYPE content_line
#include "trie.h"
#undef TYPE

typedef struct s_vcomponent vcomponent;

#define TYPE vcomponent
#include "vector.h"
#undef TYPE

struct s_vcomponent {
	char* filename;
	vcomponent* parent;
	TRIE(content_line) clines;
	VECT(vcomponent) components;
};

INIT_F(vcomponent);
INIT_F(vcomponent, char* filename);
FREE_F(vcomponent);

int content_line_copy (content_line* dest, content_line* src);

content_line* get_property (vcomponent* ev, char* key);

int add_content_line (vcomponent* ev, content_line* c);

/*
 * Appends ev to cal. Doesn't copy ev. So make sure that it wont go
 * out of scope.
 */
int PUSH(vcomponent)(vcomponent*, vcomponent*);

#endif /* VCAL_H */