#include "door.h" void door_init (struct door * a) { (*(a)).current = Opened_state; } void door_run (struct door * a, char * msg) { if ((((*(a)).current)==(Closed_Unlocked_state))||(((*(a)).current)==(Closed_Locked_state))) { if ((strcmp(msg, "burning"))==(0)) { (*(a)).current = Burned_final_state; return; } } if (((*(a)).current)==(Opened_state)) { if ((strcmp(msg, "close"))==(0)) { (*(a)).current = Closed_Unlocked_state; return; } if ((strcmp(msg, "burning"))==(0)) { (*(a)).current = Burned_final_state; return; } } if (((*(a)).current)==(Closed_Unlocked_state)) { if ((strcmp(msg, "lock"))==(0)) { (*(a)).current = Closed_Locked_state; return; } if ((strcmp(msg, "open"))==(0)) { (*(a)).current = Opened_state; return; } } if (((*(a)).current)==(Closed_Locked_state)) { if ((strcmp(msg, "unlock"))==(0)) { (*(a)).current = Closed_Unlocked_state; return; } } }