From 13be5bd50238daa2be6b42104ba20aeea427655b Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Tue, 4 Oct 2016 23:58:10 +0200 Subject: git-receiver: splitted and tested pre-receive input parser --- src/common/stdin.c | 23 +++++++++++++++++++++++ src/common/stdin.h | 14 ++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/common/stdin.c create mode 100644 src/common/stdin.h (limited to 'src/common') 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 + * + * This program can be distributed under the terms of the BSD License. + * See the file LICENSE. + */ + +#include +#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 + * + * 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 */ -- cgit v1.2.3-18-g5258