summary refs log tree commit diff
path: root/strio.h
diff options
context:
space:
mode:
Diffstat (limited to 'strio.h')
-rw-r--r--strio.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/strio.h b/strio.h
new file mode 100644
index 0000000..4dbdd74
--- /dev/null
+++ b/strio.h
@@ -0,0 +1,25 @@
+#ifndef STRIO_H
+#define STRIO_H
+
+/* optional I/O routines for strings */
+
+#include "str.h"
+
+string read_whole_file(FILE *f);
+
+#ifdef STDWRM_STR_IMPL
+
+string read_whole_file(FILE *f) {
+	char chunk[256];
+	string s;
+	DA_INIT(s);
+	while (!feof(f)) {
+		size_t n = fread(chunk, 1, sizeof chunk, f);
+		DA_PUSH_MULT(s, chunk, n);
+	}
+	DA_PUSH(s, 0);
+	return s;
+}
+
+#endif
+#endif