unsigned char buf[128], c, i = 0;

while (i < (sizeof(buf)-1) && 1 == read(fd, &buf+i, 1) && buf[i++] != '\n');