int copy_buf(char *to, int pos, char *from, int len)
{
int i;
for (i=0; i<len; i++) {
to[pos] = from[i];
pos++;
}
return pos;