/* * Program entry point * * Copyright (C) 2019 Patrick McDermott * * This file is part of Timeteller. * * Timeteller is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Timeteller is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Timeteller. If not, see . */ #include #include #include #include #include "screen.h" #include "speech.h" static const char *program_name; static void set_program_name(const char *name) { assert(name && *name); program_name = name; } static void __attribute__((format(printf, 1, 2))) error(const char *format, ...) { va_list ap; assert(format); fprintf(stderr, "%s: Error: ", program_name); va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); fputs("\n", stderr); } int main(int argc, char **argv) { struct speech *speech; struct screen *screen; int ret; assert(argc >= 1); set_program_name(argv[0]); speech = speech_new(); if (speech == NULL) { error("Failed to initialize speech synthesis engine"); return EXIT_FAILURE; } screen = screen_new(); if (screen_main(screen, speech)) { ret = EXIT_SUCCESS; } else { ret = EXIT_FAILURE; } screen_destroy(&screen); speech_destroy(&speech); return ret; }