Annotation of libwww/Library/src/HTChunk.html, revision 2.12

2.8       timbl       1: <HTML>
                      2: <HEAD>
2.11      frystyk     3: <TITLE>HTChunk: Flexible array handling for libwww</TITLE>
                      4: </HEAD>
2.6       timbl       5: <BODY>
2.11      frystyk     6: 
2.10      frystyk     7: <H1>Chunk handling: Flexible arrays</H1>
                      8: 
2.11      frystyk     9: <PRE>
                     10: /*
                     11: **     (c) COPYRIGHT CERN 1994.
                     12: **     Please first read the full copyright statement in the file COPYRIGH.
                     13: */
                     14: </PRE>
                     15: 
2.10      frystyk    16: This module implements a flexible array. It is a general utility module.
                     17: A chunk is a structure which may be extended.  These routines create
                     18: and append data to chunks, automatically reallocating them as necessary.
                     19: It is garanteed that the array is '\0' terminated at all times, so the
                     20: terminating function, <A HREF="HTChunk.html#Terminate">HTChunkTerminate</A>
2.11      frystyk    21: is only necessary to get the right size in the chunk structure. <P>
2.10      frystyk    22: 
2.11      frystyk    23: This module is implemented by <A HREF="HTChunk.c">HTChunk.c</A>, and
                     24: it is a part of the <A
                     25: HREF="http://info.cern.ch/hypertext/WWW/Library/User/Guide/Guide.html">
                     26: Library of Common Code</A>.
2.10      frystyk    27: 
                     28: <PRE>
                     29: #ifndef HTCHUNK_H
2.9       frystyk    30: #define HTCHUNK_H
2.12    ! roeber     31: 
        !            32: #include "sysdep.h"
2.9       frystyk    33: </PRE>
                     34: 
2.6       timbl      35: <PRE>typedef struct {
2.1       timbl      36:        int     size;           /* In bytes                     */
                     37:        int     growby;         /* Allocation unit in bytes     */
                     38:        int     allocated;      /* Current size of *data        */
                     39:        char *  data;           /* Pointer to malloced area or 0 */
                     40: } HTChunk;
                     41: 
                     42: 
                     43: #ifdef SHORT_NAMES
                     44: #define HTChunkClear           HTChClea
                     45: #define HTChunkPutc            HTChPutc
                     46: #define HTChunkPuts            HTChPuts
                     47: #define HTChunkCreate          HTChCrea
                     48: #define HTChunkTerminate       HTChTerm
                     49: #define HTChunkEnsure          HtChEnsu
                     50: #endif
                     51: 
                     52: 
2.6       timbl      53: </PRE>
                     54: <H2>Create new chunk</H2>
                     55: <H3>On entry,</H3>
                     56: <DL>
                     57: <DT>growby
2.7       timbl      58: <DD> The number of bytes to allocate
2.6       timbl      59: at a time when the chunk is later
                     60: extended. Arbitrary but normally
                     61: a trade-off time vs. memory
                     62: </DL>
                     63: 
                     64: <H3>On exit,</H3>
                     65: <DL>
                     66: <DT>returns
2.7       timbl      67: <DD> A chunk pointer to the new
2.6       timbl      68: chunk,
                     69: </DL>
                     70: 
                     71: <PRE>
2.1       timbl      72: extern HTChunk * HTChunkCreate PARAMS((int growby));
                     73: 
                     74: 
2.6       timbl      75: </PRE>
                     76: <H2>Free a chunk</H2>
                     77: <H3>On entry,</H3>
                     78: <DL>
                     79: <DT>ch
2.7       timbl      80: <DD> A valid chunk pointer made by
                     81: HTChunkCreate()
2.6       timbl      82: </DL>
                     83: 
                     84: <H3>On exit,</H3>
                     85: <DL>
                     86: <DT>ch
2.7       timbl      87: <DD> is invalid and may not be used.
2.6       timbl      88: </DL>
                     89: 
                     90: <PRE>
2.1       timbl      91: extern void HTChunkFree PARAMS((HTChunk * ch));
                     92: 
                     93: 
2.6       timbl      94: </PRE>
                     95: <H2>Clear a chunk</H2>
                     96: <H3>On entry,</H3>
                     97: <DL>
                     98: <DT>ch
2.7       timbl      99: <DD> A valid chunk pointer made by
                    100: HTChunkCreate()
2.6       timbl     101: </DL>
                    102: 
                    103: <H3>On exit,</H3>
                    104: <DL>
                    105: <DT>*ch
2.7       timbl     106: <DD> The size of the chunk is zero.
2.6       timbl     107: </DL>
                    108: 
                    109: <PRE>
2.1       timbl     110: extern void HTChunkClear PARAMS((HTChunk * ch));
                    111: 
                    112: 
2.6       timbl     113: </PRE>
                    114: <H2>Ensure a chunk has a certain space
                    115: in</H2>
                    116: <H3>On entry,</H3>
                    117: <DL>
                    118: <DT>ch
2.7       timbl     119: <DD> A valid chunk pointer made by
                    120: HTChunkCreate()
2.6       timbl     121: <DT>s
2.7       timbl     122: <DD> The size required
2.6       timbl     123: </DL>
                    124: 
                    125: <H3>On exit,</H3>
                    126: <DL>
                    127: <DT>*ch
2.7       timbl     128: <DD> Has size at least s
2.6       timbl     129: </DL>
                    130: 
                    131: <PRE>
2.1       timbl     132: extern void HTChunkEnsure PARAMS((HTChunk * ch, int s));
                    133: 
                    134: 
2.6       timbl     135: </PRE>
                    136: <H2>Append a character to a  chunk</H2>
                    137: <H3>On entry,</H3>
                    138: <DL>
                    139: <DT>ch
2.7       timbl     140: <DD> A valid chunk pointer made by
                    141: HTChunkCreate()
                    142: <DT>c
2.8       timbl     143: <DD> The character to be appended
2.6       timbl     144: </DL>
                    145: 
2.7       timbl     146: <H3>On exit,</H3>
                    147: <DL>
                    148: <DT>*ch
2.8       timbl     149: <DD> Is one character bigger
2.7       timbl     150: </DL>
2.1       timbl     151: 
2.7       timbl     152: <PRE>extern void HTChunkPutc PARAMS((HTChunk * ch, char c));
2.1       timbl     153: 
2.6       timbl     154: </PRE>
                    155: <H2>Append a string to a  chunk</H2>
                    156: <H3>On entry,</H3>
                    157: <DL>
                    158: <DT>ch
2.7       timbl     159: <DD> A valid chunk pointer made by
                    160: HTChunkCreate()
                    161: <DT>str
                    162: <DD> Tpoints to a zero-terminated
                    163: string to be appended
2.6       timbl     164: </DL>
                    165: 
                    166: <H3>On exit,</H3>
                    167: <DL>
                    168: <DT>*ch
2.7       timbl     169: <DD> Is bigger by strlen(str)
2.6       timbl     170: </DL>
                    171: 
                    172: <PRE>
2.1       timbl     173: 
2.7       timbl     174: extern void HTChunkPuts PARAMS((HTChunk * ch, const char *str));
2.1       timbl     175: 
                    176: 
2.6       timbl     177: </PRE>
2.10      frystyk   178: <A NAME="Terminate"><H2>Append a zero character to a  chunk</H2></A>
2.6       timbl     179: <PRE>
                    180: </PRE>
                    181: <H3>On entry,</H3>
                    182: <DL>
                    183: <DT>ch
2.7       timbl     184: <DD> A valid chunk pointer made by
                    185: HTChunkCreate()
2.6       timbl     186: </DL>
                    187: 
                    188: <H3>On exit,</H3>
                    189: <DL>
                    190: <DT>*ch
2.7       timbl     191: <DD> Is one character bigger
2.6       timbl     192: </DL>
                    193: 
                    194: <PRE>
2.1       timbl     195: 
                    196: extern void HTChunkTerminate PARAMS((HTChunk * ch));
2.9       frystyk   197: 
                    198: #endif
2.6       timbl     199: 
2.8       timbl     200: </PRE>end</A></BODY>
                    201: </HTML>

Webmaster