readr

Minimal Terminal RSS Reader
Log | Files | Refs | README | LICENSE

readr_main.c (765B)


      1 #include <stdlib.h>
      2 #include <string.h>
      3 #include <mrss.h>
      4 
      5 #define UTILS_IMPL
      6 #include "utils.h"
      7 
      8 #include "config.h"
      9 #include "db.h"
     10 #include "readr.h"
     11 #include "feeds.h"
     12 #include "tui.h"
     13 
     14 int
     15 main(void)
     16 {
     17 	switch_locale();
     18 	validate_config();
     19 	db_create();
     20 
     21 	const char* path = expand_tilde(FEEDS);
     22 	if (!path) return 1;
     23 
     24 	char* feeds_contents = read_file(path);
     25 	if (feeds_contents == NULL) {
     26 		printf("No '%s' file found. Create it and put one RSS feed URL per "
     27 		       "line.\nAlternatively change 'config.h' with your desired feeds location "
     28 		       "and recompile.\n",
     29 			FEEDS);
     30 		return 0;
     31 	}
     32 
     33 	printf("Fetching feeds...\n\n%s\n", feeds_contents);
     34 
     35 	app_t app = load_app(feeds_contents);
     36 
     37 	int display = present(&app);
     38 
     39 	db_close();
     40 	return display;
     41 }