The procedure for working with an item is the same, regardless of the item type. The procedure is as follows:
To create items for you application, you need to include the following header files:
The kernel creates and keeps track of items in system memory. When the kernel creates an item, it creates a node for that item using the ItemNode data structure:
The fields in this data structure define the status of the item and give information about the item. User tasks can't change their values, but they can look at them for information such as the version and revision numbers of an item (useful for items such as folios or devices).
typedef struct ItemNode
{
struct ItemNode *n_Next; /*pointer to next itemnode in */
/* list */
struct ItemNode *n_Prev; /*pointer to previous itemnode in
/* list */
uint8 n_SubsysType; /* what folio manages this node */
uint8 n_Type; /* what type of node for the folio */
uint8 n_Priority; /* queueing priority */
uint8 n_Flags; /* misc flags, see below */
int32 n_Size; /* total size of node including hdr */
char *n_Name; /* ptr to null terminated string or NULL*/
uint8 n_Version; /* version of of this itemnode */
uint8 n_Revision; /* revision of this itemnode */
uint8 n_FolioFlags; /* flags for this item's folio */
uint8 n_ItemFlags; /* additional system item flags */
Item n_Item; /* ItemNumber for this data structure */
Item n_Owner; /* creator, present owner, disposer */
void *n_ReservedP; /* Reserved pointer */
} ItemNode, *ItemNodeP;
LookupItem()
, described later, returns a pointer to the ItemNode structure for a specific item.
The difference between item creation and item opening is important: a created item is owned by the creating task, which can delete the item at any time. A created item is automatically deleted if the owning task quits without deleting it. On the other hand, an opened item is owned by the original creator and is shared among tasks. When a task opens the item, the item is loaded into memory and the kernel registers the opening task as a user. When another task opens the same item, the kernel registers that task as well.