morpheus-base

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

writerune.c (415B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <errno.h>
      3 #include <stdio.h>
      4 #include <string.h>
      5 #include <stdlib.h>
      6 
      7 #include "../utf.h"
      8 
      9 void
     10 writerune(const char *file, FILE *fp, Rune *r)
     11 {
     12 	char buf[UTFmax];
     13 	int n;
     14 
     15 	if ((n = runetochar(buf, r)) > 0) {
     16 		fwrite(buf, n, 1, fp);
     17 		if (ferror(fp)) {
     18 			fprintf(stderr, "%s: write error: %s\n",
     19 				file, strerror(errno));
     20 			exit(1);
     21 		}
     22 	}
     23 }