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 */ /* vms_link() -- create an additional directory for an existing file */
int int
vms_link(file, new) vms_link(const char *file, const char *new)
const char *file, *new;
{ {
struct FAB fab; struct FAB fab;
struct NAM nam; struct NAM nam;
@@ -83,8 +82,7 @@ const char *file, *new;
(because the file won't be deleted, just made inaccessible!). (because the file won't be deleted, just made inaccessible!).
*/ */
int int
vms_unlink(file) vms_unlink(const char *file)
const char *file;
{ {
struct FAB fab; struct FAB fab;
struct NAM nam; struct NAM nam;
@@ -115,9 +113,7 @@ const char *file;
*/ */
#undef creat #undef creat
int int
vms_creat(file, mode) vms_creat(const char *file, unsigned int mode)
const char *file;
unsigned int mode;
{ {
char filnambuf[BUFSIZ]; /*(not BUFSZ)*/ char filnambuf[BUFSIZ]; /*(not BUFSZ)*/
@@ -141,10 +137,7 @@ unsigned int mode;
*/ */
#undef open #undef open
int int
vms_open(file, flags, mode) vms_open(const char *file, int flags, unsigned int mode)
const char *file;
int flags;
unsigned int mode;
{ {
char filnambuf[BUFSIZ]; /*(not BUFSZ)*/ char filnambuf[BUFSIZ]; /*(not BUFSZ)*/
int fd; int fd;
@@ -165,8 +158,7 @@ unsigned int mode;
/* do likewise for fopen() */ /* do likewise for fopen() */
#undef fopen #undef fopen
FILE * FILE *
vms_fopen(file, mode) vms_fopen(const char *file, const char *mode)
const char *file, *mode;
{ {
char filnambuf[BUFSIZ]; /*(not BUFSZ)*/ char filnambuf[BUFSIZ]; /*(not BUFSZ)*/
FILE *fp; FILE *fp;
@@ -191,8 +183,7 @@ const char *file, *mode;
the command line). This version doesn't handle Unix-style file specs. the command line). This version doesn't handle Unix-style file specs.
*/ */
boolean boolean
same_dir(d1, d2) same_dir(const char *d1, const char *d2)
const char *d1, *d2;
{ {
if (!d1 || !*d1 || !d2 || !*d2) if (!d1 || !*d1 || !d2 || !*d2)
return FALSE; return FALSE;
@@ -247,8 +238,7 @@ const char *d1, *d2;
#define CASE2(V, W) CASE1(V) : CASE1(W) #define CASE2(V, W) CASE1(V) : CASE1(W)
int int
c__translate(code) c__translate(int code)
int code;
{ {
register int trans; 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 */ /* return a copy of the 'base' portion of a filename */
char * char *
vms_basename(name) vms_basename(const char *name)
const char *name;
{ {
unsigned len; unsigned len;
char *base, *base_p; 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 /* try to decipher and categorize broadcast message text
*/ */
static struct mail_info * static struct mail_info *
parse_brdcst(buf) /* called by parse_next_broadcast() */ parse_brdcst(char *buf) /* called by parse_next_broadcast() */
char *buf; /* input: filtered broadcast text */ /* input: filtered broadcast text */
{ {
int typ; int typ;
char *txt; char *txt;
@@ -294,8 +294,8 @@ char *buf; /* input: filtered broadcast text */
/* filter out non-printable characters and redundant noise /* filter out non-printable characters and redundant noise
*/ */
static void filter_brdcst(buf) /* called by parse_next_broadcast() */ static void filter_brdcst(register char *buf) /* called by parse_next_broadcast() */
register char *buf; /* in: original text; out: filtered text */ /* in: original text; out: filtered text */
{ {
register char c, *p, *buf_p; 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 /* 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; short length, msg_type;
$DESCRIPTOR(message, empty_string); /* string descriptor for buf[] */ $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 /* 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) { if (broadcasts > 0) {
short len, typ; short len, typ;
@@ -376,8 +376,7 @@ static void flush_broadcasts() /* called from disable_broadcast_trapping() */
*/ */
/*ARGSUSED*/ /*ARGSUSED*/
static void static void
broadcast_ast(dummy) /* called asynchronously by terminal driver */ broadcast_ast(int dummy UNUSED) /* called asynchronously by terminal driver */
int dummy UNUSED;
{ {
broadcasts++; broadcasts++;
} }
@@ -385,7 +384,7 @@ int dummy UNUSED;
/* initialize the broadcast manipulation code; SMG makes this easy /* initialize the broadcast manipulation code; SMG makes this easy
*/ */
unsigned long 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; 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 /* set up the terminal driver to deliver $brkthru data to a mailbox device
*/ */
unsigned long unsigned long
enable_broadcast_trapping() /* called by setftty() */ enable_broadcast_trapping(void) /* called by setftty() */
{ {
unsigned long sts = 1; unsigned long sts = 1;
@@ -427,7 +426,7 @@ 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 unsigned long
disable_broadcast_trapping() /* called by settty() */ disable_broadcast_trapping(void) /* called by settty() */
{ {
unsigned long sts = 1; unsigned long sts = 1;
@@ -445,22 +444,22 @@ disable_broadcast_trapping() /* called by settty() */
/* simple stubs for non-mail configuration */ /* simple stubs for non-mail configuration */
unsigned long unsigned long
init_broadcast_trapping() init_broadcast_trapping(void)
{ {
return 1; return 1;
} }
unsigned long unsigned long
enable_broadcast_trapping() enable_broadcast_trapping(void)
{ {
return 1; return 1;
} }
unsigned long unsigned long
disable_broadcast_trapping() disable_broadcast_trapping(void)
{ {
return 1; return 1;
} }
struct mail_info * struct mail_info *
parse_next_broadcast() parse_next_broadcast(void)
{ {
return 0; return 0;
} }
@@ -494,7 +493,7 @@ struct mail_info *foo;
} }
void void
ckmailstatus() ckmailstatus(void)
{ {
struct mail_info *brdcst, *parse_next_broadcast(); struct mail_info *brdcst, *parse_next_broadcast();
@@ -509,7 +508,7 @@ ckmailstatus()
} }
int int
main() main(int argc UNUSED, char *argv[] UNUSED)
{ {
char dummy[BUFSIZ]; char dummy[BUFSIZ];
@@ -526,23 +525,21 @@ main()
} }
void void
panic(s) panic(char *s)
char *s;
{ {
raw_print(s); raw_print(s);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
void void
raw_print(s) raw_print(char *s)
char *s;
{ {
puts(s); puts(s);
fflush(stdout); fflush(stdout);
} }
void void
wait_synch() wait_synch(void)
{ {
char dummy[BUFSIZ]; char dummy[BUFSIZ];

View File

@@ -28,9 +28,7 @@ static void wd_message(void);
static boolean wiz_error_flag = FALSE; static boolean wiz_error_flag = FALSE;
int int
main(argc, argv) main(int argc, char *argv[])
int argc;
char *argv[];
{ {
NHFILE *nhfp; NHFILE *nhfp;
#ifdef CHDIR #ifdef CHDIR
@@ -247,9 +245,7 @@ attempt_restore:
} }
static void static void
process_options(argc, argv) process_options(int argc, char *argv[])
int argc;
char *argv[];
{ {
int i; int i;
@@ -341,9 +337,7 @@ char *argv[];
#ifdef CHDIR #ifdef CHDIR
void void
chdirx(dir, wr) chdirx(const char *dir, boolean wr)
const char *dir;
boolean wr;
{ {
#ifndef HACKDIR #ifndef HACKDIR
static const char *defdir = "."; static const char *defdir = ".";
@@ -372,7 +366,7 @@ boolean wr;
#endif /* CHDIR */ #endif /* CHDIR */
static void static void
whoami() whoami(void)
{ {
/* /*
* Who am i? Algorithm: 1. Use name as specified in NETHACKOPTIONS; * 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. */ 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( /*+ prototype in <signal.h> is screwed */
genericptr_t sigargs, mechargs; /* [0] is argc, [1..argc] are the real args */ genericptr_t sigargs,
genericptr_t mechargs) /* [0] is argc, [1..argc] are the real args */
{ {
unsigned long condition = ((unsigned long *) sigargs)[1]; unsigned long condition = ((unsigned long *) sigargs)[1];
@@ -448,7 +443,7 @@ sethanguphandler(void (*handler)(int))
#ifdef PORT_HELP #ifdef PORT_HELP
void void
port_help() port_help(void)
{ {
/* /*
* Display VMS-specific help. Just show contents of the helpfile * 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 */ /* validate wizard mode if player has requested access to it */
boolean boolean
authorize_wizard_mode() authorize_wizard_mode(void)
{ {
if (!strcmpi(nh_getenv("USER"), WIZARD_NAME)) if (!strcmpi(nh_getenv("USER"), WIZARD_NAME))
return TRUE; return TRUE;
@@ -469,7 +464,7 @@ authorize_wizard_mode()
} }
static void static void
wd_message() wd_message(void)
{ {
if (wiz_error_flag) { if (wiz_error_flag) {
pline("Only user \"%s\" may access debug (wizard) mode.", pline("Only user \"%s\" may access debug (wizard) mode.",
@@ -481,7 +476,7 @@ wd_message()
} }
unsigned long unsigned long
sys_random_seed() sys_random_seed(void)
{ {
unsigned long seed; unsigned long seed;
unsigned long pid = (unsigned long) getpid(); 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 */ /* terminate, converting Unix-style exit code into VMS status code */
void void
vms_exit(status) vms_exit(int status)
int status;
{ {
/* convert non-zero to failure, zero to success */ /* convert non-zero to failure, zero to success */
exit(status ? (SS$_ABORT | STS$M_INHIB_MSG) : SS$_NORMAL); 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 */ /* put the user into the debugger; used for abort() when in wizard mode */
void void
vms_abort() vms_abort(void)
{ {
if (debuggable) if (debuggable)
lib$signal(SS$_DEBUG); 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 */ /* rename the real vms_getchar and interpose this one in front of it */
int int
vms_getchar() vms_getchar(void)
{ {
static int althack = 0, altprefix; static int althack = 0, altprefix;
char *nhalthack; char *nhalthack;
@@ -135,7 +135,7 @@ vms_getchar()
#endif /*DEBUG*/ #endif /*DEBUG*/
int int
vms_getchar() vms_getchar(void)
{ {
short key; short key;
#ifdef USE_QIO_INPUT #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). */ /* Ultimate return value is (index into smg_keypad_codes[] + 256). */
static short static short
parse_function_key(c) parse_function_key(register int c)
register int c;
{ {
struct _rd_iosb iosb; struct _rd_iosb iosb;
unsigned long sts; unsigned long sts;
@@ -356,7 +355,7 @@ register int c;
#endif /* USE_QIO_INPUT */ #endif /* USE_QIO_INPUT */
static void static void
setctty() setctty(void)
{ {
struct _sm_iosb iosb; struct _sm_iosb iosb;
unsigned long status; unsigned long status;
@@ -378,7 +377,7 @@ setctty()
/* atexit() routine */ /* atexit() routine */
static void static void
resettty() resettty(void)
{ {
if (settty_needed) { if (settty_needed) {
bombing = TRUE; /* don't clear screen; preserve traceback info */ bombing = TRUE; /* don't clear screen; preserve traceback info */
@@ -394,7 +393,7 @@ resettty()
* (for initial startup and for returning from '!' or ^Z). * (for initial startup and for returning from '!' or ^Z).
*/ */
void void
gettty() gettty(void)
{ {
static char dev_tty[] = "TT:"; static char dev_tty[] = "TT:";
static $DESCRIPTOR(tty_dsc, dev_tty); static $DESCRIPTOR(tty_dsc, dev_tty);
@@ -445,8 +444,7 @@ gettty()
/* reset terminal to original state */ /* reset terminal to original state */
void void
settty(s) settty(const char *s)
const char *s;
{ {
if (!bombing) if (!bombing)
end_screen(); end_screen();
@@ -474,8 +472,7 @@ const char *s;
/* same as settty, with no clearing of the screen */ /* same as settty, with no clearing of the screen */
void void
shuttty(s) shuttty(const char *s)
const char *s;
{ {
bombing = TRUE; bombing = TRUE;
settty(s); settty(s);
@@ -483,7 +480,7 @@ const char *s;
} }
void void
setftty() setftty(void)
{ {
unsigned long mask = LIB$M_CLI_CTRLT | LIB$M_CLI_CTRLY; unsigned long mask = LIB$M_CLI_CTRLT | LIB$M_CLI_CTRLY;
@@ -510,14 +507,14 @@ setftty()
/* enable kbd interupts if enabled when game started */ /* enable kbd interupts if enabled when game started */
void void
intron() intron(void)
{ {
intr_char = CTRL('C'); intr_char = CTRL('C');
} }
/* disable kbd interrupts if required*/ /* disable kbd interrupts if required*/
void void
introff() introff(void)
{ {
intr_char = 0; 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 /* sleep for specified number of milliseconds (note: the timer used
generally only has 10-millisecond resolution at the hardware level...) */ generally only has 10-millisecond resolution at the hardware level...) */
void void
msleep(mseconds) msleep(unsigned mseconds) /* milliseconds */
unsigned mseconds; /* milliseconds */
{ {
long pid = 0L, zero = 0L, msec, qtime[2]; long pid = 0L, zero = 0L, msec, qtime[2];

View File

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