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

Function verify_term

sys/vms/vmsunix.c:287–320  ·  view source on GitHub ↗

Support for VT420 was added to VMS in version V5.4, but as of V5.5-2 VAXCRTL still doesn't handle it and puts TERM=undefined into the environ[] array. getenv("TERM") will return "undefined" instead of something sensible. Even though that's finally fixed in V6.0, site defined terminals also return "undefined" so query SMG's TERMTABLE instead of just checking VMS's device-type value

Source from the content-addressed store, hash-verified

285 Called by verify_termcap() for convenience.
286 */
287static char *
288verify_term(void)
289{
290 char *term = getenv("NETHACK_TERM");
291 if (!term)
292 term = getenv("HACK_TERM");
293 if (!term)
294 term = getenv("EMACS_TERM");
295 if (!term)
296 term = getenv("TERM");
297 if (!term || !*term || !strcmpi(term, "undefined")
298 || !strcmpi(term, "unknown")) {
299 static char smgdevtyp[31 + 1]; /* size is somewhat arbitrary */
300 static char dev_tty[] = "TT:";
301 static $DESCRIPTOR(smgdsc, smgdevtyp);
302 static $DESCRIPTOR(tt, dev_tty);
303 unsigned short dvicode = DVI$_DEVTYPE;
304 unsigned long devtype = 0L, termtab = 0L;
305
306 (void) lib$getdvi(&dvicode, (unsigned short *) 0, &tt, &devtype,
307 (genericptr_t) 0, (unsigned short *) 0);
308
309 if (devtype && vms_ok(smg$init_term_table_by_type(&devtype, &termtab,
310 &smgdsc))) {
311 char *p = &smgdevtyp[smgdsc.dsc$w_length];
312 /* strip trailing blanks */
313 while (p > smgdevtyp && *--p == ' ')
314 *p = '\0';
315 /* (void) smg$del_term_table(); */
316 term = smgdevtyp;
317 }
318 }
319 return term;
320}
321
322/*
323 Figure out whether the termcap code will find a termcap file; if not,

Callers 1

verify_termcapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected