#include <stdio.h>
#include "uici.h"
#define BLKSIZE 1024

int read_and_write(int fromfd, int tofd) {
   char buf[BLKSIZE];
   int bytes_read;
   int bytes_written;

   if ((bytes_read = u_read(fromfd, buf, BLKSIZE)) < 0) {
      perror("Error reading fromfd");
      return -1;
   } else if (bytes_read == 0) {
      return 0;
   } else if ((bytes_written = u_write(tofd, buf, bytes_read)) < 0) {
      perror("Error writing to tofd");
      return -1;
   } else
      return bytes_written;
}


