State machine manager in C.