home *** CD-ROM | disk | FTP | other *** search
- /* (c) 1985, Phoenix Computer Products Corp. and Novum Organum, Inc. */
-
- #include "compiler.h"
-
- #include "cptpdf.h"
- #include "pdb.h"
-
- static dbinitfil();
-
- int dbist(dbfnam, f_create)
- char *dbfnam;
- int f_create;
- {
- HDL h_db_fil, flopen(), h_db, dbopen();
- int rc;
- RHDL recadd();
- // FILEINFO filinfo;
-
- rc = DB_FAIL;
- syerrrset();
-
- if (!f_create) /* don't create if already exists. */
- {
- // if (drinfo(dbfnam,FA_ORDINARY,&filinfo)==RC_FAIL)
- if (access(dbfnam, 0))
- f_create++; /* doesn't exist. Ok to create. */
- }
-
- if ((f_create) && (h_db_fil = flopen(dbfnam, "w+")))
- {
- dbinitfil(h_db_fil);
- flclose(h_db_fil);
- h_db = dbopen(dbfnam); /* open database for use*/
- recadd (h_db, xc, sizeof(xc));
- recadd (h_db, NULLPTR, 0);
- recadd (h_db, NULLPTR, 0);
- recadd (h_db, NULLPTR, 0);
- dbclose(h_db);
- rc = DB_SUCCESS;
- }
- return (rc);
- }
-
- static dbinitfil(h_db_fil)
- HDL h_db_fil;
- {
- char *pg, *memgive();
- HDL h_rec;
- char *dbdummypg();
- int fhdr_siz, pg_siz, fhdr_free, free_sp;
-
- pg_siz = dbpgsiz();
- pg = memgive(dbpgsiz());
- fhdr_siz = fhdrsizof();
-
- h_rec = (HDL) dbdummypg(pg, fhdr_siz, &fhdr_free);
-
- fhdrist (h_rec, pg_siz);
- flput (pg, dbpgsiz(), h_db_fil);
- h_rec = (HDL) dbdummypg(pg, recsizmax(), &free_sp);
-
- dbmist (h_rec);
- dbmsetfree (h_rec, 0, fhdr_free);
- dbmsetfree (h_rec, 1, 0);
- dbmsetpgct (h_rec, 1);
-
- flput (pg, dbpgsiz(), h_db_fil);
- memtake ((char *)pg);
- }
-