switch source tree from k&r to c99

This commit is contained in:
nhmall
2021-01-26 21:06:16 -05:00
parent a2a9cb7b4f
commit f963c5aca7
232 changed files with 12099 additions and 17782 deletions

132
src/dlb.c
View File

@@ -19,15 +19,15 @@
*/
typedef struct dlb_procs {
boolean NDECL((*dlb_init_proc));
void NDECL((*dlb_cleanup_proc));
boolean FDECL((*dlb_fopen_proc), (DLB_P, const char *, const char *));
int FDECL((*dlb_fclose_proc), (DLB_P));
int FDECL((*dlb_fread_proc), (char *, int, int, DLB_P));
int FDECL((*dlb_fseek_proc), (DLB_P, long, int));
char *FDECL((*dlb_fgets_proc), (char *, int, DLB_P));
int FDECL((*dlb_fgetc_proc), (DLB_P));
long FDECL((*dlb_ftell_proc), (DLB_P));
boolean (*dlb_init_proc)(void);
void (*dlb_cleanup_proc)(void);
boolean (*dlb_fopen_proc)(DLB_P, const char *, const char *);
int (*dlb_fclose_proc)(DLB_P);
int (*dlb_fread_proc)(char *, int, int, DLB_P);
int (*dlb_fseek_proc)(DLB_P, long, int);
char *(*dlb_fgets_proc)(char *, int, DLB_P);
int (*dlb_fgetc_proc)(DLB_P);
long (*dlb_ftell_proc)(DLB_P);
} dlb_procs_t;
#if defined(VERSION_IN_DLB_FILENAME)
@@ -35,7 +35,7 @@ char dlbfilename[MAX_DLB_FILENAME];
#endif
/* without extern.h via hack.h, these haven't been declared for us */
extern FILE *FDECL(fopen_datafile, (const char *, const char *, int));
extern FILE *fopen_datafile(const char *, const char *, int);
#ifdef DLBLIB
/*
@@ -57,25 +57,25 @@ extern FILE *FDECL(fopen_datafile, (const char *, const char *, int));
#define MAX_LIBS 4
static library dlb_libs[MAX_LIBS];
static boolean FDECL(readlibdir, (library * lp));
static boolean FDECL(find_file, (const char *name, library **lib,
long *startp, long *sizep));
static boolean NDECL(lib_dlb_init);
static void NDECL(lib_dlb_cleanup);
static boolean FDECL(lib_dlb_fopen, (dlb *, const char *, const char *));
static int FDECL(lib_dlb_fclose, (dlb *));
static int FDECL(lib_dlb_fread, (char *, int, int, dlb *));
static int FDECL(lib_dlb_fseek, (dlb *, long, int));
static char *FDECL(lib_dlb_fgets, (char *, int, dlb *));
static int FDECL(lib_dlb_fgetc, (dlb *));
static long FDECL(lib_dlb_ftell, (dlb *));
static boolean readlibdir(library * lp);
static boolean find_file(const char *name, library **lib, long *startp,
long *sizep);
static boolean lib_dlb_init(void);
static void lib_dlb_cleanup(void);
static boolean lib_dlb_fopen(dlb *, const char *, const char *);
static int lib_dlb_fclose(dlb *);
static int lib_dlb_fread(char *, int, int, dlb *);
static int lib_dlb_fseek(dlb *, long, int);
static char *lib_dlb_fgets(char *, int, dlb *);
static int lib_dlb_fgetc(dlb *);
static long lib_dlb_ftell(dlb *);
/* not static because shared with dlb_main.c */
boolean FDECL(open_library, (const char *lib_name, library *lp));
void FDECL(close_library, (library * lp));
boolean open_library(const char *lib_name, library *lp);
void close_library(library * lp);
/* without extern.h via hack.h, these haven't been declared for us */
extern char *FDECL(eos, (char *));
extern char *eos(char *);
/*
* Read the directory out of the library. Return 1 if successful,
@@ -120,8 +120,7 @@ extern char *FDECL(eos, (char *));
* Return TRUE on success, FALSE on failure.
*/
static boolean
readlibdir(lp)
library *lp; /* library pointer to fill in */
readlibdir(library *lp) /* library pointer to fill in */
{
int i;
char *sp;
@@ -169,10 +168,7 @@ library *lp; /* library pointer to fill in */
* 0 if not found. Fill in the size and starting position.
*/
static boolean
find_file(name, lib, startp, sizep)
const char *name;
library **lib;
long *startp, *sizep;
find_file(const char *name, library **lib, long *startp, long *sizep)
{
int i, j;
library *lp;
@@ -198,9 +194,7 @@ long *startp, *sizep;
* structure. Return TRUE if successful, FALSE otherwise.
*/
boolean
open_library(lib_name, lp)
const char *lib_name;
library *lp;
open_library(const char *lib_name, library *lp)
{
boolean status = FALSE;
@@ -217,8 +211,7 @@ library *lp;
}
void
close_library(lp)
library *lp;
close_library(library *lp)
{
(void) fclose(lp->fdata);
free((genericptr_t) lp->dir);
@@ -232,7 +225,7 @@ library *lp;
* keep track of the file position.
*/
static boolean
lib_dlb_init(VOID_ARGS)
lib_dlb_init(void)
{
/* zero out array */
(void) memset((char *) &dlb_libs[0], 0, sizeof(dlb_libs));
@@ -252,7 +245,7 @@ lib_dlb_init(VOID_ARGS)
}
static void
lib_dlb_cleanup(VOID_ARGS)
lib_dlb_cleanup(void)
{
int i;
@@ -263,8 +256,7 @@ lib_dlb_cleanup(VOID_ARGS)
#ifdef VERSION_IN_DLB_FILENAME
char *
build_dlb_filename(lf)
const char *lf;
build_dlb_filename(const char *lf)
{
Sprintf(dlbfilename, "%s%d%d%d",
lf ? lf : DLBBASENAME, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL);
@@ -274,10 +266,7 @@ const char *lf;
/*ARGSUSED*/
static boolean
lib_dlb_fopen(dp, name, mode)
dlb *dp;
const char *name;
const char *mode UNUSED;
lib_dlb_fopen(dlb *dp, const char *name, const char *mode UNUSED)
{
long start, size;
library *lp;
@@ -296,18 +285,14 @@ const char *mode UNUSED;
/*ARGUSED*/
static int
lib_dlb_fclose(dp)
dlb *dp UNUSED;
lib_dlb_fclose(dlb *dp UNUSED)
{
/* nothing needs to be done */
return 0;
}
static int
lib_dlb_fread(buf, size, quan, dp)
char *buf;
int size, quan;
dlb *dp;
lib_dlb_fread(char *buf, int size, int quan, dlb *dp)
{
long pos, nread, nbytes;
@@ -332,10 +317,7 @@ dlb *dp;
}
static int
lib_dlb_fseek(dp, pos, whence)
dlb *dp;
long pos;
int whence;
lib_dlb_fseek(dlb *dp, long pos, int whence)
{
long curpos;
@@ -360,10 +342,7 @@ int whence;
}
static char *
lib_dlb_fgets(buf, len, dp)
char *buf;
int len;
dlb *dp;
lib_dlb_fgets(char *buf, int len, dlb *dp)
{
int i;
char *bp, c = 0;
@@ -395,8 +374,7 @@ dlb *dp;
}
static int
lib_dlb_fgetc(dp)
dlb *dp;
lib_dlb_fgetc(dlb *dp)
{
char c;
@@ -406,8 +384,7 @@ dlb *dp;
}
static long
lib_dlb_ftell(dp)
dlb *dp;
lib_dlb_ftell(dlb *dp)
{
return dp->mark;
}
@@ -445,7 +422,7 @@ static const dlb_procs_t *dlb_procs;
static boolean dlb_initialized = FALSE;
boolean
dlb_init()
dlb_init(void)
{
if (!dlb_initialized) {
#ifdef DLBLIB
@@ -463,7 +440,7 @@ dlb_init()
}
void
dlb_cleanup()
dlb_cleanup(void)
{
if (dlb_initialized) {
do_dlb_cleanup();
@@ -472,8 +449,7 @@ dlb_cleanup()
}
dlb *
dlb_fopen(name, mode)
const char *name, *mode;
dlb_fopen(const char *name, const char *mode)
{
FILE *fp;
dlb *dp;
@@ -500,8 +476,7 @@ const char *name, *mode;
}
int
dlb_fclose(dp)
dlb *dp;
dlb_fclose(dlb *dp)
{
int ret = 0;
@@ -517,10 +492,7 @@ dlb *dp;
}
int
dlb_fread(buf, size, quan, dp)
char *buf;
int size, quan;
dlb *dp;
dlb_fread(char *buf, int size, int quan, dlb *dp)
{
if (!dlb_initialized || size <= 0 || quan <= 0)
return 0;
@@ -530,10 +502,7 @@ dlb *dp;
}
int
dlb_fseek(dp, pos, whence)
dlb *dp;
long pos;
int whence;
dlb_fseek(dlb *dp, long pos, int whence)
{
if (!dlb_initialized)
return EOF;
@@ -543,10 +512,7 @@ int whence;
}
char *
dlb_fgets(buf, len, dp)
char *buf;
int len;
dlb *dp;
dlb_fgets(char *buf, int len, dlb *dp)
{
if (!dlb_initialized)
return (char *) 0;
@@ -556,8 +522,7 @@ dlb *dp;
}
int
dlb_fgetc(dp)
dlb *dp;
dlb_fgetc(dlb *dp)
{
if (!dlb_initialized)
return EOF;
@@ -567,8 +532,7 @@ dlb *dp;
}
long
dlb_ftell(dp)
dlb *dp;
dlb_ftell(dlb *dp)
{
if (!dlb_initialized)
return 0;