From: Jon Trulson Date: Sun, 1 Jul 2018 02:09:49 +0000 (-0600) Subject: tt/mini_isam: add new isam_prototypes.h include file and fix up problems X-Git-Tag: 2.3.0a~273 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c0388656dce90fe56df9d919a30d2dc6ec0984f5;p=oweals%2Fcde.git tt/mini_isam: add new isam_prototypes.h include file and fix up problems There were a variety of potential 64b problems due to the complete lack of prototype declarations. So, we add a file, isam_prototypes.h, generated mostly by the 'cproto' tool. We also fixed up some errors that having proper prototypes pointed out, mainly in passing ints where pointers were expected and vice versa. The iserase() function was supposed to accept a char *, but was defined as only accepting a char. Fun stuff like that. --- diff --git a/cde/lib/tt/mini_isam/isam_impl.h b/cde/lib/tt/mini_isam/isam_impl.h index fbb6b735..8172077d 100644 --- a/cde/lib/tt/mini_isam/isam_impl.h +++ b/cde/lib/tt/mini_isam/isam_impl.h @@ -452,14 +452,6 @@ struct export_opts { }; -extern Fcb *_isfcb_create(); -extern Fcb *_isfcb_open(); -extern void _isfcb_remove(); -extern void _isfcb_close(); -extern void _isfcb_setreclength(); -extern void _isfcb_setprimkey(); -extern int _isfcb_cntlpg_w(); - #define DAT_SUFFIX ".rec" #define IND_SUFFIX ".ind" @@ -474,77 +466,8 @@ extern int _isfcb_cntlpg_w(); #define VL_RECDELETED ((long ) -1L) #define VL_RECNOTAIL ((long ) -2L) - -/* extern long lseek(); */ - -extern char *_ismalloc(), *_isrealloc(), *_isallocstring(); -extern void _isfree(), _isfreestring(); -extern void _isfatal_error(), _setiserrno2(), _seterr_errcode(); -extern void _makedat_isfname(); -extern void _makeind_isfname(); -extern void _makevar_isfname(); -extern void _amseterrcode(); - -extern void _isseekpg(), _isreadpg(), _iswritepg(); - -extern Bufhdr *_isdisk_fix(), *_isdisk_refix(); -extern void _isdisk_commit(), _isdisk_sync(), _isdisk_inval(), - _isdisk_commit1(), _isdisk_unfix(); -extern void _isdisk_rollback(); -extern void _cp_tofile(), _cp_fromfile(); -Blkno _extend_file(); - -extern void _isdln_base_insert(), _isdln_base_remove(), _isdln_base_append(), - _isdln_base_makeempty(); -extern struct dlink *_isdln_base_prev(), *_isdln_base_next(), *_isdln_base_first(); - -extern void _mngfcb_insert(), _mngfcb_delete(); -extern Fcb *_mngfcb_find(); -extern Bytearray *_mngfcb_victim(); -extern char *_getisfname(); -extern Bytearray _makeisfhandle(); - -extern Bytearray _makeisfhandle(); -extern Fcb *_openfcb(); - -extern Time _amtime_set(), _amtime_get(); - -extern void _islock_closefile(), _islock_unlockfile(); - -extern Keydesc2 *_isfcb_findkey(), *_isfcb_indfindkey(); -extern void stkey(), ldkey(); - -extern Issort *_issort_create(); -extern char *_issort_read(); -extern void _issort_destroy(), _issort_insert(), _issort_sort(), - _issort_rewind(); - -extern void _iskeycmp_set(); -extern int _iskeycmp(); - -extern char *_isbsearch(); - -extern void _iskey_extract(); -extern Blkno _isindfreel_alloc(); -extern void _isindfreel_free(); -extern long _fl_getpos(); - -extern Btree *_isbtree_create(); -extern void _isbtree_destroy(), _isbtree_search(), _isbtree_insert(), - _isbtree_remove(); -extern char *_isbtree_current(), *_isbtree_next(); - -extern void _iskey_fillmin(), _iskey_fillmax(); - -extern Bufhdr *_allockpage(); - -extern void _del1key(); -extern int _add1key(), _change1key(); -extern void _delkeys(); -extern char *_ismap_getaddr(); -extern void _ismap_endop(), _ismap_unmapfcb(); - -extern void _isam_entryhook(), _isam_exithook(); +/*------------ Prototype definitions ---------------------------------------*/ +#include "isam_prototypes.h" #define stshort(n,p) stint((n), (p)) #define ldshort(p) ldint(p) @@ -555,10 +478,6 @@ extern void _isam_entryhook(), _isam_exithook(); #define stblkno(n,p) stlong((long)(n), (p)) #define ldblkno(p) ((Blkno)ldlong(p)) -extern int _flrec_read(), _flrec_write(), _flrec_rewrite(), _flrec_delete(), - _flrec_wrrec(); -extern int _vlrec_read(), _vlrec_write(), _vlrec_rewrite(), _vlrec_delete(), - _vlrec_wrrec(); /*------------ UNIX file formats ---------------------------------------------*/ diff --git a/cde/lib/tt/mini_isam/isam_prototypes.h b/cde/lib/tt/mini_isam/isam_prototypes.h new file mode 100644 index 00000000..7e91e409 --- /dev/null +++ b/cde/lib/tt/mini_isam/isam_prototypes.h @@ -0,0 +1,343 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ + +/* JET: This code was generated using cproto, plus some fixes that + * having proper prototype definitions pointed out. + */ + +/* isadd1key.c */ +int _add1key(Fcb *fcb, Keydesc2 *pkeydesc2, char *record, Recno recnum, char *newkey); + +/* isaddindex.c */ +int isaddindex(int isfd, struct keydesc *keydesc); + +/* isaddprimary.c */ +int isaddprimary(int isfd, struct keydesc *keydesc); + +/* isalloc.c */ +char *_ismalloc(unsigned int nbytes); +char *_isrealloc(char *oldaddr, unsigned int nbytes); +char *_isallocstring(char *str); +void _isfreestring(char *str); + +/* isamaddindex.c */ +int _amaddindex(Bytearray *isfhandle, struct keydesc *keydesc, struct errcode *errcode); +int _amaddprimary(Bytearray *isfhandle, struct keydesc *keydesc, struct errcode *errcode); +int _create_index(Fcb *fcb, Keydesc2 *pkeydesc2); + +/* isamdelcurr.c */ + +/* isamdelrec.c */ +int _amdelrec(Bytearray *isfhandle, Recno recnum, struct errcode *errcode); +void _delkeys(Fcb *fcb, char *record, Recno recnum); + +/* isamerror.c */ +void _amseterrcode(struct errcode *errcode, int is_errno); + +/* isamhooks.c */ +void _isam_entryhook(void); +void _isam_exithook(void); + +/* isamopen.c */ +int _amopen(char *isfname, enum openmode openmode, Bool *varflag, int *minlen, int *maxlen, Bytearray *isfhandle, Bytearray *curpos, struct errcode *errcode); +Fcb *_openfcb(Bytearray *isfhandle, struct errcode *errcode); +char *_getisfname(Bytearray *isfhandle); +Bytearray _makeisfhandle(char *isfname); + +/* isamwrite.c */ +int _amwrite(Bytearray *isfhandle, char *record, int reclen, Bytearray *curpos, Recno *recnum, struct errcode *errcode); +int _addkeys(Fcb *fcb, char *record, Recno recnum); + +/* isapplmr.c */ +int _isapplmr(int isfd, char *buffer); + +/* isapplmw.c */ +int _isapplmw(int isfd, char *magicstring); + +/* isbsearch.c */ +char *_isbsearch(char *key, char *table, int nelems, int keylen, + int (*cmpf)(char *, char *)); + +/* isbtree2.c */ +void _isbtree_insert(Btree *btree, char *key); +void leftkey_up(Btree *btree, int level); + +/* isbtree3.c */ +void _isbtree_remove(Btree *btree); + +/* isbtree.c */ +Btree *_isbtree_create(Fcb *fcb, Keydesc2 *pkeydesc2); +void _isbtree_destroy(Btree *btree); +void _isbtree_search(Btree *btree, char *key); +char *_isbtree_current(Btree *btree); +char *_isbtree_next(Btree *btree); + +/* isbuild.c */ +int isbuild(char *isfname, int recordlength, struct keydesc *primkey, int mode); + +/* isbytearray.c */ +Bytearray _bytearr_getempty(void); +Bytearray _bytearr_new(u_short len, char *data); +Bytearray _bytearr_dup(Bytearray *old); +void _bytearr_free(Bytearray *barray); +int _bytearr_cmp(Bytearray *l, Bytearray *r); + +/* ischange1key.c */ +int _change1key(Fcb *fcb, Keydesc2 *pkeydesc2, char *record, char *oldrecord, Recno recnum, char *newkey); + +/* isclose.c */ +int isclose(int isfd); + +/* iscntl.c */ +int iscntl(int isfd, int func, ...); + +/* iscurpos.c */ +int isgetcurpos(int isfd, int *len, char **buf); +int issetcurpos(int isfd, char *buf); + +/* isdatconv.c */ +long ldlong(char *p); +int stlong(long val, char *p); +short ldint(char *p); +u_short ldunshort(char *p); +int stint(short val, char *p); +int ldchar(char *src, int len, char *dst); +int stchar(char *src, char *dst, int len); +int ldchar2(char *src, int len, char *dst); +int stchar2(char *src, char *dst, int len); +float ldfloat(char *p); +int stfloat(float f, char *p); +double lddbl(char *p); +int stdbl(double val, char *p); + +/* isdel1key.c */ +void _del1key(Fcb *fcb, Keydesc2 *pkeydesc2, char *record, Recno recnum); + +/* isdelcurr.c */ +int isdelcurr(int isfd); + +/* isdelrec.c */ +int isdelrec(int isfd, long recnum); + +/* isdiskbufs2.c */ +Bufhdr *_isdisk_fix(Fcb *fcb, int unixfd, Blkno blkno, int mode); +void _isdisk_unfix(Bufhdr *p); +void _isdisk_commit1(Bufhdr *p); +void _isdisk_commit(void); +void _isdisk_rollback(void); +Bufhdr *_isdisk_refix(Bufhdr *p, int newmode); +void _isdisk_sync(void); +void _isdisk_inval(void); + +/* isdlink.c */ +void _isdln_base_insert(char *base, struct dlink *l, struct dlink *e); +void _isdln_base_append(char *base, struct dlink *l, struct dlink *e); +void _isdln_base_remove(char *base, struct dlink *e); +struct dlink *_isdln_base_first(char *base, struct dlink *l); +struct dlink *_isdln_base_next(char *base, struct dlink *l); +struct dlink *_isdln_base_prev(char *base, struct dlink *l); +void _isdln_base_makeempty(char *base, struct dlink *l); +int _isdln_base_isempty(char *base, struct dlink *l); + +/* iserase.c */ +int iserase(char *isfname); + +/* iserror.c */ +void _isfatal_error(char *msg); +void _isfatal_error1(char *msg); +void _isam_warning(char *msg); +int _isfatal_error_set_func(int (*func)(void)); +void _setiserrno2(int error, int is1, int is2); +void _seterr_errcode(struct errcode *errcode); + +/* isfab.c */ +Fab *_fab_new(char *isfname, enum openmode openmode, Bool varlen, int minreclen, int maxreclen); +void _fab_destroy(Fab *fab); + +/* isfcb.c */ +Fcb *_isfcb_create(char *isfname, int crdat, int crind, int crvar, int owner, int group, int u_mask, struct errcode *errcode); +void _isfcb_setreclength(Fcb *fcb, Bool varflag, int minreclen, int maxreclen); +Fcb *_isfcb_open(char *isfname, struct errcode *errcode); +int _isfcb_nfds(Fcb *fcb); +void _isfcb_remove(Fcb *fcb); +void _isfcb_close(Fcb *fcb); +int _isfcb_cntlpg_w(Fcb *fcb); +int _isfcb_cntlpg_w2(Fcb *fcb); +int _isfcb_cntlpg_r(Fcb *fcb); +int _isfcb_cntlpg_r2(Fcb *fcb); +int _check_isam_magic(Fcb *fcb); +int _open2_indfile(Fcb *fcb); + +/* isfcbindex.c */ +int _isfcb_primkeyadd(Fcb *fcb, Keydesc2 *keydesc2); +int _isfcb_primkeydel(Fcb *fcb); +int _isfcb_altkeyadd(Fcb *fcb, Keydesc2 *keydesc2); +Keydesc2 *_isfcb_findkey(Fcb *fcb, Keydesc2 *keydesc2); +int _isfcb_altkeydel(Fcb *fcb, Keydesc2 *keydesc2); +Keydesc2 *_isfcb_indfindkey(Fcb *fcb, int keyid); + +/* isfcbwatchfd.c */ +int _watchfd_incr(int n); +int _watchfd_decr(int n); +int _watchfd_check(void); +int _watchfd_max_set(int n); +int _watchfd_max_get(void); + +/* isfd.c */ +Isfd _isfd_insert(Fab *fab); +Fab *_isfd_find(Isfd isfd); +void _isfd_delete(Isfd isfd); + +/* isfileio.c */ +void _cp_tofile(Fcb *fcb, int unixfd, char *data, long pos, int len); +void _cp_fromfile(Fcb *fcb, int unixfd, char *data, long pos, int len); +Blkno _extend_file(Fcb *fcb, int unixfd, Blkno oldsize); + +/* isfixrec.c */ +int _flrec_write(Fcb *fcb, char *record, Recno *recnum, int reclen); +int _flrec_read(Fcb *fcb, char *record, Recno recnum, int *reclen); +long _fl_getpos(Fcb *fcb, Recno recnum); +int _flrec_rewrite(Fcb *fcb, char *record, Recno recnum, int reclen); +int _flrec_delete(Fcb *fcb, Recno recnum); +int _flrec_wrrec(Fcb *fcb, char *record, Recno recnum, int reclen); + +/* isfname.c */ +void _makedat_isfname(char *isfname); +void _makeind_isfname(char *isfname); +void _makevar_isfname(char *isfname); +void _removelast(char *path); +char *_lastelement(char *path); + +/* isgarbage.c */ +int isgarbage(char *isfname); + +/* isindexconv.c */ +void stkey(Keydesc2 *pkeydesc2, char *p); +void ldkey(struct keydesc2 *pkeydesc2, char *p); + +/* isindexinfo.c */ +int isindexinfo(int isfd, struct keydesc *buffer, int number); + +/* isindfreel.c */ +Blkno _isindfreel_alloc(Fcb *fcb); +void _isindfreel_free(Fcb *fcb, Blkno blkno); + +/* iskeyaux.c */ +void _iskey_extract(Keydesc2 *pkeydesc2, char *recp, char *keyp); +Bufhdr *_allockpage(Fcb *fcb, int capac, int level, Blkno *blkno); + +/* iskeycalc.c */ +int getkeysperleaf(int keylen); +int getkeyspernode(int keylen); +int le_odd(int n); + +/* iskeycmp.c */ +void _iskeycmp_set(Keydesc2 *pkeydesc2, int nparts); +int _iskeycmp(char *lkey, char *rkey); + +/* iskeyconv.c */ +void _iskey_itox(struct keydesc2 *pikdesc, struct keydesc *pxkdesc); +void _iskey_xtoi(struct keydesc2 *pikdesc, struct keydesc *pxkdesc); + +/* iskeyvalid.c */ +int _validate_keydesc(struct keydesc *keydesc, int minreclen); + +/* isminmax.c */ +void _iskey_fillmax(struct keydesc2 *pkeydesc2, char *keybuf); +void _iskey_fillmin(struct keydesc2 *pkeydesc2, char *keybuf); + +/* ismngfcb.c */ +void _mngfcb_insert(Fcb *fcb, Bytearray *isfhandle); +Fcb *_mngfcb_find(Bytearray *isfhandle); +void _mngfcb_delete(Bytearray *isfhandle); +Bytearray *_mngfcb_victim(void); + +/* isopen.c */ +int isopen(char *isfname, int mode); + +/* ispageio.c */ +void _isseekpg(int fd, Blkno pgno); +void _isreadpg(int fd, char *buf); +void _iswritepg(int fd, char *buf); + +/* isperm.c */ +enum openmode _getopenmode(int mode); +enum readmode _getreadmode(int mode); + +/* isread.c */ +int isread(int isfd, char *record, int mode); + +/* isrename.c */ +int isrename(char *oldname, char *newname); + +/* isrepair.c */ +int isrepair(char *isfname, int verbose); + +/* isrewcurr.c */ +int isrewcurr(int isfd, char *record); + +/* isrewrec.c */ +int isrewrec(int isfd, long recnum, char *record); + +/* issignals.c */ +int _issignals_cntl(int opt); +void _issignals_mask(void); +void _issignals_unmask(void); + +/* issort.c */ +Issort *_issort_create(int reclen, int nrecs, int (*compfunc)(char *, char *)); +void _issort_destroy(Issort *srt); +void _issort_insert(Issort *srt, char *record); +void _issort_sort(Issort *srt); +void _issort_rewind(Issort *srt); +char *_issort_read(Issort *srt); + +/* isstart.c */ +int isstart(int isfd, struct keydesc *keydesc, int length, char *record, int mode); + +/* issync.c */ +int issync(void); +int isfsync(int isfd); +int _issync(void); +int _isfsync(int isfd); + +/* isvarrec.c */ +int _vlrec_write(Fcb *fcb, char *record, Recno *recnum, int reclen); +int _vlrec_read(Fcb *fcb, char *record, Recno recnum, int *reclen); +long _vl_getpos(Fcb *fcb, Recno recnum); +int _vlrec_rewrite(Fcb *fcb, char *record, Recno recnum, int reclen); +int _vlrec_delete(Fcb *fcb, Recno recnum); +int _vlrec_wrrec(Fcb *fcb, char *record, Recno recnum, int reclen); +long _istail_insert(Fcb *fcb, char *tailp, int taillen); +int _istail_modify(Fcb *fcb, long offset, char *tailp, int taillen); + +/* isvars.c */ + +/* isversion.c */ + +/* iswrite.c */ +int iswrite(int isfd, char *record); + +/* iswrrec.c */ +int iswrrec(int isfd, long recnum, char *record); + diff --git a/cde/lib/tt/mini_isam/isamaddindex.c b/cde/lib/tt/mini_isam/isamaddindex.c index 35480b75..f9adb675 100644 --- a/cde/lib/tt/mini_isam/isamaddindex.c +++ b/cde/lib/tt/mini_isam/isamaddindex.c @@ -431,7 +431,7 @@ _attach_dups_serial(Issort *srt, Keydesc2 *pkeydesc2) _issort_rewind(srt); - while (curkey = _issort_read(srt)) { + while ((curkey = _issort_read(srt))) { if (lastkey && memcmp(lastkey + RECNOSIZE + DUPIDSIZE, curkey + RECNOSIZE + DUPIDSIZE, netkeylength) == 0) @@ -617,7 +617,7 @@ Static int _duplicate_exist(Issort *srt, int keylength) _issort_rewind(srt); - while (curkey = _issort_read(srt)) { + while ((curkey = _issort_read(srt))) { if (lastkey && memcmp(lastkey + RECNOSIZE, curkey + RECNOSIZE, netkeylength) == 0) return 1; /* Duplicate key found */ diff --git a/cde/lib/tt/mini_isam/isamopen.c b/cde/lib/tt/mini_isam/isamopen.c index 3fec9131..680c7dd5 100644 --- a/cde/lib/tt/mini_isam/isamopen.c +++ b/cde/lib/tt/mini_isam/isamopen.c @@ -69,7 +69,6 @@ _amopen(char *isfname, enum openmode openmode, Bool *varflag, Fcb *fcb; Bytearray isfhandle0; Crp *crp; - int err; _isam_entryhook(); diff --git a/cde/lib/tt/mini_isam/isapplmr.c b/cde/lib/tt/mini_isam/isapplmr.c index 0fdeba08..1c210b99 100644 --- a/cde/lib/tt/mini_isam/isapplmr.c +++ b/cde/lib/tt/mini_isam/isapplmr.c @@ -38,6 +38,7 @@ #include "isam_impl.h" +#include #include #include #include "isam_impl.h" diff --git a/cde/lib/tt/mini_isam/isapplmw.c b/cde/lib/tt/mini_isam/isapplmw.c index b184b65b..87f356ba 100644 --- a/cde/lib/tt/mini_isam/isapplmw.c +++ b/cde/lib/tt/mini_isam/isapplmw.c @@ -38,6 +38,7 @@ #include "isam_impl.h" +#include #include #include diff --git a/cde/lib/tt/mini_isam/isbtree.c b/cde/lib/tt/mini_isam/isbtree.c index 4547adf1..7839ce66 100644 --- a/cde/lib/tt/mini_isam/isbtree.c +++ b/cde/lib/tt/mini_isam/isbtree.c @@ -35,16 +35,15 @@ * * Description: * B-tree operations: SEARCH - * + * */ #include #include "isam_impl.h" -extern int _iskeycmp(); -/* - * _isbtree_create() +/* + * _isbtree_create() * * Create a B-tree path object that will used in subsequent operations. */ @@ -53,28 +52,28 @@ Btree * _isbtree_create(Fcb *fcb, Keydesc2 *pkeydesc2) { Btree *p; - + p = (Btree *) _ismalloc(sizeof(*p)); memset((char *)p, 0, sizeof(*p)); - + p->fcb = fcb; - p->keydesc2 = pkeydesc2; - + p->keydesc2 = pkeydesc2; + return (p); } -/* - * _isbtr_destroy() +/* + * _isbtr_destroy() * - * Destroy B-tree path object + * Destroy B-tree path object */ void _isbtree_destroy(Btree *btree) { int i; - + for (i = 0; i < btree->depth;i++) { _isdisk_unfix(btree->bufhdr[i]); } @@ -82,8 +81,8 @@ _isbtree_destroy(Btree *btree) } -/* - * _isbtree_search() +/* + * _isbtree_search() * * Descend the B-tree, position pointer on or before the matched key. */ @@ -102,61 +101,61 @@ _isbtree_search( Btree *btree, char *key) char *key2; /* Equal or next lower key */ int curpos; /* index of key2 in key page */ Blkno blkno; - + /* Set comparison function. */ _iskeycmp_set(pkeydesc2, pkeydesc2->k2_nparts + 1); /* +1 for recno field */ - + index = 0; blkno = rootblkno; do { - btree->bufhdr[index] = + btree->bufhdr[index] = _isdisk_fix(btree->fcb, btree->fcb->indfd, blkno, ISFIXREAD); p = btree->bufhdr[index]->isb_buffer; /* pointer to buffer */ - + /* Load some fields from the key page. */ nkeys = ldshort(p+BT_NKEYS_OFF); /* Number of keys in the page */ elevation = ldshort(p+BT_LEVEL_OFF); /* Level of the page */ - + /* Binary search in the key page to find equal or next lowere key. */ key2 = _isbsearch(key, p+BT_KEYS_OFF, nkeys, keylength, _iskeycmp); - + curpos = (key2) ? ((key2 - p - BT_NKEYS_OFF) / keylength) : 0; - - btree->curpos[index] = + + btree->curpos[index] = (key2 == (char *)0 && elevation==0)? -1 : curpos; - - if (elevation > 0) + + if (elevation > 0) blkno = ldblkno(p + ISPAGESIZE - (curpos + 1) * BLKNOSIZE); - + index++; } while (elevation > 0); - + btree->depth = index; } -/* - * _isbtree_current() +/* + * _isbtree_current() * - * Get pointer to the current key + * Get pointer to the current key */ char * _isbtree_current(Btree *btree) { int curpos; - + assert(btree->depth > 0); if ((curpos = btree->curpos[btree->depth - 1]) == -1) return (NULL); else - return (btree->bufhdr[btree->depth - 1]->isb_buffer + return (btree->bufhdr[btree->depth - 1]->isb_buffer + BT_KEYS_OFF + curpos * btree->keydesc2->k2_len); } -/* +/* * _isbtree_next() * - * Get pointer to the next key + * Get pointer to the next key */ char * @@ -167,41 +166,40 @@ _isbtree_next(Btree *btree) char *p; int level; Blkno blkno; - + assert(depth > 0); - - /* + + /* * Move up along the path, find first block where we can move to the right. */ for (level = depth - 1; level >= 0; level--) { p = btree->bufhdr[level]->isb_buffer; - + if (btree->curpos[level] < ldshort(p + BT_NKEYS_OFF) - 1) break; } - + if (level < 0) { /* Logical end of the index file. No next record. */ return (NULL); } - + curpos = ++(btree->curpos[level]); - + while (++level < depth) { - + /* Get block number to block in next lower level. */ if (level > 0) blkno = ldblkno(p + ISPAGESIZE - (curpos + 1) * BLKNOSIZE); - + /* Unfix page in this level, fetch its right brother. */ _isdisk_unfix(btree->bufhdr[level]); - btree->bufhdr[level] = + btree->bufhdr[level] = _isdisk_fix(btree->fcb, btree->fcb->indfd, blkno, ISFIXREAD); p = btree->bufhdr[level]->isb_buffer; - + curpos = btree->curpos[level] = 0; } - + return (p + BT_KEYS_OFF + curpos * btree->keydesc2->k2_len); } - diff --git a/cde/lib/tt/mini_isam/isbuild.c b/cde/lib/tt/mini_isam/isbuild.c index bdf3b51a..875468a7 100644 --- a/cde/lib/tt/mini_isam/isbuild.c +++ b/cde/lib/tt/mini_isam/isbuild.c @@ -38,14 +38,19 @@ #include "isam_impl.h" +#include #include #include #include +#include +#include -extern char _isam_version[]; -static char *_version_ = _isam_version; - -static int _ambuild(); +static int +_ambuild(char *isfname, enum openmode openmode, Bool varflag, + int minlen, int maxlen, struct keydesc *primkey, + int owner, int group, int umask, + Bytearray *isfhandle, Bytearray *curpos, + struct errcode *errcode); /* * isfd = isbuild(isfname, recordlength, primkey, mode) diff --git a/cde/lib/tt/mini_isam/iscntl.c b/cde/lib/tt/mini_isam/iscntl.c index 9258987c..f243e534 100644 --- a/cde/lib/tt/mini_isam/iscntl.c +++ b/cde/lib/tt/mini_isam/iscntl.c @@ -87,7 +87,6 @@ iscntl(isfd, func, va_alist) va_dcl #endif { - extern int ( *_isfatal_error_set_func)(); va_list pvar; int ret; diff --git a/cde/lib/tt/mini_isam/isdatconv.c b/cde/lib/tt/mini_isam/isdatconv.c index 25b472bb..44d31114 100644 --- a/cde/lib/tt/mini_isam/isdatconv.c +++ b/cde/lib/tt/mini_isam/isdatconv.c @@ -33,7 +33,7 @@ * isdatconv.c * * Description: - * Conversion function between machine dependent and the X/OPEN + * Conversion function between machine dependent and the X/OPEN * machine independent formats. * * Some pieces of code may not be very "structured", but they result in @@ -49,7 +49,7 @@ /* ldlong() - Load a long integer from a potentially unaligned address */ -long +long ldlong(char *p) { int i; @@ -60,9 +60,9 @@ ldlong(char *p) #endif val = 0; - for (i=0; i 0); - + /* Pad with blanks. */ if (len > 0) (void) memset((void *) dst, BLANK, len); @@ -166,36 +166,35 @@ stchar(char *src, char *dst, int len) } /* ldchar2() - Load character field (C style, NULL padded) */ - + int ldchar2(char *src, int len, char *dst) { - char *p; - + if (len <= 0) return 0; - + /* Load the entire string. */ memcpy((void *) dst, (const void *) src, len); *(dst + len) = '\0'; return 0; } - + int stchar2(char *src, char *dst, int len) { char c; - + if (len <= 0) return 0; - + /* Copy up to a NULL character. */ do { if ((c = *src++) == '\0') break; *dst++ = c; } while (--len > 0); - + /* Pad with NULLs. */ if (len > 0) memset(dst, 0, len); @@ -285,7 +284,7 @@ lddbl(char *p) q = x.sval; p += DOUBLESIZE; - + for (i=0; i #include static void _unlink_datfile(), _unlink_indfile(), _unlink_varfile(); @@ -62,10 +63,10 @@ static int _amerase(); */ int -iserase(char isfname) +iserase(char *isfname) { - Isfd isfd, isfd_nfs; - Fab *fab, *fab_nfs; + Isfd isfd; + Fab *fab; /* * Open the file diff --git a/cde/lib/tt/mini_isam/iserror.c b/cde/lib/tt/mini_isam/iserror.c index 1e5c9ef5..e739a1f0 100644 --- a/cde/lib/tt/mini_isam/iserror.c +++ b/cde/lib/tt/mini_isam/iserror.c @@ -38,6 +38,7 @@ */ #include "isam_impl.h" +#include #include #include #include @@ -81,8 +82,6 @@ _isfatal_error(char *msg) void _isfatal_error1(char *msg) { - extern int _is_rpcnetisamd; /* is 1 if this is rpc.netisamd */ - extern int _is_netisamlockd; /* is 1 if this is netisamlockd */ int logerr; if (fatal_error_user_handler) { @@ -113,14 +112,17 @@ _isam_warning(char *msg) } /* Set user specified fatal_error handler */ -int (*_isfatal_error_set_func(int(*func)()))() +int _isfatal_error_set_func(int(*func)()) { +#if 0 int (*oldfunc)(); oldfunc = fatal_error_user_handler; +#endif + fatal_error_user_handler = func; - return (oldfunc); + return (0); } /* diff --git a/cde/lib/tt/mini_isam/isfcb.c b/cde/lib/tt/mini_isam/isfcb.c index e88ab48f..fc633737 100644 --- a/cde/lib/tt/mini_isam/isfcb.c +++ b/cde/lib/tt/mini_isam/isfcb.c @@ -37,6 +37,7 @@ * * */ +#include #include #include "isam_impl.h" #include @@ -841,10 +842,10 @@ _check_isam_magic(Fcb *fcb) char magicbuffer[CP_MAGIC_LEN]; (void)lseek(fcb->datfd, 0L, 0); - if (read(fcb->datfd, magicbuffer, CP_MAGIC_LEN) < CP_MAGIC_LEN || + if ((read(fcb->datfd, magicbuffer, CP_MAGIC_LEN) < CP_MAGIC_LEN) || /* The following test for compatibilty with `SunISAM 1.0 Beta files. */ - strncmp(magicbuffer, "SunISAM", strlen(ISMAGIC)) != 0 && - strncmp(magicbuffer, ISMAGIC, strlen(ISMAGIC)) != 0) { + ((strncmp(magicbuffer, "SunISAM", strlen(ISMAGIC)) != 0) && + (strncmp(magicbuffer, ISMAGIC, strlen(ISMAGIC))) != 0)) { return ISERROR; } else diff --git a/cde/lib/tt/mini_isam/ismngfcb.c b/cde/lib/tt/mini_isam/ismngfcb.c index 3cdd0a8d..23550029 100644 --- a/cde/lib/tt/mini_isam/ismngfcb.c +++ b/cde/lib/tt/mini_isam/ismngfcb.c @@ -62,7 +62,7 @@ struct hashtable { static int _hashisfhandle(); -static mrused_last = 0; /* stamp generator */ +static int mrused_last = 0; /* stamp generator */ /* @@ -219,7 +219,7 @@ _hashisfhandle(Bytearray *isfhandle) while (len-- > 0) { h = (h << 4) + (*p++); - if (g = h&0xf0000000) { + if ((g = (h & 0xf0000000))) { h = h ^ (g >> 24); h = h ^ g; } diff --git a/cde/lib/tt/mini_isam/isopen.c b/cde/lib/tt/mini_isam/isopen.c index b989a623..44b1a3d1 100644 --- a/cde/lib/tt/mini_isam/isopen.c +++ b/cde/lib/tt/mini_isam/isopen.c @@ -41,9 +41,6 @@ #include #include -extern char _isam_version[]; -static char *_version_ = _isam_version; - static int _am_open(); /* * isfd = isopen(isfname, mode) diff --git a/cde/lib/tt/mini_isam/ispageio.c b/cde/lib/tt/mini_isam/ispageio.c index 3b4d61cb..774ff235 100644 --- a/cde/lib/tt/mini_isam/ispageio.c +++ b/cde/lib/tt/mini_isam/ispageio.c @@ -39,6 +39,7 @@ */ #include "isam_impl.h" +#include /* * _isseekpg(fd, pgno) diff --git a/cde/lib/tt/mini_isam/isrename.c b/cde/lib/tt/mini_isam/isrename.c index 6e270550..81436611 100644 --- a/cde/lib/tt/mini_isam/isrename.c +++ b/cde/lib/tt/mini_isam/isrename.c @@ -38,6 +38,7 @@ #include "isam_impl.h" +#include #include void _removelast(); diff --git a/cde/lib/tt/mini_isam/isrepair.c b/cde/lib/tt/mini_isam/isrepair.c index 65ed171b..d7388eda 100644 --- a/cde/lib/tt/mini_isam/isrepair.c +++ b/cde/lib/tt/mini_isam/isrepair.c @@ -38,6 +38,7 @@ #include "isam_impl.h" +#include #include #include #include @@ -66,10 +67,10 @@ Static char *rp_readrecord_v(), *rp_readrecord_f(); Static int printkey(int, struct keydesc *, int (*)(const char *, ...)); Static void cmd_error(const char *, int (*)(const char *, ...)); Static int typeletter(); -Static rp_readcntlpg(); +Static int rp_readcntlpg(); static int isnoprintf(const char *, ...); -isrepair(char *isfname, int verbose) +int isrepair(char *isfname, int verbose) { extern char *rp_readrecord_v(), *rp_readrecord_f(); char cntlpg[ISCNTLSIZE]; @@ -342,7 +343,7 @@ isrepair(char *isfname, int verbose) static char recordbuffer[ISMAXRECLEN + LONGSIZE]; /* rp_readcntlpg() - Read the control page */ -Static +Static int rp_readcntlpg(int datfd, char *cntlpg) { if (read (datfd, cntlpg, ISCNTLSIZE) != ISCNTLSIZE) diff --git a/cde/lib/tt/mini_isam/issignals.c b/cde/lib/tt/mini_isam/issignals.c index e545d10b..4d470903 100644 --- a/cde/lib/tt/mini_isam/issignals.c +++ b/cde/lib/tt/mini_isam/issignals.c @@ -63,7 +63,7 @@ static sigset_t allsignals; /* opt, 1 will enable masking, 0 will disable masking */ -_issignals_cntl(int opt) +int _issignals_cntl(int opt) { int oldmask = do_mask; diff --git a/cde/lib/tt/mini_isam/issort.c b/cde/lib/tt/mini_isam/issort.c index 2716bd87..f5a3e43d 100644 --- a/cde/lib/tt/mini_isam/issort.c +++ b/cde/lib/tt/mini_isam/issort.c @@ -49,7 +49,7 @@ extern char *_isunix_malloc(); */ Issort * -_issort_create(int reclen, int nrecs, int (*compfunc)()) +_issort_create(int reclen, int nrecs, int (*compfunc)(char *, char *)) { Issort *p; @@ -60,7 +60,7 @@ _issort_create(int reclen, int nrecs, int (*compfunc)()) p->ist_allocrecs = nrecs; /* Maximum number of records */ /* that can inserted */ p->ist_nrecs = 0; /* Current number of records */ - p->ist_currec; /* Current position */ + p->ist_currec = 0; /* Current position */ p->ist_compf = compfunc; /* Comparison function */ p->ist_array = _ismalloc((unsigned)(reclen * nrecs)); /* Allocate array */ diff --git a/cde/lib/tt/mini_isam/issync.c b/cde/lib/tt/mini_isam/issync.c index 2f4c617c..f1c1b693 100644 --- a/cde/lib/tt/mini_isam/issync.c +++ b/cde/lib/tt/mini_isam/issync.c @@ -42,6 +42,7 @@ */ #include "isam_impl.h" +#include #include #include diff --git a/cde/lib/tt/mini_isam/isvarrec.c b/cde/lib/tt/mini_isam/isvarrec.c index 83febb35..68878a0b 100644 --- a/cde/lib/tt/mini_isam/isvarrec.c +++ b/cde/lib/tt/mini_isam/isvarrec.c @@ -44,7 +44,7 @@ int _vl_deleted(); /* 0/1 returns 1 if record is deleted */ static void remove_from_chain2(); /* used by _vlrec_wrrec() */ long _istail_insert(); static void _istail_delete(); -static _istail_read(); +static int _istail_read(); /* * _vlrec_write(fcb, record, recnum, reclen) @@ -501,7 +501,7 @@ Static void _istail_delete(Fcb *fcb, long offset) /* Read tail from .var file */ -Static _istail_read(Fcb *fcb, long offset, char *buffer) +Static int _istail_read(Fcb *fcb, long offset, char *buffer) { char frameheadbuf [2 * SHORTSIZE]; int taillen;