1 Source: extracted from gargoyle-2008-12-25-sources.zip
2 Upstream: Gentoo-specific hack
3 Reason: use Gargoyle extension functions to set a nice window title;
4 also print error messages in a possibly nicer way
6 --- git-1.2.2/git_unix.c~ 2009-01-21 18:12:38.000000000 +0000
7 +++ git-1.2.2/git_unix.c 2009-01-24 18:16:14.000000000 +0000
10 #include <glkstart.h> // This comes with the Glk library.
18 #define CACHE_SIZE (256 * 1024L)
19 #define UNDO_SIZE (512 * 1024L)
25 +void fatalError (const char * s)
30 + win = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
31 + glk_set_window(win);
33 + /* pray that this goes somewhere reasonable... */
34 + glk_put_string("\n*** fatal error: ");
35 + glk_put_string((char*)s);
36 + glk_put_string(" ***\n");
42 void fatalError (const char * s)
44 fprintf (stderr, "*** fatal error: %s ***\n", s);
51 // Fast loader that uses some fancy Unix features.
53 const char * gFilename = 0;
54 +char * gStartupError = 0;
56 int glkunix_startup_code(glkunix_startup_t *data)
61 + sprintf(buf, "Git %d.%d.%d", GIT_MAJOR, GIT_MINOR, GIT_PATCH);
62 + garglk_set_program_name(buf);
63 + sprintf(buf, "Git %d.%d.%d by Iain Merrick\n",
64 + GIT_MAJOR, GIT_MINOR, GIT_PATCH);
65 + garglk_set_program_info(buf);
71 - printf ("usage: git gamefile.ulx\n");
73 + gStartupError = "No file given";
80 + s = strrchr(data->argv[1], '\\');
81 + if (s) garglk_set_story_name(s+1);
82 + s = strrchr(data->argv[1], '/');
83 + if (s) garglk_set_story_name(s+1);
87 gFilename = data->argv[1];
95 + fatalError(gStartupError);
97 file = open (gFilename, O_RDONLY);
103 if (info.st_size < 256)
105 - fprintf (stderr, "This is too small to be a glulx file.\n");
108 + fatalError("This is too small to be a glulx file.");
110 ptr = mmap (NULL, info.st_size, PROT_READ, MAP_PRIVATE, file, 0);
111 if (ptr == MAP_FAILED)
116 git (ptr, info.st_size, CACHE_SIZE, UNDO_SIZE);
117 munmap ((void*) ptr, info.st_size);
123 + sprintf(errmsg, "git: %s", strerror(errno));
124 + fatalError(errmsg);
128 // Generic loader that should work anywhere.
131 +char * gStartupError = 0;
133 int glkunix_startup_code(glkunix_startup_t *data)
138 + sprintf(buf, "Git %d.%d.%d", GIT_MAJOR, GIT_MINOR, GIT_PATCH);
139 + garglk_set_program_name(buf);
140 + sprintf(buf, "Git %d.%d.%d by Iain Merrick\n",
141 + GIT_MAJOR, GIT_MINOR, GIT_PATCH);
142 + garglk_set_program_info(buf);
148 - printf ("usage: git gamefile.ulx\n");
150 + gStartupError = "No file given";
157 + s = strrchr(data->argv[1], '\\');
158 + if (s) garglk_set_story_name(s+1);
159 + s = strrchr(data->argv[1], '/');
160 + if (s) garglk_set_story_name(s+1);
164 gStream = glkunix_stream_open_pathname ((char*) data->argv[1], 0, 0);
171 + fatalError(gStartupError);
174 fatalError ("could not open game file");
178 gitWithStream (gStream, CACHE_SIZE, UNDO_SIZE);