meillo@13: #include meillo@13: #include meillo@13: #include "db.h" meillo@18: #include "modules.h" meillo@13: meillo@13: meillo@18: void init(void) { meillo@18: db_connect(); meillo@18: read_time(); meillo@18: } meillo@18: meillo@18: meillo@18: void cleanup(void) { meillo@18: db_close(); meillo@18: } meillo@18: meillo@18: meillo@18: void run_module(char* name, int (*module)(void)) { meillo@13: printf(" --> %s\n", name); meillo@18: if (!module()) { meillo@18: fprintf(stderr, "failure in module '%s'\n", name); meillo@18: cleanup(); meillo@18: exit(2); meillo@18: } meillo@13: printf(" --< %s\n", name); meillo@13: } meillo@13: meillo@13: meillo@13: int main(int argc, char* argv[]) { meillo@13: if (argc != 2) { meillo@13: printf("usage: %s \n", argv[0]); meillo@13: exit(1); meillo@13: } meillo@13: database = argv[1]; meillo@18: init(); meillo@13: meillo@13: /* modules */ meillo@13: run_module("clock", worldclock); meillo@13: run_module("weather", weather); meillo@13: run_module("environment", environment); meillo@13: /* run_module("market", market); */ meillo@13: run_module("growth", growth); meillo@13: /* run_module("orderexec", orderexec); */ meillo@13: meillo@18: cleanup(); meillo@13: return 0; meillo@13: }