readr_main.c (902B)
1 #include <stdlib.h> 2 #include <string.h> 3 #include <locale.h> 4 #include <mrss.h> 5 6 #define UTILS_IMPL 7 #include "utils.h" 8 9 #include "config.h" 10 #include "db.h" 11 #include "readr.h" 12 #include "feeds.h" 13 #include "tui.h" 14 15 int 16 main(void) 17 { 18 // for unicode blocks/lines, curvy quotes etc. 19 const char* ok = setlocale(LC_ALL, "C.UTF-8"); 20 21 if (!ok) { 22 perror("setlocale failed"); 23 return 1; 24 } 25 26 db_create(); 27 28 const char* path = expand_tilde(FEEDS); 29 if (!path) return 1; 30 31 char* feeds_contents = read_file(path); 32 if (feeds_contents == NULL) { 33 printf("No '%s' file found. Create it and put one RSS feed URL per " 34 "line.\nAlternatively change 'config.h' with your desired feeds location " 35 "and recompile.\n", 36 FEEDS); 37 return 0; 38 } 39 40 printf("Fetching feeds...\n\n%s\n", feeds_contents); 41 42 app_t app = load_app(feeds_contents); 43 44 int display = present(&app); 45 46 db_close(); 47 return display; 48 }