How transportdebuger/lib_fsm works
s21 FSM is a small reusable C library for defining and running finite-state machines. A caller creates an instance, registers states and transitions, selects an initial state, and initializes it; it then dispatches events or updates the current state. The API also supports changing and removing model entries and managing global, state, and transition contexts. The map focuses on runtime behavior; callback ordering and re-entrancy protection are documented capabilities. Source excerpts are partial, so internal relationships not shown there are omitted.
Main entry points: s21_fsm.c Event dispatch · s21_fsm.h C API
Components 9
Public API
- C API
include/s21_fsm.h
FSM Model
- FSM lifecycle
src/s21_fsm.c - State registry
src/s21_fsm.c - Transition registry
src/s21_fsm.c - FSM instance
src/s21_fsm.c
Execution
- Event dispatch
src/s21_fsm.c - State update
src/s21_fsm.c - User callbacks
Other components
- C/C++ or FFI caller
Connections 16
- C/C++ or FFI caller → C API: calls
README.md - C API → FSM lifecycle: implemented by
src/s21_fsm.c - C/C++ or FFI caller → State registry: registers states
README.md - C/C++ or FFI caller → Transition registry: registers transitions
README.md - C/C++ or FFI caller → FSM lifecycle: initializes
README.md - FSM lifecycle → FSM instance: creates
src/s21_fsm.c - State registry → FSM instance: stores states
src/s21_fsm.c - Transition registry → FSM instance: stores transitions
src/s21_fsm.c - C/C++ or FFI caller → Event dispatch: dispatches events
README.md - Event dispatch → FSM instance: reads current state
src/s21_fsm.c - Event dispatch → Transition registry: searches transitions
src/s21_fsm.c - Event dispatch → User callbacks: checks guard
src/s21_fsm.c - Event dispatch → User callbacks: runs effects
README.md - C/C++ or FFI caller → State update: updates state
README.md - State update → User callbacks: runs do callback
README.md - Event dispatch → User callbacks: runs entry and exit
README.md