First commit of buffering.[ch], based on testplugin.c