This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Obtain a list of properties associated with a power managed object
#include <sys/pm.h> int pm_properties(pm_hdl_t hdl, pm_property_attr_t *list, int count);
libpm
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.
The number of properties associated with the object, or -1 if an error occurred (errno is set).
#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; }
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
pm_add_property(), pm_get_property(), pm_set_property()