Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Networking With Open Transport / Part 2 - Open Transport Reference
Chapter 27 - Utilities Reference / Constants and Data Types


The Get Link Object Macro

Open Transport defines a macro (OTGetLinkObject) that you can use to easily cast back to the original object from a pointer to either a LIFO or a FIFO linked list structure.

DataType* OTGetLinkObject(OTLink* linkPtr, 
                                         DataType structName, 
                     NameOfLinkPtrField fieldName)
#define OTGetLinkObject(link, struc, field)
\
((struc*)((char*)(link) - offsetof(struc, field)))
PARAMETERS
linkPtr
A pointer to the OTLink structure from which you wish to cast back.
structName
The name of the structure containing the OTLink structure.
fieldName
The OTLink field in the above structure.
function result
The macro results in a pointer to the appropriate data type by offsetting the linkPtr appropriately and casting the result.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
15 JAN 1998