aboutsummaryrefslogtreecommitdiff
path: root/src/sc_parse.c
diff options
context:
space:
mode:
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 ) {