ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

concat.c (428B)


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