[Previous] [Contents] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

pm_properties()

Obtain a list of properties associated with a power managed object

Synopsis:

#include <sys/pm.h>

int pm_properties(pm_hdl_t hdl, 
                  pm_property_attr_t *list, 
                  int count);

Arguments:

hdl
Handle to the power managed object obtained via pm_attach().
list
Pointer to where the property information is returned.
count
The maximum number of property entries to return.

Library:

libpm

Description:

The pm_properties() is used to list the properties associated with a power managed object.

Each property is described by a pm_property_attr_t structure:

id specifies the property identifier of the property.

size the size of the property value.

Returns:

The number of properties associated with the object, or -1 if an error occurred (errno is set).

Errors:

EBADF
hdl is not a valid handle.
EFAULT
A fault occurred accessing list.
ENOMEM
Insufficient memory to allocate power manager data structures.

Examples:

#include <sys/pm.h>
#include <fcntl.h>
#include <stdlib.h>
int main()
{
   pm_hdl_t     hdl;
   int          i;
   int          count;
   pm_property_attr_t      *list;

   hdl = pm_attach("object", O_RDONLY);
   if (!pm_valid_hdl(hdl)) {
      perror("pm_attach");
      return EXIT_FAILURE;
   }

   // find out how many properties exist
   count = pm_properties(hdl, 0, 0);
   if (count == -1) {
      perror("pm_properties");
      return EXIT_FAILURE;
   }
   
   printf("Object has %d properties\n");

   // allocate memory for list and get all properties
   if ((list = malloc(count * sizeof(*list))) == 0) {
      perror("malloc");
      return EXIT_FAILURE;
   }
   
   if (pm_properties(hdl, list, count) == -1) {
      perror("pm_properties");
      return EXIT_FAILURE;
   }

   for (i = 0; i < count; i++) {
      printf("%d: id=0x%x size=%d bytes\n", i, 
            list[i].id, list[i].size);
   }
   
   return EXIT_SUCCESS;
}

Classification:

Neutrino

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

pm_add_property(), pm_get_property(), pm_set_property()


[Previous] [Contents] [Next]