/*
* Example of sparse state machine table
*/
typedef int (*FUNCPTR)(int curr_state, int event);
typedef struct {
int old_state;
int event;
int new_state;
FUNCPTR action;
} AUTOMATA_RECORD;
/*
* Note that we only define those combinations of
* state and event which are valid (or which require
* special error processing)...
*/
AUTOMATA_RECORD state_machine[] = {
{ 0, 0, 1, s0_e0_action },
{ 1, 3, 2, s1_e3_action },
{ 2, 5, 3, s2_e5_action } /* and so-on */
};
int num_records = sizeof(state_machine) / sizeof(state_machine[0]);