aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/stdin.c23
-rw-r--r--src/common/stdin.h14
2 files changed, 37 insertions, 0 deletions
diff --git a/src/common/stdin.c b/src/common/stdin.c
new file mode 100644
index 0000000..2664c3e
--- /dev/null
+++ b/src/common/stdin.c
@@ -0,0 +1,23 @@
+/*
+ * blogc: A blog compiler.
+ * Copyright (C) 2015-2016 Rafael G. Martins <rafael@rafaelmartins.eng.br>
+ *
+ * This program can be distributed under the terms of the BSD License.
+ * See the file LICENSE.
+ */
+
+#include <stdio.h>
+#include "utils.h"
+#include "stdin.h"
+
+
+// splitted in single file to make it easier to test
+char*
+bc_stdin_read(void)
+{
+ int c;
+ bc_string_t *rv = bc_string_new();
+ while (EOF != (c = fgetc(stdin)))
+ bc_string_append_c(rv, c);
+ return bc_string_free(rv, false);
+}
diff --git a/src/common/stdin.h b/src/common/stdin.h
new file mode 100644
index 0000000..ebf042d
--- /dev/null
+++ b/src/common/stdin.h
@@ -0,0 +1,14 @@
+/*
+ * blogc: A blog compiler.
+ * Copyright (C) 2015-2016 Rafael G. Martins <rafael@rafaelmartins.eng.br>
+ *
+ * This program can be distributed under the terms of the BSD License.
+ * See the file LICENSE.
+ */
+
+#ifndef _STDIN_H
+#define _STDIN_H
+
+char* bc_stdin_read(void);
+
+#endif /* _STDIN_H */