home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hall of Fame
/
HallofFameCDROM.cdr
/
proglc
/
isam.lzh
/
ISAMC.C
< prev
next >
Wrap
Text File
|
1985-03-16
|
2KB
|
55 lines
#include "stdio.h"
#include "setjmp.h"
#include "isamstr.h"
#include "isam.h"
/* checked correct 6-7-84 */
/***************************************************************
* File ISAMC.C *
* this function creates an isam file. *
* name= file name *
* asize= size of allocation allowed for this index *
* ikeylen = length of a key in bytes *
* ireclen = length of a record in bytes *
* dupflag= true for errors on duplicate keys, else 0 *
***************************************************************/
char *calloc();
int creat(), write();
int ind_create(name, asize, ikeylen, ireclen, dupflag)
char *name;
unsigned ikeylen, ireclen, dupflag, asize;
{
unsigned al, n, m, l2, l3, r, rem;
char iflags;
r = 30;
n = asize - (sizeof(struct global) + ikeylen - 1);
n -= (sizeof(struct recov) + (r - 1) * sizeof(long));
n -= 2 * sizeof(struct l2_link) + sizeof(struct l2_elem) - 3 + 3
* ikeylen;
al = (sizeof(struct m_elem) + 2 * sizeof(struct l2_elem)
+ sizeof(struct l3_elem) - 4 + 4 * ikeylen);
l2 = l3 = m = n / al;
rem = n % al;
while(rem > (sizeof(struct l3_elem) - 1 + ikeylen)) {
++l3;
rem -= (sizeof(struct l3_elem) - 1 + ikeylen);
}
iflags = dupflag ? 1 : 0;
return(ind_build(name, iflags, ikeylen, ireclen, m, l2, l3, r));
}
/***************************************************************
* end of function *
***************************************************************/