| 120 | } |
| 121 | |
| 122 | static void |
| 123 | whoami(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 */ |
| 148 | void |