1 /* unixstrt.c: Unix-specific code for Glulxe.
2 Designed by Andrew Plotkin <erkyrath@eblong.com>
3 http://eblong.com/zarf/glulx/index.html
8 #include "glkstart.h" /* This comes with the Glk library. */
10 /* The only command-line argument is the filename. */
11 glkunix_argumentlist_t glkunix_arguments[] = {
12 { "", glkunix_arg_ValueFollows, "filename: The game file to load." },
13 { NULL, glkunix_arg_End, NULL }
16 int glkunix_startup_code(glkunix_startup_t *data)
18 /* It turns out to be more convenient if we return TRUE from here, even
19 when an error occurs, and display an error in glk_main(). */
21 unsigned char buf[12];
24 if (data->argc <= 1) {
25 init_err = "You must supply the name of a game file.";
30 gamefile = glkunix_stream_open_pathname(cx, FALSE, 1);
32 init_err = "The game file could not be opened.";
37 /* Now we have to check to see if it's a Blorb file. */
39 glk_stream_set_position(gamefile, 0, seekmode_Start);
40 res = glk_get_buffer_stream(gamefile, (char *)buf, 12);
42 init_err = "The data in this stand-alone game is too short to read.";
46 if (buf[0] == 'G' && buf[1] == 'l' && buf[2] == 'u' && buf[3] == 'l') {
47 locate_gamefile(FALSE);
50 else if (buf[0] == 'F' && buf[1] == 'O' && buf[2] == 'R' && buf[3] == 'M'
51 && buf[8] == 'I' && buf[9] == 'F' && buf[10] == 'R' && buf[11] == 'S') {
52 locate_gamefile(TRUE);
56 init_err = "This is neither a Glulx game file nor a Blorb file "
57 "which contains one.";