1 #line 488 "opt2glkc.pl"
5 #line 671 "opt2glkc.pl"
6 strid_t intd_filehandle_open(strid_t savefile, glui32 operating_id,
7 glui32 contents_id, glui32 interp_id,
13 void intd_filehandle_make(strid_t savefile)
18 glui32 intd_get_size(void)
22 #line 694 "opt2glkc.pl"
23 strid_t startup_findfile(void)
27 #line 705 "opt2glkc.pl"
28 strid_t startup_open(const char *name)
30 return n_file_name(fileusage_Data | fileusage_BinaryMode,
33 #line 717 "opt2glkc.pl"
34 static strid_t startup_wopen(const char *name)
36 return n_file_name(fileusage_Data | fileusage_BinaryMode,
37 filemode_Write, name);
39 static void code_ignore(int flag)
41 { ignore_errors = flag; }
43 static void code_fullname(int flag)
47 static void code_command(strid_t stream)
49 { if(stream) input_stream1 = stream; }
51 static void code_pirate(int flag)
55 static void code_quiet(int flag)
59 static void code_spell(int flag)
61 { do_spell_correct = flag; }
63 static void code_expand(int flag)
67 static void code_symbols(strid_t stream)
69 { if(stream) init_infix(stream); }
71 static void code_tandy(int flag)
75 static void code_transcript(strid_t stream)
77 { if(stream) set_transcript(stream); }
79 static void code_debug(int flag)
81 { enter_debugger = flag; do_check_watches = flag; }
83 static void code_prompt(const char *string)
85 { n_free(db_prompt); db_prompt = n_strdup(string); }
87 static void code_path(const char *string)
89 { n_free(search_path); search_path = n_strdup(string); }
91 static void code_autoundo(int flag)
93 { auto_save_undo = flag; }
95 static void code_stacklimit(int number)
97 { stacklimit = number; }
99 static void code_alias(const char *string)
100 #line 55 "nitfol.opt"
101 { if(string) parse_new_alias(string, FALSE); }
103 static void code_ralias(const char *string)
104 #line 58 "nitfol.opt"
105 { if(string) parse_new_alias(string, TRUE); }
107 static void code_unalias(const char *string)
108 #line 61 "nitfol.opt"
109 { if(string) remove_alias(string); }
111 static void code_random(int number)
112 #line 64 "nitfol.opt"
113 { faked_random_seed = number; }
115 static void code_mapsym(const char *string)
116 #line 67 "nitfol.opt"
117 { n_free(roomsymbol); roomsymbol = n_strdup(string); }
119 static void code_mapsize(int number)
120 #line 70 "nitfol.opt"
121 { automap_size = number; }
123 static void code_maploc(const char *string)
124 #line 73 "nitfol.opt"
125 { switch(glk_char_to_lower(*string)) { case 'a': case 't': case 'u': automap_split = winmethod_Above; break; case 'b': case 'd': automap_split = winmethod_Below; break; case 'l': automap_split = winmethod_Left; break; case 'r': automap_split = winmethod_Right; } }
127 static void code_terpnum(int number)
128 #line 76 "nitfol.opt"
129 { interp_num = number; }
131 static void code_terpver(const char *string)
132 #line 79 "nitfol.opt"
133 { if(string) { if(n_strlen(string) == 1) interp_ver = *string; else interp_ver = n_strtol(string, NULL, 10); } }
135 #line 760 "opt2glkc.pl"
136 typedef enum { option_flag, option_file, option_wfile, option_number, option_string } option_type;
137 typedef struct { const char *longname; char shortname; const char *description; option_type type; void (*int_func)(int); int defint; void (*str_func)(strid_t); strid_t defstream; void (*string_func)(const char *); const char *defstring; } option_option;
139 static option_option options[] = {
140 { "ignore", 'i', "Ignore Z-machine strictness errors", option_flag, code_ignore, 0, NULL, NULL, NULL, NULL },
141 { "fullname", 'f', "For running under Emacs or DDD", option_flag, code_fullname, 0, NULL, NULL, NULL, NULL },
142 { "command", 'x', "Read commands from this file", option_file, NULL, 0, code_command, NULL, NULL, NULL },
143 { "pirate", 'P', "Aye, matey", option_flag, code_pirate, 0, NULL, NULL, NULL, NULL },
144 { "quiet", 'q', "Do not print introductory messages", option_flag, code_quiet, 1, NULL, NULL, NULL, NULL },
145 { "spell", '-', "Perform spelling correction", option_flag, code_spell, 1, NULL, NULL, NULL, NULL },
146 { "expand", '-', "Expand one letter abbreviations", option_flag, code_expand, 1, NULL, NULL, NULL, NULL },
147 { "symbols", 's', "Specify symbol file for game", option_file, NULL, 0, code_symbols, NULL, NULL, NULL },
148 { "tandy", 't', "Censors some Infocom games", option_flag, code_tandy, 0, NULL, NULL, NULL, NULL },
149 { "transcript", 'T', "Write transcript to this file", option_wfile, NULL, 0, code_transcript, NULL, NULL, NULL },
150 { "debug", 'd', "Enter debugger immediatly", option_flag, code_debug, 0, NULL, NULL, NULL, NULL },
151 { "prompt", '-', "Specify debugging prompt", option_string, NULL, 0, NULL, NULL, code_prompt, "(nitfol) " },
152 { "path", '-', "Look for games in this directory", option_string, NULL, 0, NULL, NULL, code_path, NULL },
153 { "autoundo", '-', "Ensure '@save_undo' is called every turn", option_flag, code_autoundo, 1, NULL, NULL, NULL, NULL },
154 { "stacklimit", 'S', "Exit when the stack is this deep", option_number, code_stacklimit, 0, NULL, NULL, NULL, NULL },
155 { "alias", 'a', "Specify an alias", option_string, NULL, 0, NULL, NULL, code_alias, NULL },
156 { "ralias", '-', "Specify an recursive alias", option_string, NULL, 0, NULL, NULL, code_ralias, NULL },
157 { "unalias", '-', "Remove an alias", option_string, NULL, 0, NULL, NULL, code_unalias, NULL },
158 { "random", 'r', "Set random seed", option_number, code_random, 0, NULL, NULL, NULL, NULL },
159 { "mapsym", '-', "Specify mapping glyphs", option_string, NULL, 0, NULL, NULL, code_mapsym, "*udb@UDB+" },
160 { "mapsize", '-', "Specify map size", option_number, code_mapsize, 12, NULL, NULL, NULL, NULL },
161 { "maploc", '-', "Specify map location", option_string, NULL, 0, NULL, NULL, code_maploc, "above" },
162 { "terpnum", '-', "Specify interpreter number", option_number, code_terpnum, 2, NULL, NULL, NULL, NULL },
163 { "terpver", '-', "Specify interpreter version", option_string, NULL, 0, NULL, NULL, code_terpver, "N" }
166 #line 811 "opt2glkc.pl"
167 static void set_defaults(void)
170 for(n = 0; n < sizeof(options) / sizeof(*options); n++) {
171 if(options[n].int_func)
172 options[n].int_func(options[n].defint);
173 if(options[n].str_func)
174 options[n].str_func(options[n].defstream);
175 if(options[n].string_func)
176 options[n].string_func(options[n].defstring);
180 #line 910 "opt2glkc.pl"
181 static void show_help(void)
184 printf("Usage: nitfol [OPTIONS] gamefile\n");
185 for(n = 0; n < sizeof(options) / sizeof(*options); n++) {
186 if(options[n].shortname != '-')
187 printf(" -%c, ", options[n].shortname);
190 printf("-%-15s %s\n", options[n].longname, options[n].description);
194 #line 928 "opt2glkc.pl"
195 static BOOL parse_commands(int argc, char **argv)
200 for(i = 1; i < argc; i++) {
203 const char *p = argv[i];
210 if(n_strncmp(p, "no-", 3) == 0) {
215 if(n_strcasecmp(p, "help") == 0) {
219 if(n_strcasecmp(p, "version") == 0) {
220 printf("nitfol version %d.%d\n", NITFOL_MAJOR, NITFOL_MINOR);
224 for(n = 0; n < sizeof(options) / sizeof(*options); n++) {
225 if((n_strlen(p) == 1 && *p == options[n].shortname) ||
226 n_strcmp(options[n].longname, p) == 0) {
229 switch(options[n].type) {
231 options[n].int_func(flag);
236 options[n].str_func(startup_open(argv[i]));
241 options[n].str_func(startup_wopen(argv[i]));
246 options[n].int_func(n_strtol(argv[i], NULL, 0));
251 options[n].string_func(argv[i]);
261 strid_t s = startup_open(argv[i]);
264 if(!game_use_file(s))
272 #line 504 "opt2glkc.pl"
273 void shift_string_left(char *str)
275 int len = strlen(str);
277 for(i = 0; i < len; i++)
281 int winglk_startup_code(void)
284 char *commandline = strdup(GetCommandLine());
285 char **argv = (char **) n_malloc(sizeof(char *) * strlen(commandline));
290 while(*commandline) {
291 while(*commandline && isspace(*commandline))
294 argv[argc++] = commandline;
296 while(*commandline && !isspace(*commandline)) {
297 if(*commandline == '"') {
298 shift_string_left(commandline);
299 while(*commandline && *commandline != '"')
301 shift_string_left(commandline);
312 status = parse_commands(argc, argv);
317 winglk_app_set_name("nitfol");
318 winglk_window_set_title("nitfol");