X-Git-Url: https://git.cworth.org/git?p=mnemon;a=blobdiff_plain;f=main.c;fp=main.c;h=643f49d77407b134d37e1983933b0c6157312436;hp=0000000000000000000000000000000000000000;hb=e213a74c688dc475578348ac5e0e438055d11311;hpb=f525171a603949f03a26727416556ebc69fed0b3 diff --git a/main.c b/main.c new file mode 100644 index 0000000..643f49d --- /dev/null +++ b/main.c @@ -0,0 +1,83 @@ +/* mnemon - A memory training program + * + * Copyright © 2006,2011 Carl Worth + * + * This program 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, or (at your option) + * any later version. + * + * This program 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 this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA." + */ + +/* for asprintf */ +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "mnemon.h" + +int +main (int argc, char *argv[]) +{ + mnemon_t mnemon; + char *response; + + void _load_categories() + { + if (argc > 1) { + int i; + for (i = 1; i < argc; i++) + mnemon_load_category (&mnemon, argv[i]); + } else { + mnemon_load (&mnemon); + } + } + + srand (time (NULL)); + + mnemon_init (&mnemon); + + _load_categories (); + + mnemon_do_challenges (&mnemon); + + mnemon_save (&mnemon); + + mnemon_fini (&mnemon); + + mnemon_init (&mnemon); + + _load_categories (); + + printf ("Great job.\nHere are your current results:\n"); + mnemon_print_histogram (&mnemon, NULL, 0); + response = readline ("Press enter to quit.\n"); + free (response); + + mnemon_fini (&mnemon); + + return 0; +}