diff options
author | Thomas White <taw@bitwiz.org.uk> | 2014-07-01 23:40:35 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2014-07-01 23:40:35 +0200 |
commit | 70bfc710f37bd3f134fa201299efa7bdf098a399 (patch) | |
tree | dfb3abae8447166829eadd733d14cdacdf54d518 /src/sc_parse.c | |
parent | 2c6cd610074fc9d0ed3050d4bfa39b5031de876a (diff) |
Restore saving
Diffstat (limited to 'src/sc_parse.c')
-rw-r--r-- | src/sc_parse.c | 35 |
1 files changed, 35 insertions, 0 deletions
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 ) { |