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

Function main

sys/vms/vmsmain.c:38–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36static char *progname = (char *) 0;
37
38int
39main(int argc, char *argv[])
40{
41 NHFILE *nhfp;
42#ifdef CHDIR
43 char *dir;
44#endif
45 boolean resuming = FALSE; /* assume new game */
46
47#ifdef SECURE /* this should be the very first code executed */
48 privoff();
49 fflush((FILE *) 0); /* force stdio to init itself */
50 privon();
51#endif
52
53 early_init(argc, argv);
54
55 atexit(byebye);
56 /* vms_basename(,FALSE) strips device, directory, suffix, and version;
57 the result is returned in a static buffer so we make a copy that
58 isn't at risk of getting clobbered by core's handling of DEBUGFILES */
59 progname = dupstr(vms_basename(argv[0], FALSE));
60 gh.hname = progname;
61 svh.hackpid = getpid();
62 (void) umask(0);
63
64 choose_windows(DEFAULT_WINDOW_SYS);
65
66#ifdef CHDIR /* otherwise no chdir() */
67 /*
68 * See if we must change directory to the playground.
69 * (Perhaps hack is installed with privs and playground is
70 * inaccessible for the player.)
71 * The logical name HACKDIR is overridden by a
72 * -d command line option (must be the first option given)
73 */
74 dir = nh_getenv("NETHACKDIR");
75 if (!dir)
76 dir = nh_getenv("HACKDIR");
77#endif
78 if (argc > 1) {
79 if (argcheck(argc, argv, ARG_VERSION) == 2)
80 exit(EXIT_SUCCESS);
81
82 if (argcheck(argc, argv, ARG_SHOWPATHS) == 2) {
83 gd.deferred_showpaths = TRUE;
84 return 0;
85 }
86 if (argcheck(argc, argv, ARG_DEBUG) == 1) {
87 argc--;
88 argv++;
89 }
90#ifdef CHDIR
91 if (argc > 1 && !strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') {
92 /* avoid matching "-dec" for DECgraphics; since the man page
93 * says -d directory, hope nobody's using -desomething_else
94 */
95 argc--;

Callers

nothing calls this directly

Calls 15

privoffFunction · 0.85
fflushFunction · 0.85
privonFunction · 0.85
early_initFunction · 0.85
atexitFunction · 0.85
dupstrFunction · 0.85
choose_windowsFunction · 0.85
argcheckFunction · 0.85
initoptionsFunction · 0.85
prscoreFunction · 0.85
set_playmodeFunction · 0.85
plnamesuffixFunction · 0.85

Tested by

no test coverage detected