ncsa-mosaic/libwww2/HTChunk.h

161 lines
3.0 KiB
C

2010-03-08 04:55:21 +07:00
/* /Net/dxcern/userd/timbl/hypertext/WWW/Library/Implementation/HTChunk.html
CHUNK HANDLING:
FLEXIBLE ARRAYS
2010-03-08 04:55:21 +07:00
This module implements a flexible array. It is a general utility module. A chunk is a
structure which may be extended. These routines create and append data to chunks,
automatically reallocating them as necessary.
2010-03-08 04:55:21 +07:00
*/
typedef struct {
int size; /* In bytes */
int growby; /* Allocation unit in bytes */
int allocated; /* Current size of *data */
char * data; /* Pointer to malloced area or 0 */
} HTChunk;
#ifdef SHORT_NAMES
#define HTChunkClear HTChClea
#define HTChunkPutc HTChPutc
#define HTChunkPuts HTChPuts
#define HTChunkCreate HTChCrea
#define HTChunkTerminate HTChTerm
#define HTChunkEnsure HtChEnsu
#endif
/*
Create new chunk
ON ENTRY,
2010-03-08 04:55:21 +07:00
growby The number of bytes to allocate at a time when the chunk is
later extended. Arbitrary but normally a trade-off time vs.
memory
2010-03-08 04:55:21 +07:00
ON EXIT,
2010-03-08 04:55:21 +07:00
returns A chunk pointer to the new chunk,
2010-03-08 04:55:21 +07:00
*/
extern HTChunk * HTChunkCreate PARAMS((int growby));
/*
Free a chunk
ON ENTRY,
2010-03-08 04:55:21 +07:00
ch A valid chunk pointer made by HTChunkCreate()
2010-03-08 04:55:21 +07:00
ON EXIT,
2010-03-08 04:55:21 +07:00
ch is invalid and may not be used.
2010-03-08 04:55:21 +07:00
*/
extern void HTChunkFree PARAMS((HTChunk * ch));
/*
Clear a chunk
ON ENTRY,
2010-03-08 04:55:21 +07:00
ch A valid chunk pointer made by HTChunkCreate()
2010-03-08 04:55:21 +07:00
ON EXIT,
2010-03-08 04:55:21 +07:00
*ch The size of the chunk is zero.
2010-03-08 04:55:21 +07:00
*/
extern void HTChunkClear PARAMS((HTChunk * ch));
/*
Ensure a chunk has a certain space in
ON ENTRY,
2010-03-08 04:55:21 +07:00
ch A valid chunk pointer made by HTChunkCreate()
2010-03-08 04:55:21 +07:00
s The size required
2010-03-08 04:55:21 +07:00
ON EXIT,
2010-03-08 04:55:21 +07:00
*ch Has size at least s
2010-03-08 04:55:21 +07:00
*/
extern void HTChunkEnsure PARAMS((HTChunk * ch, int s));
/*
Append a character to a chunk
ON ENTRY,
2010-03-08 04:55:21 +07:00
ch A valid chunk pointer made by HTChunkCreate()
2010-03-08 04:55:21 +07:00
c The character to be appended
2010-03-08 04:55:21 +07:00
ON EXIT,
2010-03-08 04:55:21 +07:00
*ch Is one character bigger
2010-03-08 04:55:21 +07:00
*/
extern void HTChunkPutc PARAMS((HTChunk * ch, char c));
/*
Append a string to a chunk
ON ENTRY,
2010-03-08 04:55:21 +07:00
ch A valid chunk pointer made by HTChunkCreate()
2010-03-08 04:55:21 +07:00
str Tpoints to a zero-terminated string to be appended
2010-03-08 04:55:21 +07:00
ON EXIT,
2010-03-08 04:55:21 +07:00
*ch Is bigger by strlen(str)
2010-03-08 04:55:21 +07:00
*/
extern void HTChunkPuts PARAMS((HTChunk * ch, char *str));
/*
Append a zero character to a chunk
*/
/*
ON ENTRY,
2010-03-08 04:55:21 +07:00
ch A valid chunk pointer made by HTChunkCreate()
2010-03-08 04:55:21 +07:00
ON EXIT,
2010-03-08 04:55:21 +07:00
*ch Is one character bigger
2010-03-08 04:55:21 +07:00
*/
extern void HTChunkTerminate PARAMS((HTChunk * ch));
/*
end */