You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
390 lines
8.9 KiB
390 lines
8.9 KiB
//---------------------------------------------------------------------------
|
|
//
|
|
// Microsoft Windows
|
|
// Copyright (C) Microsoft Corporation, 1992 - 1995
|
|
//
|
|
// File: cenumsch.cxx
|
|
//
|
|
// Contents: Windows NT 3.5 Schema Enumeration Code
|
|
//
|
|
// CNWCOMPATSchemaEnum::CNWCOMPATSchemaEnum()
|
|
// CNWCOMPATSchemaEnum::CNWCOMPATSchemaEnum
|
|
// CNWCOMPATSchemaEnum::EnumObjects
|
|
// CNWCOMPATSchemaEnum::EnumObjects
|
|
//
|
|
// History:
|
|
//----------------------------------------------------------------------------
|
|
#include "NWCOMPAT.hxx"
|
|
#pragma hdrstop
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// Function: CNWCOMPATSchemaEnum::Create
|
|
//
|
|
// Synopsis:
|
|
//
|
|
// Arguments: [pCollection]
|
|
// [ppEnumVariant]
|
|
//
|
|
// Returns: HRESULT
|
|
//
|
|
// Modifies:
|
|
//
|
|
// History: 01-30-95 yihsins Created.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
HRESULT
|
|
CNWCOMPATSchemaEnum::Create(
|
|
CNWCOMPATSchemaEnum FAR* FAR* ppenumvariant,
|
|
BSTR bstrADsPath,
|
|
BSTR bstrName,
|
|
VARIANT vFilter
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
CNWCOMPATSchemaEnum FAR* penumvariant = NULL;
|
|
|
|
*ppenumvariant = NULL;
|
|
|
|
penumvariant = new CNWCOMPATSchemaEnum();
|
|
if (!penumvariant)
|
|
{
|
|
hr = E_OUTOFMEMORY;
|
|
BAIL_ON_FAILURE(hr);
|
|
}
|
|
|
|
hr = ADsAllocString( bstrADsPath, &penumvariant->_bstrADsPath);
|
|
BAIL_ON_FAILURE(hr);
|
|
|
|
hr = ADsAllocString( bstrName, &penumvariant->_bstrName);
|
|
BAIL_ON_FAILURE(hr);
|
|
|
|
hr = ObjectTypeList::CreateObjectTypeList(
|
|
vFilter,
|
|
&penumvariant->_pObjList );
|
|
BAIL_ON_FAILURE(hr);
|
|
|
|
*ppenumvariant = penumvariant;
|
|
|
|
RRETURN(hr);
|
|
|
|
error:
|
|
|
|
delete penumvariant;
|
|
|
|
RRETURN_EXP_IF_ERR(hr);
|
|
}
|
|
|
|
CNWCOMPATSchemaEnum::CNWCOMPATSchemaEnum()
|
|
: _bstrADsPath( NULL ),
|
|
_bstrName( NULL ),
|
|
_pObjList( NULL ),
|
|
_dwCurrentEntry( 0 ),
|
|
_dwPropCurrentEntry( 0 )
|
|
{
|
|
}
|
|
|
|
CNWCOMPATSchemaEnum::~CNWCOMPATSchemaEnum()
|
|
{
|
|
ADsFreeString( _bstrName );
|
|
ADsFreeString( _bstrADsPath );
|
|
|
|
if ( _pObjList != NULL )
|
|
{
|
|
delete _pObjList;
|
|
_pObjList = NULL;
|
|
}
|
|
}
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// Function: CNWCOMPATSchemaEnum::Next
|
|
//
|
|
// Synopsis: Returns cElements number of requested NetOle objects in the
|
|
// array supplied in pvar.
|
|
//
|
|
// Arguments: [cElements] -- The number of elements requested by client
|
|
// [pvar] -- ptr to array of VARIANTs to for return objects
|
|
// [pcElementFetched] -- if non-NULL, then number of elements
|
|
// -- actually returned is placed here
|
|
//
|
|
// Returns: HRESULT -- S_OK if number of elements requested are returned
|
|
// -- S_FALSE if number of elements is < requested
|
|
//
|
|
// Modifies:
|
|
//
|
|
// History: 11-3-95 yihsins Created.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
STDMETHODIMP
|
|
CNWCOMPATSchemaEnum::Next(
|
|
ULONG cElements,
|
|
VARIANT FAR* pvar,
|
|
ULONG FAR* pcElementFetched
|
|
)
|
|
{
|
|
ULONG cElementFetched = 0;
|
|
HRESULT hr = S_OK;
|
|
|
|
hr = EnumObjects( cElements,
|
|
pvar,
|
|
&cElementFetched );
|
|
|
|
if ( pcElementFetched )
|
|
*pcElementFetched = cElementFetched;
|
|
|
|
RRETURN_EXP_IF_ERR(hr);
|
|
}
|
|
|
|
HRESULT
|
|
CNWCOMPATSchemaEnum::EnumObjects(
|
|
DWORD ObjectType,
|
|
ULONG cElements,
|
|
VARIANT FAR * pvar,
|
|
ULONG FAR * pcElementFetched
|
|
)
|
|
{
|
|
switch (ObjectType)
|
|
{
|
|
case NWCOMPAT_CLASS_ID:
|
|
RRETURN (EnumClasses(cElements, pvar, pcElementFetched));
|
|
|
|
|
|
case NWCOMPAT_PROPERTY_ID:
|
|
RRETURN (EnumProperties(cElements, pvar, pcElementFetched));
|
|
|
|
case NWCOMPAT_SYNTAX_ID:
|
|
RRETURN(EnumSyntaxObjects(cElements, pvar, pcElementFetched));
|
|
|
|
default:
|
|
RRETURN(S_FALSE);
|
|
}
|
|
}
|
|
|
|
HRESULT
|
|
CNWCOMPATSchemaEnum::EnumObjects(
|
|
ULONG cElements,
|
|
VARIANT FAR* pvar,
|
|
ULONG FAR* pcElementFetched
|
|
)
|
|
{
|
|
DWORD i;
|
|
ULONG cRequested = 0;
|
|
ULONG cFetchedByPath = 0;
|
|
ULONG cTotalFetched = 0;
|
|
VARIANT FAR* pPathvar = pvar;
|
|
HRESULT hr = S_OK;
|
|
DWORD ObjectType;
|
|
|
|
for (i = 0; i < cElements; i++)
|
|
VariantInit(&pvar[i]);
|
|
|
|
cRequested = cElements;
|
|
|
|
while ( SUCCEEDED( _pObjList->GetCurrentObject(&ObjectType))
|
|
&& ((hr = EnumObjects( ObjectType,
|
|
cRequested,
|
|
pPathvar,
|
|
&cFetchedByPath)) == S_FALSE )
|
|
)
|
|
{
|
|
pPathvar += cFetchedByPath;
|
|
cRequested -= cFetchedByPath;
|
|
cTotalFetched += cFetchedByPath;
|
|
|
|
cFetchedByPath = 0;
|
|
|
|
if ( FAILED(_pObjList->Next()) )
|
|
{
|
|
if ( pcElementFetched )
|
|
*pcElementFetched = cTotalFetched;
|
|
RRETURN(S_FALSE);
|
|
}
|
|
|
|
_dwCurrentEntry = 0;
|
|
}
|
|
|
|
if ( pcElementFetched )
|
|
*pcElementFetched = cTotalFetched + cFetchedByPath;
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
HRESULT
|
|
CNWCOMPATSchemaEnum::EnumClasses(
|
|
ULONG cElements,
|
|
VARIANT FAR* pvar,
|
|
ULONG FAR* pcElementFetched
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
DWORD i = 0;
|
|
IDispatch *pDispatch = NULL;
|
|
|
|
while ( i < cElements )
|
|
{
|
|
hr = GetClassObject(&pDispatch);
|
|
if ( hr == S_FALSE )
|
|
break;
|
|
|
|
VariantInit( &pvar[i] );
|
|
pvar[i].vt = VT_DISPATCH;
|
|
pvar[i].pdispVal = pDispatch;
|
|
(*pcElementFetched)++;
|
|
i++;
|
|
}
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
HRESULT
|
|
CNWCOMPATSchemaEnum::GetClassObject(
|
|
IDispatch ** ppDispatch
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
|
|
//
|
|
// Now send back the current ovbject
|
|
//
|
|
if ( _dwCurrentEntry >= g_cNWCOMPATClasses )
|
|
goto error;
|
|
|
|
hr = CNWCOMPATClass::CreateClass(
|
|
_bstrADsPath,
|
|
&g_aNWCOMPATClasses[_dwCurrentEntry],
|
|
ADS_OBJECT_BOUND,
|
|
IID_IDispatch,
|
|
(void **)ppDispatch
|
|
);
|
|
BAIL_ON_FAILURE(hr);
|
|
|
|
_dwCurrentEntry++;
|
|
|
|
RRETURN(S_OK);
|
|
|
|
error:
|
|
|
|
*ppDispatch = NULL;
|
|
RRETURN(S_FALSE);
|
|
}
|
|
|
|
HRESULT
|
|
CNWCOMPATSchemaEnum::EnumSyntaxObjects(
|
|
ULONG cElements,
|
|
VARIANT FAR* pvar,
|
|
ULONG FAR* pcElementFetched
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
DWORD i = 0;
|
|
IDispatch *pDispatch = NULL;
|
|
|
|
while ( i < cElements )
|
|
{
|
|
hr = GetSyntaxObject(&pDispatch);
|
|
if ( hr == S_FALSE )
|
|
break;
|
|
|
|
VariantInit( &pvar[i] );
|
|
pvar[i].vt = VT_DISPATCH;
|
|
pvar[i].pdispVal = pDispatch;
|
|
(*pcElementFetched)++;
|
|
i++;
|
|
}
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
HRESULT
|
|
CNWCOMPATSchemaEnum::GetSyntaxObject(
|
|
IDispatch ** ppDispatch
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
|
|
//
|
|
// Now send back the current object
|
|
//
|
|
if ( _dwCurrentEntry >= g_cNWCOMPATSyntax )
|
|
goto error;
|
|
|
|
hr = CNWCOMPATSyntax::CreateSyntax(
|
|
_bstrADsPath,
|
|
&g_aNWCOMPATSyntax[_dwCurrentEntry],
|
|
ADS_OBJECT_BOUND,
|
|
IID_IDispatch,
|
|
(void **)ppDispatch
|
|
);
|
|
BAIL_ON_FAILURE(hr);
|
|
|
|
_dwCurrentEntry++;
|
|
|
|
RRETURN(S_OK);
|
|
|
|
error:
|
|
|
|
*ppDispatch = NULL;
|
|
RRETURN(S_FALSE);
|
|
}
|
|
|
|
|
|
HRESULT
|
|
CNWCOMPATSchemaEnum::EnumProperties(
|
|
ULONG cElements,
|
|
VARIANT FAR* pvar,
|
|
ULONG FAR* pcElementFetched
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
DWORD i = 0;
|
|
IDispatch *pDispatch = NULL;
|
|
|
|
while ( i < cElements )
|
|
{
|
|
hr = GetPropertyObject(&pDispatch);
|
|
if ( hr == S_FALSE )
|
|
break;
|
|
|
|
VariantInit( &pvar[i] );
|
|
pvar[i].vt = VT_DISPATCH;
|
|
pvar[i].pdispVal = pDispatch;
|
|
(*pcElementFetched)++;
|
|
i++;
|
|
}
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
HRESULT
|
|
CNWCOMPATSchemaEnum::GetPropertyObject(
|
|
IDispatch ** ppDispatch
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
|
|
//
|
|
// Now send back the current ovbject
|
|
//
|
|
if ( _dwPropCurrentEntry >= g_cNWCOMPATProperties )
|
|
goto error;
|
|
|
|
hr = CNWCOMPATProperty::CreateProperty(
|
|
_bstrADsPath,
|
|
&g_aNWCOMPATProperties[_dwPropCurrentEntry],
|
|
ADS_OBJECT_BOUND,
|
|
IID_IDispatch,
|
|
(void **)ppDispatch
|
|
);
|
|
BAIL_ON_FAILURE(hr);
|
|
|
|
_dwPropCurrentEntry++;
|
|
|
|
RRETURN(S_OK);
|
|
|
|
error:
|
|
|
|
*ppDispatch = NULL;
|
|
RRETURN(S_FALSE);
|
|
}
|
|
|