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,30 +208,30 @@ 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],
&& !strncmp(&n1.nam$t_dvi[1], &n2.nam$t_dvi[1], n1.nam$t_dvi[0]) 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]; }*/
} }
} }
/* /*
* c__translate -- substitute for VAXCRTL routine C$$TRANSLATE. * c__translate -- substitute for VAXCRTL routine C$$TRANSLATE.
* *
* Try to convert a VMS status code into its Unix equivalent, * Try to convert a VMS status code into its Unix equivalent,
* then set `errno' to that value; use EVMSERR if there's no * then set `errno' to that value; use EVMSERR if there's no
* appropriate translation; set `vaxc$errno' to the original * appropriate translation; set `vaxc$errno' to the original
* status code regardless. * status code regardless.
* *
* These translations match only a subset of VAXCRTL's lookup * These translations match only a subset of VAXCRTL's lookup
* table, but work even if the severity has been adjusted or * table, but work even if the severity has been adjusted or
* the inhibit-message bit has been set. * the inhibit-message bit has been set.
*/ */
#include <errno.h> #include <errno.h>
#include <ssdef.h> #include <ssdef.h>
@@ -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,5 +1,5 @@
/* 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. */
#include "config.h" #include "config.h"
@@ -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 *));
@@ -49,7 +49,7 @@ static long pasteboard_id = 0; /* SMG's magic cookie */
/* /*
* Mail (et al) overview: * Mail (et al) overview:
* *
* When a broadcast is asynchronously captured, a volatile counter * When a broadcast is asynchronously captured, a volatile counter
* ('broadcasts') is incremented. Each player turn, ckmailstatus() polls * ('broadcasts') is incremented. Each player turn, ckmailstatus() polls
* the counter and calls parse_next_broadcast() if it's positive; this * the counter and calls parse_next_broadcast() if it's positive; this
* returns some display text, object name, and response command, which is * returns some display text, object name, and response command, which is
@@ -62,7 +62,7 @@ static long pasteboard_id = 0; /* SMG's magic cookie */
* If SHELL is undefined, then all broadcasts are treated as 'other'; since * If SHELL is undefined, then all broadcasts are treated as 'other'; since
* no subproceses are allowed, there'd be no way to respond to the scroll. * no subproceses are allowed, there'd be no way to respond to the scroll.
* *
* When a scroll of mail is read by the character, readmail() extracts * When a scroll of mail is read by the character, readmail() extracts
* the command string and uses it for the default when prompting the * the command string and uses it for the default when prompting the
* player for a system command to spawn. The player may enter any command * player for a system command to spawn. The player may enter any command
* he or she chooses, or just <return> to accept the default or <escape> to * he or she chooses, or just <return> to accept the default or <escape> to
@@ -73,36 +73,36 @@ static long pasteboard_id = 0; /* SMG's magic cookie */
* *
* Broadcast parsing: * Broadcast parsing:
* *
* The following broadcast messages are [attempted to be] recognized: * The following broadcast messages are [attempted to be] recognized:
* text fragment name for scroll default command * text fragment name for scroll default command
* New mail VMSmail MAIL * New mail VMSmail MAIL
* New ALL-IN-1 MAIL A1mail A1M * New ALL-IN-1 MAIL A1mail A1M
* Software Tools mail STmail MSG [+folder] * Software Tools mail STmail MSG [+folder]
* MM mail MMmail MM * MM mail MMmail MM
* WPmail: New mail WPmail OFFICE/MAIL * WPmail: New mail WPmail OFFICE/MAIL
* **M400 mail M400mail M400 * **M400 mail M400mail M400
* " mail", ^"mail " unknown mail SPAWN * " mail", ^"mail " unknown mail SPAWN
* " phoning" Phone call PHONE ANSWER * " phoning" Phone call PHONE ANSWER
* talk-daemon...by...foo Talk request TALK[/OLD] foo@bar * talk-daemon...by...foo Talk request TALK[/OLD] foo@bar
* (node)user - Bitnet noise XYZZY user@node * (node)user - Bitnet noise XYZZY user@node
* Anything else results in just the message text being passed along, no * Anything else results in just the message text being passed along, no
* scroll of mail so consequently no command to execute when scroll read. * scroll of mail so consequently no command to execute when scroll read.
* The user can set up ``$ XYZZY :== SEND'' prior to invoking NetHack if * The user can set up ``$ XYZZY :== SEND'' prior to invoking NetHack if
* vanilla JNET responses to Bitnet messages are prefered. * vanilla JNET responses to Bitnet messages are prefered.
* *
* Static return buffers are used because only one broadcast gets * Static return buffers are used because only one broadcast gets
* processed at a time, and the essential information in each one is * processed at a time, and the essential information in each one is
* either displayed and discarded or copied into a scroll-of-mail object. * either displayed and discarded or copied into a scroll-of-mail object.
* *
* The test driver code below can be used to check out potential new * The test driver code below can be used to check out potential new
* entries without rebuilding NetHack itself. CC/DEFINE="TEST_DRIVER" * entries without rebuilding NetHack itself. CC/DEFINE="TEST_DRIVER"
* Link it with hacklib.obj or nethack.olb/incl=hacklib (not nethack/lib). * Link it with hacklib.obj or nethack.olb/incl=hacklib (not nethack/lib).
*/ */
static struct mail_info msg; /* parse_*()'s return buffer */ static struct mail_info msg; /* parse_*()'s return buffer */
static char nam_buf[63], /* maximum onamelth, size of ONAME(object) */ static char nam_buf[63], /* maximum onamelth, size of ONAME(object) */
cmd_buf[99], /* arbitrary */ cmd_buf[99], /* arbitrary */
txt_buf[255 + 1]; /* same size as used for message buf[] */ txt_buf[255 + 1]; /* same size as used for message buf[] */
/* try to decipher and categorize broadcast message text /* try to decipher and categorize broadcast message text
*/ */
@@ -136,9 +136,9 @@ 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";
if (txt && (p = strrchr(txt, '(')) > txt && /* discard time */ if (txt && (p = strrchr(txt, '(')) > txt && /* discard time */
@@ -147,9 +147,9 @@ 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";
if (txt && (p = strrchr(txt, '(')) > txt if (txt && (p = strrchr(txt, '(')) > txt
@@ -159,29 +159,29 @@ 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";
if (txt && (p = strstri(p, " in ")) != 0) /* specific folder */ if (txt && (p = strstri(p, " in ")) != 0) /* specific folder */
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";
} else { } else {
@@ -193,14 +193,14 @@ 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 /*
interruptions... * end of mail recognition; now check for call-type 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";
cmd = "PHONE ANSWER"; cmd = "PHONE ANSWER";
@@ -210,10 +210,10 @@ 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 */
cmd = "TALK"; cmd = "TALK";
@@ -239,25 +239,27 @@ 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 */
Sprintf(cmd_buf, "XYZZY %s@%s", user, node); Sprintf(cmd_buf, "XYZZY %s@%s", user, node);
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 */
@@ -18,7 +18,7 @@ static void NDECL(byebye);
#define vms_handler_type unsigned int #define vms_handler_type unsigned int
#endif #endif
extern void FDECL(VAXC$ESTABLISH, extern void FDECL(VAXC$ESTABLISH,
(vms_handler_type (*) (genericptr_t, genericptr_t))); (vms_handler_type (*) (genericptr_t, genericptr_t)));
static vms_handler_type FDECL(vms_handler, (genericptr_t, genericptr_t)); static vms_handler_type FDECL(vms_handler, (genericptr_t, genericptr_t));
#include <ssdef.h> /* system service status codes */ #include <ssdef.h> /* system service status codes */
#endif #endif
@@ -54,13 +54,13 @@ char *argv[];
choose_windows(DEFAULT_WINDOW_SYS); choose_windows(DEFAULT_WINDOW_SYS);
#ifdef CHDIR /* otherwise no chdir() */ #ifdef CHDIR /* otherwise no chdir() */
/* /*
* See if we must change directory to the playground. * See if we must change directory to the playground.
* (Perhaps hack is installed with privs and playground is * (Perhaps hack is installed with privs and playground is
* inaccessible for the player.) * inaccessible for the player.)
* The logical name HACKDIR is overridden by a * The logical name HACKDIR is overridden by a
* -d command line option (must be the first option given) * -d command line option (must be the first option given)
*/ */
dir = nh_getenv("NETHACKDIR"); dir = nh_getenv("NETHACKDIR");
if (!dir) if (!dir)
dir = nh_getenv("HACKDIR"); dir = nh_getenv("HACKDIR");
@@ -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.
@@ -404,8 +404,8 @@ byebye()
/* Condition handler to prevent byebye's hangup simulation /* Condition handler to prevent byebye's hangup simulation
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 */
@@ -24,7 +24,7 @@
#define TT$M_NOBRDCST 0x00020000 /* disable broadcast messages, but */ #define TT$M_NOBRDCST 0x00020000 /* disable broadcast messages, but */
#define TT2$M_BRDCSTMBX 0x00000010 /* catch them in associated mailbox */ #define TT2$M_BRDCSTMBX 0x00000010 /* catch them in associated mailbox */
#define TT2$M_APP_KEYPAD 0x00800000 /* application vs numeric keypad mode */ #define TT2$M_APP_KEYPAD 0x00800000 /* application vs numeric keypad mode */
#endif /* __GNUC__ */ #endif /* __GNUC__ */
#ifdef USE_QIO_INPUT #ifdef USE_QIO_INPUT
#include <ssdef.h> #include <ssdef.h>
#endif #endif
@@ -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,10 +221,10 @@ 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 */
key = getchar(); key = getchar();
} }
--recurse; --recurse;
@@ -247,7 +247,7 @@ vms_getchar()
* for two reasons: * for two reasons:
* 1) retain support for arrow keys, and * 1) retain support for arrow keys, and
* 2) treat other VTxxx function keys as <esc> for aborting * 2) treat other VTxxx function keys as <esc> for aborting
* various NetHack prompts. * various NetHack prompts.
* The second reason is compelling; otherwise remaining chars of * The second reason is compelling; otherwise remaining chars of
* an escape sequence get treated as inappropriate user commands. * an escape sequence get treated as inappropriate user commands.
* *
@@ -257,26 +257,25 @@ vms_getchar()
/*= /*=
-- Summary of VTxxx-style keyboards and transmitted escape sequences. -- -- Summary of VTxxx-style keyboards and transmitted escape sequences. --
Keypad codes are prefixed by 7 bit (\033 O) or 8 bit SS3: Keypad codes are prefixed by 7 bit (\033 O) or 8 bit SS3:
keypad: PF1 PF2 PF3 PF4 codes: P Q R S keypad: PF1 PF2 PF3 PF4 codes: P Q R S
7 8 9 - w x y m 7 8 9 - w x y m
4 5 6 . t u v n 4 5 6 . t u v n
1 2 3 :en-: q r s : : 1 2 3 :en-: q r s : :
...0... , :ter: ...p... l :M: ...0... , :ter: ...p... l :M:
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)
edit keypad: <fnd> <ins> <rmv> digits: 1 2 3 edit keypad: <fnd> <ins> <rmv> digits: 1 2 3
<sel> <prv> <nxt> 4 5 6 <sel> <prv> <nxt> 4 5 6
VT52 mode: arrows and PF keys send ESCx where x is in A-D or P-S. VT52 mode: arrows and PF keys send ESCx where x is in A-D or P-S.
=*/ =*/
static const char *arrow_or_PF = "ABCDPQRS", /* suffix char */ static const char *arrow_or_PF = "ABCDPQRS", /* suffix char */
*smg_keypad_codes = "PQRSpqrstuvwxyMmlnABDC"; *smg_keypad_codes = "PQRSpqrstuvwxyMmlnABDC";
/* PF1..PF4,KP0..KP9,enter,dash,comma,dot,up-arrow,down,left,right */ /* PF1..PF4,KP0..KP9,enter,dash,comma,dot,up-arrow,down,left,right */
/* Ultimate return value is (index into smg_keypad_codes[] + 256). */ /* Ultimate return value is (index into smg_keypad_codes[] + 256). */
@@ -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
@@ -483,7 +480,7 @@ boolean screenoutput;
#ifdef SUSPEND #ifdef SUSPEND
/* dosuspend() -- if we're a subprocess, attach to our parent; /* dosuspend() -- if we're a subprocess, attach to our parent;
* if not, there's nothing we can do. * if not, there's nothing we can do.
*/ */
int int
dosuspend() dosuspend()
@@ -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: ) */
@@ -709,40 +701,40 @@ struct eiha { /* extended image header activation block, $EIHADEF */
}; };
/* /*
* We're going to use lib$initialize, not because we need or * We're going to use lib$initialize, not because we need or
* want to be called before main(), but because one of the * want to be called before main(), but because one of the
* arguments passed to a lib$initialize callback is a pointer * arguments passed to a lib$initialize callback is a pointer
* to the image header (somewhat complex data structure which * to the image header (somewhat complex data structure which
* includes the memory location(s) of where to start executing) * includes the memory location(s) of where to start executing)
* of the program being initialized. It comes in two flavors, * of the program being initialized. It comes in two flavors,
* one used by VAX and the other by Alpha and IA64. * one used by VAX and the other by Alpha and IA64.
* *
* An image can have up to three transfer addresses; one of them * An image can have up to three transfer addresses; one of them
* decides whether to run under debugger control (RUN/Debug, or * decides whether to run under debugger control (RUN/Debug, or
* LINK/Debug + plain RUN), another handles lib$initialize calls * LINK/Debug + plain RUN), another handles lib$initialize calls
* if that's used, and the last is to start the program itself * if that's used, and the last is to start the program itself
* (a jacket built around main() for code compiled with DEC C). * (a jacket built around main() for code compiled with DEC C).
* They aren't always all present; some might be zero/null. * They aren't always all present; some might be zero/null.
* A shareable image (pre-linked library) usually won't have any, * A shareable image (pre-linked library) usually won't have any,
* but can have a separate initializer (not of interest here). * but can have a separate initializer (not of interest here).
* *
* The transfer targets don't have fixed slots but do occur in a * The transfer targets don't have fixed slots but do occur in a
* particular order: * particular order:
* link link lib$initialize lib$initialize * link link lib$initialize lib$initialize
* sharable /noTrace /Trace + /noTrace + /Traceback * sharable /noTrace /Trace + /noTrace + /Traceback
* 1: (none) main debugger init-handler debugger * 1: (none) main debugger init-handler debugger
* 2: main main init-handler * 2: main main init-handler
* 3: main * 3: main
* *
* We check whether the first transfer address is SYS$IMGSTA(). * We check whether the first transfer address is SYS$IMGSTA().
* If it is, the debugger should be available to catch SS$_DEBUG * If it is, the debugger should be available to catch SS$_DEBUG
* exception even when we don't start up under debugger control. * exception even when we don't start up under debugger control.
* One extra complication: if we *do* start up under debugger * One extra complication: if we *do* start up under debugger
* control, the first address in the in-memory copy of the image * control, the first address in the in-memory copy of the image
* header will be changed from sys$imgsta() to a value in system * header will be changed from sys$imgsta() to a value in system
* space. [I don't know how to reference that one symbolically, * space. [I don't know how to reference that one symbolically,
* so I'm going to treat any address in system space as meaning * so I'm going to treat any address in system space as meaning
* that the debugger is available. pr] * that the debugger is available. pr]
*/ */
/* called via lib$initialize during image activation: before main() and /* called via lib$initialize during image activation: before main() and
@@ -760,14 +752,15 @@ 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 /*
* it is SYS$IMGSTA(). Note that they come from a file, * Check the first of three transfer addresses to see whether
* where they reside as longword or quadword integers rather * it is SYS$IMGSTA(). Note that they come from a file,
* than function pointers. (Basically just a C type issue; * where they reside as longword or quadword integers rather
* casting back and forth between integer and pointer doesn't * than function pointers. (Basically just a C type issue;
* change any bits for the architectures VMS runs on.) * casting back and forth between integer and pointer doesn't
*/ * change any bits for the architectures VMS runs on.)
*/
debuggable = 0; debuggable = 0;
/* start with a guess rather than bothering to figure out architecture */ /* start with a guess rather than bothering to figure out architecture */
vax_hdr = (struct ihd *) imghdr; vax_hdr = (struct ihd *) imghdr;
@@ -848,10 +841,11 @@ const unsigned long lib$initialize[] = { (unsigned long) (void *) vmsexeini };
#ifdef __DECC #ifdef __DECC
#pragma extern_model restore /* pop previous mode */ #pragma extern_model restore /* pop previous mode */
#endif #endif
/* We also need to link against a linker options file containing: /* We also need to link against a linker options file containing:
sys$library:starlet.olb/Include=(lib$initialize) sys$library:starlet.olb/Include=(lib$initialize)
psect_attr=lib$initialize, Con,Usr,noPic,Rel,Gbl,noShr,noExe,Rd,noWrt,Long 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*/