#ifdef SYSCF_FILE
E void NDECL(assure_syscf_file);
#endif
+E int FDECL(nhclose, (int));
#ifdef HOLD_LOCKFILE_OPEN
E void NDECL(really_close);
#endif
clear_bypasses();
fd = open_bonesfile(&u.uz, &bonesid);
if (fd >= 0) {
- (void) close(fd);
+ (void) nhclose(fd);
if (wizard) {
if (yn("Bones file already exists. Replace it?") == 'y') {
if (delete_bonesfile(&u.uz)) goto make_bones;
if (bytes_counted > freediskspace(bones)) { /* not enough room */
if (wizard)
pline("Insufficient space to create bones file.");
- (void) close(fd);
+ (void) nhclose(fd);
cancel_bonesfile();
return;
}
ok = TRUE;
if(wizard) {
if(yn("Get bones?") == 'n') {
- (void) close(fd);
+ (void) nhclose(fd);
compress_bonesfile();
return(0);
}
resetobjs(level.buriedobjlist,TRUE);
}
}
- (void) close(fd);
+ (void) nhclose(fd);
sanitize_engravings();
u.uroleplay.numbones++;
#ifdef MFLOPPY
if (!savelev(fd, ledger_no(&u.uz), COUNT_SAVE)) {
- (void) close(fd);
+ (void) nhclose(fd);
delete_levelfile(ledger_no(&u.uz));
pline("NetHack is out of disk space for making levels!");
You("can save, quit, or continue playing.");
}
minit(); /* ZEROCOMP */
getlev(fd, hackpid, new_ledger, FALSE);
- (void) close(fd);
+ (void) nhclose(fd);
oinit(); /* reassign level dependent obj probabilities */
}
/* do this prior to level-change pline messages */
lftrack.fd = -1;
lftrack.oflag = 0;
if (fd != -1)
- (void)_close(fd);
+ (void)close(fd);
return;
}
int
-close(fd)
+nhclose(fd)
int fd;
{
if (lftrack.fd == fd) {
lftrack.nethack_thinks_it_is_open = FALSE;
return 0;
}
- return _close(fd);
+ return close(fd);
+}
+#else
+int
+nhclose(fd)
+int fd;
+{
+ return close(fd);
}
#endif
-
+
/* ---------- END LEVEL FILE HANDLING ----------- */
if ((fd = open_savefile()) < 0) return fd;
if (validate(fd, fq_save) != 0) {
- (void) close(fd), fd = -1;
+ (void) nhclose(fd), fd = -1;
(void) delete_savefile();
}
return fd;
get_plname_from_file(fd, tplname);
result = dupstr(tplname);
}
- (void) close(fd);
+ (void) nhclose(fd);
}
nh_compress(SAVEF);
if (unlink(lockname) < 0)
HUP raw_printf("Can't unlink %s.", lockname);
# ifdef NO_FILE_LINKS
- (void) close(lockfd);
+ (void) nhclose(lockfd);
# endif
#endif /* UNIX || VMS */
wait_synch();
}
# endif
- (void) close(fd); /* RECORD is accessible */
+ (void) nhclose(fd); /* RECORD is accessible */
} else if ((fd = open(fq_record, O_CREAT|O_RDWR, FCMASK)) >= 0) {
- (void) close(fd); /* RECORD newly created */
+ (void) nhclose(fd); /* RECORD newly created */
# if defined(VMS) && !defined(SECURE)
/* Re-protect RECORD with world:read+write+execute+delete access. */
(void) chmod(fq_record, FCMASK | 007);
raw_printf("Warning: cannot write record %s", tmp);
wait_synch();
} else
- (void) close(fd);
+ (void) nhclose(fd);
} else /* open succeeded */
- (void) close(fd);
+ (void) nhclose(fd);
#else /* MICRO || WIN32*/
# ifdef MAC
if (read(gfd, (genericptr_t) &hpid, sizeof hpid) != sizeof hpid) {
raw_printf(
"\nCheckpoint data incompletely written or subsequently clobbered. Recovery impossible.");
- (void)close(gfd);
+ (void)nhclose(gfd);
return FALSE;
}
if (read(gfd, (genericptr_t) &savelev, sizeof(savelev))
!= sizeof(savelev)) {
raw_printf("\nCheckpointing was not in effect for %s -- recovery impossible.\n",
lock);
- (void)close(gfd);
+ (void)nhclose(gfd);
return FALSE;
}
if ((read(gfd, (genericptr_t) savename, sizeof savename)
(read(gfd, (genericptr_t) &tmpplbuf, pltmpsiz)
!= pltmpsiz)) {
raw_printf("\nError reading %s -- can't recover.\n", lock);
- (void)close(gfd);
+ (void)nhclose(gfd);
return FALSE;
}
sfd = create_savefile();
if (sfd < 0) {
raw_printf("\nCannot recover savefile %s.\n", SAVEF);
- (void)close(gfd);
+ (void)nhclose(gfd);
return FALSE;
}
lfd = open_levelfile(savelev, errbuf);
if (lfd < 0) {
raw_printf("\n%s\n", errbuf);
- (void)close(gfd);
- (void)close(sfd);
+ (void)nhclose(gfd);
+ (void)nhclose(sfd);
delete_savefile();
return FALSE;
}
if (write(sfd, (genericptr_t) &version_data, sizeof version_data)
!= sizeof version_data) {
raw_printf("\nError writing %s; recovery failed.", SAVEF);
- (void)close(gfd);
- (void)close(sfd);
+ (void)nhclose(gfd);
+ (void)nhclose(sfd);
delete_savefile();
return FALSE;
}
raw_printf(
"\nError writing %s; recovery failed (savefile_info).\n",
SAVEF);
- (void)close(gfd);
- (void)close(sfd);
+ (void)nhclose(gfd);
+ (void)nhclose(sfd);
delete_savefile();
return FALSE;
}
raw_printf(
"Error writing %s; recovery failed (player name size).\n",
SAVEF);
- (void)close(gfd);
- (void)close(sfd);
+ (void)nhclose(gfd);
+ (void)nhclose(sfd);
delete_savefile();
return FALSE;
}
raw_printf(
"Error writing %s; recovery failed (player name).\n",
SAVEF);
- (void)close(gfd);
- (void)close(sfd);
+ (void)nhclose(gfd);
+ (void)nhclose(sfd);
delete_savefile();
return FALSE;
}
if (!copy_bytes(lfd, sfd)) {
- (void) close(lfd);
- (void) close(sfd);
+ (void) nhclose(lfd);
+ (void) nhclose(sfd);
delete_savefile();
return FALSE;
}
- (void)close(lfd);
+ (void)nhclose(lfd);
processed[savelev] = 1;
if (!copy_bytes(gfd, sfd)) {
- (void) close(lfd);
- (void) close(sfd);
+ (void) nhclose(lfd);
+ (void) nhclose(sfd);
delete_savefile();
return FALSE;
}
- (void)close(gfd);
+ (void)nhclose(gfd);
processed[0] = 1;
for (lev = 1; lev < 256; lev++) {
levc = (xchar) lev;
write(sfd, (genericptr_t) &levc, sizeof(levc));
if (!copy_bytes(lfd, sfd)) {
- (void) close(lfd);
- (void) close(sfd);
+ (void) nhclose(lfd);
+ (void) nhclose(sfd);
delete_savefile();
return FALSE;
}
- (void)close(lfd);
+ (void)nhclose(lfd);
processed[lev] = 1;
}
}
}
- (void)close(sfd);
+ (void)nhclose(sfd);
#ifdef HOLD_LOCKFILE_OPEN
really_close();
break;
}
(void) write(fd, buf, strlen(buf));
- (void) close(fd);
+ (void) nhclose(fd);
}
}
#endif /* UNIX386MUSIC */
/* Remove levels and bones that may have been created.
*/
- (void) close(nfd);
+ (void) nhclose(nfd);
# ifdef AMIGA
clearlocks();
# else
if (!restgamestate(fd, &stuckid, &steedid)) {
display_nhwindow(WIN_MESSAGE, TRUE);
savelev(-1, 0, FREE_SAVE); /* discard current level */
- (void) close(fd);
+ (void) nhclose(fd);
(void) delete_savefile();
restoring = FALSE;
return(0);
get_plname_from_file(fd, plname);
getlev(fd, 0, (xchar)0, FALSE);
- (void) close(fd);
+ (void) nhclose(fd);
/* Now set the restore settings to match the
* settings used by the save file output routines
} else {
pline("Read %d instead of %u bytes.", rlen, len);
if(restoring) {
- (void) close(fd);
+ (void) nhclose(fd);
(void) delete_savefile();
error("Error restoring old game.");
}
nh_uncompress(fq_save);
fd = open_savefile();
if (fd > 0) {
- (void) close(fd);
+ (void) nhclose(fd);
clear_nhwindow(WIN_MESSAGE);
There("seems to be an old save file.");
if (yn("Overwrite the old file?") == 'n') {
pline("Require %ld bytes but only have %ld.", needed, fds);
}
flushout();
- (void) close(fd);
+ (void) nhclose(fd);
(void) delete_savefile();
return 0;
}
ofd = open_levelfile(ltmp, whynot);
if (ofd < 0) {
HUP pline1(whynot);
- (void) close(fd);
+ (void) nhclose(fd);
(void) delete_savefile();
HUP Strcpy(killer.name, whynot);
HUP done(TRICKED);
}
minit(); /* ZEROCOMP */
getlev(ofd, hackpid, ltmp, FALSE);
- (void) close(ofd);
+ (void) nhclose(ofd);
bwrite(fd, (genericptr_t) <mp, sizeof ltmp); /* level number*/
savelev(fd, ltmp, WRITE_SAVE | FREE_SAVE); /* actual level*/
delete_levelfile(ltmp);
Strcpy(killer.name, whynot);
done(TRICKED);
}
- (void) close(fd);
+ (void) nhclose(fd);
fd = create_levelfile(0, whynot);
if (fd < 0) {
bw_FILE = 0;
} else
#endif
- (void) close(fd);
+ (void) nhclose(fd);
return;
}
int fd;
{
zerocomp_bufoff(fd);
- (void) close(fd);
+ (void) nhclose(fd);
return;
}
#endif /* ZEROCOMP */
if (nto != nfrom)
panic("Copyfile failed!");
} while (nfrom == BUFSIZ);
- (void) close(fdfrom);
- (void) close(fdto);
+ (void) nhclose(fdfrom);
+ (void) nhclose(fdto);
# endif /* TOS */
}
hackpid = 1;
#endif
write(fd, (genericptr_t) &hackpid, sizeof(hackpid));
- close(fd);
+ nhclose(fd);
}
#ifdef MFLOPPY
level_info[0].where = ACTIVE;
if (sysflags.asksavedisk) {
/* Don't prompt if you can find the save file */
if ((fd = open_savefile()) >= 0) {
- (void) close(fd);
+ (void) nhclose(fd);
return 1;
}
clear_nhwindow(WIN_MESSAGE);
if ((comspec = getcomspec()))
if ((fd = open(comspec, O_RDONLY)) >= 0) {
- (void) close(fd);
+ (void) nhclose(fd);
return TRUE;
}
return FALSE;
error("Cannot open %s", fq_lock);
}
- (void) close(fd);
+ (void) nhclose(fd);
if(iflags.window_inited) {
# ifdef SELF_RECOVER
# endif
error("cannot write lock (%s)", fq_lock);
}
- if(close(fd) == -1) {
+ if(nhclose(fd) == -1) {
# if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdirx(orgdir, 0);
# endif