Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/main.cc @ 275:237a75ab7a9b draft
merge
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 04 Jun 2009 00:12:47 +0900 |
parents | ec6729fab209 |
children | 4871fc824525 |
rev | line source |
---|---|
109 | 1 #include <stdlib.h> |
275 | 2 #include <string.h> |
109 | 3 #include <SDL.h> |
4 #include "TaskManager.h" | |
5 | |
216
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
6 /* User main function */ |
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
7 extern int TMmain(int argc, char *argv[]); |
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
8 |
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
9 /* Default TMend function */ |
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
10 static void |
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
11 defaultTMend(void) {} |
109 | 12 |
13 TaskManager *manager; | |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
14 const char *help_str = "\n\ |
109 | 15 * Cerium program option *\n\ |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
16 -help Print this message \n\ |
109 | 17 -cpu Number of CPU (default 1) \n"; |
18 | |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
19 extern const char *usr_help_str; |
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
20 |
109 | 21 int |
22 main(int argc, char *argv[]) | |
23 { | |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
24 int machineNum = 1; |
109 | 25 |
26 for (int i = 1; argv[i]; ++i) { | |
27 if (strcmp(argv[i], "-cpu") == 0) { | |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
28 machineNum = atoi(argv[++i]); |
109 | 29 } |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
30 if (strcmp(argv[i], "-help") == 0) { |
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
31 if (usr_help_str) { |
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
32 printf("%s", usr_help_str); |
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
33 } |
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
34 printf("%s", help_str); |
109 | 35 return EXIT_SUCCESS; |
36 } | |
37 } | |
38 | |
253
0c9c9906d777
usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents:
242
diff
changeset
|
39 manager = new TaskManager(machineNum); |
109 | 40 manager->init(); |
41 | |
216
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
42 manager->set_TMend(defaultTMend); |
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
43 |
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
44 if (TMmain(argc, argv) < 0) { |
109 | 45 goto FINISH; |
46 } | |
47 | |
48 manager->run(); | |
49 | |
216
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
50 (manager->tm_end)(); |
e9a52d68db42
rename cerium_main to TMmain, add TMend()
gongo@localhost.localdomain
parents:
109
diff
changeset
|
51 |
109 | 52 FINISH: |
53 delete manager; | |
54 | |
55 return EXIT_SUCCESS; | |
56 } |