Commit | Line | Data |
---|---|---|
8c108c1c PMF |
1 | #ifndef SSTACK_H |
2 | #define SSTACK_H | |
3 | ||
4 | #define SSTACK_TYPE_PUSH 1 | |
5 | #define SSTACK_TYPE_POP 2 | |
6 | #define SSTACK_TYPE_EVENT 3 | |
7 | ||
8 | //#define SSTACK_PUSH_VAL(i) (()i->data_val) | |
9 | ||
10 | /* An item of a struct sstack, that describes a stack operation */ | |
11 | ||
12 | struct sstack_item { | |
13 | /* state flags */ | |
14 | unsigned char finished; | |
15 | unsigned char processable; | |
16 | unsigned char deletable; | |
17 | ||
18 | /* Type of operation: SSTACK_TYPE_PUSH, SSTACK_TYPE_POP or SSTACK_TYPE_EVENT */ | |
19 | int data_type; | |
20 | /* private, application-dependant data */ | |
21 | void *data_val; | |
22 | ||
23 | /* Function to call to delete data_val */ | |
24 | void (*delete_data_val)(void *data_val); | |
25 | ||
26 | /* The index of the corresponding push (for a pop) or pop (for a push) */ | |
27 | int pushpop; | |
28 | ||
29 | /* Does this item require that we wait for its pop to process it */ | |
30 | int wait_pop; | |
31 | ||
32 | GArray *depends; | |
33 | GArray *rev_depends; | |
34 | }; | |
35 | ||
36 | /* external debugging function to print the private data of an item */ | |
37 | extern void (*print_sstack_item_data)(struct sstack_item *); | |
38 | ||
39 | /* An actual sstack */ | |
40 | ||
41 | struct sstack { | |
42 | GArray *array; | |
43 | ||
44 | /* Stack of the indexes of the pushes that have been done. An index is popped when the | |
45 | * corresponding pop is added to the sstack. This enables us to find the index of the | |
46 | * last push. | |
47 | */ | |
48 | GArray *pushes; | |
49 | ||
50 | /* Stack of 0's and 1's. 0: don't wait for pop to process the children | |
51 | * 1: wait for pop to process its children | |
52 | */ | |
53 | GArray *wait_pop_stack; | |
54 | ||
55 | /* Next item we must try to process */ | |
56 | int proc_index; | |
57 | ||
58 | void (*process_func)(void *arg, struct sstack_item *item); | |
59 | void *process_func_arg; /* the pointer passed as the "arg" argument of process_func */ | |
60 | }; | |
61 | ||
62 | struct sstack_item *sstack_new_item(); | |
63 | ||
64 | void sstack_add_item(struct sstack *stack, struct sstack_item *item); | |
65 | ||
66 | struct sstack *sstack_new(void); | |
67 | struct sstack_item *sstack_item_new(void); | |
68 | struct sstack_item *sstack_item_new_push(unsigned char finished); | |
69 | struct sstack_item *sstack_item_new_pop(void); | |
45292ddc | 70 | struct sstack_item *sstack_item_new_event(void); |
c7cb53d7 | 71 | void sstack_force_flush(struct sstack *stack); |
8c108c1c | 72 | |
b1d18041 PMF |
73 | extern void print_stack(struct sstack *stack); |
74 | ||
8c108c1c | 75 | #endif /* SSTACK_H */ |