Code:
enum states { STATE_1, STATE_2, STATE_3 MAX_STATES } current_state;
enum events { EVENT_1, MAX_EVENTS } new_event;
void action_s1_e1 (struct call_info_s *p);
void action_s2_e1 (struct call_info_s *p);
void action_s3_e1 (struct call_info_s *p);
void (*const state_table [MAX_STATES][MAX_EVENTS]) (void) = {
{ action_s1_e1},
{ action_s2_e1},
{ action_s3_e1},
};
------------------------------------------------------------------------
Code:
new_event = get_new_event();
if (((new_event >= 0) && (new_event < MAX_EVENTS))
&& ((current_state >= 0) && (current_state < MAX_STATES))) {
state_table [current_state][new_event]();
} else {
}
------------------------------------------------------------------------
Code:
void action_s1_e1 (struct call_info_s *call_info)
{
dosomething(call_info);
}
I am trying to get this state machine code that i found on the net to work. At this step I am trying to figure out how to pass argument through the lookup table.
Code:
void (*const state_table [MAX_STATES][MAX_EVENTS]) (void) = {
{ action_s1_e1},
In the example action prototypes defines argumenttype for action_s1_e1(). stable_table prototype defines the functions to be called. What do I need to do to include passing arguments. For example dosomething function receiving struct pointer