channel: Refactor channel_write_common() code.
channel: Refactor channel_write_common() code.

This makes it easier to read and easier to debug.

sebadoom/libssh,taikoo/libssh,bigcat26/libssh-mod,nviennot/libssh,taikoo/libssh,Distrotech/libssh,wangshawn/libssh,mwgoldsmith/libssh,DouglasHeriot/libssh,wangshawn/libssh,kedazo/libssh,wangshawn/libssh,robxu9/libssh,wangshawn/libssh,mwgoldsmith/libssh,nviennot/libssh,mwgoldsmith/ssh,mwgoldsmith/libssh,bigcat26/libssh-mod,kedazo/libssh,mwgoldsmith/libssh,kedazo/libssh,Distrotech/libssh,pouete/libssh,elastichosts/libssh,robxu9/libssh,Distrotech/libssh,sebadoom/libssh,robxu9/libssh,DouglasHeriot/libssh,Distrotech/libssh,bigcat26/libssh-mod,pouete/libssh,mwgoldsmith/ssh,nviennot/libssh,DouglasHeriot/libssh,mwgoldsmith/ssh,pouete/libssh,taikoo/libssh,mwgoldsmith/ssh,robxu9/libssh,DouglasHeriot/libssh,bigcat26/libssh-mod,sebadoom/libssh,elastichosts/libssh,nviennot/libssh,sebadoom/libssh,elastichosts/libssh,pouete/libssh,taikoo/libssh,kedazo/libssh