summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index b35d079..3963e88 100644
--- a/src/main.c
+++ b/src/main.c
@@ -19,16 +19,51 @@
* along with Timeteller. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.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
+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;
+ set_program_name(argv[0]);
+
speech = speech_new();
+ if (speech == NULL) {
+ error("Failed to initialize speech synthesis engine");
+ return EXIT_FAILURE;
+ }
speech_play_time(speech);
speech_destroy(&speech);
- return 0;
+ return EXIT_SUCCESS;
}