Changeset 26111 in vbox
- Timestamp:
- Feb 1, 2010 1:41:24 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57099
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/cfgm.h
r22334 r26111 177 177 VMMR3DECL(CFGMVALUETYPE) CFGMR3GetValueType(PCFGMLEAF pCur); 178 178 VMMR3DECL(bool) CFGMR3AreValuesValid(PCFGMNODE pNode, const char *pszzValid); 179 VMMR3DECL(int) CFGMR3ValidateConfig(PCFGMNODE pNode, const char *pszNode, 180 const char *pszValidValues, const char *pszValidNodes, 181 const char *pszWho, uint32_t uInstance); 182 179 183 /** @} */ 180 184 -
trunk/include/VBox/err.h
r26066 r26111 737 737 /** A new leaf couldn't be inserted because one with the same name exists. */ 738 738 #define VERR_CFGM_LEAF_EXISTS (-2162) 739 /** An unknown config value was encountered. */ 740 #define VERR_CFGM_CONFIG_UNKNOWN_VALUE (-2163) 741 /** An unknown config node (key) was encountered. */ 742 #define VERR_CFGM_CONFIG_UNKNOWN_NODE (-2164) 739 743 /** @} */ 740 744 -
trunk/src/VBox/VMM/CFGM.cpp
r23587 r26111 347 347 * @param pszzValid List of valid names separated by '\\0' and ending with 348 348 * a double '\\0'. 349 * 350 * @deprecated Use CFGMR3ValidateConfig. 349 351 */ 350 352 VMMR3DECL(bool) CFGMR3AreChildrenValid(PCFGMNODE pNode, const char *pszzValid) … … 471 473 * @param pszzValid List of valid names separated by '\\0' and ending with 472 474 * a double '\\0'. 475 * @deprecated Use CFGMR3ValidateConfig. 473 476 */ 474 477 VMMR3DECL(bool) CFGMR3AreValuesValid(PCFGMNODE pNode, const char *pszzValid) … … 733 736 return rc; 734 737 } 738 739 740 /** 741 * Validate one level of a configuration node. 742 * 743 * This replaces the CFGMR3AreChildrenValid and CFGMR3AreValuesValid APIs. 744 * 745 * @returns VBox status code. 746 * 747 * When an error is returned, both VMSetError and AssertLogRelMsgFailed 748 * have been called. So, all the caller needs to do is to propagate 749 * the error status up to PDM. 750 * 751 * @param pNode The node to validate. 752 * @param pszNode The node path, always ends with a slash. Use 753 * "/" for the root config node. 754 * @param pszValidValues Patterns describing the valid value names. See 755 * RTStrSimplePatternMultiMatch for details on the 756 * pattern syntax. 757 * @param pszValidNodes Patterns describing the valid node (key) names. 758 * See RTStrSimplePatternMultiMatch for details on 759 * the pattern syntax. 760 * @param pszWho Who is calling. 761 * @param uInstance The instance number of the caller. 762 */ 763 VMMR3DECL(int) CFGMR3ValidateConfig(PCFGMNODE pNode, const char *pszNode, 764 const char *pszValidValues, const char *pszValidNodes, 765 const char *pszWho, uint32_t uInstance) 766 { 767 /* Input validation. */ 768 AssertPtrNullReturn(pNode, VERR_INVALID_POINTER); 769 AssertPtrReturn(pszNode, VERR_INVALID_POINTER); 770 Assert(*pszNode && pszNode[strlen(pszNode) - 1] == '/'); 771 AssertPtrReturn(pszValidValues, VERR_INVALID_POINTER); 772 AssertPtrReturn(pszValidNodes, VERR_INVALID_POINTER); 773 AssertPtrReturn(pszWho, VERR_INVALID_POINTER); 774 775 if (pNode) 776 { 777 /* 778 * Enumerate the leafs and check them against pszValidValues. 779 */ 780 for (PCFGMLEAF pLeaf = pNode->pFirstLeaf; pLeaf; pLeaf = pLeaf->pNext) 781 { 782 if (!RTStrSimplePatternMultiMatch(pszValidValues, RTSTR_MAX, 783 pLeaf->szName, pLeaf->cchName, 784 NULL)) 785 { 786 AssertLogRelMsgFailed(("%s/%u: Value '%s/%s' didn't match '%s'\n", 787 pszWho, uInstance, pszNode, pLeaf->szName, pszValidValues)); 788 return VMSetError(pNode->pVM, VERR_CFGM_CONFIG_UNKNOWN_VALUE, RT_SRC_POS, 789 N_("Unknown configuration value '%s/%s' found in the configuration of %s instance #%u"), 790 pszNode, pLeaf->szName, pszWho, uInstance); 791 } 792 793 } 794 795 /* 796 * Enumerate the child nodes and check them against pszValidNodes. 797 */ 798 for (PCFGMNODE pChild = pNode->pFirstChild; pChild; pChild = pChild->pNext) 799 { 800 if (!RTStrSimplePatternMultiMatch(pszValidNodes, RTSTR_MAX, 801 pChild->szName, pChild->cchName, 802 NULL)) 803 { 804 AssertLogRelMsgFailed(("%s/%u: Node '%s/%s' didn't match '%s'\n", 805 pszWho, uInstance, pszNode, pChild->szName, pszValidNodes)); 806 return VMSetError(pNode->pVM, VERR_CFGM_CONFIG_UNKNOWN_NODE, RT_SRC_POS, 807 N_("Unknown configuration node '%s/%s' found in the configuration of %s instance #%u"), 808 pszNode, pChild->szName, pszWho, uInstance); 809 } 810 } 811 } 812 813 /* All is well. */ 814 return VINF_SUCCESS; 815 } 816 735 817 736 818
Note:
See TracChangeset
for help on using the changeset viewer.