Add some comments plus fix a possible mem leak
[eleutheria.git] / misc / fsm / types.h
blob4d8cf5c00e1c68f818b2999613c15e31edabb345
1 #ifndef TYPES_H
2 #define TYPES_H
4 #include "../../genstructs/htable/htable.h"
6 #define MAX_EVT_DESC 64
8 typedef struct event {
9 char evt_desc[MAX_EVT_DESC];
10 void (*evt_actionf)(void *data);
11 struct state *evt_newstate;
12 } event_t;
14 typedef struct state {
15 htable_t *evttable;
16 unsigned int *st_key;
17 } state_t;
19 typedef enum {
20 ST_OK,
21 ST_EXISTS,
22 ST_NOMEM,
23 ST_NOTFOUND
24 } stret_t;
26 typedef struct pqnode {
27 void *data;
28 unsigned int evtkey;
29 unsigned int prio;
30 STAILQ_ENTRY(pqnode) pq_next;
31 } pqnode_t;
33 typedef struct fsm {
34 htable_t *sttable; /* hash table for states */
35 state_t *cstate; /* current state of fsm */
36 unsigned int nqueues; /* number of priority queues */
37 void *mobj; /* mutual exclusion object */
38 void (*fsm_pq_lock)(const struct fsm *);
39 void (*fsm_pq_unlock)(const struct fsm *);
40 STAILQ_HEAD(pqhead, pqnode) *pqtable;
41 } fsm_t;
43 typedef struct pqhead pqhead_t;
45 typedef enum {
46 FSM_CLEAN,
47 FSM_DIRTY,
48 FSM_EMPTY,
49 FSM_EPRIO,
50 FSM_EEXISTS,
51 FSM_ENOMEM,
52 FSM_ENOTFOUND,
53 FSM_OK
54 } fsmret_t;
56 #endif /* TYPES_H */