home *** CD-ROM | disk | FTP | other *** search
- /*
- bfdecl.h
-
- % block file header
-
- OWL 1.2
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 2/02/89 jdc added bfile_Clear and added fflush() in bfile_Read()
- 7/27/89 jdc renamed macros and removed static buffer
- 8/09/89 jdc changed oslist_GetSym to oslist_Get
- 1/21/90 jdc changed oslist stuff
- 1/24/90 jdc preened
-
- 3/28/90 jmd ansi-fied
- 4/15/90 jdc added bfile_ReadOnly, preened
- 9/07/90 jmd renamed oslist stuff
- 10/28/90 jdc added bfile_GetID macro
- 12/03/90 jdc changed readonly's to onlyread's
- */
-
- /* in oslist.h
- #define OSLIST_BADNAME -1 */
-
- #define BFILE_DIR -2
- #define BFILE_NOMORE -3
-
- #define COMM_LEN 50
- #define BHEAD_LEN 11L
- #define THEAD_LEN 7L
- #define FHEAD_LEN ((long)COMM_LEN + BHEAD_LEN)
-
- typedef struct bfile_struct {
-
- unsigned block_size;
- oslist_type dir;
-
- FILE *stream;
- char *path;
-
- int freeb;
-
- int current_name; /* bfile_Push() and bfile_Pop() depend on */
- int current_block; /* the current order of elements in bfile_struct */
- int curnext_block; /* changing the order will BREAK code */
-
- unsigned curblock_size;
- unsigned new_find;
-
- xarray push;
- int pindex;
-
- char *comment;
-
- } *bfile_type;
-
- /* -------------------------------------------------------------------------- */
- /* function prototypes */
-
- /* BFILE.C */
- extern bfile_type bf_open(char *pathname, unsigned block_size, char *comment, boolean onlyread);
- extern unsigned bf_gets(bfile_type bfile, char *buf, unsigned buf_len, char end_char);
-
- extern boolean bfile_Find(bfile_type bfile, char *name, int type);
- extern boolean bfile_Write(bfile_type bfile, char *data, unsigned len);
- extern boolean bfile_pad(bfile_type bfile);
- extern unsigned bfile_Read(bfile_type bfile, char *buf, unsigned buf_len);
- extern void bfile_Close(bfile_type bfile);
- extern boolean bfile_Push(bfile_type bfile);
- extern boolean bfile_Pop(bfile_type bfile);
- extern void bfile_PutFreeB(bfile_type bfile, int block);
- extern int bfile_GetFreeB(bfile_type bfile);
- extern void bfile_WriteDir(bfile_type bfile);
-
- /* BFAUX.C */
- extern boolean bfile_FindEnd(bfile_type bfile, char *name, int type);
- extern void bfile_Del(bfile_type bfile, char *name);
-
- /* -------------------------------------------------------------------------- */
- /* macros */
-
- #define bfile_Open(path, bsize, comment) \
- bf_open(path, bsize, comment, FALSE)
-
- #define bfile_ReadOnly(path, bsize, comment) \
- bf_open(path, bsize, comment, TRUE)
-
- #define bfile_Gets(bf, buf, blen) bf_gets(bf, buf, blen, '\n')
-
- #define bfwseek(bfile) fseek((bfile)->stream,\
- ( (long)(bfile)->current_block*( (long)(bfile)->block_size+BHEAD_LEN+THEAD_LEN ) ) + FHEAD_LEN,\
- SEEK_SET)
-
- #define bfrseek(bfile) fseek((bfile)->stream,\
- ( (long)(bfile)->current_block*( (long)(bfile)->block_size+BHEAD_LEN+THEAD_LEN ) ) + FHEAD_LEN+THEAD_LEN,\
- SEEK_SET)
-
- #define bfile_GetDirList(bfile) ((bfile)->dir)
- #define bfile_GetDirSize(bfile) oslist_GetSize((bfile)->dir)
- #define bfile_CloseDir(bfile) oslist_Close((bfile)->dir)
-
- #define bfile_FindDirHandle(bfile, name) oslist_FindHandle((bfile)->dir, name)
- #define bfile_DirAlphaHandle(bfile, a) oslist_GetAlphaHandle((bfile)->dir, a)
-
- #define bfile_SetDirName(bfile, s, d) oslist_SetSym((bfile)->dir, s, d)
- #define bfile_GetDirName(bfile, h) oslist_GetSym((bfile)->dir, h)
- #define bfile_GetDirData(bfile, h) oslist_GetData((bfile)->dir, h)
- #define bfile_GetDirAlpha(bfile, h) oslist_GetSym((bfile)->dir, oslist_GetAlphaHandle((bfile)->dir, h))
-
- #define bfile_GetID(bfile, h) (((int*)bfile_GetDirData(bfile, h))[1])
- #define bfile_Contains(bfile, name) \
- ((bfile_FindDirHandle(bfile, name) != OSLIST_BADNAME) ? TRUE:FALSE)
-