/*
* Example of dense state machine table
*/
typedef int (*FUNCPTR)(int curr_state, int event);
typedef struct {
int new_state;
FUNCPTR action;
} AUTOMATA_RECORD;
#define MAX_STATES 3
#define MAX_EVENTS 4
/*
* Note that we define a record for every possible
* combination of state and event...
*/
AUTOMATA_RECORD state_machine[MAX_STATES][MAX_EVENTS] = {
{ 1, s0_e0_action }, { 2, s0_e1_action },
{ 3, s0_e2_action }, { 4, s0_e3_action },
{ 1, s1_e0_action }, { 2, s1_e1_action },
{ 3, s1_e2_action }, { 4, s1_e3_action },
{ 1, s2_e0_action }, { 2, s2_e1_action },
{ 3, s2_e2_action }, { 4, s2_e3_action }
};