+/* If it turns out that we need to make this conditional on config.sh derived
+ values, it might be easier just to rip out the use of strerrer(). */
+#include <string.h>
+/* If a platform doesn't support errno.h, it's probably so strange that
+ "hello world" won't port easily to it. */
+#include <errno.h>
+
+void output_block_to_file(const char *progname, const char *filename,
+ const char *block, size_t count) {
+ FILE *const out = fopen(filename, "w");
+
+ if (!out) {
+ fprintf(stderr, "%s: Could not open '%s': %s\n", progname, filename,
+ strerror(errno));
+ exit(1);
+ }
+
+ fputs("{\n ", out);
+ while (count--) {
+ fprintf(out, "%d", *block);
+ block++;
+ if (count) {
+ fputs(", ", out);
+ if (!(count & 15)) {
+ fputs("\n ", out);
+ }
+ }
+ }
+ fputs("\n}\n", out);
+
+ if (fclose(out)) {
+ fprintf(stderr, "%s: Could not close '%s': %s\n", progname, filename,
+ strerror(errno));
+ exit(1);
+ }
+}
+