readr

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

readr_main.c (765B)



#include <stdlib.h>
#include <string.h>
#include <mrss.h>

#define UTILS_IMPL
#include "utils.h"

#include "config.h"
#include "db.h"
#include "readr.h"
#include "feeds.h"
#include "tui.h"

int
main(void)
{
	switch_locale();
	validate_config();
	db_create();

	const char* path = expand_tilde(FEEDS);
	if (!path) return 1;

	char* feeds_contents = read_file(path);
	if (feeds_contents == NULL) {
		printf("No '%s' file found. Create it and put one RSS feed URL per "
		       "line.\nAlternatively change 'config.h' with your desired feeds location "
		       "and recompile.\n",
			FEEDS);
		return 0;
	}

	printf("Fetching feeds...\n\n%s\n", feeds_contents);

	app_t app = load_app(feeds_contents);

	int display = present(&app);

	db_close();
	return display;
}