From cba13eb85af0714aa7ffa605773215baf5833612 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 8 Sep 2014 20:57:24 +0200 Subject: Insert furniture --- src/sc_parse.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/sc_parse.c') diff --git a/src/sc_parse.c b/src/sc_parse.c index 7218ec9..f30d6b0 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -132,6 +132,36 @@ SCBlock *sc_block_append(SCBlock *bl, char *name, char *opt, char *contents, } +/* Insert a new block at the end of the chain starting 'bl'. + * "name", "options" and "contents" will not be copied. Returns the block just + * created, or NULL on error. */ +SCBlock *sc_block_append_end(SCBlock *bl, char *name, char *opt, char *contents) +{ + SCBlock *bln = sc_block_new(); + + if ( bln == NULL ) return NULL; + + while ( bl->next != NULL ) { + bl = bl->next; + }; + + bln->name = name; + bln->options = opt; + bln->contents = contents; + bln->child = NULL; + bln->next = NULL; + + if ( bl == NULL ) { + bln->prev = NULL; + } else { + bl->next = bln; + bln->prev = bl; + } + + return bln; +} + + /* Append a new block to the chain inside "parent". * "name", "options" and "contents" will not be copied. Returns the block just * created, or NULL on error. */ -- cgit v1.2.3