home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
INCLUDE
/
BBCDECL.H
< prev
next >
Wrap
C/C++ Source or Header
|
1990-04-05
|
3KB
|
104 lines
/*
bbcdecl.h
% byte block chain header
OWL 1.2
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
8/21/88 jmd preened and poked
10/17/88 jmd added _arg
3/03/90 jdc changed char's to byte's
3/28/90 jmd ansi-fied
*/
typedef struct bblock_struct {
struct bblock_struct *prev;
struct bblock_struct *next;
char *start; /* pointer to the memory chunk */
unsigned int len; /* used length */
unsigned int size; /* allocated size */
long row; /* hint */
unsigned int off; /* offset from "start" (in bytes) to start of current row */
byte attr; /* for text blocks */
} *bblock_type;
typedef struct _bbc {
unsigned int esize; /* element size */
unsigned int bsize; /* block size */
unsigned int asize; /* minimum alloc size */
bblock_type b;
} bbc_struct, *bbc_type;
typedef struct _bbpeek {
bblock_type b;
int off;
char *p;
long len;
} bbpeek_struct, *bbpeek_type;
/* -------------------------------------------------------------------------- */
/* function prototypes */
/* BBCHAIN.C */
extern bbc_type bbc_Open(unsigned esize, unsigned bsize, unsigned asize);
extern long bbc_work(bbc_type bbc, long offset, char *line, byte chr, long len, int mode);
extern boolean bbc_Attr(bbc_type bbc, long offset, byte attr, long len);
extern long bbc_Del(bbc_type bbc, long offset, long len);
extern void bbc_Close(bbc_type bbc);
extern void bblock_close(bblock_type b, int flag);
extern int bbpeek(bbpeek_type bp);
extern bblock_type bblock_open(bbc_type bbc, long size, bblock_type prev, byte attr);
extern bblock_type bblock_grow(bbc_type bbc, bblock_type b, long size);
extern bblock_type bblock_split(bbc_type bbc, bblock_type top, long offset);
extern bblock_type bblock_rewind(bblock_type b);
/* -------------------------------------------------------------------------- */
/* macros */
#define BBC_SET FALSE
#define BBC_INSERT TRUE
#define BBC_GET 2
#define BBC_ENDINS 3
#define BBC_SINGLE 0
#define BBC_BELOW 1
#define bblen(b) ((b)->len)
#define bboff(b) ((b)->off)
#define bbc_Copy(b, offset, line, len, ins) \
bbc_work(b, offset, line, 0, len, ins)
#define bbc_Set(b, offset, chr, len, ins) \
bbc_work(b, offset, NULL, chr, len, ins)
#define bbc_Get(b, offset, buf, len) \
bbc_work(b, offset, buf, 0, len, BBC_GET)
/* for use when "offset" += n 'ing */
#define bbadv(b, o, chk) while ((o) >= (b)->len){if((b)==NULL){(chk)=TRUE;break;} else{(o) -= (b)->len; \
(b)=(b)->next;}}
/* for use only when "offset"++ 'ing */
#define bbinc(b, o, t) if ((o) >= (b)->len){(b)=(b)->next;(o)=0;(t)=(b)->start;}
#define bblockchk(b, t, e, chk) while ((t) >= (e)){if((b)->next==NULL){ \
(chk)=TRUE;break;} else{(b)=(b)->next;(t)=(b)->start;(e)=(b)->end;}}