2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * Utility functions used by all of libpower 2N/A * Add a property and value to a result set to be returned to a caller of 2N/A * libpower. The result list has the structure: 2N/A * Name Type Description 2N/A * ------------------- ------ ------------------------------------- 2N/A * property_name nvlist The list of available values and 2N/A * other information about the 2N/A * property. See below for the structure 2N/A * Name Type Description 2N/A * ------------------- ------ ------------------------------------- 2N/A * PM_PROP_PGNAME string The name of the SMF property 2N/A * group to which the property belongs 2N/A * other information about the 2N/A * PM_AUTHORITY_SMF_STR varies The value of the property from SMF. 2N/A * PM_AUTHORITY_CURRENT_STR 2N/A * varies The value of the property in use by 2N/A * PM_AUTHORITY_PLATFORM_STR 2N/A * varies The value of the property contained 2N/A /* Allocate a new result list if necessary */ 2N/A /* Get the list of values for this property from the result set */ 2N/A * This property does not exist in the result set. Add it 2N/A * The property exists. Update it with the data from the new 2N/A * Some properties in SMF may have no value. This is 2N/A * valid, but the property is intentionally not added 2N/A * to the result set. 2N/A * Create a new property entry in a result set as specified by pm_result_add 2N/A /* Create the new list and add required elements */ 2N/A /* Add the new value to the list */ 2N/A /* Add the property to the main list */ 2N/A * Add a new value to a property value list 2N/A * We assume that a property cannot exist in multiple property 2N/A * groups and simply add the value from the authority. 2N/A * Given a result set built by pm_result_add, above, created a new result set 2N/A * with just the requested properties. 2N/A * Scan each requested property and find the matching entry in the 2N/A /* This property entry is invalid. */ 2N/A * Get the property name and potential group name from the 2N/A * Get the unique property name from the list. There can be 2N/A /* The requested property is not found. Error. */ 2N/A "%s property %s not found in result set\n",
2N/A /* Now match the property group name */ 2N/A * This is the only property with this name and the 2N/A * group does not match. 2N/A "%s property %s/%s not found in result set\n",
2N/A * Does this property contain an nvpair with the requested 2N/A * This is the special match-everything 2N/A * authority. Declare success and add the value 2N/A * The specified authority does not contain the 2N/A * requested property name. 2N/A "%s authority %s not found in value list " 2N/A * Merge the requested nvpair into the results and remove 2N/A * all the the requested authorities. 2N/A * Add a specified nvpair to an existing result set 2N/A /* Add the property to the result set and retrieve it's value list */ 2N/A * Remove any authorities that do not match the requested authority 2N/A * from the result set. 2N/A /* The request is for all available authorities */ 2N/A /* The request is for this authority. Do not remove */ 2N/A * Remove this authority from the list of authorities if 2N/A "%s nvlist_remove_all returned %d for %s\n",
2N/A * Property name specifiers may also include a property group designation: 2N/A * Given a buffer with a property name specifier, determine the location of 2N/A * the property name and the property group name. Modify the given buffer 2N/A /* Find the potential separator in the buffer */ 2N/A /* The buffer contains only a potential property name */ 2N/A * The buffer contains both a potential property name and a 2N/A * potential property group name. Modify the buffer and 2N/A "%s property group name has zero length\n",
2N/A * Determine if the string in the given buffer is a valid boolean value 2N/A * Compare the given buffer with the valid values for a boolean value. 2N/A /* The value is valid and true. */ 2N/A /* The value is valid and false. */ 2N/A * Determine if the string in the given buffer contains a valid integer value 2N/A /* Make sure that all the characters are numbers */ 2N/A "string \"%s\" is not a valid integer\n",
buf);
2N/A /* Convert the integer to an int64 value */ 2N/A "integer \"%s\" could not be converted\n",
buf);
2N/A * Determine if the given property group name matches a given property value 2N/A * list by comparing the strings. An input property group name of null 2N/A * matches all values. 2N/A /* Match. The request wants any possible property group */ 2N/A * No match. The property group name for this property list 2N/A * does not exist and therefore does not match. 2N/A * No match. The property group name for this property list 2N/A * does not match the requested property group name.