Debian Codegraph @

terps/git/git_mac.c

raw symbols SCIP
1 /* macglk_startup.c: Sample Mac-specific startup code.
2 Designed by Andrew Plotkin <[email protected]>
3 http://www.eblong.com/zarf/glk/index.html
4
5 This is an extremely simple piece of startup code; it doesn't
6 do anything.
7 */
8
9 #include "glk.h"
10 #include "macglk_startup.h"
11 #include "git.h"
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <assert.h>
15
16 static strid_t mac_gamefile;
17
18 Boolean macglk_startup_code(macglk_startup_t *data)
19 {
20 OSType mac_gamefile_types[] = { 'UlxG', 'IFRS' };
21
22 data->startup_model = macglk_model_ChooseOrBuiltIn;
23 data->app_creator = 'MGit' /* 'niTf' */;
24 data->gamefile_types = mac_gamefile_types;
25 data->num_gamefile_types = sizeof(mac_gamefile_types) / sizeof(*mac_gamefile_types);
26 data->savefile_type = 'IFZS' /* 'IFZS' */;
27 data->datafile_type = 'UlxD' /* 'ZipD' */;
28 data->gamefile = &mac_gamefile;
29 /* data->when_selected = mac_whenselected;
30 data->when_builtin = mac_whenbuiltin;*/
31 return TRUE;
32 }
33
34 #define CACHE_SIZE (256 * 1024L)
35 #define UNDO_SIZE (2 * 1024 * 1024L)
36
37 void glk_main ()
38 {
39 strid_t file = mac_gamefile;
40 size_t size, remaining;
41 git_uint8 * data;
42 git_uint8 * ptr;
43
44 glk_stream_set_position (file, 0, seekmode_End);
45 size = glk_stream_get_position (file);
46 glk_stream_set_position (file, 0, seekmode_Start);
47
48 data = malloc (size);
49
50 ptr = data;
51 remaining = size;
52 while (remaining > 0)
53 {
54 size_t n = glk_get_buffer_stream (file, (char *) ptr, remaining);
55 if (n == 0)
56 {
57 printf ("Can't read file.");
58 exit(1);
59 }
60 remaining -= n;
61 ptr += n;
62 }
63 glk_stream_close (file, NULL);
64
65 git (data, size, CACHE_SIZE, UNDO_SIZE);
66 }
67
68 void __msl_assertion_failed (const char * cond, const char * file, const char * func, int line)
69 {
70 fprintf (stderr, "*** fatal error: assertion failed in function \"%s\" (%s:%d) ***\n", func, file, line);
71 fprintf (stderr, "*** assert(%s) ***\n", cond);
72 exit (1);
73 }
74
75 void fatalError (const char * s)
76 {
77 fprintf (stderr, "*** fatal error: %s ***\n", s);
78 exit (1);
79 }