agendafs
A filesystem for your calendar.
git clone git://mccd.space/agendafscommit ab0a518c53ae312d3e7f40e370695213c88ab375
parent 357674c1e85afb8d934fecb15c0ce9387b7d9a89
Author: Marc Coquand <marc@coquand.email>
Date: Sat, 26 Jul 2025 12:47:12 +0200
Cleanup
Diffstat:
| M | main.c | | | 80 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
1 file changed, 40 insertions(+), 40 deletions(-)
diff --git a/main.c b/main.c
@@ -580,6 +580,46 @@ fuse_utimens(const char *path, const struct timespec tv[2],
return 0;
}
+struct agendafs_config {
+ char *ics_directory;
+};
+enum {
+ KEY_HELP,
+ KEY_VERSION,
+};
+
+#define CUSTOMFS_OPT(t, p, v) {t, offsetof(struct agendafs_config, p), v}
+
+static struct fuse_opt agendafs_opts[] = {
+ CUSTOMFS_OPT("vdir=%s", ics_directory, 0), FUSE_OPT_KEY("-V", KEY_VERSION),
+ FUSE_OPT_KEY("--version", KEY_VERSION), FUSE_OPT_KEY("-h", KEY_HELP),
+ FUSE_OPT_KEY("--help", KEY_HELP), FUSE_OPT_END};
+
+size_t
+load_agendafs_environment(char *vdir_env)
+{
+ wordexp_t expanded;
+ if (wordexp(vdir_env, &expanded, 0) != 0 || expanded.we_wordc == 0) {
+ fprintf(stderr, "Failed to expand CALDAVFS_ICS_DIR\n");
+ wordfree(&expanded);
+ return -1;
+ }
+
+ char *expanded_path = expanded.we_wordv[0];
+
+ struct stat s;
+ if (stat(expanded_path, &s) == 0 && S_ISDIR(s.st_mode)) {
+ assert(strlen(expanded_path) < 256);
+ set_vdir(expanded_path);
+ wordfree(&expanded);
+ return 0;
+ }
+
+ fprintf(stderr, "CALDAVFS_ICS_DIR is not a directory: %s\n",
+ expanded_path);
+ return -1;
+}
+
struct fuse_operations fuse_oper = {.getattr = fuse_getattr,
.readdir = fuse_readdir,
.open = fuse_open,
@@ -597,21 +637,6 @@ struct fuse_operations fuse_oper = {.getattr = fuse_getattr,
.readlink = fuse_readlink,
.rename = fuse_rename};
-struct agendafs_config {
- char *ics_directory;
-};
-enum {
- KEY_HELP,
- KEY_VERSION,
-};
-
-#define CUSTOMFS_OPT(t, p, v) {t, offsetof(struct agendafs_config, p), v}
-
-static struct fuse_opt agendafs_opts[] = {
- CUSTOMFS_OPT("vdir=%s", ics_directory, 0), FUSE_OPT_KEY("-V", KEY_VERSION),
- FUSE_OPT_KEY("--version", KEY_VERSION), FUSE_OPT_KEY("-h", KEY_HELP),
- FUSE_OPT_KEY("--help", KEY_HELP), FUSE_OPT_END};
-
static int
agendafs_opt_proc(void *data, const char *arg, int key,
struct fuse_args *outargs)
@@ -637,31 +662,6 @@ agendafs_opt_proc(void *data, const char *arg, int key,
return 1;
}
-size_t
-load_agendafs_environment(char *vdir_env)
-{
- wordexp_t expanded;
- if (wordexp(vdir_env, &expanded, 0) != 0 || expanded.we_wordc == 0) {
- fprintf(stderr, "Failed to expand CALDAVFS_ICS_DIR\n");
- wordfree(&expanded);
- return -1;
- }
-
- char *expanded_path = expanded.we_wordv[0];
-
- struct stat s;
- if (stat(expanded_path, &s) == 0 && S_ISDIR(s.st_mode)) {
- assert(strlen(expanded_path) < 256);
- set_vdir(expanded_path);
- wordfree(&expanded);
- return 0;
- }
-
- fprintf(stderr, "CALDAVFS_ICS_DIR is not a directory: %s\n",
- expanded_path);
- return -1;
-}
-
int
main(int argc, char *argv[])
{