diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | Pull requests |Archive | README | LICENSE

utils.h (2081B)


      1 #ifndef DIARY_UTILS_H
      2 #define DIARY_UTILS_H
      3 
      4 #include <regex.h>
      5 #include <stdio.h>
      6 #include <unistd.h>
      7 #include <stdlib.h>
      8 #include <time.h>
      9 #include <string.h>
     10 #include <pthread.h>
     11 #include <wordexp.h>
     12 #include <stdbool.h>
     13 #include <ncurses.h>
     14 #include <libxml/parser.h>
     15 #include <libxml/xpath.h>
     16 #include <libxml/tree.h>
     17 
     18 #include "diary-tp.h"
     19 
     20 #define CAL_WIDTH 21
     21 #define ASIDE_WIDTH 4
     22 #define MAX_MONTH_HEIGHT 6
     23 
     24 void update_date(WINDOW* header, struct tm* curs_date);
     25 bool date_has_entry(const char* dir, size_t dir_size, const struct tm* i);
     26 char* fold(const char* str);
     27 char* unfold(const char* str);
     28 char* extract_ical_field(const char* ical, char* key, long* start_pos, bool multline);
     29 char* extract_xml_content(const char* xml, const char* xpathExpression, WINDOW* w, pthread_t* p);
     30 char* expand_path(const char* str);
     31 char* strrstr(char *haystack, char *needle);
     32 void fpath(const char* dir, size_t dir_size, const struct tm* date, char** rpath, size_t rpath_size);
     33 bool go_to(WINDOW* calendar, WINDOW* aside, time_t date, int* cur_pad_pos, struct tm* curs_date, struct tm* cal_start, struct tm* cal_end);
     34 void* show_progress(void* vargp);
     35 void show_info(WINDOW* w, char* msg, pthread_t* p);
     36 
     37 typedef struct
     38 {
     39     // Path that holds the journal text files
     40     char* dir;
     41     // Number of years to show before/after todays date
     42     int range;
     43     // 7 = Sunday, 1 = Monday, ..., 6 = Saturday
     44     int weekday;
     45     // 2020-12-31
     46     char* fmt;
     47     // Text formatting command/utility fmt,
     48     // default width 75 chars (-w75), do not refill lines (-s)
     49     char* fmt_cmd;
     50     // Don't use pty, use ncurses for preview
     51     bool no_pty;
     52     // Don't listen for mouse events
     53     bool no_mouse;
     54     // Editor to open journal files with
     55     char* editor;
     56     // CalDAV calendar to synchronize
     57     char* caldav_calendar;
     58     // CalDAV server URI
     59     char* caldav_server;
     60     // CalDAV username
     61     char* caldav_username;
     62     // CalDAV password
     63     char* caldav_password;
     64     // OAuth command to fetch access token
     65     char* oauth_eval_cmd;
     66 } config;
     67 
     68 extern config CONFIG;
     69 
     70 #endif