#ifndef TERM_SM_H #define TERM_SM_H typedef int sm_event_id; struct sm_state; struct sm_transition; struct sm_context; typedef void (*sm_action)(struct sm_context*, sm_event_id); typedef int (*sm_predicate)(sm_event_id); struct sm_transition { sm_predicate event_matcher; sm_action transition_action; struct sm_state *transition_target; }; struct sm_state { const char *name; sm_action entry_action; sm_action exit_action; struct sm_transition *transitions; }; struct sm_context { struct sm_state *current_state; struct sm_transition *global_transitions; }; void sm_put_event(struct sm_context *machine, sm_event_id event); #endif