Platform SDK: Exchange Server

Reading a View’s Row Restriction

The following steps are necessary to read in the view’s row restriction. The restriction’s data in the two streams comes immediately after the VCD structures. Therefore, the VCD structures must be read before the restriction.

  1. Declare a pointer to an SRestriction (presRoot) to retain the root level of the restriction. Set the pointer to NULL.
  2. Read the restriction’s main data structure into a temporary SRestriction (resT) by reading sizeof (SRestriction) bytes into this structure from the binary stream.
  3. Allocate sizeof (SRestriction) bytes for another SRestriction (pres) by either calling the MAPI function MAPIAllocateBuffer or MAPIAllocateMore, depending on whether presRoot has previously been allocated.
  4. Set a variable (ppres) to point to this block of memory.
  5. Set pres->rt to resT->rt and then do the following:
  6. Allocate a property value pointer: LPSPropValue * ppval.

Depending on the value for the restriction type (rt), process as follows:

switch (pres->rt)  

case RES_CONTENT:
ppval = &pres->res.resContent.lpProp 
//Read the property values from the streams.//
break;

case RES_PROPERTY:
ppval = &pres->res.resProperty.lpProp
//Read the property values from the streams.//
break;

case RES_SUBRESTRICTION:
ppres = &pres->res.resSub.lpRes;
*ppres = NULL;   
//Forces the following recursive call to allocate memory for ppres.//
//Call to step 2 to read the subrestriction.//
//Then, ppres should be passed in to point to the next restriction in the stream.// 
break;

case RES_NOT:
ppres = &pres->res.resNot.lpRes;
*ppres = NULL;
//Recursively call to step 2 to read the negated sub-restriction. //

case RES_AND:
  case RES_OR:
ppres = &pres->res.resAnd.lpRes
//Declare an unsigned long variable: ULONG cres//
cres = pres->res.resAnd.cRes  

// Remember the number of restrictions being AND'd or OR'd. Append ppres onto the end of presRoot by calling MAPIAllocateMore.//

presNext (LPSRestriction * presNext)
//Point to the next restriction.//

(pres->res.resAnd.lpRes)

presLast (LPSRestriction * presLast) 
//Point to the last restriction. //

(pres->res.resAnd.lpRes)

//For each AND or OR'd restriction, recursively call to step 2 to read the AND/OR clauses. //
//Then, ppresNext should be passed in to point to the next restriction in the stream.//

case RES_COMMENT:
//Read the property values from the stream into pres.//
pres->res.resComment.lpRes = NULL
//To force the recursive call below to allocate memory for pres. This pointer was saved but is no longer valid.//

pres->res.resComment.cValues = resT ->res.resComment.cValues
pres->res.resComment.lpRes = resT ->res.resComment.lpRes
pres->res.resComment.lpProp = resT->res.resComment.lpProp

//Recursively call to step 2 to read the sub-restriction. //

pres->res.resComment.lpRes 

//Then, ppresNext should be passed in to point to the next restriction in the stream.//

At the end of this algorithm, the restriction has been read completely.