lib/cpp: split input and output protocols