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

Function sys_early_init

src/sys.c:20–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18struct sysopt_s sysopt;
19
20void
21sys_early_init(void)
22{
23 const char *p;
24
25 /* Don't assume that these are not already set, and that it is
26 * safe to dupstr() without orphaning any pointers. Check them. */
27
28 sysopt.support = (char *) 0;
29 sysopt.recover = (char *) 0;
30#ifdef SYSCF
31 sysopt.wizards = (char *) 0;
32#else
33 if (sysopt.wizards)
34 free((genericptr_t) sysopt.wizards);
35 sysopt.wizards = dupstr(WIZARD_NAME);
36#endif
37
38 if ((p = getenv("DEBUGFILES")) != 0) {
39 if (sysopt.debugfiles)
40 free((genericptr_t) sysopt.debugfiles);
41 sysopt.debugfiles = dupstr(p);
42 sysopt.env_dbgfl = 1; /* prevent sysconf processing from overriding */
43 } else {
44#if defined(SYSCF) || !defined(DEBUGFILES)
45 sysopt.debugfiles = (char *) 0;
46#else
47 if (sysopt.debugfiles)
48 free((genericptr_t) sysopt.debugfiles);
49 sysopt.debugfiles = dupstr(DEBUGFILES);
50#endif
51 sysopt.env_dbgfl = 0;
52 }
53
54#ifdef DUMPLOG
55 sysopt.dumplogfile = (char *) 0;
56#endif
57 sysopt.shellers = (char *) 0;
58 sysopt.explorers = (char *) 0;
59 sysopt.genericusers = (char *) 0;
60 sysopt.msghandler = (char *) 0;
61 sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */
62 sysopt.bones_pools = 0;
63 sysopt.livelog = LL_NONE;
64
65 /* record file */
66 sysopt.persmax = max(PERSMAX, 1);
67 sysopt.entrymax = max(ENTRYMAX, 10);
68 sysopt.pointsmin = max(POINTSMIN, 1);
69 sysopt.pers_is_uid = PERS_IS_UID;
70 sysopt.tt_oname_maxrank = 10;
71
72 /* sanity checks */
73 if (sysopt.pers_is_uid != 0 && sysopt.pers_is_uid != 1)
74 panic("config error: PERS_IS_UID must be either 0 or 1");
75
76#ifdef PANICTRACE
77 /* panic options */

Callers 1

early_initFunction · 0.85

Calls 3

dupstrFunction · 0.85
sysopt_seduce_setFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected