morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base
Log | Files | Refs

concat.c (423B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdio.h>
      3 #include <unistd.h>
      4 
      5 #include "../text.h"
      6 #include "../util.h"
      7 
      8 void
      9 concat(FILE *fp1, const char *s1, FILE *fp2, const char *s2)
     10 {
     11 	char buf[BUFSIZ];
     12 	ssize_t n;
     13 
     14 	while ((n = read(fileno(fp1), buf, sizeof buf)) > 0) {
     15 		if (write(fileno(fp2), buf, n) != n)
     16 			eprintf("%s: write error:", s2);
     17 	}
     18 	if (n < 0)
     19 		eprintf("%s: read error:", s1);
     20 }