#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; }