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

Function whoami

outdated/sys/be/bemain.c:122–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122static void
123whoami(void)
124{
125 /*
126 * Who am i? Algorithm: 1. Use name as specified in NETHACKOPTIONS
127 * 2. Use $USER or $LOGNAME (if 1. fails)
128 * The resulting name is overridden by command line options.
129 * If everything fails, or if the resulting name is some generic
130 * account like "games", "play", "player", "hack" then eventually
131 * we'll ask him.
132 */
133 char *s;
134
135 if (*svp.plname)
136 return;
137 if (s = nh_getenv("USER")) {
138 (void) strncpy(svp.plname, s, sizeof(svp.plname) - 1);
139 return;
140 }
141 if (s = nh_getenv("LOGNAME")) {
142 (void) strncpy(svp.plname, s, sizeof(svp.plname) - 1);
143 return;
144 }
145}
146
147/* normalize file name - we don't like .'s, /'s, spaces */
148void

Callers 1

MAINFunction · 0.70

Calls 1

nh_getenvFunction · 0.50

Tested by

no test coverage detected