lib/tt/mini_isam: Update to use strict prototypes, required for C23/GCC 15 etc

This commit is contained in:
Peter Howkins
2025-12-23 17:34:45 +00:00
parent 2081389353
commit dd3fd3ddf8
34 changed files with 100 additions and 90 deletions

View File

@@ -58,7 +58,6 @@
int int
isaddindex(int isfd, struct keydesc *keydesc) isaddindex(int isfd, struct keydesc *keydesc)
{ {
int _amaddindex();
Fab *fab; Fab *fab;
int ret; int ret;

View File

@@ -40,7 +40,7 @@
#include "isam_impl.h" #include "isam_impl.h"
#include <sys/time.h> #include <sys/time.h>
Static int _am_addprimary(); Static int _am_addprimary(Fab *fab, struct keydesc *keydesc);
/* /*

View File

@@ -52,12 +52,15 @@ SMI */
#define LONG_BIT 32 #define LONG_BIT 32
#endif #endif
extern short ldint(); extern short ldint(char *);
extern long ldlong(); extern long ldlong(char *);
extern float ldfloat(); extern float ldfloat(char *);
extern double lddbl(); extern double lddbl(char *);
extern short ldshort(); extern short ldshort();
extern int ldchar(), stchar(), stlong(), stdbl(); extern int ldchar(char *, int, char *);
extern int stchar(char *, char *, int);
extern int stlong(long, char *);
extern int stdbl(double, char *);
extern int stint(short val, char *p); extern int stint(short val, char *p);
extern int stfloat(float f, char *p); extern int stfloat(float f, char *p);

View File

@@ -162,9 +162,9 @@ typedef struct bytearray {
char *data; char *data;
} Bytearray; } Bytearray;
extern Bytearray _bytearr_getempty(), _bytearr_dup(); extern Bytearray _bytearr_getempty(), _bytearr_dup(Bytearray *);
extern Bytearray _bytearr_new(u_short len, char *data); extern Bytearray _bytearr_new(u_short len, char *data);
extern void _bytearr_free(); extern void _bytearr_free(Bytearray *);
/* Client identification - used to identify owners of locks */ /* Client identification - used to identify owners of locks */
@@ -176,9 +176,8 @@ extern void _bytearr_free();
#define MAXISFD FD_SETSIZE #define MAXISFD FD_SETSIZE
#define NOISFD (-1) /* Not a valid file descriptor */ #define NOISFD (-1) /* Not a valid file descriptor */
extern struct fab *_isfd_find(); extern struct fab *_isfd_find(Isfd);
extern void _isfd_delete(); extern void _isfd_delete(Isfd);
extern Isfd _isfd_insert();
/* Definitions related to File access block (isfab.c file */ /* Definitions related to File access block (isfab.c file */
@@ -194,8 +193,8 @@ enum readmode { RM_FIRST = 0, RM_LAST = 1, RM_NEXT = 2, RM_PREV = 3,
/* lock flag is passed to Access Method module for every record oriented op. */ /* lock flag is passed to Access Method module for every record oriented op. */
/* Bit position in the lock flag: */ /* Bit position in the lock flag: */
enum openmode _getopenmode(); enum openmode _getopenmode(int);
enum readmode _getreadmode(); enum readmode _getreadmode(int);
/* Error code structure */ /* Error code structure */
struct errcode { struct errcode {
@@ -228,8 +227,8 @@ typedef struct fab {
#define FAB_ISFDSET(fab, isfd) (fab->isfd = isfd) #define FAB_ISFDSET(fab, isfd) (fab->isfd = isfd)
extern Fab *_fab_new(); extern Fab *_fab_new(char *, enum openmode, Bool, int, int);
void _fab_destroy(); void _fab_destroy(Fab *);
/* ISAM file identification for locking purposes. */ /* ISAM file identification for locking purposes. */
typedef struct lckfid { typedef struct lckfid {

View File

@@ -166,7 +166,7 @@ int iserase(char *isfname);
void _isfatal_error(char *msg); void _isfatal_error(char *msg);
void _isfatal_error1(char *msg); void _isfatal_error1(char *msg);
void _isam_warning(char *msg); void _isam_warning(char *msg);
int _isfatal_error_set_func(int (*func)(void)); int _isfatal_error_set_func(int (*func)(char *));
void _setiserrno2(int error, int is1, int is2); void _setiserrno2(int error, int is1, int is2);
void _seterr_errcode(struct errcode *errcode); void _seterr_errcode(struct errcode *errcode);

View File

@@ -42,11 +42,10 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
extern int _iskeycmp(); static void _readallrecords(Fcb *fcb, Issort *srt, Keydesc2 *pkeydesc2);
static void _attach_dups_serial(Issort *srt, Keydesc2 *pkeydesc2);
static void _readallrecords(), _attach_dups_serial(); static Blkno _buildbtree(Fcb *fcb, Keydesc2 *pkeydesc2, Issort *srt);
static Blkno _buildbtree(); static int _duplicate_exist(Issort *srt, int keylength);
static int _duplicate_exist();
static void checkavailfd(void); static void checkavailfd(void);
/* /*
@@ -386,7 +385,7 @@ _readallrecords(Fcb *fcb, Issort *srt, Keydesc2 *pkeydesc2)
char keybuf [MAXKEYSIZE]; char keybuf [MAXKEYSIZE];
Recno recnum; Recno recnum;
int reclen = 0; int reclen = 0;
int (*rec_read)() = (fcb->varflag?_vlrec_read:_flrec_read); int (*rec_read)(Fcb *, char *, Recno, int *) = (fcb->varflag?_vlrec_read:_flrec_read);
for (recnum = 1; recnum <= fcb->lastrecno; recnum++) { for (recnum = 1; recnum <= fcb->lastrecno; recnum++) {
@@ -457,7 +456,6 @@ _attach_dups_serial(Issort *srt, Keydesc2 *pkeydesc2)
Static Blkno Static Blkno
_buildbtree(Fcb *fcb, Keydesc2 *pkeydesc2, Issort *srt) _buildbtree(Fcb *fcb, Keydesc2 *pkeydesc2, Issort *srt)
{ {
Bufhdr *_allockpage();
int depth; int depth;
int nrecords = fcb->nrecords; int nrecords = fcb->nrecords;
int keyspernode[ISMAXBTRLEVEL]; int keyspernode[ISMAXBTRLEVEL];

View File

@@ -40,7 +40,7 @@
#include "isam_impl.h" #include "isam_impl.h"
void _delkeys(); void _delkeys(Fcb *fcb, char *record, Recno recnum);
/* /*
* _amdelrec(isfhandle, recnum, errcode) * _amdelrec(isfhandle, recnum, errcode)
@@ -62,8 +62,8 @@ _amdelrec(Bytearray *isfhandle, Recno recnum, struct errcode *errcode)
Fcb *fcb = NULL; Fcb *fcb = NULL;
char recbuf[ISMAXRECLEN]; char recbuf[ISMAXRECLEN];
int reclen; int reclen;
int (*rec_read)(); int (*rec_read)(Fcb *, char *, Recno, int *);
int (*rec_delete)(); int (*rec_delete)(Fcb *, Recno);
_isam_entryhook(); _isam_entryhook();

View File

@@ -40,7 +40,7 @@
#include "isam_impl.h" #include "isam_impl.h"
static int _addkeys2 (); static int _addkeys2 (Fcb *fcb, char *record, Recno recnum, Bytearray *curpos);
extern long *ismaxlong; extern long *ismaxlong;
/* /*
@@ -70,7 +70,7 @@ _amwrite(Bytearray *isfhandle, char *record, int reclen,
Recno recnum2; Recno recnum2;
Crp *crp; Crp *crp;
int err; int err;
int (*rec_write)(); int (*rec_write)(Fcb *, char *, Recno *, int);
_isam_entryhook(); _isam_entryhook();

View File

@@ -40,8 +40,6 @@
#include "isam_impl.h" #include "isam_impl.h"
extern int _iskeycmp();
void leftkey_up(Btree *, int); void leftkey_up(Btree *, int);
static void insert_key(Btree *, char *, int, char *, Blkno); static void insert_key(Btree *, char *, int, char *, Blkno);

View File

@@ -40,8 +40,6 @@
#include "isam_impl.h" #include "isam_impl.h"
extern int _iskeycmp();
static void remove_entry(Btree *, char *, int); static void remove_entry(Btree *, char *, int);
static void move_from_right(Btree *, char *, char *, int); static void move_from_right(Btree *, char *, char *, int);
static void move_from_left(Btree *, char *, char *, int); static void move_from_left(Btree *, char *, char *, int);

View File

@@ -70,7 +70,7 @@
* *
*/ */
typedef int (* intfunc)(); typedef int (* intfunc)(char *);
int int
iscntl(int isfd, int func, ...) iscntl(int isfd, int func, ...)

View File

@@ -40,7 +40,7 @@
#include "isam_impl.h" #include "isam_impl.h"
#include <sys/time.h> #include <sys/time.h>
static int _amdelcurr(); static int _amdelcurr(Bytearray *isfhandle, Bytearray *curpos, Recno *recnum, struct errcode *errcod);
/* /*
* err = isdelcurr(isfd, record) * err = isdelcurr(isfd, record)
@@ -118,8 +118,8 @@ _amdelcurr(Bytearray *isfhandle, Bytearray *curpos, Recno *recnum,
Crp *crp; Crp *crp;
char recbuf[ISMAXRECLEN]; char recbuf[ISMAXRECLEN];
int reclen; int reclen;
int (*rec_read)(); int (*rec_read)(Fcb *, char *, Recno, int *);
int (*rec_delete)(); int (*rec_delete)(Fcb *, Recno);
_isam_entryhook(); _isam_entryhook();

View File

@@ -62,7 +62,6 @@
int int
isdelrec(int isfd, long recnum) isdelrec(int isfd, long recnum)
{ {
int _amdelrec();
Fab *fab; Fab *fab;
int ret; int ret;

View File

@@ -62,9 +62,13 @@ extern struct dlink *_isdln_next(), *_isdln_first();
#define _isdln_isempty(l) _isdln_base_isempty(base,(l)) #define _isdln_isempty(l) _isdln_base_isempty(base,(l))
/*---------------------- Local data ---------------------------------------*/ /*---------------------- Local data ---------------------------------------*/
static Bufhdr *_getavail(), *_findblock(); static Bufhdr *_getavail(void);
static void _disk_init(), _commit1buffer(), _rollback1buffer(), _flush1buffer(); static Bufhdr *_findblock(Fcb *fcb, int unixfd, Blkno blkno);
static void _makenodata(); static void _disk_init(void);
static void _commit1buffer(Bufhdr *p);
static void _rollback1buffer(Bufhdr *p);
static void _flush1buffer(Bufhdr *p);
static void _makenodata(Bufhdr *p);
Bufhdr bufhdrs [ISMAXBUFFERS]; Bufhdr bufhdrs [ISMAXBUFFERS];
struct dlink hashhdrs [ISHASHHDRS]; /* Heads of hashed lists */ struct dlink hashhdrs [ISHASHHDRS]; /* Heads of hashed lists */

View File

@@ -41,8 +41,10 @@
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
static void _unlink_datfile(), _unlink_indfile(), _unlink_varfile(); static void _unlink_datfile(char *isfname);
static int _amerase(); static void _unlink_indfile(char *isfname);
static void _unlink_varfile(char *isfnam);
static int _amerase(Bytearray *isfhandle, struct errcode *errcode);
/* /*
* isfd = iserase(isfname, mode) * isfd = iserase(isfname, mode)

View File

@@ -48,7 +48,7 @@
* Fatal error. Display message and terminate program. * Fatal error. Display message and terminate program.
*/ */
static int (*fatal_error_user_handler)(); /* set by iscntl(..,ISCNTL_FATAL,..) */ static int (*fatal_error_user_handler)(char *); /* set by iscntl(..,ISCNTL_FATAL,..) */
void void
_isfatal_error(char *msg) _isfatal_error(char *msg)
@@ -109,10 +109,10 @@ _isam_warning(char *msg)
} }
/* Set user specified fatal_error handler */ /* Set user specified fatal_error handler */
int _isfatal_error_set_func(int(*func)()) int _isfatal_error_set_func(int(*func)(char *))
{ {
#if 0 #if 0
int (*oldfunc)(); int (*oldfunc)(char *);
oldfunc = fatal_error_user_handler; oldfunc = fatal_error_user_handler;
#endif #endif

View File

@@ -42,9 +42,15 @@
#include "isam_impl.h" #include "isam_impl.h"
#include <sys/stat.h> #include <sys/stat.h>
static int _create_datfile(), _create_indfile(), _create_varfile(); static int _create_datfile(char *isfname);
static void _remove_datfile(), _remove_indfile(), _remove_varfile(); static int _create_indfile(char *isfname);
Static int _open_datfile(), _open_indfile(), _open_varfile(); static int _create_varfile(char *isfname);
static void _remove_datfile(char *isfname);
static void _remove_indfile(char *isfname);
static void _remove_varfile(char *isfname);
static int _open_datfile(char *isfname, Bool *rdonly);
static int _open_indfile(char *isfname, Bool rdonly);
static int _open_varfile(char *isfname, Bool rdonly);
/* /*
* _isfcb_create(isfname, crdat, crind, crvar, owner, group, u_mask, errcode) * _isfcb_create(isfname, crdat, crind, crvar, owner, group, u_mask, errcode)

View File

@@ -40,7 +40,7 @@
#include "isam_impl.h" #include "isam_impl.h"
Static int _keypart2cmp(); Static int _keypart2cmp(struct keypart2 *l, struct keypart2 *r);
/* /*
* _isfcb_primkeyadd(fcb, keydesc2) * _isfcb_primkeyadd(fcb, keydesc2)
* *

View File

@@ -38,8 +38,8 @@
#include "isam_impl.h" #include "isam_impl.h"
static int _getoffset(); static int _getoffset(long pos);
static Blkno _getblkno(); static Blkno _getblkno(long pos);
/* /*

View File

@@ -39,9 +39,9 @@
#include "isam_impl.h" #include "isam_impl.h"
/* Local functions */ /* Local functions */
long _fl_getpos(); /* Get offset in .rec file */ long _fl_getpos(Fcb *fcb, Recno recnum); /* Get offset in .rec file */
int _fl_deleted(); /* 0/1 returns 1 if record is deleted */ int _fl_deleted(); /* 0/1 returns 1 if record is deleted */
static void remove_from_chain(); /* used by _flrec_wrrec() */ static void remove_from_chain(Fcb *fcb, Recno recnum); /* used by _flrec_wrrec() */
/* /*
* _flrec_write(fcb, record, recnum, reclen) * _flrec_write(fcb, record, recnum, reclen)

View File

@@ -40,9 +40,6 @@
#include "isam_impl.h" #include "isam_impl.h"
void _removelast();
char *_lastelement();
/* /*
* _makedat_isfname(isfname) * _makedat_isfname(isfname)
* *

View File

@@ -39,8 +39,6 @@
#include "isam_impl.h" #include "isam_impl.h"
extern Bufhdr *_isdisk_fix();
/* /*
* blkno = _isfreel_alloc() * blkno = _isfreel_alloc()
* *

View File

@@ -40,7 +40,7 @@
#include "isam_impl.h" #include "isam_impl.h"
static int _check_typelen(); static int _check_typelen(int type, int length);
/* /*
* _validate_keydesc(keydesc, minreclen) * _validate_keydesc(keydesc, minreclen)

View File

@@ -60,7 +60,7 @@ struct hashtable {
} hashtable [FCBHASHSIZE]; } hashtable [FCBHASHSIZE];
#define unused(entry) ((entry).fcb == NULL) #define unused(entry) ((entry).fcb == NULL)
static int _hashisfhandle(); static int _hashisfhandle(Bytearray *isfhandle);
static int mrused_last = 0; /* stamp generator */ static int mrused_last = 0; /* stamp generator */

View File

@@ -41,7 +41,7 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/time.h> #include <sys/time.h>
static int _am_open(); static int _am_open(Fab *fab);
/* /*
* isfd = isopen(isfname, mode) * isfd = isopen(isfname, mode)
* *

View File

@@ -40,7 +40,9 @@
#include "isam_impl.h" #include "isam_impl.h"
#include <sys/time.h> #include <sys/time.h>
static int _amread(); static int _amread(Bytearray *isfhandle, char *record, int *reclen,
enum readmode readmode, Bytearray *curpos, Recno *recnum,
struct errcode *errcode);
/* /*
* err = isread(isfd, record, mode) * err = isread(isfd, record, mode)
@@ -159,7 +161,7 @@ _amread(Bytearray *isfhandle, char *record, int *reclen,
int skipbytes; int skipbytes;
int ret; int ret;
Bytearray oldcurpos; Bytearray oldcurpos;
int (*rec_read)(); int (*rec_read)(Fcb *, char *, Recno, int *);
_isam_entryhook(); _isam_entryhook();

View File

@@ -41,11 +41,11 @@
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
void _removelast(); static void _removelast2(char *);
static void _removelast2(); static void _rename_datfile(char *isfname, char *newnam);
char *_lastelement(); static void _rename_indfile(char *isfname, char *newnam);
static void _rename_datfile(), _rename_indfile(), _rename_varfile(); static void _rename_varfile(char *isfname, char *newnam);
static int _amrename(); static int _amrename(Bytearray *isfhandle, char *newname, struct errcode *errcode);
/* /*
* isfd = isrename(oldname, newname) * isfd = isrename(oldname, newname)

View File

@@ -63,16 +63,16 @@
* verbose option (if set to nonzero) will print messages to stdout. * verbose option (if set to nonzero) will print messages to stdout.
*/ */
Static char *rp_readrecord_v(), *rp_readrecord_f(); Static char *rp_readrecord_v(int datfd, int varfd, long offset, int minreclen, int maxreclen);
Static char *rp_readrecord_f(int datfd, long offset, int reclen);
Static int printkey(int, struct keydesc *, int (*)(const char *, ...)); Static int printkey(int, struct keydesc *, int (*)(const char *, ...));
Static void cmd_error(const char *, int (*)(const char *, ...)); Static void cmd_error(const char *, int (*)(const char *, ...));
Static int typeletter(); Static int typeletter(int type);
Static int rp_readcntlpg(); Static int rp_readcntlpg(int datfd, char *cntlpg);
static int isnoprintf(const char *, ...); static int isnoprintf(const char *, ...);
int isrepair(char *isfname, int verbose) int isrepair(char *isfname, int verbose)
{ {
extern char *rp_readrecord_v(), *rp_readrecord_f();
char cntlpg[ISCNTLSIZE]; char cntlpg[ISCNTLSIZE];
int datfd = -1, indfd = -1, varfd = -1; int datfd = -1, indfd = -1, varfd = -1;
int minreclen, maxreclen; int minreclen, maxreclen;

View File

@@ -40,7 +40,10 @@
#include "isam_impl.h" #include "isam_impl.h"
#include <sys/time.h> #include <sys/time.h>
static int _amrewcurr(), _changekeys2(); static int _amrewcurr(Bytearray *isfhandle, char *record, int reclen,
Bytearray *curpos, Recno *recnum, struct errcode *errcode);
static int _changekeys2(Fcb *fcb, char *record, char *oldrecord,
Recno recnum, Bytearray *curpos);
/* /*
* err = isrewcurr(isfd, record) * err = isrewcurr(isfd, record)
@@ -138,8 +141,8 @@ _amrewcurr(Bytearray *isfhandle, char *record, int reclen,
int err; int err;
char oldrecord[ISMAXRECLEN]; char oldrecord[ISMAXRECLEN];
int reclen2; int reclen2;
int (*rec_read)(); int (*rec_read)(Fcb *, char *, Recno, int *);
int (*rec_rewrite)(); int (*rec_rewrite)(Fcb *, char *, Recno, int);
_isam_entryhook(); _isam_entryhook();

View File

@@ -40,7 +40,8 @@
#include "isam_impl.h" #include "isam_impl.h"
#include <sys/time.h> #include <sys/time.h>
static int _amrewrec(), _changekeys(); static int _amrewrec(Bytearray *isfhandle, char *record, int reclen, Recno recnum, struct errcode *errcode);
static int _changekeys(Fcb *fcb, char *record, char *oldrecord, Recno recnum);
/* /*
* err = isrewrec(isfd, recnum, record) * err = isrewrec(isfd, recnum, record)
@@ -132,8 +133,8 @@ _amrewrec(Bytearray *isfhandle, char *record, int reclen, Recno recnum,
char oldrecbuf[ISMAXRECLEN]; char oldrecbuf[ISMAXRECLEN];
int err; int err;
int reclen2; int reclen2;
int (*rec_read)(); int (*rec_read)(Fcb *, char *, Recno, int *);
int (*rec_rewrite)(); int (*rec_rewrite)(Fcb *, char *, Recno, int);
_isam_entryhook(); _isam_entryhook();

View File

@@ -41,7 +41,9 @@
#include <sys/time.h> #include <sys/time.h>
#include <stdlib.h> #include <stdlib.h>
static int _amstart(); static int _amstart(Bytearray *isfhandle, char *record, int *reclen,
enum readmode readmode, struct keydesc *keydesc, int keylen,
Bytearray *curpos, Recno *recnum, struct errcode *errcod);
/* /*
* err = isstart(isfd, keydesc, length, record, mode) * err = isstart(isfd, keydesc, length, record, mode)
@@ -171,7 +173,7 @@ _amstart(Bytearray *isfhandle, char *record, int *reclen,
char *pkey; char *pkey;
Btree *btree = NULL; Btree *btree = NULL;
int reclen2; int reclen2;
int (*rec_read)(); int (*rec_read)(Fcb *, char *, Recno, int *);
_isam_entryhook(); _isam_entryhook();

View File

@@ -39,12 +39,12 @@
#include "isam_impl.h" #include "isam_impl.h"
/* Local functions */ /* Local functions */
long _vl_getpos(); /* Get offset in .rec file */ long _vl_getpos(Fcb *fcb, Recno recnum); /* Get offset in .rec file */
int _vl_deleted(); /* 0/1 returns 1 if record is deleted */ int _vl_deleted(); /* 0/1 returns 1 if record is deleted */
static void remove_from_chain2(); /* used by _vlrec_wrrec() */ static void remove_from_chain2(Fcb *fcb, Recno recnum); /* used by _vlrec_wrrec() */
long _istail_insert(); long _istail_insert(Fcb *fcb, char *tailp, int taillen);
static void _istail_delete(); static void _istail_delete(Fcb *fcb, long offset);
static int _istail_read(); static int _istail_read(Fcb *fcb, long offset, char *buffer);
/* /*
* _vlrec_write(fcb, record, recnum, reclen) * _vlrec_write(fcb, record, recnum, reclen)

View File

@@ -41,7 +41,8 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/time.h> #include <sys/time.h>
static int _am_write(); static int _am_write(Fab *fab, char *record, int reclen,
Bytearray *curpos, Recno *recnum);
/* /*
* err = iswrite(isfd, record) * err = iswrite(isfd, record)
@@ -70,7 +71,6 @@ static int _am_write();
int int
iswrite(int isfd, char *record) iswrite(int isfd, char *record)
{ {
int _am_write();
Fab *fab; Fab *fab;
int reclen; int reclen;
Recno recnum; Recno recnum;

View File

@@ -39,7 +39,8 @@
#include "isam_impl.h" #include "isam_impl.h"
#include <sys/time.h> #include <sys/time.h>
static int _amwrrec(); static int _amwrrec(Bytearray *isfhandle, char *record, int reclen, Recno recnum,
struct errcode *errcode);
/* /*
* isfd = iswrrec(isfd, recnum, record) * isfd = iswrrec(isfd, recnum, record)
@@ -130,7 +131,7 @@ _amwrrec(Bytearray *isfhandle, char *record, int reclen, Recno recnum,
{ {
Fcb *fcb = NULL; Fcb *fcb = NULL;
int err; int err;
int (*rec_wrrec)(); int (*rec_wrrec)(Fcb *, char *, Recno, int);
_isam_entryhook(); _isam_entryhook();