vms bits to c99

This commit is contained in:
nhmall
2021-01-27 21:15:31 -05:00
parent 5ac860bdc7
commit c2cb89cae9
6 changed files with 75 additions and 114 deletions

View File

@@ -35,8 +35,7 @@ extern int VDECL(lib$match_cond, (int, int, ...));
/* vms_link() -- create an additional directory for an existing file */
int
vms_link(file, new)
const char *file, *new;
vms_link(const char *file, const char *new)
{
struct FAB fab;
struct NAM nam;
@@ -83,8 +82,7 @@ const char *file, *new;
(because the file won't be deleted, just made inaccessible!).
*/
int
vms_unlink(file)
const char *file;
vms_unlink(const char *file)
{
struct FAB fab;
struct NAM nam;
@@ -115,9 +113,7 @@ const char *file;
*/
#undef creat
int
vms_creat(file, mode)
const char *file;
unsigned int mode;
vms_creat(const char *file, unsigned int mode)
{
char filnambuf[BUFSIZ]; /*(not BUFSZ)*/
@@ -141,10 +137,7 @@ unsigned int mode;
*/
#undef open
int
vms_open(file, flags, mode)
const char *file;
int flags;
unsigned int mode;
vms_open(const char *file, int flags, unsigned int mode)
{
char filnambuf[BUFSIZ]; /*(not BUFSZ)*/
int fd;
@@ -165,8 +158,7 @@ unsigned int mode;
/* do likewise for fopen() */
#undef fopen
FILE *
vms_fopen(file, mode)
const char *file, *mode;
vms_fopen(const char *file, const char *mode)
{
char filnambuf[BUFSIZ]; /*(not BUFSZ)*/
FILE *fp;
@@ -191,8 +183,7 @@ const char *file, *mode;
the command line). This version doesn't handle Unix-style file specs.
*/
boolean
same_dir(d1, d2)
const char *d1, *d2;
same_dir(const char *d1, const char *d2)
{
if (!d1 || !*d1 || !d2 || !*d2)
return FALSE;
@@ -247,8 +238,7 @@ const char *d1, *d2;
#define CASE2(V, W) CASE1(V) : CASE1(W)
int
c__translate(code)
int code;
c__translate(int code)
{
register int trans;
@@ -306,8 +296,7 @@ static char base_name[NAM$C_MAXRSS + 1];
/* return a copy of the 'base' portion of a filename */
char *
vms_basename(name)
const char *name;
vms_basename(const char *name)
{
unsigned len;
char *base, *base_p;

View File

@@ -107,8 +107,8 @@ static char nam_buf[63], /* maximum onamelth, size of ONAME(object) */
/* try to decipher and categorize broadcast message text
*/
static struct mail_info *
parse_brdcst(buf) /* called by parse_next_broadcast() */
char *buf; /* input: filtered broadcast text */
parse_brdcst(char *buf) /* called by parse_next_broadcast() */
/* input: filtered broadcast text */
{
int typ;
char *txt;
@@ -294,8 +294,8 @@ char *buf; /* input: filtered broadcast text */
/* filter out non-printable characters and redundant noise
*/
static void filter_brdcst(buf) /* called by parse_next_broadcast() */
register char *buf; /* in: original text; out: filtered text */
static void filter_brdcst(register char *buf) /* called by parse_next_broadcast() */
/* in: original text; out: filtered text */
{
register char c, *p, *buf_p;
@@ -330,7 +330,7 @@ static char empty_string[] = "";
/* 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(void) /* called by ckmailstatus(mail.c) */
{
short length, msg_type;
$DESCRIPTOR(message, empty_string); /* string descriptor for buf[] */
@@ -353,7 +353,7 @@ struct mail_info *parse_next_broadcast() /* called by ckmailstatus(mail.c) */
/* spit out any pending broadcast messages whenever we leave
*/
static void flush_broadcasts() /* called from disable_broadcast_trapping() */
static void flush_broadcasts(void) /* called from disable_broadcast_trapping() */
{
if (broadcasts > 0) {
short len, typ;
@@ -376,8 +376,7 @@ static void flush_broadcasts() /* called from disable_broadcast_trapping() */
*/
/*ARGSUSED*/
static void
broadcast_ast(dummy) /* called asynchronously by terminal driver */
int dummy UNUSED;
broadcast_ast(int dummy UNUSED) /* called asynchronously by terminal driver */
{
broadcasts++;
}
@@ -385,7 +384,7 @@ int dummy UNUSED;
/* initialize the broadcast manipulation code; SMG makes this easy
*/
unsigned long
init_broadcast_trapping() /* called by setftty() [once only] */
init_broadcast_trapping(void) /* called by setftty() [once only] */
{
unsigned long sts, preserve_screen_flag = 1;
@@ -405,7 +404,7 @@ init_broadcast_trapping() /* called by setftty() [once only] */
/* set up the terminal driver to deliver $brkthru data to a mailbox device
*/
unsigned long
enable_broadcast_trapping() /* called by setftty() */
enable_broadcast_trapping(void) /* called by setftty() */
{
unsigned long sts = 1;
@@ -427,7 +426,7 @@ enable_broadcast_trapping() /* called by setftty() */
/* return to 'normal'; $brkthru data goes straight to the terminal
*/
unsigned long
disable_broadcast_trapping() /* called by settty() */
disable_broadcast_trapping(void) /* called by settty() */
{
unsigned long sts = 1;
@@ -445,22 +444,22 @@ disable_broadcast_trapping() /* called by settty() */
/* simple stubs for non-mail configuration */
unsigned long
init_broadcast_trapping()
init_broadcast_trapping(void)
{
return 1;
}
unsigned long
enable_broadcast_trapping()
enable_broadcast_trapping(void)
{
return 1;
}
unsigned long
disable_broadcast_trapping()
disable_broadcast_trapping(void)
{
return 1;
}
struct mail_info *
parse_next_broadcast()
parse_next_broadcast(void)
{
return 0;
}
@@ -494,7 +493,7 @@ struct mail_info *foo;
}
void
ckmailstatus()
ckmailstatus(void)
{
struct mail_info *brdcst, *parse_next_broadcast();
@@ -509,7 +508,7 @@ ckmailstatus()
}
int
main()
main(int argc UNUSED, char *argv[] UNUSED)
{
char dummy[BUFSIZ];
@@ -526,23 +525,21 @@ main()
}
void
panic(s)
char *s;
panic(char *s)
{
raw_print(s);
exit(EXIT_FAILURE);
}
void
raw_print(s)
char *s;
raw_print(char *s)
{
puts(s);
fflush(stdout);
}
void
wait_synch()
wait_synch(void)
{
char dummy[BUFSIZ];

View File

@@ -28,9 +28,7 @@ static void wd_message(void);
static boolean wiz_error_flag = FALSE;
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
NHFILE *nhfp;
#ifdef CHDIR
@@ -247,9 +245,7 @@ attempt_restore:
}
static void
process_options(argc, argv)
int argc;
char *argv[];
process_options(int argc, char *argv[])
{
int i;
@@ -341,9 +337,7 @@ char *argv[];
#ifdef CHDIR
void
chdirx(dir, wr)
const char *dir;
boolean wr;
chdirx(const char *dir, boolean wr)
{
#ifndef HACKDIR
static const char *defdir = ".";
@@ -372,7 +366,7 @@ boolean wr;
#endif /* CHDIR */
static void
whoami()
whoami(void)
{
/*
* Who am i? Algorithm: 1. Use name as specified in NETHACKOPTIONS;
@@ -422,8 +416,9 @@ byebye(void)
from saving the game after a fatal error has occurred. */
/*ARGSUSED*/
static vms_handler_type /* should be `unsigned long', but the -*/
vms_handler(sigargs, mechargs) /*+ prototype in <signal.h> is screwed */
genericptr_t sigargs, mechargs; /* [0] is argc, [1..argc] are the real args */
vms_handler( /*+ prototype in <signal.h> is screwed */
genericptr_t sigargs,
genericptr_t mechargs) /* [0] is argc, [1..argc] are the real args */
{
unsigned long condition = ((unsigned long *) sigargs)[1];
@@ -448,7 +443,7 @@ sethanguphandler(void (*handler)(int))
#ifdef PORT_HELP
void
port_help()
port_help(void)
{
/*
* Display VMS-specific help. Just show contents of the helpfile
@@ -460,7 +455,7 @@ port_help()
/* validate wizard mode if player has requested access to it */
boolean
authorize_wizard_mode()
authorize_wizard_mode(void)
{
if (!strcmpi(nh_getenv("USER"), WIZARD_NAME))
return TRUE;
@@ -469,7 +464,7 @@ authorize_wizard_mode()
}
static void
wd_message()
wd_message(void)
{
if (wiz_error_flag) {
pline("Only user \"%s\" may access debug (wizard) mode.",
@@ -481,7 +476,7 @@ wd_message()
}
unsigned long
sys_random_seed()
sys_random_seed(void)
{
unsigned long seed;
unsigned long pid = (unsigned long) getpid();

View File

@@ -17,8 +17,7 @@ extern void VDECL(lib$signal, (unsigned, ...));
/* terminate, converting Unix-style exit code into VMS status code */
void
vms_exit(status)
int status;
vms_exit(int status)
{
/* convert non-zero to failure, zero to success */
exit(status ? (SS$_ABORT | STS$M_INHIB_MSG) : SS$_NORMAL);
@@ -27,7 +26,7 @@ int status;
/* put the user into the debugger; used for abort() when in wizard mode */
void
vms_abort()
vms_abort(void)
{
if (debuggable)
lib$signal(SS$_DEBUG);

View File

@@ -108,7 +108,7 @@ extern int nh_vms_getchar(void);
/* rename the real vms_getchar and interpose this one in front of it */
int
vms_getchar()
vms_getchar(void)
{
static int althack = 0, altprefix;
char *nhalthack;
@@ -135,7 +135,7 @@ vms_getchar()
#endif /*DEBUG*/
int
vms_getchar()
vms_getchar(void)
{
short key;
#ifdef USE_QIO_INPUT
@@ -281,8 +281,7 @@ static const char *arrow_or_PF = "ABCDPQRS", /* suffix char */
/* Ultimate return value is (index into smg_keypad_codes[] + 256). */
static short
parse_function_key(c)
register int c;
parse_function_key(register int c)
{
struct _rd_iosb iosb;
unsigned long sts;
@@ -356,7 +355,7 @@ register int c;
#endif /* USE_QIO_INPUT */
static void
setctty()
setctty(void)
{
struct _sm_iosb iosb;
unsigned long status;
@@ -378,7 +377,7 @@ setctty()
/* atexit() routine */
static void
resettty()
resettty(void)
{
if (settty_needed) {
bombing = TRUE; /* don't clear screen; preserve traceback info */
@@ -394,7 +393,7 @@ resettty()
* (for initial startup and for returning from '!' or ^Z).
*/
void
gettty()
gettty(void)
{
static char dev_tty[] = "TT:";
static $DESCRIPTOR(tty_dsc, dev_tty);
@@ -445,8 +444,7 @@ gettty()
/* reset terminal to original state */
void
settty(s)
const char *s;
settty(const char *s)
{
if (!bombing)
end_screen();
@@ -474,8 +472,7 @@ const char *s;
/* same as settty, with no clearing of the screen */
void
shuttty(s)
const char *s;
shuttty(const char *s)
{
bombing = TRUE;
settty(s);
@@ -483,7 +480,7 @@ const char *s;
}
void
setftty()
setftty(void)
{
unsigned long mask = LIB$M_CLI_CTRLT | LIB$M_CLI_CTRLY;
@@ -510,14 +507,14 @@ setftty()
/* enable kbd interupts if enabled when game started */
void
intron()
intron(void)
{
intr_char = CTRL('C');
}
/* disable kbd interrupts if required*/
void
introff()
introff(void)
{
intr_char = 0;
}
@@ -535,8 +532,7 @@ static const long mseconds_to_delta = VMS_UNITS_PER_SECOND / 1000L * -1L;
/* sleep for specified number of milliseconds (note: the timer used
generally only has 10-millisecond resolution at the hardware level...) */
void
msleep(mseconds)
unsigned mseconds; /* milliseconds */
msleep(unsigned mseconds) /* milliseconds */
{
long pid = 0L, zero = 0L, msec, qtime[2];

View File

@@ -44,8 +44,7 @@ static void hack_resume(boolean);
#endif
static int
veryold(fd)
int fd;
veryold(int fd)
{
register int i;
time_t date;
@@ -87,7 +86,7 @@ int fd;
}
void
getlock()
getlock(void)
{
register int i = 0, fd;
@@ -154,8 +153,8 @@ getlock()
}
}
void regularize(s) /* normalize file name */
register char *s;
/* normalize file name */
void regularize(register char *s)
{
register char *lp;
@@ -166,7 +165,7 @@ register char *s;
#undef getuid
int
vms_getuid()
vms_getuid(void)
{
return ((getgid() << 16) | getuid());
}
@@ -176,8 +175,7 @@ vms_getuid()
#endif
/* check whether the open file specified by `fd' is in stream-lf format */
boolean
file_is_stmlf(fd)
int fd;
file_is_stmlf(int fd)
{
int rfm;
struct stat buf;
@@ -205,10 +203,7 @@ int fd;
/* vms_define() - assign a value to a logical name */
int
vms_define(name, value, flag)
const char *name;
const char *value;
int flag;
vms_define(const char *name, const char *value, int flag)
{
struct dsc {
unsigned short len, mbz;
@@ -251,8 +246,7 @@ int flag;
/* vms_putenv() - create or modify an environment value */
int
vms_putenv(string)
const char *string;
vms_putenv(const char *string)
{
char name[ENVSIZ + 1], value[ENVSIZ + 1], *p; /* [255+1] */
@@ -277,7 +271,7 @@ const char *string;
Called by verify_termcap() for convenience.
*/
static char *
verify_term()
verify_term(void)
{
char *term = getenv("NETHACK_TERM");
if (!term)
@@ -320,7 +314,7 @@ verify_term()
#define NETHACK_DEF_TERMCAP "nethackdir:termcap"
#define HACK_DEF_TERMCAP "hackdir:termcap"
char *verify_termcap() /* called from startup(src/termcap.c) */
char *verify_termcap(void) /* called from startup(src/termcap.c) */
{
struct stat dummy;
const char *tc = getenv("TERMCAP");
@@ -356,7 +350,7 @@ char *verify_termcap() /* called from startup(src/termcap.c) */
static unsigned long oprv[2];
void
privoff()
privoff(void)
{
unsigned long pid = 0, prv[2] = { ~0, ~0 };
unsigned short code = JPI$_PROCPRIV;
@@ -367,7 +361,7 @@ privoff()
}
void
privon()
privon(void)
{
(void) sys$setprv(1, oprv, 0, (unsigned long *) 0);
}
@@ -375,8 +369,7 @@ privon()
#ifdef SYSCF
boolean
check_user_string(userlist)
const char *userlist;
check_user_string(const char *userlist)
{
char usrnambuf[BUFSZ];
const char *sptr, *p, *q;
@@ -414,9 +407,7 @@ const char *userlist;
#if defined(SHELL) || defined(SUSPEND)
static void
hack_escape(screen_manip, msg_str)
boolean screen_manip;
const char *msg_str;
hack_escape(boolean screen_manip, const char *msg_str)
{
if (screen_manip)
suspend_nhwindows(msg_str); /* clear screen, reset terminal, &c */
@@ -425,8 +416,7 @@ const char *msg_str;
}
static void
hack_resume(screen_manip)
boolean screen_manip;
hack_resume(boolean screen_manip)
{
(void) signal(SIGINT, (SIG_RET_TYPE) done1);
if (wizard)
@@ -443,7 +433,7 @@ unsigned long dosh_pid = 0, /* this should cover any interactive escape */
leave any process hanging around) */
int
dosh()
dosh(void)
{
#ifdef SYSCF
if (!sysopt.shellers || !sysopt.shellers[0]
@@ -469,9 +459,7 @@ dosh()
* will be piped into oblivion. Used for silent phone call rejection.
*/
int
vms_doshell(execstring, screenoutput)
const char *execstring;
boolean screenoutput;
vms_doshell(const char *execstring, boolean screenoutput)
{
unsigned long status, new_pid, spawnflags = 0;
struct dsc$descriptor_s comstring, *command, *inoutfile = 0;
@@ -531,7 +519,7 @@ boolean screenoutput;
* if not, there's nothing we can do.
*/
int
dosuspend()
dosuspend(void)
{
static long owner_pid = -1;
unsigned long status;
@@ -598,9 +586,8 @@ vmscond lib$find_file_end(void **);
/* collect a list of character names from all save files for this player */
int
vms_get_saved_games(savetemplate, outarray)
const char *savetemplate; /* wildcarded save file name in native VMS format */
char ***outarray;
vms_get_saved_games(const char *savetemplate, /* wildcarded save file name in native VMS format */
char ***outarray)
{
struct dsc in, out;
unsigned short l;
@@ -638,8 +625,7 @@ char ***outarray;
/* nethack has detected an internal error; try to give a trace of call stack
*/
void
vms_traceback(how)
int how; /* 1: exit after traceback; 2: stay in debugger */
vms_traceback(int how) /* 1: exit after traceback; 2: stay in debugger */
{
/* assumes that a static initializer applies to the first union
field and that no padding will be placed between len and str */
@@ -786,9 +772,8 @@ struct eiha { /* extended image header activation block, $EIHADEF */
with magic arguments; C run-time library won't be initialized yet */
/*ARGSUSED*/
int
vmsexeini(inirtn_unused, clirtn_unused, imghdr)
const void *inirtn_unused, *clirtn_unused;
const unsigned char *imghdr;
vmsexeini(const void *inirtn_unused, const void *clirtn_unused,
const unsigned char *imghdr)
{
const struct ihd *vax_hdr;
const struct eihd *axp_hdr;