Apple OS X Server User Manual


 
tContextData context = NULL;
dirStatus = dsGetDirNodeCount( gDirRef, &nodeCount );
printf( "Registered node count is: %lu\n", nodeCount );
if ( (dirStatus == eDSNoErr) && (nodeCount != 0) )
{
//Allocate a 32k buffer.
dataBuffer = dsDataBufferAllocate( gDirRef, 32 * 1024 );
if ( dataBuffer != NULL )
{
while ( (dirStatus == eDSNoErr) && (done == false) )
{
dirStatus = dsGetDirNodeList( gDirRef, dataBuffer, &bufferCount,
&context );
if ( dirStatus == eDSNoErr )
{
for ( index = 1; index <= bufferCount; index++ )
{
dirStatus = dsGetDirNodeName( gDirRef, dataBuffer,
index, &nodeName );
if ( dirStatus == eDSNoErr )
{
printf( "#%4ld ", index );
PrintNodeName( nodeName );
//Deallocate the data list containing the node
name.
dirStatus = dsDataListDeallocate( gDirRef, nodeName
);
free(nodeName);
}
else
{
printf("dsGetDirNodeName error = %ld\n", dirStatus
);
}
}
}
done = (context == NULL);
}
if (context != NULL)
{
dsReleaseContinueData( gDirRef, context );
}
dsDataBufferDeAllocate( gDirRef, dataBuffer );
dataBuffer = NULL;
}
}
} // ListNodes
void PrintNodeName ( tDataListPtr inNode ) {
char* pPath;
pPath = dsGetPathFromList( gDirRef, inNode, "/" );
printf( "%s\n", pPath );
if ( pPath != NULL )
{
free( pPath );
pPath = NULL;
}
26
Listing Registered Nodes
2007-01-08 | © 2007 Apple Inc. All Rights Reserved.
CHAPTER 2
Working with Nodes