C H A P T E R 3
Working with Records
When the GetRecordList routine returns, the sample code in Listing
Listing
void main ( )
{
long dirStatus = eDSNoErr; tDirNodeReference nodeRef = NULL; dirStatus = dsOpenDirService( &gDirRef ); if ( dirStatus == eDSNoErr )
{
dirStatus = MyOpenDirNode( &nodeRef ); if ( dirStatus == eDSNoErr )
{
GetRecordList(nodeRef); dsCloseDirNode( nodeRef );
}
}
if ( gDirRef != NULL )
{
dirStatus = dsCloseDirService( gDirRef );
}
}
long GetRecordList ( const tDirNodeReference nodeRef )
{
unsigned long i = 0; unsigned long j = 0; unsigned long k = 0; long dirStatus = eDSNoErr;
unsigned long recCount = 0; // Get all records. tDataBufferPtr dataBuffer = NULL; tContextData context = NULL; tAttributeListRef attrListRef = NULL; tAttributeValueListRef valueRef = NULL; tRecordEntry *pRecEntry = NULL; tAttributeEntry *pAttrEntry = NULL; tAttributeValueEntry *pValueEntry = NULL; tDataList recNames;
tDataList recTypes; tDataList attrTypes;
dataBuffer = dsDataBufferAllocate( gDirRef, 2 * 1024 ); // allocate a 2k buffer
if ( dataBuffer != NULL )
{
//For readability, the sample code does not check dirStatus after
//each call, but
//your code should.
dirStatus = dsBuildListFromStringsAlloc ( gDirRef, &recNames, kDSRecordsAll, NULL );
dirStatus = dsBuildListFromStringsAlloc ( gDirRef, &recTypes, kDSStdRecordTypeUsers, NULL );
dirStatus = dsBuildListFromStringsAlloc ( gDirRef, &attrTypes, kDSAttributesAll, NULL );
do
{