//*************************************************************
//
//  Hash table for registry Rsop data
//
//  Microsoft Confidential
//  Copyright (c) Microsoft Corporation 1999
//  All rights reserved
//
//  History:    7-Jun-99   SitaramR    Created
//
//*************************************************************

#define HASH_TABLE_SIZE 97                  // # buckets in hash table
#define STARCOMMAND     TEXT("**Command")   // A special valuename created to keep the commands
//
// List of data values for key registry value in precedence order,
// entries at the beginning of list have higher precedence.
//

typedef struct _REGDATAENTRY {
    BOOL                      bDeleted;        // Is this a deleted value ?
    BOOL                      bAdmPolicy;      // Is this generated by an Adm policy ?
    DWORD                     dwValueType;
    DWORD                     dwDataLen;
    BYTE  *                   pData;
    WCHAR *                   pwszGPO;         // Gpo that set this data
    WCHAR *                   pwszSOM;         // SDOU that the above Gpo is linked to
    WCHAR *                   pwszCommand;     // The actual command that caused the change in data value
    struct _REGDATAENTRY *    pNext;
} REGDATAENTRY, *LPREGDATAENTRY;


//
// List of registry value names under a common registry key
//

typedef struct _REGVALUEENTRY {
    WCHAR *                   pwszValueName;    // Registry value name
    REGDATAENTRY *            pDataList;
    struct _REGVALUEENTRY *   pNext;

} REGVALUEENTRY, *LPREGVALUEENTRY;



//
// List of registry keys that map to same hash bucket
//

typedef struct _REGKEYENTRY {
    WCHAR *                 pwszKeyName;        // Registry key name
    REGVALUEENTRY *         pValueList;
    struct _REGKEYENTRY *   pNext;
} REGKEYENTRY, *LPREGKEYENTRY;


//
// Hash table for looking up registry keys
//

typedef struct _REGHASHTABLE {
    REGKEYENTRY *   aHashTable[HASH_TABLE_SIZE];
    HRESULT         hrError;
} REGHASHTABLE, *LPREGHASHTABLE;


//
// Registry operation types for deleting and
// adding values.
//

typedef enum _REGOPERATION {
    REG_DELETEVALUE = 0,
    REG_DELETEALLVALUES,
    REG_DELETEKEY,
    REG_ADDVALUE,
    REG_SOFTADDVALUE,
    REG_INTERNAL_DELETESINGLEKEY
} REGOPERATION;

//
// Public methods of hash table: alloc, free and addentry
//

#ifdef __cplusplus
extern "C" {
#endif

REGHASHTABLE * AllocHashTable();

void FreeHashTable( REGHASHTABLE *pHashTable );

BOOL AddRegHashEntry( REGHASHTABLE *pHashTable,
                      REGOPERATION opnType,
                      WCHAR *pwszKeyName,
                      WCHAR *pwszValueName,
                      DWORD dwType,
                      DWORD dwDataLen,
                      BYTE *pData,
                      WCHAR *pwszGPO,
                      WCHAR *pwszSOM,
                      WCHAR *szCommand, 
                      BOOL bCreateCommand);
#ifdef __cplusplus
}
#endif
