/*static char *SCCSID = "@(#)pr_ea.h    6.3 92/02/19";*/
#include "PR_EA.NAM"

PAUXHAND AAH (PFRAME pfrm);

USHORT AppendAux (PAUXINFO paxi, PFNODE pfnd, USHORT cb,
                  PBYTE pbData, LSN lsn, PFRAME pfrm);

PALBLK BuildAlBlk (PSPTR psptr, BOOL fSingleExt, PFRAME pfrm);

USHORT BuildEAAT (PSPTR psptr, PALBLK palb);

USHORT ConsistentFEA(PFEALIST pfeal);

USHORT ConsistentGEA(PGEALIST pgeal);


#define CopyEAName( pszDest, pszSrc, cbName )                           \
    ( pszSrc[cbName] == '\0' &&                                         \
      FSH_UPPERCASE( (pszSrc), (cbName)+1, (pszDest) ) == NO_ERROR &&   \
      FSH_CHECKEANAME( 1, (LONG)(cbName), (pszDest) ) == NO_ERROR )

USHORT CSS (PFEALIST pfeal);

BOOL DelAux (PAUXINFO paxi, PFNODE pfnd, PFRAME pfrm);

UINT far DelEA (PFNODE pfn, PFRAME pfrm);

void DelEAData( PFEA pfeaLst, PFEA pfeaEnd, PFRAME pfrm );

BOOL EAA (PALBLK palb, LSN lsnFNode, USHORT cbAlloc, PFRAME pfrm);

/*
 * BOOL EndOfEA( PAUXHAND paxh )
 *      returns TRUE iff there are no more bytes left to read in the EA's.
 */
#define EndOfEA( paxh )  ( (paxh)->cbFile == 0 )

PBYTE far GetBuf (USHORT cbNeeded, PBUFNODE far * ppbuf, PFRAME pfrm);

USHORT far GetEA(PFEALIST pfeal,PGEALIST pgeal,
                 POFT poft, PUSHORT poError, BOOL fLevel, PFRAME pfrm);

USHORT far MkFEAFromGEA( PGEALIST pgealInPut, PFEALIST pfeal, PUSHORT poError,
                         BOOL fLevel );

USHORT QPathEA (PGEALIST pgeal,
                PFEALIST pfeal,
                PDIRBLK  pdb,
                PDIRENT  pde,
                PUSHORT  poError,
      BOOL      fLevel,
                PFRAME   pfrm);

USHORT far QueryEA (PFHT pfht, PGEALIST pgeal,
                    PFEALIST pfeal, PUSHORT poError, BOOL fLevel, PFRAME pfrm);

USHORT RdAH (PAUXHAND paxh, PUSHORT pcbXfer, PBYTE FAR *ppbSrc,
             PBYTE FAR *ppbDest, PFRAME pfrm);

PBYTE RdAux (PAUXINFO paxi, PFNODE pfn, USHORT ibSeek, PBUFNODE *ppbuf,
             PUSHORT pusSize, PUSHORT pusRem);

USHORT ReadEA (PAUXHAND paxh, PBYTE pbDest, PUSHORT pcbMax, PFRAME pfrm);

/*
 * void RelAuxHand( PAUXHAND paxh )
 *
 *      Releases all memory and buffers associated with an auxhand
 *      including the heap space for the auxhand itself
 * @76193 - use DecrHoldsBUF
 */
#define RelAuxHand( paxh )  {                                   \
    if( (paxh)->pbuf != NULL ) {                                \
        DecrHoldsBUF( (paxh)->pbuf );                           \
    }                                                           \
    if( (paxh)->palb != NULL ) {                                \
        RetHeap( (paxh)->palb );                                \
    }                                                           \
    RetHeap( (paxh) );                                          \
}


VOID far RelBuf( PBYTE pbData, PBUFNODE pbuf, PFRAME pfrm );

BOOL ScanEA (PFEA pfea, PEALIST peal, BOOL fFEAList);

USHORT far SetEA (PFEALIST pfeal,
                   POFT poft,
                   PUSHORT poError,
                   PUSHORT pcbLen,
                   BOOL fReplace,
                   PFRAME pfrm);

USHORT SetFileEA (PFHT pfht, PFEALIST pfeal, PUSHORT poError, PFRAME pfrm);

UINT far SetOpenEA(POFT poft,PEAOP peaop, PULONG pcbLen,
                             PBYTE pfDirFlag, BOOL fVMLock, PFRAME pfrm);

USHORT SetPathEA (PFEALIST pfeal,
                        PDIRBLK  pdb,
                        PDIRENT  pde,
                        PBUFNODE pbuf,
                        PUSHORT poError,
                        PFRAME pfrm);

BOOL WriteALB (USHORT cbToWrite, PBYTE pbData, PALBLK palb, PFRAME pfrm);

extern USHORT far LockEAs (PEAOP peaop,
                       USHORT flag,
                       LHANDLE far * plhFEA,
                       LHANDLE far * plhGEA,
                       PFEALIST far * ppFEA,
                       PGEALIST far * ppGEA,
             BOOL fVMLock,
                       PFRAME pfrm);

extern USHORT far LockFindEAs (PEAOP peaop,
                       USHORT cbList,
                       LHANDLE far * plhList,
                       LHANDLE far * plhGEA,
                       PFRAME pfrm);

extern void far UnlockEAs (LHANDLE lhFEA, LHANDLE lhGEA, PFRAME pfrm);

#include "PR_EA.SEG"
