home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
DOOG
/
CBASE09.ZIP
/
LSEQ.ZIP
/
LSEQ.H
< prev
next >
Wrap
Text File
|
1989-08-30
|
5KB
|
126 lines
/* Copyright (c) 1989 Citadel */
/* All Rights Reserved */
/* #ident "lseq.h 1.1 - 89/07/03" */
/*man---------------------------------------------------------------------------
NAME
lseq - linked sequential file management library
SYNOPSIS
#include <lseq.h>
DESCRIPTION
The lseq library consists of a set of routines for the creation and
manipulation of doubly-linked sequential files.
lseq uses the blkio library for file access and buffering. Therefore
bexit should be used in place of exit when using lseq.
SEE ALSO
lsclose, lscreate, lscursor, lsdelcur, lsfirst, lsgetcur, lsgetlck,
lsgetr, lsgetrf, lsinscur, lsinsert, lslast, lslock, lsnext, lsopen,
lsprev, lsputr, lsputrf, lsreccnt, lsrecsize, lssearch, lssetbuf,
lssetcur, lssetvbuf, lssync.
------------------------------------------------------------------------------*/
#ifndef LSEQ_H /* prevent multiple includes */
#define LSEQ_H
#include <blkio.h>
/* #include <stddef.h> */
/* lseq constants */
#define LSOPEN_MAX BOPEN_MAX /* max # lseqs open at once */
#define LSBUFCNT ((size_t)10) /* default # of records to buffer */
/* macro to calculate buffer size needed by a lseq */
#define LSBUFSIZ(RECSIZE, BUFCNT) (sizeof(lshdr_t) + ((BUFCNT) * \
(offsetof(lsrec_t, recbuf) + (RECSIZE)))
/* lseq type definitions */
typedef bpos_t lspos_t; /* lseq position */
typedef struct { /* lseq record */
lspos_t next; /* next record in list */
lspos_t prev; /* previous record in list */
void *recbuf; /* record contents */
} lsrec_t;
typedef struct { /* lseq file header */
bpos_t flh; /* block number of free list head */
size_t recsize; /* size of records */
int flags; /* flags */
lspos_t first; /* position of first record */
lspos_t last; /* position of last record */
size_t reccnt; /* number of records currently stored in lseq */
} lshdr_t;
typedef struct { /* lseq control structure */
lshdr_t lshdr; /* file header */
BLKFILE *bp; /* block file */
int flags; /* status flags */
lspos_t clspos; /* current lseq position */
lsrec_t *clsrp; /* current record */
} lseq_t;
extern lseq_t lsb[LSOPEN_MAX]; /* lseq control structure table declaration */
/* lshdr flag bits */
#define LSHMOD (01) /* lseq file being modified */
/* lsb flag bits */
#define LSOPEN (03) /* open status bits */
#define LSREAD (01) /* lseq is open for reading */
#define LSWRITE (02) /* lseq is open for writing */
#define LSLOCKS (030) /* lock status bits */
#define LSRDLCK (010) /* lseq is read locked */
#define LSWRLCK (020) /* lseq is write locked */
#define LSERR (0100) /* error has occurred on this lseq */
/* function declarations */
int lsclose(/* lseq_t *lsp */);
int lscreate(/* char *filename, size_t recsize */);
#define lscursor(LSP) ((void *)(((LSP)->clspos == 0) ? NULL : ~NULL))
int lsdelcur(/* lseq_t *lsp */);
int lsfirst(/* lseq_t *lsp */);
int lsgetcur(/* lseq_t *lsp, lspos_t *lspos_p */);
int lsgetlck(/* lseq_t *lsp */);
int lsgetr(/* lseq_t *lsp, void *buf */);
int lsgetrf(/* lseq_t *lsp, size_t offset, void *buf, size_t bufsize */);
int lsinscur(/* lseq_t *lsp, void *buf */);
int lsinsert(/* lseq_t *lsp, void *buf */);
int lslast(/* lseq_t *lsp */);
int lslock(/* lseq_t *lsp, int l_type */);
int lsnext(/* lseq_t *lsp */);
lseq_t * lsopen(/* char *filename, char *type */);
int lsprev(/* lseq_t *lsp */);
int lsputr(/* lseq_t *lsp, void *buf */);
int lsputrf(/* lseq_t *lsp, size_t offset, void *buf, size_t bufsize */);
#define lsreccnt(LSP) ((LSP)->lshdr.reccnt)
#define lsrecsize(LSP) ((LSP)->lshdr.recsize)
int lssearch(/* lseq_t *lsp, size_t offset, void *buf, size_t bufsize, lscmp_t (*cmp_p)() */);
int lssetbuf(/* lseq_t *lsp, void *buf */);
int lssetcur(/* lseq_t *lsp, lspos_t *lspos_p */);
int lssetvbuf(/* lseq_t *lsp, void *buf, size_t bufcnt */);
int lssync(/* lseq_t *lsp */);
/* lseq lock types */
#define LS_UNLCK (0) /* unlock */
#define LS_RDLCK (1) /* read lock */
#define LS_WRLCK (2) /* write lock */
#define LS_RDLKW (3) /* read lock, wait */
#define LS_WRLKW (4) /* write lock, wait */
/* lseq error codes */
#define LSEOS (-50) /* start of lseq error code domain */
#define LSEMFILE (LSEOS - 1) /* too many open lseqs */
#define LSECORRUPT (LSEOS - 2) /* lseq is corrupt */
#define LSENOPEN (LSEOS - 3) /* lseq not open */
#define LSENBUF (LSEOS - 4) /* buffering is off */
#define LSELOCK (LSEOS - 5) /* incorrect lock type */
#define LSENREC (LSEOS - 6) /* no record */
#define LSEBOUND (LSEOS - 7) /* record boundary error */
#define LSEPANIC (LSEOS - 10) /* internal lseq error */
#endif /* #ifndef LSEQ_H */