2
* $Id: ext_hdr.c,v 1.1.1.1 2002/03/28 00:02:52 andrew_belov Exp $
3
* ---------------------------------------------------------------------------
4
* Handy functions for dealing with extended headers.
10
DEBUGHDR(__FILE__) /* Debug information block */
12
/* Allocates a per-file extended header structure */
14
struct ext_hdr FAR *eh_alloc()
16
struct ext_hdr FAR *rc;
18
rc=(struct ext_hdr FAR *)farmalloc_msg(sizeof(struct ext_hdr));
19
far_memset((char FAR *)rc, 0, sizeof(struct ext_hdr));
23
/* Locates a block with the specified tag, returning pointer to it */
25
struct ext_hdr FAR *eh_lookup(struct ext_hdr FAR *eh, char tag)
36
/* Locates an unfinalized block */
38
struct ext_hdr FAR *eh_find_pending(struct ext_hdr FAR *eh)
44
if(EH_STATUS(eh)!=EH_FINALIZED)
51
/* Inserts a new block into an instantiated extended header structure. If the
52
block is given as NULL, performs reallocation only */
54
struct ext_hdr FAR *eh_append(struct ext_hdr FAR *eh, char tag, char FAR *block, unsigned int size)
56
struct ext_hdr FAR *p_eh;
58
if((p_eh=eh_lookup(eh, tag))==NULL)
60
for(p_eh=eh; p_eh->next!=NULL; p_eh=p_eh->next);
62
p_eh->next=eh_alloc();
64
p_eh->raw=(char FAR *)farrealloc_msg(p_eh->raw, p_eh->size+size);
66
far_memmove(p_eh->raw+p_eh->size, block, size);
71
/* Releases the extended header structure */
73
void eh_release(struct ext_hdr FAR *eh)
75
struct ext_hdr FAR *p_eh;
77
while((p_eh=eh->next)!=NULL)