summaryrefslogtreecommitdiff
path: root/src/reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reader.c')
-rw-r--r--src/reader.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/reader.c b/src/reader.c
new file mode 100644
index 0000000..787f785
--- /dev/null
+++ b/src/reader.c
@@ -0,0 +1,53 @@
+
+#define RAW_BUFFER_SIZE 16384
+#define BUFFER_SIZE (RAW_BUFFER_SIZE*2) /* Should be enough for decoding
+ the whole raw buffer. */
+
+/*
+ * Ensure that the buffer contains at least length characters.
+ * Return 1 on success, 0 on failure.
+ */
+
+int
+yaml_parser_update_reader(yaml_parser_t *parser, size_t length)
+{
+ /* If the EOF flag is set, do nothing. */
+
+ if (parser->eof)
+ return 1;
+
+ /* First, let us check that the buffers are allocated. */
+
+ if (!parser->buffer) {
+ parser->buffer = yaml_malloc(BUFFER_SIZE);
+ if (!parser->buffer) {
+ parser->error = YAML_MEMORY_ERROR;
+ return 0;
+ }
+ parser->buffer_size = BUFFER_SIZE;
+ parser->buffer_pointer = parser->buffer;
+ parser->buffer_length = 0;
+ }
+
+ if (!parser->raw_buffer) {
+ parser->raw_buffer = yaml_malloc(RAW_BUFFER_SIZE);
+ if (!parser->raw_buffer) {
+ parser->error = YAML_MEMORY_ERROR;
+ return 0;
+ }
+ parser->raw_buffer_size = RAW_BUFFER_SIZE;
+ }
+
+ /* Next, determine the input encoding. */
+
+ if (!parser->encoding) {
+ if (!yaml_parser_determine_encoding(parser))
+ return 0;
+ }
+
+ /* more... */
+
+}
+
+
+