Since I'm not quite there yet writing a DSL for this, how to get the benefit of abstraction on the C level? The base abstraction should be state machines in the form of state + read() / write() functions. I think sm.h already has an abstraction for this. Work with that. EDIT: This is just Unix pipe read/write.