root/scenario.c
/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- initscenario
- addevent
- resetmark
- getcurrentmark
- setmark
- getnextevent
1 /* scenario.c */
2 #include<scenario.h>
3 #include<bidlist.h>
4 #include<stdio.h>
5
6 static bidlist* scenario;
7 static int mark;
8
9 void initscenario(void){
10 scenario = newbidlist();
11 mark = 0;
12 }
13
14 void addevent(event* ev){
15 bidlistadd(scenario, ev);
16 }
17
18 void resetmark(void){
19 bidlistreset(scenario);
20 mark = 0;
21 }
22
23 int getcurrentmark(void){
24 return mark;
25 }
26
27 void setmark(int pos){
28 int cnt = bidlistcount(scenario);
29 if(pos<cnt){
30 mark = pos;
31 bidlistsetmark(scenario, bidlistget(scenario, mark));
32 }else{
33 mark = cnt;
34 bidlistsetmark(scenario, scenario->tail);
35 }
36 }
37
38 event* getnextevent(void){
39 event* ret = NULL;
40 bidnode* node = bidlistnext(scenario);
41 if(node != NULL){
42 ret = (event*)(node->data);
43 }
44 return ret;
45 }