sys/vms/*.c - mostly reformatting

I'm not sure whether basic formatting cleanup belongs in 3.6.1, but
there are also a couple of strings that got split and require the
implicit concatenation of adjacent string literals introduced with
C89/C90.  The code itself compiles with pre-ANSI compilers, or at
least used to--most of it was developed with one....

Much of it is tabs in comments.  But there was one substantive item:
an obsolete reference to "use 'Q' to Quit" after however many years....
This commit is contained in:
PatR
2015-12-10 18:42:27 -08:00
parent ef5b37a03a
commit ebdfafb42d
5 changed files with 261 additions and 245 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 vmsfiles.c $NHDT-Date: 1432512790 2015/05/25 00:13:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */ /* NetHack 3.6 vmsfiles.c $NHDT-Date: 1449801740 2015/12/11 02:42:20 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.10 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -29,7 +29,7 @@ int FDECL(c__translate, (int));
extern unsigned long sys$parse(), sys$search(), sys$enter(), sys$remove(); extern unsigned long sys$parse(), sys$search(), sys$enter(), sys$remove();
extern int VDECL(lib$match_cond, (int, int, ...)); extern int VDECL(lib$match_cond, (int, int, ...));
#define vms_success(sts) ((sts) &1) /* odd, */ #define vms_success(sts) ((sts) & 1) /* odd, */
#define vms_failure(sts) (!vms_success(sts)) /* even */ #define vms_failure(sts) (!vms_success(sts)) /* even */
/* vms_link() -- create an additional directory for an existing file */ /* vms_link() -- create an additional directory for an existing file */
@@ -208,13 +208,13 @@ const char *d1, *d2;
f2.fab$b_fns = strlen(f2.fab$l_fna = (char *) d2); f2.fab$b_fns = strlen(f2.fab$l_fna = (char *) d2);
f1.fab$l_nam = (genericptr_t) &n1; /* link nam to fab */ f1.fab$l_nam = (genericptr_t) &n1; /* link nam to fab */
f2.fab$l_nam = (genericptr_t) &n2; f2.fab$l_nam = (genericptr_t) &n2;
n1.nam$b_nop = n2.nam$b_nop = /* want true device name */
NAM$M_NOCONCEAL; /* want true device name */ n1.nam$b_nop = n2.nam$b_nop = NAM$M_NOCONCEAL;
return ( return (vms_success(sys$parse(&f1)) && vms_success(sys$parse(&f2))
vms_success(sys$parse(&f1)) && vms_success(sys$parse(&f2))
&& n1.nam$t_dvi[0] == n2.nam$t_dvi[0] && n1.nam$t_dvi[0] == n2.nam$t_dvi[0]
&& !strncmp(&n1.nam$t_dvi[1], &n2.nam$t_dvi[1], n1.nam$t_dvi[0]) && !strncmp(&n1.nam$t_dvi[1], &n2.nam$t_dvi[1],
n1.nam$t_dvi[0])
&& !memcmp((genericptr_t) n1.nam$w_did, && !memcmp((genericptr_t) n1.nam$w_did,
(genericptr_t) n2.nam$w_did, (genericptr_t) n2.nam$w_did,
sizeof n1.nam$w_did)); /*{ short nam$w_did[3]; }*/ sizeof n1.nam$w_did)); /*{ short nam$w_did[3]; }*/
@@ -251,37 +251,46 @@ int code;
{ {
register int trans; register int trans;
/* clang-format off */
/* *INDENT-OFF* */
switch ((code & 0x0FFFFFF8) >> 3) { /* strip upper 4 and bottom 3 bits */ switch ((code & 0x0FFFFFF8) >> 3) { /* strip upper 4 and bottom 3 bits */
CASE2(RMS$_PRV, SS$_NOPRIV) : VALUE(EPERM); /* not owner */ CASE2(RMS$_PRV, SS$_NOPRIV):
CASE2(RMS$_DNF, RMS$_DIR) VALUE(EPERM); /* not owner */
: CASE2(RMS$_FNF, RMS$_FND) CASE2(RMS$_DNF, RMS$_DIR):
: CASE1(SS$_NOSUCHFILE) CASE2(RMS$_FNF, RMS$_FND):
: VALUE(ENOENT); /* no such file or directory */ CASE1(SS$_NOSUCHFILE):
CASE2(RMS$_IFI, RMS$_ISI) : VALUE(EIO); /* i/o error */ VALUE(ENOENT); /* no such file or directory */
CASE1(RMS$_DEV) CASE2(RMS$_IFI, RMS$_ISI):
: CASE2(SS$_NOSUCHDEV, SS$_DEVNOTMOUNT) VALUE(EIO); /* i/o error */
: VALUE(ENXIO); /* no such device or address codes */ CASE1(RMS$_DEV):
CASE1(RMS$_DME) CASE2(SS$_NOSUCHDEV, SS$_DEVNOTMOUNT):
: /* CASE1(LIB$INSVIRMEM): */ VALUE(ENXIO); /* no such device or address codes */
CASE2(SS$_VASFULL, SS$_INSFWSL) CASE1(RMS$_DME):
: VALUE(ENOMEM); /* not enough core */ /* CASE1(LIB$INSVIRMEM): */
CASE1(SS$_ACCVIO) : VALUE(EFAULT); /* bad address */ CASE2(SS$_VASFULL, SS$_INSFWSL):
CASE2(RMS$_DNR, SS$_DEVASSIGN) VALUE(ENOMEM); /* not enough core */
: CASE2(SS$_DEVALLOC, SS$_DEVALRALLOC) CASE1(SS$_ACCVIO):
: CASE2(SS$_DEVMOUNT, SS$_DEVACTIVE) VALUE(EFAULT); /* bad address */
: VALUE(EBUSY); /* mount device busy codes to name a few */ CASE2(RMS$_DNR, SS$_DEVASSIGN):
CASE2(RMS$_FEX, SS$_FILALRACC) : VALUE(EEXIST); /* file exists */ CASE2(SS$_DEVALLOC, SS$_DEVALRALLOC):
CASE2(RMS$_IDR, SS$_BADIRECTORY) CASE2(SS$_DEVMOUNT, SS$_DEVACTIVE):
: VALUE(ENOTDIR); /* not a directory */ VALUE(EBUSY); /* mount device busy codes to name a few */
CASE1(SS$_NOIOCHAN) : VALUE(EMFILE); /* too many open files */ CASE2(RMS$_FEX, SS$_FILALRACC):
CASE1(RMS$_FUL) VALUE(EEXIST); /* file exists */
: CASE2(SS$_DEVICEFULL, SS$_EXDISKQUOTA) CASE2(RMS$_IDR, SS$_BADIRECTORY):
: VALUE(ENOSPC); /* no space left on disk codes */ VALUE(ENOTDIR); /* not a directory */
CASE2(RMS$_WLK, SS$_WRITLCK) CASE1(SS$_NOIOCHAN):
: VALUE(EROFS); /* read-only file system */ VALUE(EMFILE); /* too many open files */
CASE1(RMS$_FUL):
CASE2(SS$_DEVICEFULL, SS$_EXDISKQUOTA):
VALUE(ENOSPC); /* no space left on disk codes */
CASE2(RMS$_WLK, SS$_WRITLCK):
VALUE(EROFS); /* read-only file system */
default: default:
VALUE(EVMSERR); VALUE(EVMSERR);
}; };
/* clang-format on */
/* *INDENT-ON* */
errno = trans; errno = trans;
vaxc$errno = code; vaxc$errno = code;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 vmsmail.c $NHDT-Date: 1432512789 2015/05/25 00:13:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */ /* NetHack 3.6 vmsmail.c $NHDT-Date: 1449801741 2015/12/11 02:42:21 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.10 $ */
/* Copyright (c) Robert Patrick Rankin, 1991. */ /* Copyright (c) Robert Patrick Rankin, 1991. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -25,7 +25,7 @@ struct mail_info *NDECL(parse_next_broadcast);
#endif /*__GNUC__*/ #endif /*__GNUC__*/
#include <signal.h> #include <signal.h>
/* #include <string.h> */ /* #include <string.h> */
#define vms_ok(sts) ((sts) &1) #define vms_ok(sts) ((sts) & 1)
static struct mail_info *FDECL(parse_brdcst, (char *)); static struct mail_info *FDECL(parse_brdcst, (char *));
static void FDECL(filter_brdcst, (char *)); static void FDECL(filter_brdcst, (char *));
@@ -136,8 +136,8 @@ char *buf; /* input: filtered broadcast text */
if (!strncmpi(buf, "new mail", 8)) { if (!strncmpi(buf, "new mail", 8)) {
/* /*
New mail [on node FOO] from [SPAM::]BAR [\"personal_name\"] * New mail [on node FOO] from [SPAM::]BAR
[\(HH:MM:SS\)] * [\"personal_name\"] [\(HH:MM:SS\)]
*/ */
nam = "VMSmail"; /* assume VMSmail */ nam = "VMSmail"; /* assume VMSmail */
cmd = "MAIL"; cmd = "MAIL";
@@ -147,8 +147,8 @@ char *buf; /* input: filtered broadcast text */
} else if (!strncmpi(buf, "new all-in-1", 12)) { } else if (!strncmpi(buf, "new all-in-1", 12)) {
int i; int i;
/* /*
New ALL-IN-1 MAIL message [on node FOO] from Personal Name * New ALL-IN-1 MAIL message [on node FOO] from Personal Name
\(BAR@SPAM\) [\(DD-MMM-YYYY HH:MM:SS\)] * \(BAR@SPAM\) [\(DD-MMM-YYYY HH:MM:SS\)]
*/ */
nam = "A1mail"; nam = "A1mail";
cmd = "A1M"; cmd = "A1M";
@@ -159,7 +159,7 @@ char *buf; /* input: filtered broadcast text */
*--p = '\0'; *--p = '\0';
} else if (!strncmpi(buf, "software tools", 14)) { } else if (!strncmpi(buf, "software tools", 14)) {
/* /*
Software Tools mail has arrived on FOO from \'BAR\' [in SPAM] * Software Tools mail has arrived on FOO from \'BAR\' [in SPAM]
*/ */
nam = "STmail"; nam = "STmail";
cmd = "MSG"; cmd = "MSG";
@@ -167,20 +167,20 @@ char *buf; /* input: filtered broadcast text */
cmd = strcat(strcpy(cmd_buf, "MSG +"), p + 4); cmd = strcat(strcpy(cmd_buf, "MSG +"), p + 4);
} else if (q - 2 >= buf && !strncmpi(q - 2, "mm", 2)) { } else if (q - 2 >= buf && !strncmpi(q - 2, "mm", 2)) {
/* /*
{MultiNet\ |PMDF\/}MM mail has arrived on FOO from BAR\n * {MultiNet\ |PMDF\/}MM mail has arrived on FOO from BAR\n
[Subject: subject_text] (PMDF only) * [Subject: subject_text] (PMDF only)
*/ */
nam = "MMmail"; /* MultiNet's version of MM */ nam = "MMmail"; /* MultiNet's version of MM */
cmd = "MM"; /*{ perhaps "MM READ"? }*/ cmd = "MM"; /*{ perhaps "MM READ"? }*/
} else if (!strncmpi(buf, "wpmail:", 7)) { } else if (!strncmpi(buf, "wpmail:", 7)) {
/* /*
WPmail: New mail from BAR. subject_text * WPmail: New mail from BAR. subject_text
*/ */
nam = "WPmail"; /* WordPerfect [sic] Office */ nam = "WPmail"; /* WordPerfect [sic] Office */
cmd = "OFFICE/MAIL"; cmd = "OFFICE/MAIL";
} else if (!strncmpi(buf, "**m400 mail", 7)) { } else if (!strncmpi(buf, "**m400 mail", 7)) {
/* /*
**M400 mail waiting** * **M400 mail waiting**
*/ */
nam = "M400mail"; /* Messenger 400 [not seen] */ nam = "M400mail"; /* Messenger 400 [not seen] */
cmd = "M400"; cmd = "M400";
@@ -193,13 +193,13 @@ char *buf; /* input: filtered broadcast text */
if (!txt) if (!txt)
txt = strcat(strcpy(txt_buf, "Mail for you: "), buf); txt = strcat(strcpy(txt_buf, "Mail for you: "), buf);
/* /*
: end of mail recognition; now check for call-type * end of mail recognition; now check for call-type interruptions...
interruptions...
*/ */
} else if ((q = strstri(buf, " phoning")) != 0) { } else if ((q = strstri(buf, " phoning")) != 0) {
/* /*
BAR is phoning you [on FOO] \(HH:MM:SS\) * BAR is phoning you [on FOO] \(HH:MM:SS\)
*/ */
typ = MSG_CALL; typ = MSG_CALL;
nam = "Phone call"; nam = "Phone call";
@@ -210,9 +210,9 @@ char *buf; /* input: filtered broadcast text */
} else if ((q = strstri(buf, " talk-daemon")) != 0 } else if ((q = strstri(buf, " talk-daemon")) != 0
|| (q = strstri(buf, " talk_daemon")) != 0) { || (q = strstri(buf, " talk_daemon")) != 0) {
/* /*
Message from TALK-DAEMON@FOO at HH:MM:SS\n * Message from TALK-DAEMON@FOO at HH:MM:SS\n
Connection request by BAR@SPAM\n * Connection request by BAR@SPAM\n
\[Respond with: TALK[/OLD] BAR@SPAM\] * \[Respond with: TALK[/OLD] BAR@SPAM\]
*/ */
typ = MSG_CALL; typ = MSG_CALL;
nam = "Talk request"; /* MultiNet's TALK and/or TALK/OLD */ nam = "Talk request"; /* MultiNet's TALK and/or TALK/OLD */
@@ -239,7 +239,7 @@ char *buf; /* input: filtered broadcast text */
} else if (is_jnet_send) { /* sscanf(,"(%[^)])%s -%c",,,)==3 */ } else if (is_jnet_send) { /* sscanf(,"(%[^)])%s -%c",,,)==3 */
jnet_send: jnet_send:
/* /*
\(SPAM\)BAR - arbitrary_message_text (from BAR@SPAM) * \(SPAM\)BAR - arbitrary_message_text (from BAR@SPAM)
*/ */
typ = MSG_CALL; typ = MSG_CALL;
nam = "Bitnet noise"; /* RSCS/NJE message received via JNET */ nam = "Bitnet noise"; /* RSCS/NJE message received via JNET */
@@ -247,17 +247,19 @@ char *buf; /* input: filtered broadcast text */
cmd = cmd_buf; cmd = cmd_buf;
/*{ perhaps just vanilla SEND instead of XYZZY? }*/ /*{ perhaps just vanilla SEND instead of XYZZY? }*/
Sprintf(txt_buf, "Message from %s@%s:%s", user, node, Sprintf(txt_buf, "Message from %s@%s:%s", user, node,
&buf[1 + strlen(node) + 1 + strlen(user) + 2 /* "(node)user -" */
- 1]); /* "(node)user -" */ &buf[1 + strlen(node) + 1 + strlen(user) + 2 - 1]);
txt = txt_buf; txt = txt_buf;
/* /*
: end of call recognition; anything else is none-of-the-above... * end of call recognition; anything else is none-of-the-above...
*/ */
} else { } else {
other: other:
#endif /* SHELL */ #endif /* SHELL */
/* arbitrary broadcast: batch job completed, system shutdown imminent, /* arbitrary broadcast: batch job completed, system shutdown
* &c */ * imminent, &c
*/
typ = MSG_OTHER; typ = MSG_OTHER;
nam = (char *) 0; /*"captured broadcast message"*/ nam = (char *) 0; /*"captured broadcast message"*/
cmd = (char *) 0; cmd = (char *) 0;
@@ -300,21 +302,22 @@ register char *buf; /* in: original text; out: filtered text */
/* filter the text; restrict consecutive spaces or dots to just two */ /* filter the text; restrict consecutive spaces or dots to just two */
for (p = buf_p = buf; *buf_p; buf_p++) { for (p = buf_p = buf; *buf_p; buf_p++) {
c = *buf_p & '\177'; c = *buf_p & '\177';
if (c == ' ' || c == '\t' || c == '\n') if (c == ' ' || c == '\t' || c == '\n') {
if (p == buf || /* ignore leading whitespace */ if (p == buf || /* ignore leading whitespace */
(p >= buf + 2 && *(p - 1) == ' ' && *(p - 2) == ' ')) (p >= buf + 2 && *(p - 1) == ' ' && *(p - 2) == ' '))
continue; continue;
else else
c = ' '; c = ' ';
else if (c == '.' || c < ' ' || c == '\177') } else if (c == '.' || c < ' ' || c == '\177') {
if (p == buf || /* skip leading beeps & such */ if (p == buf || /* skip leading beeps & such */
(p >= buf + 2 && *(p - 1) == '.' && *(p - 2) == '.')) (p >= buf + 2 && *(p - 1) == '.' && *(p - 2) == '.'))
continue; continue;
else else
c = '.'; c = '.';
else if (c == '%' && /* trim %%% OPCOM verbosity %%% */ } else if (c == '%' && /* trim %%% OPCOM verbosity %%% */
p >= buf + 2 && *(p - 1) == '%' && *(p - 2) == '%') p >= buf + 2 && *(p - 1) == '%' && *(p - 2) == '%') {
continue; continue;
}
*p++ = c; *p++ = c;
} }
*p = '\0'; /* terminate, then strip trailing junk */ *p = '\0'; /* terminate, then strip trailing junk */
@@ -326,7 +329,7 @@ register char *buf; /* in: original text; out: filtered text */
static char empty_string[] = ""; static char empty_string[] = "";
/* fetch the text of a captured broadcast, then mangle and decipher it /* fetch the text of a captured broadcast, then mangle and decipher it
*/ */
struct mail_info *parse_next_broadcast() /* called by ckmailstatus(mail.c) */ struct mail_info *parse_next_broadcast() /* called by ckmailstatus(mail.c) */
{ {
short length, msg_type; short length, msg_type;
@@ -349,7 +352,7 @@ struct mail_info *parse_next_broadcast() /* called by ckmailstatus(mail.c) */
} }
/* spit out any pending broadcast messages whenever we leave /* spit out any pending broadcast messages whenever we leave
*/ */
static void flush_broadcasts() /* called from disable_broadcast_trapping() */ static void flush_broadcasts() /* called from disable_broadcast_trapping() */
{ {
if (broadcasts > 0) { if (broadcasts > 0) {
@@ -369,27 +372,26 @@ static void flush_broadcasts() /* called from disable_broadcast_trapping() */
} }
} }
/* AST routine called when the terminal's associated mailbox receives a /* AST routine called when terminal's associated mailbox receives a message
* message */
*/
/*ARGSUSED*/ /*ARGSUSED*/
static void static void
broadcast_ast(dummy) /* called asynchronously by terminal driver */ broadcast_ast(dummy) /* called asynchronously by terminal driver */
int dummy; /* not used */ int dummy UNUSED;
{ {
broadcasts++; broadcasts++;
} }
/* initialize the broadcast manipulation code; SMG makes this easy /* initialize the broadcast manipulation code; SMG makes this easy
*/ */
unsigned long init_broadcast_trapping() /* called by setftty() [once only] */ unsigned long
init_broadcast_trapping() /* called by setftty() [once only] */
{ {
unsigned long sts, preserve_screen_flag = 1; unsigned long sts, preserve_screen_flag = 1;
/* we need a pasteboard to pass to the broadcast setup/teardown routines /* we need a pasteboard to pass to the broadcast setup/teardown routines */
*/ sts = smg$create_pasteboard(&pasteboard_id, 0, 0, 0,
sts = &preserve_screen_flag);
smg$create_pasteboard(&pasteboard_id, 0, 0, 0, &preserve_screen_flag);
if (!vms_ok(sts)) { if (!vms_ok(sts)) {
errno = EVMSERR, vaxc$errno = sts; errno = EVMSERR, vaxc$errno = sts;
raw_print(""); raw_print("");
@@ -401,8 +403,9 @@ unsigned long init_broadcast_trapping() /* called by setftty() [once only] */
} }
/* set up the terminal driver to deliver $brkthru data to a mailbox device /* set up the terminal driver to deliver $brkthru data to a mailbox device
*/ */
unsigned long enable_broadcast_trapping() /* called by setftty() */ unsigned long
enable_broadcast_trapping() /* called by setftty() */
{ {
unsigned long sts = 1; unsigned long sts = 1;
@@ -422,8 +425,9 @@ unsigned long enable_broadcast_trapping() /* called by setftty() */
} }
/* return to 'normal'; $brkthru data goes straight to the terminal /* return to 'normal'; $brkthru data goes straight to the terminal
*/ */
unsigned long disable_broadcast_trapping() /* called by settty() */ unsigned long
disable_broadcast_trapping() /* called by settty() */
{ {
unsigned long sts = 1; unsigned long sts = 1;
@@ -436,7 +440,9 @@ unsigned long disable_broadcast_trapping() /* called by settty() */
} }
return sts; return sts;
} }
#else /* MAIL */ #else /* MAIL */
/* simple stubs for non-mail configuration */ /* simple stubs for non-mail configuration */
unsigned long unsigned long
init_broadcast_trapping() init_broadcast_trapping()
@@ -458,6 +464,7 @@ parse_next_broadcast()
{ {
return 0; return 0;
} }
#endif /* MAIL */ #endif /* MAIL */
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
@@ -538,6 +545,7 @@ void
wait_synch() wait_synch()
{ {
char dummy[BUFSIZ]; char dummy[BUFSIZ];
printf("\nPress <return> to continue: "); printf("\nPress <return> to continue: ");
fflush(stdout); fflush(stdout);
(void) gets(dummy); (void) gets(dummy);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 vmsmain.c $NHDT-Date: 1432512790 2015/05/25 00:13:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.31 $ */ /* NetHack 3.6 vmsmain.c $NHDT-Date: 1449801742 2015/12/11 02:42:22 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.32 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
/* main.c - VMS NetHack */ /* main.c - VMS NetHack */
@@ -225,7 +225,7 @@ attempt_restore:
moveloop(resuming); moveloop(resuming);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
/*NOTREACHED*/ /*NOTREACHED*/
return (0); return 0;
} }
static void static void
@@ -357,8 +357,8 @@ static void
whoami() whoami()
{ {
/* /*
* Who am i? Algorithm: 1. Use name as specified in NETHACKOPTIONS * Who am i? Algorithm: 1. Use name as specified in NETHACKOPTIONS;
* 2. Use lowercase of $USER (if 1. fails) * 2. Use lowercase of $USER (if 1. fails).
* The resulting name is overridden by command line options. * The resulting name is overridden by command line options.
* If everything fails, or if the resulting name is some generic * If everything fails, or if the resulting name is some generic
* account like "games" then eventually we'll ask him. * account like "games" then eventually we'll ask him.
@@ -405,7 +405,7 @@ byebye()
from saving the game after a fatal error has occurred. */ from saving the game after a fatal error has occurred. */
/*ARGSUSED*/ /*ARGSUSED*/
static vms_handler_type /* should be `unsigned long', but the -*/ static vms_handler_type /* should be `unsigned long', but the -*/
vms_handler(sigargs, mechargs) /*+ prototype in <signal.h> is screwed */ vms_handler(sigargs, mechargs) /*+ prototype in <signal.h> is screwed */
genericptr_t sigargs, mechargs; /* [0] is argc, [1..argc] are the real args */ genericptr_t sigargs, mechargs; /* [0] is argc, [1..argc] are the real args */
{ {
unsigned long condition = ((unsigned long *) sigargs)[1]; unsigned long condition = ((unsigned long *) sigargs)[1];
@@ -416,7 +416,7 @@ genericptr_t sigargs, mechargs; /* [0] is argc, [1..argc] are the real args */
program_state.done_hup = TRUE; /* pretend hangup has been attempted */ program_state.done_hup = TRUE; /* pretend hangup has been attempted */
#ifndef BETA #ifndef BETA
if (wizard) if (wizard)
#endif /* !BETA */ #endif
abort(); /* enter the debugger */ abort(); /* enter the debugger */
} }
return SS$_RESIGNAL; return SS$_RESIGNAL;
@@ -442,10 +442,6 @@ port_help()
} }
#endif /* PORT_HELP */ #endif /* PORT_HELP */
/* for KR1ED config, WIZARD is 0 or 1 and WIZARD_NAME is a string;
for usual config, WIZARD is the string and vmsconf.h forces WIZARD_NAME
to match it, avoiding need to test which one to use in string ops */
/* validate wizard mode if player has requested access to it */ /* validate wizard mode if player has requested access to it */
boolean boolean
authorize_wizard_mode() authorize_wizard_mode()

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 vmstty.c $NHDT-Date: 1432512790 2015/05/25 00:13:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */ /* NetHack 3.6 vmstty.c $NHDT-Date: 1449801743 2015/12/11 02:42:23 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.17 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
/* tty.c - (VMS) version */ /* tty.c - (VMS) version */
@@ -44,7 +44,7 @@ static void NDECL(resettty);
#define vms_ok(sts) ((sts) &1) #define vms_ok(sts) ((sts) &1)
#define META(c) ((c) | 0x80) /* 8th bit */ #define META(c) ((c) | 0x80) /* 8th bit */
#define CTRL(c) ((c) &0x1F) #define CTRL(c) ((c) & 0x1F)
#define CMASK(c) (1 << CTRL(c)) #define CMASK(c) (1 << CTRL(c))
#define LIB$M_CLI_CTRLT CMASK('T') /* 0x00100000 */ #define LIB$M_CLI_CTRLT CMASK('T') /* 0x00100000 */
#define LIB$M_CLI_CTRLY CMASK('Y') /* 0x02000000 */ #define LIB$M_CLI_CTRLY CMASK('Y') /* 0x02000000 */
@@ -221,7 +221,7 @@ vms_getchar()
} }
} else { } else {
/* abnormal input--either SMG didn't initialize properly or /* abnormal input--either SMG didn't initialize properly or
vms_getchar() has been called recursively (via SIGINT handler). * vms_getchar() has been called recursively (via SIGINT handler).
*/ */
if (kb != 0) /* must have been a recursive call */ if (kb != 0) /* must have been a recursive call */
smg$cancel_input(&kb); /* from an interrupt handler */ smg$cancel_input(&kb); /* from an interrupt handler */
@@ -265,8 +265,7 @@ Keypad codes are prefixed by 7 bit (\033 O) or 8 bit SS3:
Arrows are prefixed by either SS3 or CSI (either 7 or 8 bit), depending on Arrows are prefixed by either SS3 or CSI (either 7 or 8 bit), depending on
whether the terminal is in application or numeric mode (ditto for PF keys): whether the terminal is in application or numeric mode (ditto for PF keys):
arrows: <up> <dwn> <lft> <rgt> A B D C arrows: <up> <dwn> <lft> <rgt> A B D C
Additional function keys (vk201/vk401) generate CSI nn ~ (nn is 1 or 2 Additional function keys (vk201/vk401) generate CSI nn ~ (nn is 1 or 2 digits):
digits):
vk201 keys: F6 F7 F8 F9 F10 F11 F12 F13 F14 Help Do F17 F18 F19 F20 vk201 keys: F6 F7 F8 F9 F10 F11 F12 F13 F14 Help Do F17 F18 F19 F20
'nn' digits: 17 18 19 20 21 23 24 25 26 28 29 31 32 33 34 'nn' digits: 17 18 19 20 21 23 24 25 26 28 29 31 32 33 34
alternate: ^C ^[ ^H ^J (when in VT100 mode) alternate: ^C ^[ ^H ^J (when in VT100 mode)
@@ -310,6 +309,7 @@ register int c;
if (vms_ok(sts) || sts == SS$_TIMEOUT) { if (vms_ok(sts) || sts == SS$_TIMEOUT) {
register int cnt = iosb.trm_offset + iosb.trm_siz + inc; register int cnt = iosb.trm_offset + iosb.trm_siz + inc;
register char *p = seq_buf; register char *p = seq_buf;
if (c == ESC) /* check for 7-bit vt100/ANSI, or vt52 */ if (c == ESC) /* check for 7-bit vt100/ANSI, or vt52 */
if (*p == '[' || *p == 'O') if (*p == '[' || *p == 'O')
c = META(CTRL(*p++)), cnt--; c = META(CTRL(*p++)), cnt--;
@@ -317,6 +317,7 @@ register int c;
c = SS3; /*CSI*/ c = SS3; /*CSI*/
if (cnt > 0 && (c == SS3 || (c == CSI && strchr(arrow_or_PF, *p)))) { if (cnt > 0 && (c == SS3 || (c == CSI && strchr(arrow_or_PF, *p)))) {
register char *q = strchr(smg_keypad_codes, *p); register char *q = strchr(smg_keypad_codes, *p);
if (q) if (q)
result = 256 + (q - smg_keypad_codes); result = 256 + (q - smg_keypad_codes);
p++, --cnt; /* one more char consumed */ p++, --cnt; /* one more char consumed */
@@ -334,6 +335,7 @@ register int c;
}; /* note: there are several missing nn in CSI nn ~ values */ }; /* note: there are several missing nn in CSI nn ~ values */
int nn; int nn;
char *q; char *q;
*(p + cnt) = '\0'; /* terminate string */ *(p + cnt) = '\0'; /* terminate string */
q = strchr(p, '~'); q = strchr(p, '~');
if (q && sscanf(p, "%d~", &nn) == 1) { if (q && sscanf(p, "%d~", &nn) == 1) {
@@ -373,7 +375,9 @@ setctty()
} }
} }
static void resettty() /* atexit() routine */ /* atexit() routine */
static void
resettty()
{ {
if (settty_needed) { if (settty_needed) {
bombing = TRUE; /* don't clear screen; preserve traceback info */ bombing = TRUE; /* don't clear screen; preserve traceback info */
@@ -451,7 +455,8 @@ const char *s;
disable_broadcast_trapping(); disable_broadcast_trapping();
#if 0 /* let SMG's exit handler do the cleanup (as per doc) */ #if 0 /* let SMG's exit handler do the cleanup (as per doc) */
/* #ifndef USE_QIO_INPUT */ /* #ifndef USE_QIO_INPUT */
if (kb) smg$delete_virtual_keyboard(&kb), kb = 0; if (kb)
smg$delete_virtual_keyboard(&kb), kb = 0;
#endif /* 0 (!USE_QIO_INPUT) */ #endif /* 0 (!USE_QIO_INPUT) */
if (ctrl_mask) if (ctrl_mask)
(void) lib$enable_ctrl(&ctrl_mask, 0); (void) lib$enable_ctrl(&ctrl_mask, 0);
@@ -502,12 +507,16 @@ setftty()
settty_needed = TRUE; settty_needed = TRUE;
} }
void intron() /* enable kbd interupts if enabled when game started */ /* enable kbd interupts if enabled when game started */
void
intron()
{ {
intr_char = CTRL('C'); intr_char = CTRL('C');
} }
void introff() /* disable kbd interrupts if required*/ /* disable kbd interrupts if required*/
void
introff()
{ {
intr_char = 0; intr_char = 0;
} }

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 vmsunix.c $NHDT-Date: 1432512790 2015/05/25 00:13:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.14 $ */ /* NetHack 3.6 vmsunix.c $NHDT-Date: 1449801743 2015/12/11 02:42:23 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.15 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -28,7 +28,7 @@ extern void VDECL(lib$signal, (unsigned, ...));
extern unsigned long sys$setprv(); extern unsigned long sys$setprv();
extern unsigned long lib$getdvi(), lib$getjpi(), lib$spawn(), lib$attach(); extern unsigned long lib$getdvi(), lib$getjpi(), lib$spawn(), lib$attach();
extern unsigned long smg$init_term_table_by_type(), smg$del_term_table(); extern unsigned long smg$init_term_table_by_type(), smg$del_term_table();
#define vms_ok(sts) ((sts) &1) /* odd => success */ #define vms_ok(sts) ((sts) & 1) /* odd => success */
/* this could be static; it's only used within this file; /* this could be static; it's only used within this file;
it won't be used at all if C_LIB$INTIALIZE gets commented out below, it won't be used at all if C_LIB$INTIALIZE gets commented out below,
@@ -51,10 +51,10 @@ int fd;
struct stat buf; struct stat buf;
if (fstat(fd, &buf)) if (fstat(fd, &buf))
return (0); /* cannot get status */ return 0; /* cannot get status */
#ifndef INSURANCE #ifndef INSURANCE
if (buf.st_size != sizeof(int)) if (buf.st_size != sizeof(int))
return (0); /* not an xlock file */ return 0; /* not an xlock file */
#endif #endif
(void) time(&date); (void) time(&date);
if (date - buf.st_mtime < 3L * 24L * 60L * 60L) { /* recent */ if (date - buf.st_mtime < 3L * 24L * 60L * 60L) { /* recent */
@@ -81,8 +81,8 @@ int fd;
} }
set_levelfile_name(lock, 0); set_levelfile_name(lock, 0);
if (delete (lock)) if (delete (lock))
return (0); /* cannot remove it */ return 0; /* cannot remove it */
return (1); /* success! */ return 1; /* success! */
} }
void void
@@ -167,7 +167,7 @@ register char *s;
int int
vms_getuid() vms_getuid()
{ {
return (getgid() << 16) | getuid(); return ((getgid() << 16) | getuid());
} }
#ifndef FAB$C_STMLF #ifndef FAB$C_STMLF
@@ -189,7 +189,7 @@ int fd;
#else #else
rfm = buf.st_fab_rfm; rfm = buf.st_fab_rfm;
#endif #endif
return rfm == FAB$C_STMLF; return (boolean) (rfm == FAB$C_STMLF);
} }
/*------*/ /*------*/
@@ -303,7 +303,7 @@ verify_term()
/* strip trailing blanks */ /* strip trailing blanks */
while (p > smgdevtyp && *--p == ' ') while (p > smgdevtyp && *--p == ' ')
*p = '\0'; *p = '\0';
/* (void)smg$del_term_table(); */ /* (void) smg$del_term_table(); */
term = smgdevtyp; term = smgdevtyp;
} }
} }
@@ -398,9 +398,9 @@ boolean screen_manip;
#ifdef SHELL #ifdef SHELL
unsigned long dosh_pid = 0, /* this should cover any interactive escape */ unsigned long dosh_pid = 0, /* this should cover any interactive escape */
mail_pid = 0; /* this only covers the last mail or phone; */ mail_pid = 0; /* this only covers the last mail or phone;
/*(mail & phone commands aren't expected to leave any process hanging (mail & phone commands aren't expected to
* around)*/ leave any process hanging around) */
int int
dosh() dosh()
@@ -408,20 +408,18 @@ dosh()
return vms_doshell("", TRUE); /* call for interactive child process */ return vms_doshell("", TRUE); /* call for interactive child process */
} }
/* vms_doshell -- called by dosh() and readmail() */ /* vms_doshell -- called by dosh() and readmail()
*
/* If execstring is not a null string, then it will be executed in a spawned * If execstring is not a null string, then it will be executed in a spawned
* subprocess, which will then return. It is for handling mail or phone
* interactive commands, which are only available if both MAIL and SHELL are
* #defined, but we don't bother making the support code conditionalized on
* MAIL here, just on SHELL being enabled.
*
* Normally, all output from this interaction will be 'piped' to the user's
* screen (SYS$OUTPUT). However, if 'screenoutput' is set to FALSE, output
* will be piped into oblivion. Used for silent phone call rejection.
*/ */
/* subprocess, which will then return. It is for handling mail or phone */
/* interactive commands, which are only available if both MAIL and SHELL are
*/
/* #defined, but we don't bother making the support code conditionalized on */
/* MAIL here, just on SHELL being enabled. */
/* Normally, all output from this interaction will be 'piped' to the user's */
/* screen (SYS$OUTPUT). However, if 'screenoutput' is set to FALSE, output */
/* will be piped into oblivion. Used for silent phone call rejection. */
int int
vms_doshell(execstring, screenoutput) vms_doshell(execstring, screenoutput)
const char *execstring; const char *execstring;
@@ -449,9 +447,8 @@ boolean screenoutput;
} }
hack_escape(screenoutput, hack_escape(screenoutput,
command ? (const char *) 0 : " \"Escaping\" into a " command ? (const char *) 0
"subprocess; LOGOUT to " : " \"Escaping\" into a subprocess; LOGOUT to reconnect and resume play. ");
"reconnect and resume play. ");
if (command || !dosh_pid || !vms_ok(status = lib$attach(&dosh_pid))) { if (command || !dosh_pid || !vms_ok(status = lib$attach(&dosh_pid))) {
#ifdef CHDIR #ifdef CHDIR
@@ -494,15 +491,15 @@ dosuspend()
if (owner_pid == -1) /* need to check for parent */ if (owner_pid == -1) /* need to check for parent */
owner_pid = getppid(); owner_pid = getppid();
if (owner_pid == 0) { if (owner_pid == 0) {
pline(" No parent process. Use '!' to Spawn, 'S' to Save, or 'Q' " pline(
"to Quit. "); " No parent process. Use '!' to Spawn, 'S' to Save, or '#quit' to Quit. ");
mark_synch(); mark_synch();
return 0; return 0;
} }
/* restore normal tty environment & clear screen */ /* restore normal tty environment & clear screen */
hack_escape(1, " Attaching to parent process; use the ATTACH command to " hack_escape(1,
"resume play. "); " Attaching to parent process; use the ATTACH command to resume play. ");
status = lib$attach(&owner_pid); /* connect to parent */ status = lib$attach(&owner_pid); /* connect to parent */
@@ -535,7 +532,7 @@ char ***array;
while (indx >= *asize - 1) { while (indx >= *asize - 1) {
oldsize = *asize; oldsize = *asize;
*asize += 5; *asize += 5;
newarray = (char **) alloc(*asize * sizeof(char *)); newarray = (char **) alloc(*asize * sizeof (char *));
/* poor man's realloc() */ /* poor man's realloc() */
for (i = 0; i < *asize; ++i) for (i = 0; i < *asize; ++i)
newarray[i] = (i < oldsize) ? (*array)[i] : 0; newarray[i] = (i < oldsize) ? (*array)[i] : 0;
@@ -543,7 +540,7 @@ char ***array;
free((genericptr_t) *array); free((genericptr_t) *array);
*array = newarray; *array = newarray;
} }
(*array)[indx] = strcpy((char *) alloc(strlen(name) + 1), name); (*array)[indx] = dupstr(name);
} }
struct dsc { struct dsc {
@@ -551,8 +548,7 @@ struct dsc {
char *adr; char *adr;
}; /* descriptor */ }; /* descriptor */
typedef unsigned long vmscond; /* vms condition value */ typedef unsigned long vmscond; /* vms condition value */
vmscond FDECL(lib$find_file, vmscond FDECL(lib$find_file, (const struct dsc *, struct dsc *, genericptr *));
(const struct dsc *, struct dsc *, genericptr *));
vmscond FDECL(lib$find_file_end, (void **)); vmscond FDECL(lib$find_file_end, (void **));
/* collect a list of character names from all save files for this player */ /* collect a list of character names from all save files for this player */
@@ -605,15 +601,11 @@ int how; /* 1: exit after traceback; 2: stay in debugger */
union dbgcmd { union dbgcmd {
struct ascic { struct ascic {
unsigned char len; /* 8-bit length prefix */ unsigned char len; /* 8-bit length prefix */
char char str[79]; /* could be up to 255, but we don't need so much */
str[79]; /* could be up to 255, but we don't need that much */
} cmd_fields; } cmd_fields;
char cmd[1 + 79]; char cmd[1 + 79];
}; };
#define DBGCMD(arg) \ #define DBGCMD(arg) { (unsigned char) (sizeof arg - sizeof ""), arg }
{ \
(unsigned char)(sizeof arg - sizeof ""), arg \
}
static union dbgcmd dbg[3] = { static union dbgcmd dbg[3] = {
/* prologue for less verbose feedback (when combined with /* prologue for less verbose feedback (when combined with
$ define/User_mode dbg$output _NL: ) */ $ define/User_mode dbg$output _NL: ) */
@@ -760,6 +752,7 @@ const unsigned char *imghdr;
unsigned long trnadr1; unsigned long trnadr1;
(void) lib$establish(lib$sig_to_ret); /* set up condition handler */ (void) lib$establish(lib$sig_to_ret); /* set up condition handler */
/* /*
* Check the first of three transfer addresses to see whether * Check the first of three transfer addresses to see whether
* it is SYS$IMGSTA(). Note that they come from a file, * it is SYS$IMGSTA(). Note that they come from a file,
@@ -854,4 +847,5 @@ psect_attr=lib$initialize, Con,Usr,noPic,Rel,Gbl,noShr,noExe,Rd,noWrt,Long
*/ */
#endif /* C_LIB$INITIALIZE */ #endif /* C_LIB$INITIALIZE */
/* End of debugger hackery. */ /* End of debugger hackery. */
/*vmsunix.c*/ /*vmsunix.c*/