//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//
//  Copyright (C) Microsoft Corporation, 1997 - 1998
//
//  File:       mprsnap.idl
//
//--------------------------------------------------------------------------

// mprsnap.idl : IDL source for MPRSNAP DLLs
//

#ifndef _MPRSNAP_IDL_
#define _MPRSNAP_IDL_

import "wtypes.idl";

typedef BYTE *	PBYTE;

//----------------------------------------------------------------------------
// Struct:  InfoBlock
//
// Contains the information for a single block in an infobase.
//----------------------------------------------------------------------------


typedef struct _InfoBlock
{
    DWORD   dwType;     // block type (e.g. IP_RIP, IPX_PROTOCOL_SAP)
    DWORD   dwSize;     // size in bytes of each entry in 'pData'
    DWORD   dwCount;    // number of structures in 'pData'
    PBYTE   pData;      // block data bytes
} InfoBlock;


/*---------------------------------------------------------------------------
	IEnumInfoBlock
 ---------------------------------------------------------------------------*/

[
   object,
   uuid(66A2DB01-D706-11d0-A37B-00C04FC9DA04),
   local,
   pointer_default(unique),
]
   
interface IEnumInfoBlock : IUnknown
{
	HRESULT	Next( [in]	ULONG	uNum,
				  [out]	InfoBlock **ppBlock,
				  [out]	ULONG *	pNumReturned );
	
	HRESULT	Skip( [in]	ULONG	uNum );
	
	HRESULT	Reset();
	
	HRESULT	Clone( [out] IEnumInfoBlock **ppBlockEnum );
};

cpp_quote("#define DeclareIEnumInfoBlockMembers(IPURE) \\")
cpp_quote("	STDMETHOD(Next)(ULONG uNum, InfoBlock **ppBlock, \\")
cpp_quote("				   ULONG *pNumReturned) IPURE; \\")
cpp_quote("	STDMETHOD(Skip)(ULONG uNum) IPURE; \\")
cpp_quote("	STDMETHOD(Reset)() IPURE; \\")
cpp_quote("	STDMETHOD(Clone)(IEnumInfoBlock **ppBlockEnum) IPURE; \\")


/*---------------------------------------------------------------------------
	IInfoBase
 ---------------------------------------------------------------------------*/
[
   object,
   uuid(66a2db00-d706-11d0-a37b-00c04fc9da04),
   local,
   pointer_default(unique),
]

interface IInfoBase : IUnknown
{
	import "unknwn.idl";
//	import "wtypes.idl";


	//--------------------------------------------------------------------
	// Function:    Load
	//
	// Loads value named 'pszValue' from subkey 'pszKey' of 'hkey'
	//--------------------------------------------------------------------
	HRESULT	Load( [in]	HKEY hKey,
				  [in,string]	LPCOLESTR pszKey,
				  [in,string]	LPCOLESTR pszValue);
	
	//--------------------------------------------------------------------
	// Function:    Save
	//
	// saves value named 'pszValue' to subkey 'pszKey' of 'hkey';
	// 'pszKey' cannot be a path
	//--------------------------------------------------------------------
	HRESULT Save( [in]  HKEY hKey,
				  [in,string]	LPCOLESTR pszKey,
				  [in,string]	LPCOLESTR pszValue);

	//--------------------------------------------------------------------
	// Function:    Unload
	//
	// unloads current infobase contents
	//--------------------------------------------------------------------
	HRESULT	Unload();

	//--------------------------------------------------------------------
	// Function:    CopyFrom
	//
	// copies contents of infobase 'src'
	//--------------------------------------------------------------------
	HRESULT	CopyFrom( [in]	IInfoBase *	pSrc );

	//--------------------------------------------------------------------
	// Function:    LoadFrom
	//
	// loads from byte-array 'pBase'
	//--------------------------------------------------------------------
	HRESULT	LoadFrom( [in]	DWORD dwSize,
					  [in,size_is(dwSize)] PBYTE pBase);

	//--------------------------------------------------------------------
	// Function:    WriteTo
	//
	// sets 'pBase' to point to allocated memory into which
	// opaque info is written; saves size of '*pBase' in 'dwSize'
	//--------------------------------------------------------------------
	HRESULT	WriteTo( [out]	PBYTE *ppBase,
					 [out]	DWORD *pdwSize);
	
	//--------------------------------------------------------------------
	// Function:    GetBlock
	//
	// retrieves 'dwNth' block of type 'dwType' from the list of blocks
	// The block does NOT need to be freed up (this assumes that this
	// local, not remote).
	//--------------------------------------------------------------------
	HRESULT GetBlock( [in]	DWORD dwType,
					  [out]	InfoBlock **ppBlock,
					  [in]	DWORD dwNth);
	
	//--------------------------------------------------------------------
	// Function:    SetBlock
	//
	// Replaces 'dwNth' block of type 'dwType' with a copy of 'pBlock'.
	// Note that this copies the data for the block from 'pBlock->pData'.
	//--------------------------------------------------------------------
	HRESULT SetBlock( [in]	DWORD dwType,
					  [in]	InfoBlock *pBlock,
					  [in]	DWORD dwNth);
	
	//--------------------------------------------------------------------
	// Function:    AddBlock
	//
	// Add's a new block of type 'dwType' to the list of blocks
	//
	// This will make a copy of pData (this behavior differs from SetData()).
	//
	//	Defaults: dwCount=1, bRemoveFirst=FALSE
	//--------------------------------------------------------------------
	HRESULT	AddBlock( [in]	DWORD	dwType,
					  [in]	DWORD	dwSize,
					  [in]	PBYTE	pData,
					  [in]	DWORD	dwCount,
					  [in]	BOOL	bRemoveFirst);
	
	//--------------------------------------------------------------------
	// Function:    GetData
	//
	// Retrieves the data for the 'dwNth' block of type 'dwType'.
	// Do NOT free up the data here.
	//--------------------------------------------------------------------
	HRESULT GetData( [in]	DWORD	dwType,
					 [in]	DWORD	dwNth,
					 [out]	PBYTE *	ppData);
	
	//--------------------------------------------------------------------
	// Function:    SetData
	//
	// Replaces the data for the 'dwNth' block of type 'dwType'.
	// Note that this does not copy 'pData'; the block is changed
	// to point to 'pData', and thus 'pData' should not be a pointer
	// to data on the stack, and it should not be deleted.
	// Furthermore, it must have been allocated using 'new'.
	//--------------------------------------------------------------------
	HRESULT	SetData( [in]	DWORD	dwType,
					 [in]	DWORD	dwSize,
					 [in]	PBYTE	pData,
					 [in]	DWORD	dwCount,
					 [in]	DWORD	dwNth);

	//--------------------------------------------------------------------
	// Function:    RemoveBlock
	//
	// Removes the 'dwNth' block of type 'dwType' from the list of blocks.
	//--------------------------------------------------------------------
	HRESULT	RemoveBlock( [in]	DWORD	dwType,
						 [in]	DWORD	dwNth);

	//--------------------------------------------------------------------
	// Function:    BlockExists
	//
	// Returns S_OK if a block of the specified type is in the block-list,
	// S_FALSE otherwise
	//--------------------------------------------------------------------
	HRESULT	BlockExists( [in]	DWORD	dwType );

	//--------------------------------------------------------------------
	// Function:    ProtocolExists
	//
	// Returns TRUE if the given routing-protocol exists in the info-base;
	// this is so if the block is present and non-empty.
	//--------------------------------------------------------------------
	HRESULT ProtocolExists( [in]	DWORD	dwProtocol );

	//--------------------------------------------------------------------
	// Function:    RemoveAllBlocks
	//
	// Removes all blocks from the list of blocks.
	//--------------------------------------------------------------------
	HRESULT RemoveAllBlocks ();

	//--------------------------------------------------------------------
	// Function:    QueryBlockList
	//
	// Returns a reference to the list of blocks;
	// the returned list contains items of type 'SInfoBlock',
	// and the list must not be modified.
	//--------------------------------------------------------------------
	HRESULT	QueryBlockList([out] IEnumInfoBlock **ppBlockEnum);
	
	//--------------------------------------------------------------------
	// Function:    GetInfo
	//
	// Returns information about the infobase.  This is useful for
	// determining if this is a new infobase or not.
	//
	// Returns the size (in bytes) of the InfoBase as well as the
	// number of blocks.
	//--------------------------------------------------------------------
	HRESULT	GetInfo([out] DWORD *pdwSize, [out] int *pcBlocks);
};

cpp_quote("#define DeclareIInfoBaseMembers(IPURE) \\")
cpp_quote("	STDMETHOD(Load)(HKEY hKey, \\")
cpp_quote("					  LPCOLESTR pszKey, \\")
cpp_quote("					  LPCOLESTR pszValue) IPURE; \\")
cpp_quote("	STDMETHOD(Save)(HKEY hKey, \\")
cpp_quote("					  LPCOLESTR pszKey, \\")
cpp_quote("					  LPCOLESTR pszValue) IPURE; \\")
cpp_quote("	STDMETHOD(Unload)() IPURE; \\")
cpp_quote("	STDMETHOD(CopyFrom)(IInfoBase * pSrc) IPURE; \\")
cpp_quote("	STDMETHOD(LoadFrom)(DWORD dwSize, \\")
cpp_quote("						  PBYTE pBase) IPURE; \\")
cpp_quote("	STDMETHOD(WriteTo)(PBYTE *ppBase, \\")
cpp_quote("						 DWORD *pdwSize) IPURE; \\")
cpp_quote("	STDMETHOD(GetBlock)(DWORD dwType, \\")
cpp_quote("						  InfoBlock **ppBlock, \\")
cpp_quote("						  DWORD dwNth) IPURE; \\")
cpp_quote("	STDMETHOD(SetBlock)(DWORD dwType, \\")
cpp_quote("						  InfoBlock *pBlock, \\")
cpp_quote("						  DWORD dwNth) IPURE; \\")
cpp_quote("	STDMETHOD(AddBlock)(DWORD	dwType, \\")
cpp_quote("						  DWORD	dwSize, \\")
cpp_quote("						  PBYTE	pData, \\")
cpp_quote("						  DWORD	dwCount, \\")
cpp_quote("						  BOOL	bRemoveFirst) IPURE; \\")
cpp_quote("	STDMETHOD(GetData)(DWORD	dwType, \\")
cpp_quote("						 DWORD	dwNth, \\")
cpp_quote("						 PBYTE *	ppData) IPURE; \\")
cpp_quote("	STDMETHOD(SetData)(DWORD	dwType, \\")
cpp_quote("						 DWORD	dwSize, \\")
cpp_quote("						 PBYTE	pData, \\")
cpp_quote("						 DWORD	dwCount, \\")
cpp_quote("						 DWORD	dwNth) IPURE; \\")
cpp_quote("	STDMETHOD(RemoveBlock)(DWORD	dwType, \\")
cpp_quote("							 DWORD	dwNth) IPURE; \\")
cpp_quote("	STDMETHOD(BlockExists)(DWORD	dwType ) IPURE; \\")
cpp_quote("	STDMETHOD(ProtocolExists)(DWORD	dwProtocol ) IPURE; \\")
cpp_quote("	STDMETHOD(RemoveAllBlocks)() IPURE; \\")
cpp_quote("	STDMETHOD(QueryBlockList)(IEnumInfoBlock **ppBlockEnum) IPURE; \\")
cpp_quote("	STDMETHOD(GetInfo)(DWORD *pdwSize, int *pcBlocks) IPURE; \\")


#endif  // _MPRSNAP_IDL_
