#include #include #include /* * buftest.c - tests copying files with varying buffer sizes * * usage: reads from stdin to stdout but takes buffer size as arg */ main(int ac, char **av) { char *buf; int buflen; int n; if ( ac == 1 || ( buflen = atoi(av[1])) <= 0 ){ buflen = 512; } buf = (char *) malloc(buflen); while( (n = read(0, buf, buflen)) > 0 ){ if ( write(1, buf, n) != n ) break; } }