aboutsummaryrefslogtreecommitdiff
path: root/src/sc_parse.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2018-04-29 21:01:08 +0200
committerThomas White <taw@bitwiz.me.uk>2018-04-29 21:01:08 +0200
commit447184ed2c2cdfdc91b36e46b0a46db1e61f29b1 (patch)
tree00cb64c8dbf75a4ba1b4875f3deb47cf9d17d12a /src/sc_parse.c
parent9eb793a14ed92f0eaaa57fa6bb09d35a51f4c8e2 (diff)
Add serialise_sc_block_chain()
Diffstat (limited to 'src/sc_parse.c')
-rw-r--r--src/sc_parse.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/sc_parse.c b/src/sc_parse.c
index a13c876..b66dc1f 100644
--- a/src/sc_parse.c
+++ b/src/sc_parse.c
@@ -337,6 +337,7 @@ void sc_block_free(SCBlock *bl)
}
+/* Serialise one block (including children) */
char *serialise_sc_block(const SCBlock *bl)
{
char *a;
@@ -412,6 +413,36 @@ char *serialise_sc_block(const SCBlock *bl)
}
+/* Serialise an entire chain of blocks */
+char *serialise_sc_block_chain(const SCBlock *bl)
+{
+ char *a = strdup("");
+ size_t len = 1;
+
+ if ( a == NULL ) return NULL;
+
+ while ( bl != NULL ) {
+
+ char *c = serialise_sc_block(bl);
+ if ( c == NULL ) {
+ free(a);
+ return NULL;
+ }
+
+ len += strlen(c);
+ a = realloc(a, len);
+ if ( a == NULL ) return NULL;
+ strcat(a, c);
+ free(c);
+
+ bl = bl->next;
+
+ }
+
+ return a;
+}
+
+
int save_sc_block(GOutputStream *fh, const SCBlock *bl)
{
while ( bl != NULL ) {