The API is defined in the header file sysroot-*-kos/include/kos/objcontainernolock.h from the KasperskyOS SDK.
Information about API functions and macros is provided in the table below.
Creating a container
To create a container, call the KosCreateObjContainerNolock() function. In the parent parameter, you can specify the ID of the parent container, which is the KosObjContainer, KosObjContainerNolock or KosBaseContainer to which the created container will be added.
Adding an object to a container
To add an object to a container, call the KosInsertObjContainerNolockObject() function. You can add any KosObject, including a KosObjContainer, KosObjContainerNolock or KosBaseContainer. You must use the name parameter to define the object name that this object will have within the container. This name is not related to the name that was defined when the object was created. The name of an object within a container must be unique. You can add the same object multiple times with different names. When an object is added to a container, the reference counter for this object is incremented.
Removing an object from a container
To remove an object from a container, call the KosRemoveObjContainerNolockObjectByName() or KosRemoveObjContainerNolockObject() function. When an object is removed from a container, the reference counter for this object is decremented.
Searching for an object in a container
To search for an object with the defined name in a container, call the KosGetObjContainerNolockObjectByName() function. Child containers will not be searched for the object. This function increments the reference counter for the found object.
Navigation within a container
To initialize an iterator for navigation within a container and to receive access to objects, call the KosInitObjContainerNolockIterator() function. After initialization, the iterator is in the initial position.
To move the iterator to the next position, call the KosNextObjContainerNolockIterator() function.
To check whether the iterator is in the final position, call the KosIsObjContainerNolockIteratorEnd() function.
To get the object corresponding to the current position of the iterator, call the KosGetObjContainerNolockIteratorObject() function.
Traversing objects in a container
To traverse objects in a container, use the KosWalkObjContainerNolockObjects() function or the KosForEachObjContainerNolockObject() macro.
When using the KosWalkObjContainerNolockObjects() function, use the walk parameter to define the callback function that is called for each object during traversal and receives pointers to the object and data that is passed to the KosWalkObjContainerNolockObjects() function via the context parameter. If the callback function returns a value with the KOS_OBJECT_WALK_FINISH flag, the KosWalkObjContainerNolockObjects() function stops traversal. If a callback function returns a value with the KOS_OBJECT_WALK_REMOVE_OBJECT flag, the KosWalkObjContainerNolockObjects() function removes the corresponding object from the container. (The flags are defined in the header file sysroot-*-kos/include/kos/objects.h from the KasperskyOS SDK.)
The KosForEachObjContainerNolockObject() macro is expanded into the header of the for operator. The pointer defined in the obj parameter will contain the address of the next object in each iteration. You can use this pointer to perform operations with objects. For example, you can delete an object from a container by calling the KosRemoveObjContainerNolockObject() function.
Objects in child containers are not traversed.
Enumerating the names of objects in a container
To enumerate the names of objects in a container, use the KosEnumObjContainerNolockNames() function. The order of enumeration for object names matches the order in which these objects are added to the container. Object names in child containers are not enumerated. The function increments the reference counter for the KosString containing the object name. If this string is no longer needed, you need to decrement the reference counter for it by calling the KosPutString() function from the strings.h API.
Getting the number of objects in a container
To get the number of objects in a container, call the KosCountObjContainerNolockObjects() function. Objects in child containers are not taken into account.
Clearing a container
To remove all objects from a container, call the KosClearObjContainerNolock() function. This function decrements the counters for links to objects that are removed from the container.
Checking whether an object is a container
To check whether an object is a KosObjContainer or KosObjContainerNolock, call the KosIsObjContainerNolock() function.
Deleting a container
To delete a container, call the KosDestroyObjContainerNolock() function. When a container is deleted, the counters for links to objects within this container are decremented.
Information about API functions and macros
objcontainernolock.h functions and macros
Function/Macro |
Information about the function/macro |
|---|---|
|
Purpose Creates a container. Parameters
Returned values If successful, the function returns |
|
Purpose Deletes a container. Parameters
Returned values If successful, the function returns |
|
Purpose Clears a container. Parameters
Returned values If successful, the function returns |
|
Purpose Adds an object to a container. Parameters
Returned values If successful, the function returns |
|
Purpose Removes the object with the defined name from a container. Parameters
Returned values If successful, the function returns |
|
Purpose Removes an object from a container. Parameters
Returned values If successful, the function returns |
|
Purpose Searches a container for the object with the defined name. Parameters
Returned values If successful, the function returns Additional information If an object with the defined name is not found, the function returns the |
|
Purpose Traverses objects in a container and calls the defined function for each object during traversal. Parameters
Returned values If successful, the function returns |
|
Purpose Enumerates the names of objects in a container. Parameters
Returned values If successful, the function returns |
|
Purpose Gets the number of objects in a container. Parameters
Returned values Number of objects in a container. |
|
Purpose Initializes an iterator for navigation within a container and receives access to objects. Parameters
Returned values Initialized iterator for navigation within a container and access to objects. |
|
Purpose Checks whether the iterator is in the final position. Parameters
Returned values If the verification is successful, the function returns |
|
Purpose Gets the object corresponding to the current position of the iterator. Parameters
Returned values Pointer to the object. If the iterator is in the final position, the function returns |
|
Purpose Moves the iterator to the next position. Parameters
Returned values N/A |
|
Purpose Traverses objects in a container. Parameters
Macro values N/A |
|
Purpose Checks whether the object is a Parameters
Returned values If the verification is successful, the function returns |