diff options
author | Thomas White <taw@bitwiz.org.uk> | 2014-09-08 20:57:24 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2014-09-08 20:57:24 +0200 |
commit | cba13eb85af0714aa7ffa605773215baf5833612 (patch) | |
tree | 4295d49db28d642de9c17c0f4a209a11a87b39e5 /src/sc_parse.c | |
parent | cf20a05e3f18d11ded94a74b072c963b3174e168 (diff) |
Insert furniture
Diffstat (limited to 'src/sc_parse.c')
-rw-r--r-- | src/sc_parse.c | 30 |
1 files changed, 30 insertions, 0 deletions
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. */ |