aboutsummaryrefslogtreecommitdiff
path: root/libstorycode/storycode.c
diff options
context:
space:
mode:
Diffstat (limited to 'libstorycode/storycode.c')
-rw-r--r--libstorycode/storycode.c42
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;
+}