garten

view main.c @ 20:17b2bcc42d72

added check for empty result; minor stuff
author meillo@marmaro.de
date Sun, 27 Jul 2008 21:34:54 +0200
parents 5937504619f2
children
line source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "db.h"
4 #include "modules.h"
7 void init(void) {
8 db_connect();
9 read_time();
10 }
13 void cleanup(void) {
14 db_close();
15 }
18 void run_module(char* name, int (*module)(void)) {
19 printf(" --> %s\n", name);
20 if (!module()) {
21 fprintf(stderr, "failure in module '%s'\n", name);
22 cleanup();
23 exit(2);
24 }
25 printf(" --< %s\n", name);
26 }
29 int main(int argc, char* argv[]) {
30 if (argc != 2) {
31 printf("usage: %s <database>\n", argv[0]);
32 exit(1);
33 }
34 database = argv[1];
35 init();
37 /* modules */
38 run_module("clock", worldclock);
39 run_module("weather", weather);
40 run_module("environment", environment);
41 /* run_module("market", market); */
42 run_module("growth", growth);
43 /* run_module("orderexec", orderexec); */
45 cleanup();
46 return 0;
47 }