From 70bfc710f37bd3f134fa201299efa7bdf098a399 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 1 Jul 2014 23:40:35 +0200 Subject: Restore saving --- src/sc_parse.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/sc_parse.c') diff --git a/src/sc_parse.c b/src/sc_parse.c index 51f55de..510f097 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -147,6 +147,41 @@ void sc_block_free(SCBlock *bl) } +void save_sc_block(FILE *fh, const SCBlock *bl) +{ + while ( bl != NULL ) { + + if ( bl->name == NULL ) { + fprintf(fh, "%s", bl->contents); + } else { + + fprintf(fh, "\\%s", bl->name); + if ( bl->options != NULL ) { + fprintf(fh, "[%s]", bl->options); + } + if ( (bl->contents != NULL) || (bl->child != NULL) ) { + fprintf(fh, "{"); + } + if ( bl->contents != NULL ) { + fprintf(fh, "%s", bl->contents); + } + + } + + if ( bl->child != NULL ) { + save_sc_block(fh, bl->child); + } + + if ( (bl->name != NULL) && + ((bl->contents != NULL) || (bl->child != NULL)) ) { + fprintf(fh, "}"); + } + + bl = bl->next; + } +} + + static void recursive_show_sc_blocks(const char *prefix, const SCBlock *bl) { while ( bl != NULL ) { -- cgit v1.2.3