about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTWAIS.h
Commit message (Expand)AuthorAgeFilesLines
* snapshot of project "lynx", label v2-8-8dev_11Thomas E. Dickey2012-02-201-0/+43
* snapshot of project "lynx", label v2-8-8dev_10bThomas E. Dickey2012-02-201-43/+0
* snapshot of project "lynx", label v2-8-8dev_8mThomas E. Dickey2011-06-111-0/+43
* snapshot of project "lynx", label v2_8_8dev_9aThomas E. Dickey2011-06-111-43/+0
* snapshot of project "lynx", label v2-8-8dev_3cThomas E. Dickey2010-05-031-0/+43
* snapshot of project "lynx", label v2_8_8dev_6cThomas E. Dickey2010-04-291-43/+0
* snapshot of project "lynx", label v2-8-6dev_10Thomas E. Dickey2005-01-021-4/+10
* snapshot of project "lynx", label v2-8-6dev_3Thomas E. Dickey2004-05-071-1/+2
* snapshot of project "lynx", label v2-8-5dev_13Thomas E. Dickey2003-01-221-5/+0
* snapshot of project "lynx", label v2-8-2dev_9Thomas E. Dickey1998-12-131-11/+11
* snapshot of project "lynx", label v2-8-2dev_2Thomas E. Dickey1998-11-101-3/+0
* snapshot of project "lynx", label v2-8-1dev_4Thomas E. Dickey1998-11-061-0/+3
* snapshot of project "lynx", label v2-8-1dev_20Thomas E. Dickey1998-08-061-3/+0
* snapshot of project "lynx", label v2-8-1dev_5Thomas E. Dickey1998-03-291-2/+2
* snapshot of project "lynx", label v2_6Thomas E. Dickey1996-09-021-0/+44
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228



































































































































































































































                                                                                
/*
 * $LynxId: HTChunk.h,v 1.20 2010/09/24 08:37:39 tom Exp $
 *
 *				     HTChunk: Flexible array handling for libwww
 *					CHUNK HANDLING:
 *					FLEXIBLE ARRAYS
 *
 * 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.
 *
 */
#ifndef HTCHUNK_H
#define HTCHUNK_H 1

#ifndef HTUTILS_H
#include <HTUtils.h>
#endif

#include <UCMap.h>

#ifdef __cplusplus
extern "C" {
#endif
    typedef struct _HTChunk HTChunk;

    struct _HTChunk {
	int size;		/* In bytes                     */
	int growby;		/* Allocation unit in bytes     */
	int allocated;		/* Current size of *data        */
	char *data;		/* Pointer to malloc'd area or 0 */
	int failok;		/* allowed to fail without exiting program? */
	HTChunk *next;		/* pointer to the next chunk */
    };

/*
 * Initialize a chunk's allocation data and allocation-increment.
 */
    extern void HTChunkInit(HTChunk *ch, int grow);

/*
 *
 * Create new chunk
 *
 *   ON ENTRY,
 *
 *   growby		The number of bytes to allocate at a time when the chunk
 *			is later extended.  Arbitrary but normally a trade-off
 *			of time vs memory.
 *
 *   ON EXIT,
 *
 *   returns		A chunk pointer to the new chunk,
 *
 */

    extern HTChunk *HTChunkCreate(int growby);

/*
 *  Create a chunk for which an allocation error is not a fatal application
 *  error if failok != 0, but merely resets the chunk.  When using a chunk
 *  created this way, the caller should always check whether the contents
 *  are ok each time after data have been appended.
 *  The create call may also fail and will reurn NULL in that case. - kw
 */
    extern HTChunk *HTChunkCreateMayFail(int growby, int failok);

/*
 *  Like HTChunkCreate but with initial allocation - kw
 *
 */
    extern HTChunk *HTChunkCreate2(int growby, size_t needed);

/*
 *
 * Free a chunk
 *
 *   ON ENTRY,
 *
 *   ch			A valid chunk pointer made by HTChunkCreate()
 *
 *   ON EXIT,
 *
 *   ch			is invalid and may not be used.
 *
 */

    extern void HTChunkFree(HTChunk *ch);

/*
 *
 * Clear a chunk
 *
 *   ON ENTRY,
 *
 *   ch			A valid chunk pointer made by HTChunkCreate()
 *
 *   ON EXIT,
 *
 *   *ch		The size of the chunk is zero.
 *
 */

    extern void HTChunkClear(HTChunk *ch);

/*
 *
 * Realloc a chunk
 *
 *   ON ENTRY,
 *
 *   ch			A valid chunk pointer made by HTChunkCreate()
 *
 *   growby		growby
 *
 *   ON EXIT,
 *
 *   *ch		Expanded by growby
 *
 */

    extern BOOL HTChunkRealloc(HTChunk *ch, int growby);

/*
 *
 * Ensure a chunk has a certain space in
 *
 *   ON ENTRY,
 *
 *   ch			A valid chunk pointer made by HTChunkCreate()
 *
 *   s			The size required
 *
 *   ON EXIT,
 *
 *   *ch		Has size at least s
 *
 */

    extern void HTChunkEnsure(HTChunk *ch, int s);

/*
 *
 * Append a character to a  chunk
 *
 *   ON ENTRY,
 *
 *   ch			A valid chunk pointer made by HTChunkCreate()
 *
 *   c			The character to be appended
 *
 *   ON EXIT,
 *
 *   *ch		Is one character bigger
 *
 */
    extern void HTChunkPutc(HTChunk *ch, unsigned c);

    extern void HTChunkPutb(HTChunk *ch, const char *b, int l);

    extern void HTChunkPutUtf8Char(HTChunk *ch, UCode_t code);

/*
 * Append a string to a  chunk
 *
 *   ON ENTRY,
 *
 *   ch			A valid chunk pointer made by HTChunkCreate()
 *
 *   str		Points to a zero-terminated string to be appended
 *
 *   ON EXIT,
 *
 *   *ch		Is bigger by strlen(str)
 *
 */

    extern void HTChunkPuts(HTChunk *ch, const char *str);

/*
 *
 * Append a zero character to a  chunk
 *
 */

/*
 *
 *   ON ENTRY,
 *
 *   ch			A valid chunk pointer made by HTChunkCreate()
 *
 *   ON EXIT,
 *
 *   *ch		Is one character bigger
 *
 */

    extern void HTChunkTerminate(HTChunk *ch);

/* like the above but no realloc: extend to another chunk if necessary */
/*
 *
 * Append a character (string, data) to a chunk
 *
 *   ON ENTRY,
 *
 *   ch                        A valid chunk pointer made by HTChunkCreate()
 *
 *   c                 The character to be appended
 *
 *   ON EXIT,
 *
 *   returns           original chunk or a pointer to the new chunk
 *                     (orginal chunk is referenced to the new one
 *                     by the field 'next')
 *
 */
    extern HTChunk *HTChunkPutc2(HTChunk *ch, int c);
    extern HTChunk *HTChunkPuts2(HTChunk *ch, const char *str);
    extern HTChunk *HTChunkPutb2(HTChunk *ch, const char *b, int l);

/* New pool infrastructure: UNlike the above, store data using alignment */
    extern HTChunk *HTChunkPutb0(HTChunk *ch, const char *b, int l);

#ifdef __cplusplus
}
#endif
#endif				/* HTCHUNK_H */