File en memory streams, en lezen van input streams. Nog niet getest. Alle
[rodin/chimara.git] / src / model.c
1 #include "glk.h"
2
3 static winid_t mainwin = NULL;
4
5 void glk_main(void)
6 {
7     /* Open the main window. */
8     mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
9     if (!mainwin) {
10         /* It's possible that the main window failed to open. There's
11             nothing we can do without it, so exit. */
12         return; 
13     }
14     
15     /* Set the current output stream to print to it. */
16     glk_set_window(mainwin);
17     
18     unsigned char buffer[256];
19     int i;
20     for(i = 0; i < 256; i++)
21         buffer[i] = glk_char_to_upper(i);
22     
23     glk_put_string("Philip en Marijn zijn vet goed.\n");
24     glk_put_buffer((gchar *)buffer, 256);
25     
26     frefid_t f = 
27         glk_fileref_create_by_prompt(fileusage_TextMode, filemode_Write, 0);
28     if(f) {
29                 if( glk_fileref_does_file_exist(f) )
30                         glk_put_string("\n\nFile exists!\n");
31                 else
32                         glk_put_string("\n\nFile does not exist!\n");
33                 glk_fileref_destroy(f);
34         } else
35                 glk_put_string("\n\nCancel was clicked!\n");
36         
37         /* Bye bye */
38         glk_exit();
39 }