MCPcopy Create free account
hub / github.com/NetHack/NetHack / choose_windows

Function choose_windows

src/windows.c:266–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264#endif
265
266void
267choose_windows(const char *s)
268{
269 int i;
270 char *tmps = 0;
271
272 for (i = 0; winchoices[i].procs; i++) {
273 if ('+' == winchoices[i].procs->name[0])
274 continue;
275 if ('-' == winchoices[i].procs->name[0])
276 continue;
277 if (!strcmpi(s, winchoices[i].procs->name)) {
278 windowprocs = *winchoices[i].procs;
279
280 if (gl.last_winchoice && gl.last_winchoice->ini_routine)
281 (*gl.last_winchoice->ini_routine)(WININIT_UNDO);
282 if (winchoices[i].ini_routine)
283 (*winchoices[i].ini_routine)(WININIT);
284 gl.last_winchoice = &winchoices[i];
285 return;
286 }
287 }
288
289 if (!windowprocs.win_raw_print)
290 windowprocs.win_raw_print = def_raw_print;
291 if (!windowprocs.win_wait_synch)
292 /* early config file error processing routines call this */
293 windowprocs.win_wait_synch = def_wait_synch;
294
295 if (!winchoices[0].procs) {
296 raw_printf("No window types supported?");
297 nh_terminate(EXIT_FAILURE);
298 }
299 /* 50: arbitrary, no real window_type names are anywhere near that long;
300 used to prevent potential raw_printf() overflow if user supplies a
301 very long string (on the order of 1200 chars) on the command line
302 (config file options can't get that big; they're truncated at 1023) */
303#define WINDOW_TYPE_MAXLEN 50
304 if (strlen(s) >= WINDOW_TYPE_MAXLEN) {
305 tmps = (char *) alloc(WINDOW_TYPE_MAXLEN);
306 (void) strncpy(tmps, s, WINDOW_TYPE_MAXLEN - 1);
307 tmps[WINDOW_TYPE_MAXLEN - 1] = '\0';
308 s = tmps;
309 }
310#undef WINDOW_TYPE_MAXLEN
311
312 if (!winchoices[1].procs) {
313 config_error_add(
314 "Window type %s not recognized. The only choice is: %s",
315 s, winchoices[0].procs->name);
316 } else {
317 char buf[BUFSZ];
318 boolean first = TRUE;
319
320 buf[0] = '\0';
321 for (i = 0; winchoices[i].procs; i++) {
322 if ('+' == winchoices[i].procs->name[0])
323 continue;

Callers 9

mainFunction · 0.85
libnhmain.cFile · 0.85
process_optionsFunction · 0.85
MAINFunction · 0.85
mainFunction · 0.85
pcmainFunction · 0.85
optfn_windowtypeFunction · 0.85
initoptions_initFunction · 0.85
MAINFunction · 0.85

Calls 5

config_error_addFunction · 0.85
eosFunction · 0.85
raw_printfFunction · 0.70
nh_terminateFunction · 0.70
allocFunction · 0.70

Tested by

no test coverage detected