Defines | Functions | Variables

files.c File Reference

#include "hack.h"
#include "dlb.h"
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
Include dependency graph for files.c:

Defines

#define O_BINARY   0
#define SAVESIZE   FILENAME
#define HUP   if (!program_state.done_hup)
#define fopenp   fopen
#define match_varname(INP, NAM, LEN)   match_optname(INP, NAM, LEN, TRUE)
#define tmp_levels   (char *)0
#define tmp_ramdisk   (char *)0

Functions

STATIC_DCL char * FDECL (set_bonesfile_name,(char *, d_level *))
STATIC_DCL char * NDECL (set_bonestemp_name)
STATIC_DCL char * FDECL (make_lockname,(const char *, char *))
STATIC_DCL FILE * FDECL (fopen_config_file,(const char *))
STATIC_DCL int FDECL (get_uchars,(FILE *, char *, char *, uchar *, BOOLEAN_P, int, const char *))
int FDECL (parse_config_line,(FILE *, char *, char *, char *))
char * fname_encode (char *legal, char quotechar, char *s, char *callerbuf, int bufsz) const
char * fname_decode (char quotechar, char *s, char *callerbuf, int bufsz)
const char * fqname (char *basename, int whichprefix, int buffnum) const
int validate_prefix_locations (char *reasonbuf)
FILE * fopen_datafile (char *filename, char *mode, int prefix) const
void set_levelfile_name (char *file, int lev)
int create_levelfile (int lev, errbuf)
int open_levelfile (int lev, errbuf)
void delete_levelfile (int lev)
void clearlocks ()
STATIC_OVL char * set_bonesfile_name (char *file, d_level *lev)
STATIC_OVL char * set_bonestemp_name ()
int create_bonesfile (d_level *lev, char **bonesid, errbuf)
void commit_bonesfile (d_level *lev)
int open_bonesfile (d_level *lev, char **bonesid)
int delete_bonesfile (d_level *lev)
void compress_bonesfile ()
void set_savefile_name ()
int create_savefile ()
int open_savefile ()
int delete_savefile ()
int restore_saved_game ()
char ** get_saved_games ()
void free_saved_games (char **saved)
void compress (char *filename) const
void uncompress (char *filename) const
STATIC_OVL char * make_lockname (char *filename, char *lockname) const
boolean lock_file (char *filename, int whichprefix, int retryct) const
void unlock_file (char *filename) const
STATIC_OVL FILE * fopen_config_file (char *filename) const
STATIC_OVL int get_uchars (FILE *fp, char *buf, char *bufp, uchar *list, boolean modlist, int size, const char *name)
int parse_config_line (FILE *fp, char *buf, char *tmp_ramdisk, char *tmp_levels)
void read_config_file (char *filename) const
void check_recordfile (char *dir) const
void paniclog (char *type, const char *reason) const

Variables

int errno
char bones [] = "bonesnn.xxx"
char lock [PL_NSIZ+14] = "1lock"
char SAVEF [SAVESIZE]
int n_dgns
static int nesting = 0
const char * configfile = "UnNetHack.cnf"
const char * oldconfigfile = "NetHack.cnf"

Define Documentation

#define fopenp   fopen

Referenced by fopen_config_file().

#define HUP   if (!program_state.done_hup)

Referenced by lock_file(), topten(), and unlock_file().

#define match_varname (   INP,
  NAM,
  LEN 
)    match_optname(INP, NAM, LEN, TRUE)

Referenced by parse_config_line().

#define O_BINARY   0
#define SAVESIZE   FILENAME

Referenced by parse_config_line().

#define tmp_levels   (char *)0

Referenced by read_config_file().

#define tmp_ramdisk   (char *)0

Referenced by read_config_file().


Function Documentation

void check_recordfile ( char *  dir ) const

References close(), FCMASK, fqname(), open(), PATHLEN, RECORD, S_IREAD, S_IWRITE, SCOREPREFIX, Strcat, Strcpy, and wait_synch.

Here is the call graph for this function:

void clearlocks (  )

References alllevels, delete_levelfile(), levels, maxledgerno(), permbones, and ramdisk.

Referenced by done(), and restlevelfile().

Here is the call graph for this function:

Here is the caller graph for this function:

void commit_bonesfile ( d_level lev )

References bones, BONESPREFIX, fqname(), pline(), rename(), set_bonesfile_name(), set_bonestemp_name(), unlink(), and wizard.

Referenced by savebones().

Here is the call graph for this function:

Here is the caller graph for this function:

void compress ( char *  filename ) const

References FALSE.

Referenced by compress_bonesfile(), and dosave0().

Here is the caller graph for this function:

void compress_bonesfile (  )

References bones, BONESPREFIX, compress(), and fqname().

Referenced by getbones(), and savebones().

Here is the call graph for this function:

Here is the caller graph for this function:

int create_bonesfile ( d_level lev,
char **  bonesid,
errbuf   
)

References bones, BONESPREFIX, creat(), errno, FCMASK, fqname(), lock, O_BINARY, open(), set_bonesfile_name(), set_bonestemp_name(), and Sprintf.

Referenced by savebones().

Here is the call graph for this function:

Here is the caller graph for this function:

int create_levelfile ( int  lev,
errbuf   
)

References creat(), errno, FCMASK, linfo::flags, fqname(), level_info, LEVELPREFIX, LFILE_EXISTS, lock, O_BINARY, open(), set_levelfile_name(), and Sprintf.

Referenced by currentlevel_rewrite(), and restlevelfile().

Here is the call graph for this function:

Here is the caller graph for this function:

int create_savefile (  )

References creat(), FCMASK, fqname(), getuid, O_BINARY, open(), SAVEF, and SAVEPREFIX.

Referenced by dosave0().

Here is the call graph for this function:

Here is the caller graph for this function:

int delete_bonesfile ( d_level lev )

References bones, BONESPREFIX, fqname(), set_bonesfile_name(), and unlink().

Referenced by getbones(), and savebones().

Here is the call graph for this function:

Here is the caller graph for this function:

void delete_levelfile ( int  lev )

References linfo::flags, flags, fqname(), level_info, LEVELPREFIX, LFILE_EXISTS, lock, set_levelfile_name(), and unlink().

Referenced by clearlocks(), currentlevel_rewrite(), dosave0(), and goto_level().

Here is the call graph for this function:

Here is the caller graph for this function:

int delete_savefile (  )

References fqname(), SAVEF, SAVEPREFIX, and unlink().

Referenced by dorecover(), dosave0(), mread(), and restore_saved_game().

Here is the call graph for this function:

Here is the caller graph for this function:

STATIC_DCL FILE* FDECL ( fopen_config_file  ,
(const char *)   
)
STATIC_DCL int FDECL ( get_uchars  ,
(FILE *, char *, char *, uchar *, BOOLEAN_P, int, const char *)   
)
STATIC_DCL char* FDECL ( make_lockname  ,
(const char *, char *)   
)
int FDECL ( parse_config_line  ,
(FILE *, char *, char *, char *)   
)
STATIC_DCL char* FDECL ( set_bonesfile_name  ,
(char *, d_level *)   
)
char* fname_decode ( char  quotechar,
char *  s,
char *  callerbuf,
int  bufsz 
)
char* fname_encode ( char *  legal,
char  quotechar,
char *  s,
char *  callerbuf,
int  bufsz 
) const

References index.

Referenced by set_savefile_name().

Here is the caller graph for this function:

STATIC_OVL FILE* fopen_config_file ( char *  filename ) const

References access(), BUFSZ, CONFIGPREFIX, errno, fopenp, fqname(), nh_getenv(), Sprintf, Strcpy, and wait_synch.

Referenced by read_config_file().

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* fopen_datafile ( char *  filename,
char *  mode,
int  prefix 
) const

References BUFSIZ, fqname(), index, and TROUBLEPREFIX.

Referenced by paniclog(), prscore(), topten(), and tt_oname().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* fqname ( char *  basename,
int  whichprefix,
int  buffnum 
) const
void free_saved_games ( char**  saved )
char** get_saved_games (  )

References BUFSZ, getuid, and Sprintf.

STATIC_OVL int get_uchars ( FILE *  fp,
char *  buf,
char *  bufp,
uchar list,
boolean  modlist,
int  size,
const char *  name 
)

References BUFSZ, FALSE, TRUE, and wait_synch.

Referenced by parse_config_line().

Here is the caller graph for this function:

boolean lock_file ( char *  filename,
int  whichprefix,
int  retryct 
) const

References BUFSZ, DeleteFile, errno, FALSE, fqname(), HUP, LOCKPREFIX, make_lockname(), open(), perror, raw_print(), S_IWRITE, SEEK_SET, and TRUE.

Referenced by topten().

Here is the call graph for this function:

Here is the caller graph for this function:

STATIC_OVL char* make_lockname ( char *  filename,
char *  lockname 
) const

References rindex, Strcat, and Strcpy.

Referenced by lock_file(), and unlock_file().

Here is the caller graph for this function:

STATIC_DCL char* NDECL ( set_bonestemp_name   )
int open_bonesfile ( d_level lev,
char **  bonesid 
)

References bones, BONESPREFIX, fqname(), O_BINARY, open(), set_bonesfile_name(), and uncompress().

Referenced by getbones(), and savebones().

Here is the call graph for this function:

Here is the caller graph for this function:

int open_levelfile ( int  lev,
errbuf   
)

References errno, fqname(), level_info, LEVELPREFIX, lock, O_BINARY, open(), set_levelfile_name(), Sprintf, and where.

Referenced by dosave0(), and goto_level().

Here is the call graph for this function:

Here is the caller graph for this function:

int open_savefile (  )

References fqname(), O_BINARY, open(), SAVEF, and SAVEPREFIX.

Referenced by dosave0(), and restore_saved_game().

Here is the call graph for this function:

Here is the caller graph for this function:

void paniclog ( char *  type,
const char *  reason 
) const

References BUFSZ, fopen_datafile(), PANICLOG, plname, program_state, TROUBLEPREFIX, u, you::ubirthday, version_string(), and yyyymmdd().

Referenced by done(), savebones(), validate_prefix_locations(), and yn_function().

Here is the call graph for this function:

Here is the caller graph for this function:

int parse_config_line ( FILE *  fp,
char *  buf,
char *  tmp_ramdisk,
char *  tmp_levels 
)
void read_config_file ( char *  filename ) const

References bones, BUFSZ, fopen_config_file(), levels, parse_config_line(), PATHLEN, permbones, ramdisk, set_duplicate_opt_detection(), Strcpy, tmp_levels, tmp_ramdisk, TRUE, and wait_synch.

Referenced by initoptions().

Here is the call graph for this function:

Here is the caller graph for this function:

int restore_saved_game (  )

References close(), delete_savefile(), fqname(), open_savefile(), SAVEF, SAVEPREFIX, set_savefile_name(), uncompress(), and uptodate().

Here is the call graph for this function:

STATIC_OVL char* set_bonesfile_name ( char *  file,
d_level lev 
)

References s_level::boneid, dungeon::boneid, d_level::dlevel, d_level::dnum, dungeons, eos(), Role::filecode, In_quest(), Is_special(), Sprintf, Strcat, and urole.

Referenced by commit_bonesfile(), create_bonesfile(), delete_bonesfile(), and open_bonesfile().

Here is the call graph for this function:

Here is the caller graph for this function:

STATIC_OVL char* set_bonestemp_name (  )

References eos(), lock, rindex, Sprintf, and Strcat.

Referenced by commit_bonesfile(), and create_bonesfile().

Here is the call graph for this function:

Here is the caller graph for this function:

void set_levelfile_name ( char *  file,
int  lev 
)

References eos(), rindex, Sprintf, and Strcat.

Referenced by create_levelfile(), delete_levelfile(), and open_levelfile().

Here is the call graph for this function:

Here is the caller graph for this function:

void set_savefile_name (  )

References BUFSZ, FILENAME, fname_encode(), getuid, PATHLEN, plname, regularize(), SAVEF, Sprintf, Strcat, and Strcpy.

Referenced by restore_saved_game().

Here is the call graph for this function:

Here is the caller graph for this function:

void uncompress ( char *  filename ) const

References TRUE.

Referenced by dosave0(), open_bonesfile(), and restore_saved_game().

Here is the caller graph for this function:

void unlock_file ( char *  filename ) const

References BUFSZ, close(), DeleteFile, fqname(), HUP, LOCKPREFIX, make_lockname(), and unlink().

Referenced by topten().

Here is the call graph for this function:

Here is the caller graph for this function:

int validate_prefix_locations ( char *  reasonbuf )

References BUFSZ, CONFIGPREFIX, DATAPREFIX, errno, fqn_prefix, fqname(), paniclog(), PREFIX_COUNT, Sprintf, Strcat, and unlink().

Here is the call graph for this function:


Variable Documentation

char bones[] = "bonesnn.xxx"
const char* configfile = "UnNetHack.cnf"
int errno
char lock[PL_NSIZ+14] = "1lock"
int n_dgns
int nesting = 0 [static]
const char* oldconfigfile = "NetHack.cnf"
char SAVEF[SAVESIZE]