Below is the code to "Initialize" FairCom DB:
/* Initialize the c-tree system */
if (InitCTreeXtd(10,2,4,10,USERPRF_NTKEY,"admin","ADMIN","FAIRCOMS"))
terminate("Could not initialize c-tree",-1);
if (argc > 1)
db_create(); /* create the database files */
db_init(); /* open the database files that are already created */
database(); /* perform database routines */
db_close(); /* close the files, and any other ending stuff */
fflush(stdout);
return(0); /* dummy to remove compiler warning */
}
/********************************************************
* *
* db_init: Open the data files and indices. They *
* must have been already created. Most of *
* the important parameters for the files *
* are set when the file was created. *
* *
********************************************************/
#ifdef PROTOTYPE
VOID db_init(void)
#else
VOID db_init()
#endif
{
/* Open the data file */
if (OpenCtFile(INVENTDAT,"invent.dat",ctVIRTUAL|ctSHARED)) {
db_create();
if (OpenCtFile(INVENTDAT,"invent.dat",ctVIRTUAL|ctSHARED))
terminate("Could not open invent.dat",INVENTDAT);
}
/* Open the index file */
if (OpenCtFile(INVENTIDX,"invent.idx",ctVIRTUAL|ctSHARED))
terminate("Could not open invent.idx",INVENTIDX);
return;
}