aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index e69de29..625e860 100644
--- a/src/main.c
+++ b/src/main.c
@@ -0,0 +1,65 @@
+#include "opt.h"
+
+#include "../reqs/simple-xdg-bdirs/simple-xdg-bdirs.h"
+
+int main(int argc, char **argv)
+{
+ enum every_opt_outputmode omode;
+ FILE *calendar;
+
+ char **rdirs, **cur, *s;
+
+ opt_parse(argc, argv);
+
+ omode = opt_outputmode();
+
+ if (opt_calpath() != NULL) {
+ s = opt_calpath();
+
+ calendar = fopen(s, "r");
+ if (calendar == NULL) {
+ printf("err: could not read calendar at `%s`\n", s);
+ exit(EXIT_FAILURE);
+ }
+ } else {
+ rdirs = simple_xdg_bdirs_read_dirs(SIMPLE_XDG_BDIRS_CONFIG);
+
+ if (rdirs == NULL) {
+ printf(
+ "err: no calendar specified, and default was not found or "
+ "readable\n"
+ );
+ exit(EXIT_FAILURE);
+ }
+
+ s = simple_xdg_bdirs_fullpath_read("every/calendar", rdirs);
+
+ for (cur = rdirs; *cur != NULL; cur++)
+ free(*cur);
+ free(rdirs);
+
+ if (s == NULL) {
+ printf(
+ "err: no calendar specified, and default was not found or "
+ "readable\n"
+ );
+ exit(EXIT_FAILURE);
+ }
+
+ calendar = fopen(s, "r");
+
+ free(s);
+
+ if (calendar == NULL) {
+ printf(
+ "err: no calendar specified, and default was not found or "
+ "readable\n"
+ );
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ fclose(calendar);
+
+ return 0;
+}