Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=d93594f2f47c0af4574842306285a8e1d1aca95f
commit d93594f2f47c0af4574842306285a8e1d1aca95f Author: James Buren <[email protected]> Date: Wed Sep 5 23:28:18 2012 -0500 add a framework for cycling through a modules list diff --git a/src/local.h b/src/local.h index 2b8d34f..52ff938 100644 --- a/src/local.h +++ b/src/local.h @@ -56,3 +56,4 @@ extern int main(int argc,char **argv); extern struct global g; extern struct module install_module; +extern struct module *modules[]; diff --git a/src/main.c b/src/main.c index 2a0a4a1..0c2908c 100644 --- a/src/main.c +++ b/src/main.c @@ -22,3 +22,9 @@ struct global g = { .netinstall = true }; + +struct module *modules[] = +{ + &install_module, + 0 +}; diff --git a/src/ui_newt.c b/src/ui_newt.c index 384274e..cb0fbe7 100644 --- a/src/ui_newt.c +++ b/src/ui_newt.c @@ -8,6 +8,10 @@ extern int ui_main(int argc,char **argv) { int w = 0; int h = 0; + struct module *module = 0; + size_t n = 0; + char text[4096] = {0}; + int code = EXIT_SUCCESS; // This parameter is never used. argc = argc; @@ -32,11 +36,43 @@ extern int ui_main(int argc,char **argv) newtCls(); - install_module.run(); + while(true) + { + module = modules[n]; + + if(module == 0) + break; + + if(module->run == 0 || module->reset == 0 || module->name == 0) + { + errno = EINVAL; + fprintf(logfile,"%s: %s\n",__func__,strerror(errno)); + code = EXIT_FAILURE; + break; + } + + fprintf(logfile,_("About to run module '%s'.\n"),module->name); + + bool success = module->run(); + + if(!success) + { + fprintf(logfile,_("A fatal error has been reported by module '%s'.\n"),module->name); + module->reset(); + snprintf(text,4096,_("A fatal error has been reported by module '%s'.\n\nFor more information, please see the logfile at '%s'. Thank you.\n"),module->name,LOGFILE); + ui_dialog_text(_("Module Fatal Error"),text); + code = EXIT_FAILURE; + break; + } + + module->reset(); + + ++n; + } newtFinished(); - return 0; + return code; } extern void ui_dialog_text(const char *title,const char *text) _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
