diff options
author | Thomas White <taw@bitwiz.me.uk> | 2019-04-03 00:03:02 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2019-04-03 00:03:02 +0200 |
commit | 65b623afe376e0331e106f00f487b755d555b7d1 (patch) | |
tree | ac74d02c668b8fc51d8ab5918c98616c26249af0 /libstorycode/storycode.c | |
parent | 50f6327a047673818e9b121ae9128b54c92cb90f (diff) |
Stylesheet saving skeleton
Diffstat (limited to 'libstorycode/storycode.c')
-rw-r--r-- | libstorycode/storycode.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libstorycode/storycode.c b/libstorycode/storycode.c index b34785d..7fe46d7 100644 --- a/libstorycode/storycode.c +++ b/libstorycode/storycode.c @@ -27,10 +27,13 @@ #include <stdlib.h> #include <string.h> +#include <gio/gio.h> #include "narrative.h" #include "slide.h" #include "stylesheet.h" +#include "narrative_priv.h" +#include "slide_priv.h" #include "storycode_parse.h" #include "storycode_lex.h" @@ -48,3 +51,42 @@ Narrative *storycode_parse_presentation(const char *sc) return parse_ctx.n; } + + +static int write_string(GOutputStream *fh, char *str) +{ + gssize r; + GError *error = NULL; + r = g_output_stream_write(fh, str, strlen(str), NULL, &error); + if ( r == -1 ) { + fprintf(stderr, "Write failed: %s\n", error->message); + return 1; + } + return 0; +} + + +int storycode_write_presentation(Narrative *n, GOutputStream *fh) +{ + int i; + char *ss_text; + + /* Stylesheet */ + ss_text = stylesheet_serialise(n->stylesheet); + if ( ss_text == NULL ) return 1; + if ( write_string(fh, ss_text) ) return 1; + + for ( i=0; i<n->n_items; i++ ) { + + gssize r; + GError *error = NULL; + char *a = "Hello"; + + r = g_output_stream_write(fh, a, strlen(a), NULL, &error); + if ( r == -1 ) { + fprintf(stderr, "Write failed: %s\n", error->message); + return 1; + } + } + return 0; +} |