annotate main.c @ 19:eb8db0d906de
updated runtick.sh to current program
author |
meillo@marmaro.de |
date |
Wed, 23 Jul 2008 17:44:15 +0200 |
parents |
5937504619f2 |
children |
|
rev |
line source |
meillo@13
|
1 #include <stdio.h>
|
meillo@13
|
2 #include <stdlib.h>
|
meillo@13
|
3 #include "db.h"
|
meillo@18
|
4 #include "modules.h"
|
meillo@13
|
5
|
meillo@13
|
6
|
meillo@18
|
7 void init(void) {
|
meillo@18
|
8 db_connect();
|
meillo@18
|
9 read_time();
|
meillo@18
|
10 }
|
meillo@18
|
11
|
meillo@18
|
12
|
meillo@18
|
13 void cleanup(void) {
|
meillo@18
|
14 db_close();
|
meillo@18
|
15 }
|
meillo@18
|
16
|
meillo@18
|
17
|
meillo@18
|
18 void run_module(char* name, int (*module)(void)) {
|
meillo@13
|
19 printf(" --> %s\n", name);
|
meillo@18
|
20 if (!module()) {
|
meillo@18
|
21 fprintf(stderr, "failure in module '%s'\n", name);
|
meillo@18
|
22 cleanup();
|
meillo@18
|
23 exit(2);
|
meillo@18
|
24 }
|
meillo@13
|
25 printf(" --< %s\n", name);
|
meillo@13
|
26 }
|
meillo@13
|
27
|
meillo@13
|
28
|
meillo@13
|
29 int main(int argc, char* argv[]) {
|
meillo@13
|
30 if (argc != 2) {
|
meillo@13
|
31 printf("usage: %s <database>\n", argv[0]);
|
meillo@13
|
32 exit(1);
|
meillo@13
|
33 }
|
meillo@13
|
34 database = argv[1];
|
meillo@18
|
35 init();
|
meillo@13
|
36
|
meillo@13
|
37 /* modules */
|
meillo@13
|
38 run_module("clock", worldclock);
|
meillo@13
|
39 run_module("weather", weather);
|
meillo@13
|
40 run_module("environment", environment);
|
meillo@13
|
41 /* run_module("market", market); */
|
meillo@13
|
42 run_module("growth", growth);
|
meillo@13
|
43 /* run_module("orderexec", orderexec); */
|
meillo@13
|
44
|
meillo@18
|
45 cleanup();
|
meillo@13
|
46 return 0;
|
meillo@13
|
47 }
|