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:
@@ -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. */
|
||||
/* 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 lib$getdvi(), lib$getjpi(), lib$spawn(), lib$attach();
|
||||
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;
|
||||
it won't be used at all if C_LIB$INTIALIZE gets commented out below,
|
||||
@@ -51,10 +51,10 @@ int fd;
|
||||
struct stat buf;
|
||||
|
||||
if (fstat(fd, &buf))
|
||||
return (0); /* cannot get status */
|
||||
return 0; /* cannot get status */
|
||||
#ifndef INSURANCE
|
||||
if (buf.st_size != sizeof(int))
|
||||
return (0); /* not an xlock file */
|
||||
return 0; /* not an xlock file */
|
||||
#endif
|
||||
(void) time(&date);
|
||||
if (date - buf.st_mtime < 3L * 24L * 60L * 60L) { /* recent */
|
||||
@@ -81,8 +81,8 @@ int fd;
|
||||
}
|
||||
set_levelfile_name(lock, 0);
|
||||
if (delete (lock))
|
||||
return (0); /* cannot remove it */
|
||||
return (1); /* success! */
|
||||
return 0; /* cannot remove it */
|
||||
return 1; /* success! */
|
||||
}
|
||||
|
||||
void
|
||||
@@ -167,7 +167,7 @@ register char *s;
|
||||
int
|
||||
vms_getuid()
|
||||
{
|
||||
return (getgid() << 16) | getuid();
|
||||
return ((getgid() << 16) | getuid());
|
||||
}
|
||||
|
||||
#ifndef FAB$C_STMLF
|
||||
@@ -189,7 +189,7 @@ int fd;
|
||||
#else
|
||||
rfm = buf.st_fab_rfm;
|
||||
#endif
|
||||
return rfm == FAB$C_STMLF;
|
||||
return (boolean) (rfm == FAB$C_STMLF);
|
||||
}
|
||||
|
||||
/*------*/
|
||||
@@ -303,7 +303,7 @@ verify_term()
|
||||
/* strip trailing blanks */
|
||||
while (p > smgdevtyp && *--p == ' ')
|
||||
*p = '\0';
|
||||
/* (void)smg$del_term_table(); */
|
||||
/* (void) smg$del_term_table(); */
|
||||
term = smgdevtyp;
|
||||
}
|
||||
}
|
||||
@@ -398,9 +398,9 @@ boolean screen_manip;
|
||||
|
||||
#ifdef SHELL
|
||||
unsigned long dosh_pid = 0, /* this should cover any interactive escape */
|
||||
mail_pid = 0; /* this only covers the last mail or phone; */
|
||||
/*(mail & phone commands aren't expected to leave any process hanging
|
||||
* around)*/
|
||||
mail_pid = 0; /* this only covers the last mail or phone;
|
||||
(mail & phone commands aren't expected to
|
||||
leave any process hanging around) */
|
||||
|
||||
int
|
||||
dosh()
|
||||
@@ -408,20 +408,18 @@ dosh()
|
||||
return vms_doshell("", TRUE); /* call for interactive child process */
|
||||
}
|
||||
|
||||
/* vms_doshell -- called by dosh() and readmail() */
|
||||
|
||||
/* If execstring is not a null string, then it will be executed in a spawned
|
||||
/* vms_doshell -- called by dosh() and readmail()
|
||||
*
|
||||
* 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
|
||||
vms_doshell(execstring, screenoutput)
|
||||
const char *execstring;
|
||||
@@ -449,9 +447,8 @@ boolean screenoutput;
|
||||
}
|
||||
|
||||
hack_escape(screenoutput,
|
||||
command ? (const char *) 0 : " \"Escaping\" into a "
|
||||
"subprocess; LOGOUT to "
|
||||
"reconnect and resume play. ");
|
||||
command ? (const char *) 0
|
||||
: " \"Escaping\" into a subprocess; LOGOUT to reconnect and resume play. ");
|
||||
|
||||
if (command || !dosh_pid || !vms_ok(status = lib$attach(&dosh_pid))) {
|
||||
#ifdef CHDIR
|
||||
@@ -483,7 +480,7 @@ boolean screenoutput;
|
||||
|
||||
#ifdef SUSPEND
|
||||
/* 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
|
||||
dosuspend()
|
||||
@@ -494,15 +491,15 @@ dosuspend()
|
||||
if (owner_pid == -1) /* need to check for parent */
|
||||
owner_pid = getppid();
|
||||
if (owner_pid == 0) {
|
||||
pline(" No parent process. Use '!' to Spawn, 'S' to Save, or 'Q' "
|
||||
"to Quit. ");
|
||||
pline(
|
||||
" No parent process. Use '!' to Spawn, 'S' to Save, or '#quit' to Quit. ");
|
||||
mark_synch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* restore normal tty environment & clear screen */
|
||||
hack_escape(1, " Attaching to parent process; use the ATTACH command to "
|
||||
"resume play. ");
|
||||
hack_escape(1,
|
||||
" Attaching to parent process; use the ATTACH command to resume play. ");
|
||||
|
||||
status = lib$attach(&owner_pid); /* connect to parent */
|
||||
|
||||
@@ -535,7 +532,7 @@ char ***array;
|
||||
while (indx >= *asize - 1) {
|
||||
oldsize = *asize;
|
||||
*asize += 5;
|
||||
newarray = (char **) alloc(*asize * sizeof(char *));
|
||||
newarray = (char **) alloc(*asize * sizeof (char *));
|
||||
/* poor man's realloc() */
|
||||
for (i = 0; i < *asize; ++i)
|
||||
newarray[i] = (i < oldsize) ? (*array)[i] : 0;
|
||||
@@ -543,7 +540,7 @@ char ***array;
|
||||
free((genericptr_t) *array);
|
||||
*array = newarray;
|
||||
}
|
||||
(*array)[indx] = strcpy((char *) alloc(strlen(name) + 1), name);
|
||||
(*array)[indx] = dupstr(name);
|
||||
}
|
||||
|
||||
struct dsc {
|
||||
@@ -551,8 +548,7 @@ struct dsc {
|
||||
char *adr;
|
||||
}; /* descriptor */
|
||||
typedef unsigned long vmscond; /* vms condition value */
|
||||
vmscond FDECL(lib$find_file,
|
||||
(const struct dsc *, struct dsc *, genericptr *));
|
||||
vmscond FDECL(lib$find_file, (const struct dsc *, struct dsc *, genericptr *));
|
||||
vmscond FDECL(lib$find_file_end, (void **));
|
||||
|
||||
/* 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 {
|
||||
struct ascic {
|
||||
unsigned char len; /* 8-bit length prefix */
|
||||
char
|
||||
str[79]; /* could be up to 255, but we don't need that much */
|
||||
char str[79]; /* could be up to 255, but we don't need so much */
|
||||
} cmd_fields;
|
||||
char cmd[1 + 79];
|
||||
};
|
||||
#define DBGCMD(arg) \
|
||||
{ \
|
||||
(unsigned char)(sizeof arg - sizeof ""), arg \
|
||||
}
|
||||
#define DBGCMD(arg) { (unsigned char) (sizeof arg - sizeof ""), arg }
|
||||
static union dbgcmd dbg[3] = {
|
||||
/* prologue for less verbose feedback (when combined with
|
||||
$ 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
|
||||
* want to be called before main(), but because one of the
|
||||
* arguments passed to a lib$initialize callback is a pointer
|
||||
* to the image header (somewhat complex data structure which
|
||||
* includes the memory location(s) of where to start executing)
|
||||
* of the program being initialized. It comes in two flavors,
|
||||
* one used by VAX and the other by Alpha and IA64.
|
||||
* We're going to use lib$initialize, not because we need or
|
||||
* want to be called before main(), but because one of the
|
||||
* arguments passed to a lib$initialize callback is a pointer
|
||||
* to the image header (somewhat complex data structure which
|
||||
* includes the memory location(s) of where to start executing)
|
||||
* of the program being initialized. It comes in two flavors,
|
||||
* one used by VAX and the other by Alpha and IA64.
|
||||
*
|
||||
* An image can have up to three transfer addresses; one of them
|
||||
* decides whether to run under debugger control (RUN/Debug, or
|
||||
* LINK/Debug + plain RUN), another handles lib$initialize calls
|
||||
* if that's used, and the last is to start the program itself
|
||||
* (a jacket built around main() for code compiled with DEC C).
|
||||
* They aren't always all present; some might be zero/null.
|
||||
* A shareable image (pre-linked library) usually won't have any,
|
||||
* but can have a separate initializer (not of interest here).
|
||||
* An image can have up to three transfer addresses; one of them
|
||||
* decides whether to run under debugger control (RUN/Debug, or
|
||||
* LINK/Debug + plain RUN), another handles lib$initialize calls
|
||||
* if that's used, and the last is to start the program itself
|
||||
* (a jacket built around main() for code compiled with DEC C).
|
||||
* They aren't always all present; some might be zero/null.
|
||||
* A shareable image (pre-linked library) usually won't have any,
|
||||
* but can have a separate initializer (not of interest here).
|
||||
*
|
||||
* The transfer targets don't have fixed slots but do occur in a
|
||||
* particular order:
|
||||
* link link lib$initialize lib$initialize
|
||||
* sharable /noTrace /Trace + /noTrace + /Traceback
|
||||
* 1: (none) main debugger init-handler debugger
|
||||
* 2: main main init-handler
|
||||
* 3: main
|
||||
* The transfer targets don't have fixed slots but do occur in a
|
||||
* particular order:
|
||||
* link link lib$initialize lib$initialize
|
||||
* sharable /noTrace /Trace + /noTrace + /Traceback
|
||||
* 1: (none) main debugger init-handler debugger
|
||||
* 2: main main init-handler
|
||||
* 3: main
|
||||
*
|
||||
* We check whether the first transfer address is SYS$IMGSTA().
|
||||
* If it is, the debugger should be available to catch SS$_DEBUG
|
||||
* exception even when we don't start up under debugger control.
|
||||
* One extra complication: if we *do* start up under debugger
|
||||
* control, the first address in the in-memory copy of the image
|
||||
* header will be changed from sys$imgsta() to a value in system
|
||||
* space. [I don't know how to reference that one symbolically,
|
||||
* so I'm going to treat any address in system space as meaning
|
||||
* that the debugger is available. pr]
|
||||
* We check whether the first transfer address is SYS$IMGSTA().
|
||||
* If it is, the debugger should be available to catch SS$_DEBUG
|
||||
* exception even when we don't start up under debugger control.
|
||||
* One extra complication: if we *do* start up under debugger
|
||||
* control, the first address in the in-memory copy of the image
|
||||
* header will be changed from sys$imgsta() to a value in system
|
||||
* space. [I don't know how to reference that one symbolically,
|
||||
* so I'm going to treat any address in system space as meaning
|
||||
* that the debugger is available. pr]
|
||||
*/
|
||||
|
||||
/* called via lib$initialize during image activation: before main() and
|
||||
@@ -760,14 +752,15 @@ const unsigned char *imghdr;
|
||||
unsigned long trnadr1;
|
||||
|
||||
(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,
|
||||
* where they reside as longword or quadword integers rather
|
||||
* than function pointers. (Basically just a C type issue;
|
||||
* casting back and forth between integer and pointer doesn't
|
||||
* change any bits for the architectures VMS runs on.)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Check the first of three transfer addresses to see whether
|
||||
* it is SYS$IMGSTA(). Note that they come from a file,
|
||||
* where they reside as longword or quadword integers rather
|
||||
* than function pointers. (Basically just a C type issue;
|
||||
* casting back and forth between integer and pointer doesn't
|
||||
* change any bits for the architectures VMS runs on.)
|
||||
*/
|
||||
debuggable = 0;
|
||||
/* start with a guess rather than bothering to figure out architecture */
|
||||
vax_hdr = (struct ihd *) imghdr;
|
||||
@@ -848,10 +841,11 @@ const unsigned long lib$initialize[] = { (unsigned long) (void *) vmsexeini };
|
||||
#ifdef __DECC
|
||||
#pragma extern_model restore /* pop previous mode */
|
||||
#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)
|
||||
psect_attr=lib$initialize, Con,Usr,noPic,Rel,Gbl,noShr,noExe,Rd,noWrt,Long
|
||||
*/
|
||||
#endif /* C_LIB$INITIALIZE */
|
||||
/* End of debugger hackery. */
|
||||
|
||||
/*vmsunix.c*/
|
||||
|
||||
Reference in New Issue
Block a user