agendafs
A filesystem for your calendar.
git clone git://mccd.space/agendafs| Log | Files | Refs | README | LICENSE | Mail | Website |
arena.h (1448B)
1 #ifndef arena_h_INCLUDED
2 #define arena_h_INCLUDED
3 #include "util.h"
4 #include <assert.h>
5 #include <libical/ical.h>
6 #include <stdarg.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10
11 typedef void (*free_func_t)(void *);
12
13 typedef struct memory_block {
14 void *ptr;
15 free_func_t free_func;
16 struct memory_block *next;
17 } memory_block;
18
19 /*
20 * Dynamic arena allocator
21 */
22 typedef struct {
23 memory_block *head;
24 } arena;
25
26 arena *
27 create_arena(void);
28
29 void
30 arena_register(arena *region, void *ptr, free_func_t free_func);
31
32 void *
33 rmalloc(arena *region, size_t size);
34
35 void
36 free_all(arena *region);
37
38 char *
39 rstrndup(arena *ar, const char *src, size_t len);
40
41 char *
42 rstrins(arena *region, const char *str, size_t offset, const char *buf,
43 size_t size);
44 // String functions
45 char *
46 rstrdup(arena *region, const char *str);
47
48 int
49 rasprintf(arena *region, char **strp, const char *fmt, ...);
50
51 // iCal functions
52
53 icalparser *
54 ricalparser_new(arena *region);
55
56 void
57 ricalcomponent_free(icalcomponent *ic);
58
59 icalcomponent *
60 ricalcomponent_empty(arena *region);
61
62 icalcomponent *
63 ricalcomponent_new_clone(arena *region, icalcomponent *ic);
64
65 icalcomponent *
66 ricalcomponent_new_from_string(arena *region, const char *ic);
67
68 char *
69 ricalcomponent_as_ical_string(arena *region, icalcomponent *ic);
70
71 char *
72 ricalcomponent_as_ical_string_r(arena *region, icalcomponent *ic);
73
74 icalcomponent *
75 ricalcomponent_new_vcalendar(arena *region);
76 #endif // mrgeion_h_INCLUDED