Kernel

Version:4.2
Status:Stable
Date:January 2005
Author:Rocklyte Systems
Copyright:  Rocklyte Systems (c) 1996-2005. All rights reserved.
Short:  The object kernel interface controls and maintains the system.



Description

The Pandora object kernel is a function library that provides the features expected of a traditional kernel, while also providing a fully featured object oriented programming interface. This makes it a unique hybrid that allows for better portability and services. Support for the management of memory and resources are all present, plus you will also find extensive support for class management and field and object handling.

The portability of the object kernel has been ensured by keeping the functions as generalised as possible. Depending on the intended platform, the object kernel can be developed to run independently (i.e. as a real kernel) or it can leech functionality from a dedicated kernel (as is the case with the Linux version). It is vital that when running on a host environment that the temptation to use the host's functions are avoided, or you will lose compatibility with other computer systems running the Pandora Engine.

For summarised information about how the system works, please refer to the General Documentation which covers all aspects of the design and object orientation in the system. From here on in the subject matter is very technical, so if you do not have any background knowledge of the Pandora Engine, please read the beginner manuals before continuing.

Function Index
AccessMemory  Grants access to public memory blocks.
AccessObject  Grants exclusive access to public objects.
AccessSemaphore  Grants access to semaphores.
Action  This function is responsible for executing action routines.
ActionList  Returns a pointer to the kernel's most current action table.
ActionMsg  Provides a mechanism for sending actions to objects that belong to other tasks.
ActionTags  This is a tag-based version of the Action() function.
AllocMemory  Allocates system memory blocks.
AllocSemaphore  Allocates a new public semaphore.
AllocateClassID  Generates dynamic class ID's.
AllocateID  Generates unique ID's for various purposes within the Pandora Engine.
CheckAction  Checks objects to see whether or not they support certain actions.
CheckMemoryExists  Checks if a memory block still exists.
CheckObjectExists  Checks if a particular object is still available in the system.
ClearMemory  Clears large blocks of memory very quickly.
CloneMemory  Makes an exact duplicate of a memory block.
CreateObject  Provides a fast way of creating and initialising new objects.
CurrentContext  Returns a pointer to the object that has the current context.
CurrentTaskID  Returns the object ID of the current Task.
DPrintF  Sends formatted strings to the debugger.
DebugState  Turns debug messages on and off.
DeregisterFD  Removes previously register FD's from the system.
FastFindObject  Searches for objects by name.
FindClass  Returns all class objects for a given class ID.
FindObject  Searches for objects by name and class.
FindPrivateObject  Searches for objects by name.
Forbid  Locks other tasks out of the shared memory and object areas.
FreeMemory  Frees private memory blocks allocated from AllocMemory().
FreeMemoryID  Frees public memory blocks allocated from AllocMemory().
FreeSemaphore  Frees an allocated semaphore.
GetClassID  Returns the class ID of an object.
GetField  Retrieves single field values from objects.
GetFieldVariable  Retrieves field values by converting them into strings.
GetFields  Retrieves multiple field values in a single function call.
GetMessage  Reads messages from message queues.
GetName  Retrieves object names.
GetOwnerID  Returns the unique ID of an object's owner.
GetResource  Retrieves miscellaneous resource identifiers.
ListChildren  Returns a list of all children belonging to an object.
ListMemory  Returns a list of public or private memory blocks that have been allocated in the system.
ListObjects  Returns a list of objects that match specific parameters.
ManageAction  Allows modules to intercept and manage action calls.
MemoryIDInfo  Returns information on memory ID's.
MemoryPtrInfo  Returns information on memory addresses.
NewObject  Creates new objects.
NotifySubscribers  Used to send notification messages to action subscribers.
ObtainMethod  Returns a direct pointer to an object's method code.
Permit  Releases a lock obtained from Forbid().
ProcessMessages  Processes system messages that are queued in the Task's message buffer.
RandomNumber  Generates random numbers.
ReallocMemory  Reallocates memory blocks.
RegisterFD  Registers a file descriptor for monitoring when the task is asleep.
ReleaseMemory  Releases memory blocks from access locks.
ReleaseObject  Releases objects from exclusive use.
ReleaseSemaphore  Releases a locked semaphore.
ResolveClassName  Used to resolve unique class ID's from class names.
ResolveFields  Converts field names into globally supported Field ID's.
ScanMessages  Scans a message queue for multiple occurances of a message type.
SelfDestruct  Destroys the task and frees its resources.
SendError  Sends basic error messages to the active debugger.
SendMessage  Send messages to message queues.
SetContext  Tells the system which object currently has resource control.
SetField  Used to set field values of objects.
SetFieldVariable  Sets any field using an abstract string value.
SetFields  Sets the values of multiple object fields.
SetName  Sets the name of an object.
SetOwner  Changes object ownership dynamically.
SetResource  Sets miscellaneous resource identifiers.
StepBack  Steps back the debugging tree.
StrCompare  Compares strings to see if they are identical.
SubscribeAction  Listens for actions that may be performed on an object.
SubscribeActionTags  Listens for actions that may be performed on an object.
SubscribeChannel  Listens to an object's incoming data port.
SubscribeField  Listens to field read/write activity in an object.
SubscribeTimer  Subscribes an object to the system's timer service.
SystemTime  Returns the current system time, in milliseconds.
TotalChildren  Calculates the total number of children belonging to an object.
UnsubscribeAction  Removes action subscriptions from external objects.
UnsubscribeChannel  Removes data channel subscriptions from an external object.
UnsubscribeField  Removes field-based subscriptions from an object.
UnsubscribeTimer  Unsubscribes an object from the system's timer service.
UpdateMessage  Updates the data of any message that is queued.
WaitTime  Waits for a specified amount of seconds and/or microseconds.
WatchPublicMemory  Monitors public memory blocks for foreign access.

 

Function:AccessMemory()
Short:Grants access to public memory blocks.
Synopsis:ERROR AccessMemory(MEMORYID MemoryID, LONG Flags, APTR *Address)
Arguments:
MemoryID  The ID of the memory block that you want to access.
Flags  Set to MEM_READ, MEM_WRITE or MEM_READWRITE according to your requirements.
Address  Must point to an APTR variable that will store the resolved address.

In order to gain access to a block of public memory, the AccessMemory() function must be called to page the block into your task's memory space. If the MemoryID is valid and the block is available, a valid address pointer. will be returned that you may use for direct read/write operations. For your convenience, this function may also be used to resolve the memory addresses of private memory block IDs.

Public memory blocks should never be locked for long periods of time. You must match all locks that you make with calls to ReleaseMemory() inside a reasonable time frame. Always keep in mind that other tasks may be waiting to gain access to memory blocks that you lock.

Please note that the address that is returned is specific to your task only and cannot be passed to any other task in the system.

Result
ERR_Okay  The function executed successfully.
ERR_Args  Invalid arguments were passed to the function.
ERR_LockFailed  An internal lock failure has occurred.
ERR_DeadLock  Access cannot be granted because another task has locked the block and is currently sleeping on a response from your task.
ERR_TimeOut  While waiting for the memory block to become accessible, sufficient time elapsed for a time-out to occur.
ERR_SystemCorrupt  The task has lost its process ID.
ERR_MemoryDoesNotExist  The MemoryID that you supplied does not refer to an existing memory block.
ERR_MarkedForDeletion  The memory block cannot be accessed because it has been marked for deletion.
ERR_SystemLockedUp  Access to the global memory pool was denied.

Function:AccessObject()
Short:Grants exclusive access to public objects.
Synopsis:ERROR AccessObject(LONG ObjectID, LONG Milliseconds, OBJECTPTR *Result)
Arguments:
ObjectID   The unique ID of the object that you want exclusive access to. If you only know the name of the object, use FindObject() to acquire the correct object ID.
Milliseconds   The amount of milliseconds you are prepared to wait before your attempt will timeout. The maximum wait is 60 seconds (60,000 milliseconds). Use a value of 0 if you do not want to wait.
Result   Must refer to an OBJECTPTR variable that will store the resulting object address.

This function is provided so that tasks can gain temporary exclusive access to public objects. It is specially designed to prevent more than one task from having access to a specific object at any given moment. The AccessObject() function also works on private objects for reasons of consistency.

Once you call this function, it will immediately attempt to page the object's address space into your task. If it cannot do this, the function will wait until the object becomes available. This must occur within the amount of time specified by the Milliseconds argument. If the time runs out, the function will return with an ERR_TimeOut error code. If successful, ERR_Okay will be returned and you will have exclusive access to the object through the address pointed to in the Result variable. Once you are done with the object, call ReleaseObject() so that other tasks can access it.

If this function fails, the Result variable will be automatically set to a NULL pointer on return.

Result
ERR_Okay  Exclusive access has been granted.
ERR_Args  Invalid arguments were specified.
ERR_MarkedForDeletion  The object that you want to access is marked for deletion.
ERR_MissingClass  The class that is associated with the object is mysteriously unavailable.
ERR_NoMatchingObject  The supplied ObjectID does not match any known object in the system.

Function:AccessSemaphore()
Short:Grants access to semaphores.
Synopsis:ERROR AccessSemaphore(LONG SemaphoreID, LONG TimeOut, LONG Flags)
Arguments:
SemaphoreID  The ID of an allocated semaphore.
TimeOut  The total number of microseconds to wait before timing out.
Flags  Optional flags.

The AccessSemaphore() function will give your task access to a semaphore once it becomes available. If the semaphore is available immediately then the function will return instantly. If other processes have blocked the semaphore through their usage, your task will be put to sleep for up to the time specified in the Timeout parameter. If you do not specify a Timeout, then the function will return immediately with an ERR_Timeout error.

Each time you call AccessSemaphore(), the system will try to 'block' the semaphore by default, which means you get exclusive access to the resource represented by the semaphore. If you only need non-blocking access to the semaphore, you must use the SMF_NONBLOCKING flag. In this mode, the system will decrement the semaphore counter by 1 and return. If the semaphore counter reaches a value of zero then the function will wait until one of the accessing processes releases its hold on the semaphore.

You must match each call to AccessSemaphore() with a call to the ReleaseSemaphore() function.

Result
ERR_Okay  Access has been granted to the semaphore.
ERR_Args  A valid SemaphoreID was not specified.
ERR_Timeout  Your task was put to sleep and the timeout was met before the semaphore became available.
ERR_SystemCorrupt  The internal semaphore management array is corrupt.
ERR_Forbid  A call to the Forbid() function failed.
ERR_ArrayFull  There are too processes waiting on this semaphore for you to be put on the queue.
ERR_DeadLock  Your process cannot be put to sleep because it would cause a system deadlock.

Function:Action()
Short:This function is responsible for executing action routines.
Synopsis:ERROR Action(ACTIONID ActionID, OBJECTPTR Object, APTR Parameters)
Arguments:
ActionID  An action or method ID must be specified here (e.g. AC_Query). Action ID's are obtained from the "system/actioncodes.h" include file.
Object  A pointer to the object that is going to perform the action.
Parameters  If the action or method is documented as taking parameters, point to the relevant parameter structure here. Pre-defined parameter structures are obtained from the "system/actions.h" include file.

This function is the key entry point for executing actions and method routines. An action is a predefined function call that can be called on any object, while a method is a function call that is specific to a particular object type. You can find a complete list of available actions and their associated details in the Action List document. If an object supports methods, they will be listed in the object's class document.

Here are two examples that demonstrate how to make an action call. The first performs an initialisation, which does not require any additional arguments. The second performs a move operation, which requires three additional arguments to be passed to the Action() function:

   1. Action(AC_Init, Picture, NULL);

   3. struct acMove move;
      move.XChange = 30;
      move.YChange = 15;
      move.ZChange = 0;
      Action(AC_Move, Window, &move);

If the target object does not support the action code that you have specified, an error code of ERR_NoSupport will be returned. If you need to test an object to see if it supports a particular action, use the CheckAction() function.

If you need to send an action to an object that does not belong to your task space, use the ActionMsg() function. If you're in a situation where you only have an object ID and are unsure as to whether or not the object is in your task space, use ActionMsg() anyway as it will divert to the Action() function if the object is local.

If you are writing a class and need to know how to add support for a particular action, look it up in the Action Support Guide.

Result
ERR_Okay  The function executed successfully.
ERR_Args  Incorrect arguments passed to function (missing ActionID or Object).
ERR_NoAction  The action is not supported by the object's supporting class.
ERR_ObjectCorrupt  The object that was received is badly corrupted in a critical area.

Function:ActionList()
Short:Returns a pointer to the kernel's most current action table.
Synopsis:struct ActionTable * ActionList(void)

If you need a dynamic list of all the actions supported by the object kernel, including information on ID's, names, arguments and structure sizes, use the ActionList() function. This function will return an array that is arranged into a look-up table, sorted by action ID. The ActionTable structure is defined as follows:

   struct ActionTable {
      STRING Name;
      struct FunctionField *Args;
      LONG Size;
   };

The Name field specifies the name of the action. The Args field refers to the action's argument definition structure, which lists the argument names and their relevant types. This is matched by the Size field, which indicates the byte-size of the action's related argument structure. If the action does not support arguments, the Args and Size fields will be set to NULL. Here are two argument definition examples:

   struct FunctionField argsCopyData[] = {
      { "Destination", ARG_LONG  },
      { NULL, NULL }
   };

   struct FunctionField argsResize[] = {
      { "Width",  ARG_DOUBLE },
      { "Height", ARG_DOUBLE },
      { "Depth",  ARG_DOUBLE },
      { NULL, NULL }
   };

The argument types that can be set by actions are limited to those listed in the following table:

TypeDescription
ARG_LONGA 32-bit integer value ranging from -2,147,483,647 to 2,147,483,648.
ARG_LARGEA 64-bit integer value.
ARG_PTRA standard 32-bit address space pointer.
ARG_STRINGA 32-bit address space pointer that refers to a null-terminated string.
ARG_DOUBLEA 64-bit floating point value.
ARG_OBJECTThis flag is sometimes set in conjunction with the ARG_LONG type. It indicates that the argument refers to an object ID.
ARG_PTRSIZEThis argument type can only be used if it follows an ARG_PTR type, and if the argument itself is intended to reflect the size of the buffer referred to by the previous ARG_PTR argument.
ARG_RESULTThis special flag is set in conjunction with the other data-based argument types. Example: If the developer is required to supply a pointer to a LONG field in which the function will store a result, the correct argument definition will be ARG_RESULT|ARG_LONG|ARG_PTR. To make the definition of these argument types easier, ARG_PTRRESULT, ARG_LONGRESULT and ARG_FLOATRESULT macros are also available for use.

 

Result
This function returns a pointer to the object kernel's action table (struct ActionTable *). If a failure occurs, NULL will be returned.

Please note that the first entry in the ActionTable list has all fields driven to NULL, because valid action ID's start from one, not zero. The final action in the list is also terminated with NULL fields in order to indicate an end to the list. Knowing this can be helpful if you wish to search the list or calculate the total number of actions supported by the kernel.


Function:ActionMsg()
Short:Provides a mechanism for sending actions to objects that belong to other tasks.
Synopsis:ERROR ActionMsg(LONG ActionID, OBJECTID Object, APTR Args)
Arguments:
ActionID  The ID of the action that you want to execute.
ObjectID  The ID of the object to receive the action.
Args  The argument structure related to the specific action that you are calling.

ActionMsg() provides the necessary functionality to execute an action on any shared object that does not reside within your task space. The function works first by testing the object to see if it it belongs to your task space, or someone else's task space. If the object is yours then the action will be called immediately, as if Action() was called under normal circumstances. Otherwise, the action call will be sent to the object's owner as a message and the function will immediately return to your program.

Once an action has been sent, you need to work on the assumption that its owner will respond to the message and execute the action. If the Task does not respond, then likely causes may include a task crash, buggy programming or an extended busy period.

There is one exception to the rule: In cases where an action or method returns a result (e.g. the Read and Write actions do this), the ActionMsg() function will actually ask the other Task to send back the result information. This causes the function to sleep for a short period of time until it receives the result information from the other Task. By doing this, the normal behaviour that would be expected of an action that returns results is preserved.

Result
ERR_Okay  The message was successfully passed to the object (this is not indicative of whether or not the object was actually successful in executing the action).
ERR_Args  A NULL value was detected in the ActionID or ObjectID arguments.
ERR_NoMatchingObject  There is no object for the given ObjectID.

Function:ActionTags()
Short:This is a tag-based version of the Action() function.
Synopsis:ERROR ActionTags(ACTIONID ActionID, OBJECTPTR Object, Tags...)
Arguments:
ActionID  The ID of the action or method that you want to execute.
Object  The object that is to receive the action.
Tags  Each argument that would normally be specified in the action structure must be listed as tags, in the same order as the fields in the original action structure. There is no need to terminate the tag-list.

This function is identical to the Action() function in every respect, except that it allows you to send action arguments as tags rather than in a structure. Here are a few examples:

   ActionTags(AC_Resize, Object, 100, 300, 200);
   ActionTags(MT_Rename, Object, "athene:documents.txt");

Whether you choose to use ActionTags() or Action() to make your action calls is a matter of personal preference. However, be aware that ActionTags() does not support actions or methods that return results in the argument structure - e.g. Read and Write actions are not supported.

Result
ERR_Okay  The action was executed successfully.
ERR_Args  Invalid arguments were supplied to the function.
ERR_IllegalMethodID  The ActionID is not a supported method of the target object.

Function:AllocMemory()
Short:Allocates system memory blocks.
Synopsis:ERROR AllocMemory(LONG Size, LONG Flags, APTR *Address, MEMORYID *MemoryID)
Arguments:
Size  The size of the memory block.
Flags  Flag specifications - set to NULL to allocate a standard data memory block.
Address  Set this argument to refer to an APTR type to store an address reference to the allocated memory block.
MemoryID  Set this argument to refer to a MEMORYID type to store a unique ID reference to the allocated memory block. This is compulsory when allocating public memory blocks.

The AllocMemory() function is used to allocate blocks of memory from the system memory pool. To allocate a new block you need to specify its Size, allocation Flags and Address and/or MemoryID arguments to store references to the allocation. Here is an example:

   APTR Address;

   if (AllocMemory(1000, MEM_DATA, &Address, NULL) IS ERR_Okay) {
      ...
      FreeMemory(Address);
   }

A number of flag definitions are available that affect the memory allocation process. They are:

FlagDescription
MEM_DATAThe default type, MEM_DATA, is used to indicate a standard memory allocation from system RAM.
MEM_PUBLICPublic memory can be allocated by specifying this flag. Public memory blocks are accessible by all tasks, but access can only be gained by knowing the unique memory ID and utilising the AccessMemory() function.
MEM_CODEIf the memory will contain executable program code, set this flag.
MEM_UNTRACKED  Allocating an untracked memory block will prevent the memory block from being tracked back to the object holding the current context.
MEM_STRINGThis flag is used to aid debugging - set it if the memory block will be used to store printable string data.
MEM_NOBLOCKING  If this flag is set against a public memory block then the access blocking mechanism will be permanently turned off for all accesses to that particular memory block. This means that multiple tasks can have full read/write access to the memory block at once regardless of the flags passed to AccessMemory().
MEM_NOCLEARIf this flag is set, the memory block's data will not be cleared by the AllocMemory() function.
MEM_FIXEDThis flag can be applied to public memory blocks that need to be mapped to a fixed address that is common to all tasks. For instance, if the system locks the memory block to address 0x56084000 for your task, then all other tasks that map the memory block will also see it at that address. This flag is typically used for supporting absolute code execution.
MEM_CALLERThis flag is useable only in routines that support a class method. It forces the memory allocation to be resourced against the object that made the method call. This is particularly important in methods that return memory blocks that do not form a part of the object itself.
MEM_TASKTells the allocation function to track the memory block to the current Task, as opposed to the current object.
MEM_RESERVEDThis special flag is used to allocate shared memory blocks that require reserved ID numbers. When using the MEM_RESERVED flag, you are required to set the longword pointed to by the MemoryID argument to the ID that you wish to reserve. If that memory ID is already taken, the AllocMemory() call will fail.

You will notice that you have the option of receiving the memory allocation as an address pointer and/or as a unique memory ID. When allocating private memory, you can generally just accept an address result and drive the MemoryID argument to NULL. However when allocating public memory, you should always retrieve the MemoryID, and optionally the Address pointer if you need immediate access to the block.

If the block is allocated as private and you retrieve both the MemoryID and Address pointer, or if the allocation is public and you choose to retrieve the Address pointer, an internal call will be made to AccessMemory() to lock the memory block and resolve its address. This means that before freeing the memory block, you must make a call to the ReleaseMemory() function to remove the lock, or it will remain in memory till your Task is terminated.

Memory that is allocated through AllocMemory() is automatically cleared with zero-byte values. When allocating large blocks it may be wise to turn off this feature - you can do this by setting the MEM_NOCLEAR flag.

Result
ERR_Okay  The memory block was allocated successfully.
ERR_Args  Incorrect arguments were specified (no Size, or no Address and no MemoryID).
ERR_Failed  The block could not be allocated due to insufficient memory space.
ERR_ArrayFull  Although memory space for the block was available, all available memory records are in use.
ERR_LockFailed  The function failed to gain access to the public memory control semaphore.
ERR_SystemCorrupt  The internal tables that manage memory allocations are corrupt.
ERR_AccessMemory  The block was allocated but access to it was not granted, causing failure.
ERR_ResourceExists  This error is returned if MEM_RESERVED was used and the memory block ID was found to already exist.

Function:AllocSemaphore()
Short:Allocates a new public semaphore.
Synopsis:ERROR AllocSemaphore(STRING Name, LONG Value, LONG Flags, LONG *Semaphore)
Arguments:
Name  The name of the semaphore (up to 12 characters, case-sensitive) that you want to create or find. This argument is optional.
Value  The starting value of the semaphore can be specified here. The minimum starting value is 1, for a simple blocking semaphore.
Flags  Special flags, currently SMF_EXISTS is supported.
Semaphore  A reference to the semaphore will be returned through this pointer.

The AllocSemaphore() function is used to create new semaphores and join existing ones. To create a simple semaphore for private usage, you only need to provide this function with a return value in the Semaphore parameter. If you want to share a semaphore with other processes, you need to give it a unique name limited to 15 characters. The Value argument is optional and only needs to be used if you need more complex signalling for your program.

Semaphores are most commonly used to control access to shared resources, typically in shared memory areas. For instance, if you create a shared memory area for read/write operations between tasks, you need a control system to prevent the tasks from writing to the memory at the same time (allowing multiple read access is usually non-harmful and quite convenient). Using a semaphore is perfect for controlling this type of situation.

For a simple blocking semaphore, you should set a value of 1 in the Value parameter. If you want to allow multiple processes to read from the resource then you should set the Value much higher - 100 or more. In this mode, there are two ways for processes to access the semaphore - blocking and non-blocking mode. Either type of access is achieved through the AccessSemaphore() function. Blocking mode is the default and will grant you full access to the resource if it succeeds. Non-blocking access grants you limited access to the resource - typically considered 'read only' access. Multiple processes can have non-blocking access at the same time, but only one process may have access when blocking mode is required. If you set a value of 100, then the number of non-blocking accesses will be limited to 100 processes. Any more processes than this wishing to use the semaphore will need to wait until some of the accesses are released. If 50 processes currently have read access and a new process requires blocking access, it will have to wait until all 50 read accesses are released. The specifics of this are discussed in the documentation for AccessSemaphore() and ReleaseSemaphore().

The handle returned in the Semaphore argument is global, so if you want to secretly share an anonymous semaphore with other processes, you may do so if you pass the handle to them. The other processes will still need to call AllocSemaphore() to register their interest, but they need to add the SMF_EXISTS Flag and also pass the semaphore handle to this function via the Semaphore parameter.

To free a semaphore after you have allocated it, call the FreeSemaphore() function. It is possible to call AllocSemaphore() with the same Name as many times as you like because the calls will nest, but you must match them all with FreeSemaphore() calls. A semaphore will not be completely freed from the system until all processes that have gained access drop their control of the semaphore.

Result
ERR_Okay  The semaphore was successfully allocated.
ERR_Args  The SemaphoreID argument was not supplied.
ERR_ArrayFull  Allocation failed as the semaphore array is at full capacity.
ERR_Forbid  Internal system locking failure.

Function:AllocateClassID()
Short:Generates dynamic class ID's.
Synopsis:ERROR AllocateClassID(STRING Name, CLASSID *ClassID)
Arguments:
Name  The name of the class that requires an ID.
ClassID  Must refer to a CLASSID variable that will store the resulting ID.

This function generates unique ID's that can be used for unregistered classes. ID's that are allocated through this function are permanent for the duration that the system is active. There is no need to free allocated class ID's when you are finished with them.

Result
ERR_Okay  A unique ID was successfully allocated and placed in the ClassID variable.

Function:AllocateID()
Short:Generates unique ID's for various purposes within the Pandora Engine.
Synopsis:LONG AllocateID(LONG Type)
Arguments:
Type  The type of ID that you are requesting.

This function generates unique ID's that can be used in certain areas of the object kernel. Simply tell this function the type of unique ID that you want to retrieve, and it will pass a unique ID back to you. The following ID types are currently supported:

TypeDescription
IDTYPE_MESSAGE  Message ID's are allocated for the purpose of sending uniquely identifiable messages between tasks.
IDTYPE_GLOBAL  Global ID's have no particular association with anything.

ID allocations are permanent, so there is no need to free an allocated ID when you are finished with it.

Result
A unique ID matching the requested type will be returned. This function can return NULL if the Type you supplied is unrecognised, or if an internal error occurred.


Function:CheckAction()
Short:Checks objects to see whether or not they support certain actions.
Synopsis:ERROR CheckAction(OBJECTPTR Object, ACTIONID ActionID)
Arguments:
Object  Pointer to the object that you want to check.
ActionID  One of the action ID's as specified in the "system/actioncodes.h" include file.

This function checks if a particular object supports a given action or method ID. To check if a Picture object supports the Query action for instance, a code segment such as this would be sufficient:

   if (CheckAction(Picture, AC_Query) IS ERR_Okay) {
      ...
   }
Result
ERR_Okay  The object supports the specified action.
ERR_False  The action is not supported.
ERR_Args  Incorrect arguments detected.
ERR_LostClass  The object has lost its class reference (object corrupt).

Function:CheckMemoryExists()
Short:Checks if a memory block still exists.
Synopsis:ERROR CheckMemoryExists(MEMORYID MemoryID)
Arguments:
MemoryID  The ID of the memory block that you wish to look for.

If you need to know whether or not a specific memory block still exists, you can check by using the CheckMemoryExists() function. Simply provide it with the ID of the block that you are interested in and it will return an error code of ERR_Okay if it is in the system at the time of calling.

Result
ERR_Okay  The block exists.
ERR_False  The block does not exist.
ERR_Args  You supplied a MemoryID of NULL.
ERR_SystemCorrupt  The internal memory tables are corrupt.

Function:CheckObjectExists()
Short:Checks if a particular object is still available in the system.
Synopsis:ERROR CheckObjectExists(OBJECTID ObjectID, STRING Name)
Arguments:
ObjectID  The object ID that you want to look for.
Name  If the ID is not known, specify the Name of the object here. Otherwise set to NULL.

The CheckObjectExists() function checks for the existence of an object within the system. CheckObjectExists() is commonly used to check for the presence of shared objects, which can be removed from the system at any time by other tasks.

This function allows you to check for an object either by ID or name. Please note that in the case of name checking, it is possible for multiple objects with the same name to exist at the time of calling this function.

Result
ERR_Okay  The object exists.
ERR_False  The object ID does not exist.
ERR_Args  Neither of the ObjectID or Name arguments were specified.

Function:ClearMemory()
Short:Clears large blocks of memory very quickly.
Synopsis:ERROR ClearMemory(APTR Memory, LONG Length)
Arguments:
Memory  Pointer to the memory block that you want to clear.
Length  The total number of bytes that you want to clear.

Use the ClearMemory() function when you need to clear a block of memory as efficiently as possible.

Result
ERR_Okay  The memory was cleared.
ERR_Args  The Memory argument was not specified.

Function:CloneMemory()
Short:Makes an exact duplicate of a memory block.
Synopsis:ERROR CloneMemory(APTR Address, LONG Flags, APTR *NewAddress, MEMORYID *NewMemoryID)
Arguments:
Address  Pointer to the memory block that you want to clone.
Flags  Specifies the memory flags that you want to use for your newly cloned memory block. See AllocMemory() for flag definitions.
NewAddress  Set this argument to refer to an APTR type, to store an address reference to the cloned memory block.
NewMemoryID  Set this argument to refer to a MEMORYID type, to store a unique ID reference to the cloned memory block.

This function allows you to make a duplicate of any memory block that has been allocated from AllocMemory(). The new memory block will be completely identical to the block you have specified, except for the type of memory, which you can alter through the Flags argument. The contents of the original memory block will be copied over to the duplicate block.

You have the option of receiving the cloned memory block as an address pointer and/or as a unique memory ID. When allocating private memory, you can request an address result only and leave the MemoryID argument as NULL. However when cloning public memory, you should always retrieve the MemoryID, and optionally the Address pointer if you need immediate access to the cloned block.

If the block is cloned as private memory and you retrieve both the MemoryID and Address pointer, or if the allocation is public and you choose to retrieve the Address pointer, an internal call will be made to AccessMemory() to lock the memory block. This means that before freeing the memory block, you must make a call to the ReleaseMemory() function to remove the lock, or it will remain in memory.

Remember to free the cloned memory block when you are finished with it.

Result
ERR_Okay  A duplicate of the memory block was successfully created.
ERR_Args  Invalid arguments were supplied to the function.
ERR_AccessMemory  Access to the newly created memory block was denied to the function.
ERR_AllocMemory  Failed to allocate the duplicate memory block.

Function:CreateObject()
Short:Provides a fast way of creating and initialising new objects.
Synopsis:ERROR CreateObject(LONG ClassID, LONG Flags, OBJECTPTR *Object, OBJECTID *ObjectID, Tags...)
Arguments:
ClassID  Set to a class ID obtained from the "system/register.h" file or from ResolveClassName().
Flags  Flag specifications - set to NULL to allocate a standard private object.
Object  Set this argument to refer to an OBJECTPTR type to store an address reference to the new object.
ObjectID  Set this argument to refer to an OBJECTID type to store a unique ID reference to the new object.
Tags  Field tags are specified here. See the SetFields() function for information on the arrangement of these tags. Remember to terminate the tag-list with TAGEND.

CreateObject() is an enhanced version of the NewObject() function. It performs the same activity as NewObject(), but will also set field values and initialise the object automatically for you. In other words, this function is provided for your convenience, and is not an integral part of the system's object management services.

Please refer to the NewObject() function for information on the allocation of new objects. Also see the SetFields() function for an outline of the formatting details of the tag arguments.

Result
ERR_Okay  The object was created successfully.
ERR_Args  Invalid arguments were specified.
ERR_NewObject  The NewObject() function failed.
ERR_SetField  The SetFields() function failed.

Function:CurrentContext()
Short:Returns a pointer to the object that has the current context.
Synopsis:OBJECTPTR CurrentContext(void)

The CurrentContext() function returns a pointer to the object that has the current context. In order for an object to have the context of the current Task, it must have been successfully set from the SetContext() function.

CurrentContext() is typically used to find out what object is currently receiving resource allocations. It is useful in improving the management of resources that your code may be allocating.

Result
Returns an object pointer (of which the Task has exclusive access to). This function rarely returns a NULL pointer - this is only possible during the initial startup and shutdown sequences of the object kernel.


Function:CurrentTaskID()
Short:Returns the object ID of the current Task.
Synopsis:OBJECTID CurrentTask(void)

The CurrentTaskID() function returns the object ID of the Task that is making the call - i.e. "you". Task objects' are used for storing data that is specific to a running program. Refer to the Task class for details.

There are some cases where CurrentTaskID() can return a NULL value. This can occur if there is no related Task object, or if the Task object has been corrupted. For this reason it is recommended that calls to CurrentTask() are enclosed within an IF statement.

If there is a legitimate circumstance where there is no current task (for example if this function is called during kernel initialisation) then the "system task" may be returned (the system task controls and maintains the kernel).

It is also possible to retrieve a direct pointer to the task's object structure by calling the CurrentTask() function. This saves on the time required to access and release the task object when using ID's.

Result
Returns a unique ID reference to the current Task object or NULL if failure. You will need to use the AccessObject() function if you need to gain direct access to the Task object.


Function:DPrintF()
Short:Sends formatted strings to the debugger.
Synopsis:void DPrintF(STRING Header, STRING Array, ...)
Arguments:
Header  A short name for the first column. Usually function names are placed here, so that it is obvious who is sending the message.
Array  The first member of the array must be a string. All other members of the array must be supplied according to the string formatting, 1 parameter for every % symbol that you have used.

The DPrintF() function follows the same functionality and rules as the ANSI printf() function. The only difference is that it prints directly to the debug window. Due to internal limits your string is limited to a total of 256 bytes output, although you should keep everything within 80 bytes to avoid running onto a second row. You can supply a maximum amount of 5 '%' parameters to this function.

The following example will print the default width of a Screen object to the debug window.

   if (NewObject(ID_SCREEN, NULL, &Screen, NULL) IS ERR_Okay) {
      if (Action(AC_Init, Screen, NULL)) {
         DPrintF("Demo:","The width of the screen is: %d", Screen->Width);
      }
      Action(AC_Free, Screen, NULL);
   }

Function:DebugState()
Short:Turns debug messages on and off.
Synopsis:LONG DebugState(LONG State, LONG Level)
Arguments:
State  Set to TRUE to turn messages on, FALSE to turn messages off. Any other value will be ignored.
Level  Indicates the level of detail that you want from debug output. The higher the number, the more messages that will be printed. Valid settings range from 0 to 10.

This function provides a switch for turning debug messages on and off. This is useful for turning off messages just before running intense looping sequences. It is also used to dynamically alter the amount of detail printed to the debugger, using the Level argument.

Calls to this function will nest according to the State argument, so if the function is called twice with State set to FALSE, then it must be called twice again with State set to TRUE to reenable debugging.

Result
Returns the debug level that was set prior to calling this function.


Function:DeregisterFD()
Short:Removes previously register FD's from the system.
Synopsis:void DeregisterFD(LONG FD)
Arguments:
FD  The file descriptor that you want to deregister.

The DeregisterFD() function is used to de-register file descriptors that you have registered via the RegisterFD() function. Once removed, the task will stop monitoring the file descriptor for activity.


Function:FastFindObject()
Short:Searches for objects by name.
Synopsis:ERROR FastFindObject(STRING Name, CLASSID ClassID, OBJECTID *Array, LONG ArraySize, LONG *Count)
Arguments:
Name  The name of the object that you are looking for.
ClassID  Setting this field to a class ID will filter the results down to a specific class type.
Array  Pointer to the array that will store the results.
ArraySize  Indicates the size of the array that you have supplied. Must be set to a value of 1 or greater.
Count  Set this pointer to a longword so that FastFindObject() can tell you how many objects were stored in your array. This argument can be set to NULL if you wish.

The FastFindObject() function is an optimised implementation of the FindObject() function. You can use it to search for objects in the system by their name and/or class. Unlike FindObject(), which will return an allocated memory block that lists all of the objects that were found, FastFindObject() requires that you provide a memory area to write the results to. This saves the cost of allocation time, which can be expensive in some situations.

The following code example is a typical illustration of this function's use. It finds the most recent object created with a given name:

   OBJECTID SystemPointerID;
   FastFindObject("SystemPointer", ID_POINTER, &SystemPointerID, 1, NULL);

If FastFindObject() cannot find any objects with the name that you are looking for, it will return an error code.

The list is sorted so that the oldest private object is placed at the start of the list, and the most recent public object is placed at the end. This will assist you in situations where you may be looking for the oldest or youngest object to have the particular name that you have searched for. Preference is also given to objects that have been created by your own task, so foreign objects are also pushed towards to the top of the list.

Result
ERR_Okay  At least one object was found and stored in the supplied array.
ERR_Args  The Name/ClassID, Array or ArraySize arguments were not supplied.
ERR_Search  No objects matching the given name could be found.
ERR_AccessMemory  Access to the RPM_SharedObjects memory block was denied.

Function:FindClass()
Short:Returns all class objects for a given class ID.
Synopsis:OBJECTPTR FindClass(CLASSID ClassID, OBJECTPTR LastClass)
Arguments:
ClassID  A class ID as specified in "system/register.h" or obtained from ResolveClassName(). If NULL, all classes currently loaded by the Pandora Engine will be returned in no particular order.
LastClass  Points to the last received Class structure if continuing a search, otherwise NULL to start a new search.

This function is used to search the system for all members of a specific class. If you wanted to search for all members of the Picture class for example, the following code could be used:

   OBJECTPTR Class;

   Class = NULL;
   while (Class = FindClass(ID_PICTURE, Class)) {
      ...
   }

If a matching class is found in the system, it will be returned immediately. The base class is always returned first, while subsequent calls to this function will return sub-classes. Once all of the matching classes have been discovered, a NULL pointer will be returned to indicate an end to the search.

Please note that if you are looking for a specific sub-class, you should call ResolveClassName() and then call this function with the resulting sub-class ID.

Result
Returns a pointer to the Class structure that has been found as a result of the search, or NULL if no matching classes were found.


Function:FindObject()
Short:Searches for objects by name and class.
Synopsis:ERROR FindObject(STRING Name, CLASSID ClassID, OBJECTID **List, LONG *Count)
Arguments:
Name  The name of the object that you are looking for.
ClassID  Setting this field to a class ID will filter the results down to a specific class type.
List  On success, a memory block containing a list of ObjectID's will be placed in this variable.
Count  The total number of objects listed in the List array will be stored in this variable.

The FindObject() function is used to search for objects in the system by name and class type. If the function cannot find any object with the name or class that you are looking for, then it will return an error code. If it does find one or more matching objects, then a complete list of them will be returned in an allocated memory block.

The List is sorted so that the oldest object is placed at the start of the list, and the most recent is placed at the end. This will assist you in situations where you may be looking for the oldest or youngest object that has the particular name that you have searched for.

The List is terminated with a NULL entry.

The List is returned as an allocated memory block. Please call FreeMemory() on the List pointer so that it is not left in memory after you have used it.

Result
ERR_Okay  One or more objects have been found and are listed.
ERR_Search  There are no objects in the system with the given name or class type.
ERR_Args  Invalid arguments were specified.
ERR_Memory  The function failed to allocate enough memory for the List array.
ERR_AccessDenied  The function failed to gain access to the PublicObjects structure (internal error).

Function:FindPrivateObject()
Short:Searches for objects by name.
Synopsis:ERROR FindPrivateObject(STRING Name, OBJECTPTR *Object)
Arguments:
Name  The name of the object that you are looking for.
Object  Pointer to an OBJECTPTR variable that will store the discovered object address.

The FindPrivateObject() function is provided as a simple implementation of the FastFindObject() function. This implementation is specifically limited to finding private objects by name only. It is capable of returning only one object address in its search results. Unlike FastFindObject(), this function returns directly accessible object addresses that may be used immediately after a successful search.

If multiple objects with the same name exists, the most recently created object will be returned by this function.

If you require more advanced functionality for object searches, please use the FastFindObject() function.

Result
ERR_Okay  A matching object was found.
ERR_Args  The Name and/or Object argument was not specified.
ERR_Search  No objects matching the given name could be found.

Function:Forbid()
Short:Locks other tasks out of the shared memory and object areas.
Synopsis:ERROR Forbid(void)

Use the Forbid() function to aggressively lock out the kernel's shared memory and shared object services. This allows you to use the shared areas of the object kernel without encountering race conditions caused by other tasks trying to access the same areas. Calls to Forbid() must be followed with a call to Permit() to undo the lock.

Due to the powerful nature of this function, you should only ever use it in small code segments and never in areas that involve communication with other tasks. Locking for extended periods of time (over 4 seconds) may also result in your task being automatically killed off by the system.

Multiple calls to Forbid() will nest.

Result
ERR_Okay  Success.
ERR_LockFailed  Failed to acquire a lock on the system.

Function:FreeMemory()
Short:Frees private memory blocks allocated from AllocMemory().
Synopsis:ERROR FreeMemory(APTR Address)
Arguments:
Address  Points to the start of a memory block to be freed.

This function frees memory areas allocated from AllocMemory(). Crash protection is incorporated into various areas of this function. If the memory header or tail is missing from the block, then it is assumed that a routine has has over-written the memory boundaries, or you are attempting to free a non-existant allocation. Such problems are immediately reported to the system debugger. Bear in mind that it does pay to save your development work if such a message appears, as it indicates that important memory areas could have been destroyed.

For speed reasons, this function only supports private memory. If you wish to free a public memory block, you will need to use the FreeMemoryID() function instead.

Result
ERR_Okay  The memory block was freed successfully.
ERR_Args  You passed an Address argument of NULL.
ERR_Memory  The memory address that you supplied is not a recognised memory block.

Function:FreeMemoryID()
Short:Frees public memory blocks allocated from AllocMemory().
Synopsis:ERROR FreeMemoryID(MEMORYID MemoryID)
Arguments:
MemoryID  The unique ID of the memory block.

When a public memory block is no longer required, it can be freed from the system with this function. The action of freeing the block will not necessarily take place immediately - if another Task is using the block for example, deletion cannot occur for safety reasons. In a case such as this, the block will be marked for deletion and will be freed once all Tasks have stopped using it.

Result
ERR_Okay  The memory block was freed or marked for deletion.
ERR_Args  A NULL value was passed for the MemoryID.
ERR_MemoryDoesNotExist  The MemoryID that you supplied was not found in the system.
ERR_LockFailed  Failed to lock the public memory control semaphore.

Function:FreeSemaphore()
Short:Frees an allocated semaphore.
Synopsis:ERROR FreeSemaphore(LONG Semaphore)
Arguments:
Semaphore  The handle of the semaphore that you want to deallocate.

The FreeSemaphore() function is used to deallocate semaphores when you are no longer in need of them. You must call FreeSemaphore() for each time that you have called the AllocSemaphore() function. If you still have locks on the semaphore at the time that you call this function, the semaphore will not be removed from the system until those locks are released.

A semaphore is never completely removed from the system until all processes have given up their allocations against the semaphore.

Result
ERR_Okay  The semaphore was freed successfully.
ERR_Args  A semaphore handle was not specified.
ERR_Search  The supplied semaphore handle was not found in the internal semaphore list.

Function:GetClassID()
Short:Returns the class ID of an object.
Synopsis:CLASSID GetClassID(OBJECTID ObjectID)
Arguments:
ObjectID  The object to be examined.

This function can be used on any valid object ID to retrieve the ID of its class. This is the quickest way to retrieve the class of an object without having to gain exclusive access to the object first.

Please note that if you already have access to an object through an address pointer, the quickest way to learn of its class is to read the ClassID field in the object header.

Result
Returns the class ID of the object or NULL if failure.


Function:GetField()
Short:Retrieves single field values from objects.
Synopsis:ERROR GetField(OBJECTPTR Object, LONG FieldID, LONG ResultType, APTR Result)
Arguments:
Object  Pointer to an object.
FieldID  The ID of the field that you wish to read.
ResultType  The type of value that the field should be converted to.
Result  Pointer to the variable that will store the result.

The GetField() function is used to read field values from objects. You don't need to know anything about the object structure in order to read information from it - you just need to know what field you want to read.

The following code segment illustrates how to read values from an object:

   LONG XCoord, YCoord;

   GetField(Object, FID_XCoord, FT_LONG, &XCoord);
   GetField(Object, FID_YCoord, FT_LONG, &YCoord);

As GetField() is based on field ID's that reflect field names ("FID's"), you will find that there are occasions where there is no reserved ID for the field that you wish to read. To convert field names into their relevant IDs, call the ResolveFields() function. Reserved field ID's are listed in the "system/fields.h" include file.

When reading a field you are required to make an educated guess as to its type, in order to prevent a type mismatch from occurring. For instance, reading a coordinate field would mean that the field is a number, so you should read the field as a numeric type rather than choosing a pointer type.

Available field types are listed in the following table:

TypeDescription
FT_FLOATA 32-bit floating point value.
FT_LONGA 32-bit integer value.
FT_DOUBLEA 64-bit floating point value.
FT_LARGEA 64-bit integer value.
FT_POINTER  A standard 32-bit address space pointer.
FT_STRING  A 32-bit pointer that refers to a string.

The variable that you point to in the Result argument must match the ResultType that you have specified, or you will risk crashing your program code.

Result
ERR_Okay  The field value was read successfully.
ERR_Args  Invalid arguments were specified.
ERR_NoFieldAccess  Permissions for this field indicate that it is not readable.
ERR_UnsupportedField  The FieldID is not supported by the object's class.

Function:GetFieldVariable()
Short:Retrieves field values by converting them into strings.
Synopsis:ERROR GetFieldVariable(OBJECTPTR Object, STRING Field, STRING Buffer, LONG Size)
Arguments:
Object  Pointer to an object.
Field  The name of the field that is to be retrieved.
Buffer  Pointer to a buffer space large enough to hold the expected field value.
Size  The size of the buffer that has been provided, in bytes.

The GetFieldVariable() function is used in situations where you need to retrieve the value of a field without knowing the field's type or any details beyond the field name. Although simple to use, it is the slowest of the field retrieval instructions because the field's value must be converted from its original type into a string.

You need to provide a buffer that is large enough to hold the expected value. If the buffer is not large enough then the resulting value will be cut short. 256 bytes is considered a large enough buffer for most occasions. In more extreme circumstances, a buffer as large as 1kb may be needed.

This function does not support pointer based fields as they cannot be translated, although an exception is made for string field types.

Result
ERR_Okay  The field was value retrieved.
ERR_UnsupportedField  The requested field is not supported by the object's class.
ERR_NoFieldAccess  Permissions for this field state that it is not readable.
ERR_Mismatch  The field value cannot be converted into a string.

Function:GetFields()
Short:Retrieves multiple field values in a single function call.
Synopsis:ERROR GetFields(OBJECTPTR Object, { FIELD FieldID, APTR Value }...)
Arguments:
Object  Pointer to the object that you want to access.
FieldID  The ID of the field that you want to get.
Value  Points to the storage area that is to receive the field value.

This function can be used to grab the values of multiple fields in a single function call. It is primarily provided to give a speed increase over calling the GetField() function multiple times. The arguments passed to this function are tag-based and must be terminated with a TAGEND marker, as shown in the following example:

   LONG Width, Height;

   GetFields(Screen,
      FID_Width|TLONG,  &Width,
      FID_Height|TLONG, &Height,
      TAGEND);

The field ID's that you specify must be logically or'd with tag definitions that indicate the type of values that you want to get from each field. For instance, if want to retrieve a field in floating point format, then you must use the TFLOAT tag and supply a pointer to a FLOAT variable. Please note that failing to set the tag values correctly can often cause a program to crash.

The recognised tag types are TPTR, TSTRING, TLONG, TLARGE, TFLOAT, and TDOUBLE.

If the GetFields() does not return an ERR_Okay code, you should work on the assumption that all of the field settings failed, meaning that your routine should abort in most cases. This function aborts immediately and makes no attempt to 'salvage' any other fields that may be left in the list, or undo earlier field settings that were successful.

For information on the field retrieval process, refer to the GetField() function.

Result
ERR_Okay  The field values were retrieved successfully.
ERR_Args  Invalid arguments were specified.
ERR_UnsupportedField  One of the fields is not supported by the target object.

Function:GetMessage()
Short:Reads messages from message queues.
Synopsis:ERROR GetMessage(MEMORYID QueueID, LONG Type, LONG Flags, APTR Buffer, LONG Size)
Arguments:
QueueID  The memory ID of the message queue is specified here. If NULL, the message queue of the local Task will be used.
Type  The message type that you would like to receive, or NULL if you would like to receive the next message on the queue.
Flags  This argument is reserved for future use. Set it to NULL.
Buffer  Pointer to a buffer that is large enough to hold the incoming message information. If set to NULL then all accompanying message data will be destroyed.
Size  The byte-size of the buffer that you have supplied.

The GetMessage() function is used to read messages that have been stored in message queues. You can use this function to read the next immediate message stored on the queue, or the first message on the queue that matches a particular Type. It is also possible to call this function in a loop to clear out all messages, until an error code other than ERR_Okay is returned.

Messages will often (although not always) carry data that is relevant to the message type. To retrieve this data you need to supply a buffer, preferably one that is large enough to receive all the data that you expect from your messages. If the buffer is too small, the message data will be cut off to fit inside the buffer.

Message data is written to the supplied buffer with a Message structure (struct Message), which is immediately followed up with the actual message data. The message structure includes the following fields:

FieldDescription
LONG TypeThe message type ID.
LONG Size  The size of the message data, in bytes. If there is no data associated with the message, the Size will be set to NULL.
Result
ERR_Okay  The message was successfully retrieved from the message queue.
ERR_Args  Invalid arguments were supplied to the function.
ERR_AccessMemory  Failed to gain access to the message queue.
ERR_Search  No more messages are left on the queue, or no messages that match the given Type are on the queue.

Function:GetName()
Short:Retrieves object names.
Synopsis:ERROR GetName(OBJECTPTR Object, STRING Buffer, LONG Length)
Arguments:
Object  Pointer to the object that you want to get the name of.
Buffer  Pointer to a string buffer that will store the object name.
Length  The total size of the string buffer.

The object kernel allows names to be assigned to objects for the purpose of easy identification. Naming is also important for scripts and identification from a user point of view. Calling GetName() will return the name of any object that you have access to. If the target object has not been assigned a name, then you will receive a null-string.

The length of an object name is limited to the value indicated by the MAX_NAMELEN definition in the "main.h" include file.

Result
ERR_Okay  The name of the object was successfully written to the Buffer.
ERR_Args  The arguments are invalid.

Function:GetOwnerID()
Short:Returns the unique ID of an object's owner.
Synopsis:OBJECTID GetOwnerID(OBJECTID ObjectID)
Arguments:
ObjectID  The ID of the object that you want to examine.

This function can be used on any valid object ID to retrieve the unique ID of its owner. This is the quickest way to retrieve the owner of an object without having to gain exclusive access to the object first.

Please note that if you already have access to an object through an address pointer, the quickest way to learn of its owner is to read the OwnerID field in the object header.

Result
Returns the ID of the object's owner. If the object does not have a owner (i.e. if it is untracked) or if the ID that you provided is invalid, this function will return NULL.


Function:GetResource()
Short:Retrieves miscellaneous resource identifiers.
Synopsis:LARGE GetResource(LONG Resource)
Arguments:
Resource  The ID of the resource that you want to obtain.

The GetResource() function is used to retrieve miscellaneous resource ID's that are either global or local to your task. To retrieve a resource you need to make a reference to it with the Resource parameter. Currently the following resource ID's are available:

ResourceDescription
RES_MESSAGEQUEUE  Use this resource to retrieve the message queue ID of the current task.
RES_TIMEOUTUse this resource to retrieve the timeout value used when the current task goes to sleep (measured in milliseconds).
RES_KERNELVERSIONUse this resource to retrieve the kernel version number.
RES_KERNELREVISIONUse this resource to retrieve the kernel revision number.
RES_CURRENTTASKUse this resource to get the object ID of the current task.
RES_CURRENTTASKPTRUse this resource to get a direct pointer to the current task's object structure.
RES_TOTALMEMThe total amount of installed RAM in bytes.
RES_FREEMEMThe total amount of available memory, in bytes.
RES_SHAREDMEMThe total amount of shared memory in use.
RES_TOTALSWAPThe total amount of available swap space..
RES_FREESWAPThe total amount of unused swap space.
RES_PLATFORMString-based field indicating the user's platform. Currently returns 'Athene', 'Windows' or 'Linux'.
RES_ERRORCODESThis resource holds a pointer to a sorted array of all error codes, translated into human readable strings.
RES_ERRORCODES_TOTALIndicates the total number of error codes listed in the RES_ERRORCODES array.
RES_HEADERCODESThis resource holds a pointer to a sorted array of all error header codes, translated into human readable strings.
RES_HEADERCODES_TOTALIndicates the total number of error headers listed in the RES_HEADERCODES array.

Result
Returns the value of the resource that you have requested. If the resource ID is not known by the kernel, NULL is returned.


Function:ListChildren()
Short:Returns a list of all children belonging to an object.
Synopsis:ERROR ListChildren(OBJECTID ObjectID, struct ChildEntry *List, LONG *Count)
Arguments:
ObjectID  The ID of the object that you wish to examine.
List  Must refer to an array of ChildEntry structures.
Count  The longword that this argument refers to must be set with a value that indicates the size of your list array. Before returning, this argument will be updated with the total number of entries listed in the array.

The ListChildren() function provides the necessary means for listing an object's children in a single function call.

You need to provide an empty array of ChildEntry structures in the List argument, so that this function has an area to write the results to. The Count argument must point to a longword that indicates the size of the array that you have supplied. Before returning, the ListChildren() function will update the Count variable so that it reflects the total number of children that were written to the array.

The definition of the ChildEntry structure is as follows:

   struct ChildEntry {
      OBJECTID ObjectID;
      LONG ClassID;
   };

The ClassID field is included to assist you in finding specific object types.

Objects that are specially marked with the CHILD flag are not returned in the resulting list; such objects are considered to be private extensions of the targetted parent.

Result
ERR_Okay  Zero or more children were found and listed.
ERR_Args  Invalid arguments were specified.

Function:ListMemory()
Short:Returns a list of public or private memory blocks that have been allocated in the system.
Synopsis:ERROR ListMemory(LONG Flags, struct ListMemory **List)
Arguments:
Flags  Set to MEM_PUBLIC to retrieve public memory blocks, otherwise set to NULL for private memory blocks.
List  Must refer to a "struct ListMemory *" variable to store the resulting array pointer.

The ListMemory() function is typically used for debugging and memory monitoring purposes. It is capable of returning a complete list of public memory blocks, or all private blocks that are local to your task.

The function will return the list by allocating an array and storing it in the variable provided by the List argument. The ListMemory structure used to create the array contains the following fields:

FieldDescription
MEMORYID MemoryIDUnique memory ID.
OBJECTID ObjectIDThe object that the memory block belongs to.
APTR AddressMemory address (applies only to private memory blocks).
LONG SizeSize of the memory block in bytes.
WORD AccessCount  The total count of locks on this memory block.
WORD FlagsThe flags associated with this memory block.
OBJECTID LockIDRefers to the Task that has a current lock on the block.
OBJECTID TaskIDRefers to the Task that created and has overall ownership of the block.

The ListMemory array is terminated with a final entry that has all fields driven to NULL.

Result
ERR_Okay  The function succeeded in listing the system's memory blocks.
ERR_Args  You failed to set the List argument.
ERR_LockFailed  Failed to gain access to the public memory control semaphore.
ERR_AllocMemory  The function failed to allocate the memory needed to create the list.

Function:ListObjects()
Short:Returns a list of objects that match specific parameters.
Synopsis:ERROR ListObjects(CLASSID ClassID, LONG Flags, struct ObjectInfo **List)
Arguments:
ClassID  The ID of the class that you are interested in, or NULL to ignore class types. Note that you may only scan for base classes and not child classes.
Flags  Filtering flags. LOF_PRIVATE and/or LOF_PUBLIC must be set at a minimum.
List  Refers to an address pointer that will store the resulting array.