agendafs
A filesystem for your calendar.
git clone git://mccd.space/agendafs| Log | Files | Refs | README | LICENSE | Mail | Website |
agenda_entry.c (1151B)
1 #include "agenda_entry.h"
2 #include "arena.h"
3 #include "util.h"
4 #include <dirent.h>
5 #include <libical/ical.h>
6 #include <pthread.h>
7 #include <regex.h>
8 #include <stdbool.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <sys/inotify.h>
13 #include <sys/stat.h>
14 #include <time.h>
15 #include <unistd.h>
16 #include <uuid/uuid.h>
17 #include <wordexp.h>
18
19 struct agenda_entry *
20 copy_agenda_entry(const struct agenda_entry *src)
21 {
22 // Root node
23 if (!src) {
24 return NULL;
25 }
26 struct agenda_entry *copy = xmalloc(sizeof(struct agenda_entry));
27 copy->filename = xstrdup(src->filename);
28 copy->filename_vdir = xstrdup(src->filename_vdir);
29 return copy;
30 }
31
32 void
33 free_agenda_entry(struct agenda_entry *entry)
34 {
35 if (!entry)
36 return;
37 if (entry->filename)
38 free(entry->filename);
39 if (entry->filename_vdir)
40 free(entry->filename_vdir);
41 free(entry);
42 return;
43 }
44
45 struct agenda_entry *
46 create_agenda_entry(arena *ar, const char *filename,
47 const char *filename_vdir)
48 {
49 struct agenda_entry *copy = rmalloc(ar, sizeof(struct agenda_entry));
50 copy->filename = rstrdup(ar, filename);
51 copy->filename_vdir = rstrdup(ar, filename_vdir);
52 return copy;
53 }