#ifndef __CDSRefTable_h__
#define __CDSRefTable_h__ 1
#include "DirServicesTypes.h"
#include "PrivateTypes.h"
#include "DSMutexSemaphore.h"
class CDSRefTable;
extern DSMutexSemaphore *gFWTableMutex;
extern CDSRefTable *gFWRefTable;
#define kMaxTableItems 512
#define kMaxTables 0x0F
typedef struct sListInfo *sListInfoPtr;
typedef struct sListInfo {
uInt32 fRefNum;
uInt32 fType;
sInt32 fPID;
sListInfoPtr fNext;
} sListInfo;
typedef struct sPIDInfo {
sInt32 fPID;
sPIDInfo *fNext;
} sPIDInfo;
typedef struct sFWRefEntry {
uInt32 fRefNum;
uInt32 fType;
uInt32 fOffset;
uInt32 fBufTag;
uInt32 fParentID;
sInt32 fPID;
sListInfo *fChildren;
sPIDInfo *fChildPID;
} sFWRefEntry;
typedef sInt32 RefDeallocateProc ( uInt32 inRefNum, sFWRefEntry *entry );
typedef struct sRefTable *sRefTablePtr;
typedef struct sRefTable {
uInt32 fTableNum;
uInt32 fCurRefNum;
uInt32 fItemCnt;
sFWRefEntry *fTableData[ kMaxTableItems ];
} sRefTable;
typedef enum {
eDirectoryRefType = 'Dire',
eNodeRefType = 'Node',
eRecordRefType = 'Reco',
eAttrListRefType = 'AtLi',
eAttrValueListRefType = 'AtVa'
} eRefTypes;
class CDSRefTable {
public:
CDSRefTable ( RefDeallocateProc *deallocProc );
virtual ~CDSRefTable ( void );
static tDirStatus VerifyDirRef ( tDirReference inDirRef, sInt32 inPID );
static tDirStatus VerifyNodeRef ( tDirNodeReference inDirNodeRef, sInt32 inPID );
static tDirStatus VerifyRecordRef ( tRecordReference inRecordRef, sInt32 inPID );
static tDirStatus VerifyAttrListRef ( tAttributeListRef inAttributeListRef, sInt32 inPID );
static tDirStatus VerifyAttrValueRef ( tAttributeValueListRef inAttributeValueListRef, sInt32 inPID );
static tDirStatus NewDirRef ( uInt32 *outNewRef, sInt32 inPID );
static tDirStatus NewNodeRef ( uInt32 *outNewRef, uInt32 inParentID, sInt32 inPID );
static tDirStatus NewRecordRef ( uInt32 *outNewRef, uInt32 inParentID, sInt32 inPID );
static tDirStatus NewAttrListRef ( uInt32 *outNewRef, uInt32 inParentID, sInt32 inPID );
static tDirStatus NewAttrValueRef ( uInt32 *outNewRef, uInt32 inParentID, sInt32 inPID );
static tDirStatus RemoveDirRef ( uInt32 inDirRef, sInt32 inPID );
static tDirStatus RemoveNodeRef ( uInt32 inNodeRef, sInt32 inPID );
static tDirStatus RemoveRecordRef ( uInt32 inRecRef, sInt32 inPID );
static tDirStatus RemoveAttrListRef ( uInt32 inAttrListRef, sInt32 inPID );
static tDirStatus RemoveAttrValueRef ( uInt32 InAttrValueRef, sInt32 inPID );
static tDirStatus AddChildPIDToRef ( uInt32 inRefNum, uInt32 inParentPID, sInt32 inChildPID );
static void CheckClientPIDs ( bool inUseTimeOuts );
static tDirStatus GetOffset ( uInt32 inRefNum, uInt32 inType, uInt32* outOffset, sInt32 inPID );
static tDirStatus SetOffset ( uInt32 inRefNum, uInt32 inType, uInt32 inOffset, sInt32 inPID );
static tDirStatus GetBufTag ( uInt32 inRefNum, uInt32 inType, uInt32* outBufTag, sInt32 inPID );
static tDirStatus SetBufTag ( uInt32 inRefNum, uInt32 inType, uInt32 inBufTag, sInt32 inPID );
private:
tDirStatus VerifyReference ( tDirReference inDirRef, uInt32 inType, sInt32 inPID );
tDirStatus GetNewRef ( uInt32 *outRef, uInt32 inParentID, eRefTypes inType, sInt32 inPID );
tDirStatus RemoveRef ( uInt32 inRefNum, uInt32 inType, sInt32 inPID );
tDirStatus GetReference ( uInt32 inRefNum, sFWRefEntry **outRefData );
tDirStatus LinkToParent ( uInt32 inRefNum, uInt32 inType, uInt32 inParentID, sInt32 inPID );
tDirStatus UnlinkFromParent ( uInt32 inRefNum );
void RemoveChildren ( sListInfo *inChildList, sInt32 inPID );
sRefTable* GetNextTable ( sRefTable *inCurTable );
sRefTable* GetThisTable ( uInt32 inTableNum );
sFWRefEntry* GetTableRef ( uInt32 inRefNum );
uInt32 UpdateClientPIDRefCount
( sInt32 inClientPID, bool inUpRefCount, uInt32 inDirRef=0 );
void DoCheckClientPIDs ( bool inUseTimeOuts );
uInt32 fTableCount;
sRefTable *fRefTables[ kMaxTables + 1 ]; RefDeallocateProc *fDeallocProc;
time_t fSunsetTime;
};
#endif