📄 cimconfigcommand.cpp
字号:
static const char PROPERTY_VALUE_ALREADY_SET_TO_KEY [] = "Clients.CIMConfig.CIMConfigCommand.PROPERTY_VALUE_ALREADY_SET_TO";//static const char PROPERTY_SET_TO_DEFAULT [] = //"$0 value for the property '$1' is set to default value in CIMServer."; //static const char PROPERTY_SET_TO_DEFAULT_KEY [] = //"Clients.CIMConfig.CIMConfigCommand.PROPERTY_SET_TO_DEFAULT";static const char PLANNED_PROPERTY_SET_TO_DEFAULT [] = "Planned value for the property '$0' is set to default value in CIMServer.";static const char PLANNED_PROPERTY_SET_TO_DEFAULT_KEY [] = "Clients.CIMConfig.CIMConfigCommand.PLANNED_PROPERTY_SET_TO_DEFAULT";static const char CURRENT_PROPERTY_SET_TO_DEFAULT [] = "Current value for the property '$0' is set to default value in CIMServer.";static const char CURRENT_PROPERTY_SET_TO_DEFAULT_KEY [] = "Clients.CIMConfig.CIMConfigCommand.CURRENT_PROPERTY_SET_TO_DEFAULT";static const char PROPERTY_UNSET_IN_FILE [] = "Property '$0' is unset in the configuration file.";static const char PROPERTY_UNSET_IN_FILE_KEY [] = "Clients.CIMConfig.CIMConfigCommand.PROPERTY_UNSET_IN_FILE";//static const char PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING [] = //"$0 value for the property '$1' can not be unset because the CIM server is not running.";//static const char PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING_KEY [] = //"Clients.CIMConfig.CIMConfigCommand.PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING";static const char PLANNED_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING [] = "Planned value for the property '$0' can not be unset because the CIM server is not running.";static const char PLANNED_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING_KEY [] = "Clients.CIMConfig.CIMConfigCommand.PLANNED_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING";static const char CURRENT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING [] = "Current value for the property '$0' can not be unset because the CIM server is not running.";static const char CURRENT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING_KEY [] = "Clients.CIMConfig.CIMConfigCommand.CURRENT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING";static const char DEFAULT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING [] = "Default value for the property '$0' can not be unset because the CIM server is not running.";static const char DEFAULT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING_KEY [] = "Clients.CIMConfig.CIMConfigCommand.DEFAULT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING";static const char PROPERTY_VALUE_ALREADY_UNSET [] = "The property '$0' value is already unset.";static const char PROPERTY_VALUE_ALREADY_UNSET_KEY [] = "Clients.CIMConfig.CIMConfigCommand.PROPERTY_VALUE_ALREADY_UNSET";//static const char VALUES_CANNNOT_BE_LISTED_CIM_NOT_RUNNING [] = //"$0 value of properties can not be listed because the CIM server is not running.";//static const char VALUES_CANNNOT_BE_LISTED_CIM_NOT_RUNNING_KEY [] = //"Clients.CIMConfig.CIMConfigCommand.VALUES_CANNNOT_BE_LISTED_CIM_NOT_RUNNING";static const char PLANNED_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING [] = "Planned value of properties can not be listed because the CIM server is not running.";static const char PLANNED_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING_KEY [] = "Clients.CIMConfig.CIMConfigCommand.PLANNED_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING";static const char CURRENT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING [] = "Current value of properties can not be listed because the CIM server is not running.";static const char CURRENT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING_KEY [] = "Clients.CIMConfig.CIMConfigCommand.CURRENT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING";static const char DEFAULT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING [] = "Default value of properties can not be listed because the CIM server is not running.";static const char DEFAULT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING_KEY [] = "Clients.CIMConfig.CIMConfigCommand.DEFAULT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING";static const char NO_PROPERTIES_FOUND_IN_FILE [] = "No configuration properties found in the configuration file.";static const char NO_PROPERTIES_FOUND_IN_FILE_KEY [] = "Clients.CIMConfig.CIMConfigCommand.NO_PROPERTIES_FOUND_IN_FILE";static const char REQUIRED_ARGS_MISSING [] = "Required arguments missing.";static const char REQUIRED_ARGS_MISSING_KEY [] = "Clients.cimuser.CIMUserCommand.REQUIRED_ARGS_MISSING";static const char ERR_OPTION_NOT_SUPPORTED [] = "Invalid option. Use '--help' to obtain command syntax.";static const char ERR_OPTION_NOT_SUPPORTED_KEY [] = "Clients.CIMConfig.CIMConfigCommand.ERR_OPTION_NOT_SUPPORTED";static const char ERR_USAGE [] = "Incorrect usage. Use '--help' to obtain command syntax.";static const char ERR_USAGE_KEY [] = "Clients.CIMConfig.CIMConfigCommand.ERR_USAGE";//l10n end default messages and keys/** The option character used to specify get config property.*/static const char OPTION_GET = 'g';/** The option character used to specify set config property.*/static const char OPTION_SET = 's';#ifdef PEGASUS_OS_OS400/** The option character used to specify no output to stdout or stderr.*/ static const char OPTION_QUIET_VALUE = 'q';#endif/** The option character used to specify unset config property.*/static const char OPTION_UNSET = 'u';/** The option character used to specify listing of config properties.*/static const char OPTION_LIST = 'l';/** The option character used to specify the current config value.*/static const char OPTION_CURRENT_VALUE = 'c';/** The option character used to specify the planned config value.*/static const char OPTION_PLANNED_VALUE = 'p';/** The option character used to specify the default config value.*/static const char OPTION_DEFAULT_VALUE = 'd';/** The option character used to display help info.*/static const char OPTION_HELP = 'h';/** The option character used to display version info.*/static const char OPTION_VERSION = 'v';static const char LONG_HELP [] = "help";static const char LONG_VERSION [] = "version";/** Constructs a CIMConfigCommand and initializes instance variables.*/CIMConfigCommand::CIMConfigCommand (){ /** Initialize the instance variables. */ _operationType = OPERATION_TYPE_UNINITIALIZED; _propertyName = CIMName (); _propertyValue = String::EMPTY; _currentValueSet = false; _plannedValueSet = false; _defaultValueSet = false;#ifdef PEGASUS_OS_OS400 _defaultQuietSet = false;#endif _hostName = String::EMPTY; /** Build the usage string for the config command. */ usage.reserveCapacity(200); usage.append(USAGE); usage.append(COMMAND_NAME);#ifdef PEGASUS_OS_OS400 usage.append(" -").append(OPTION_GET).append(" name"); usage.append(" [ -").append(OPTION_CURRENT_VALUE); usage.append(" ] [ -").append(OPTION_DEFAULT_VALUE); usage.append(" ] [ -").append(OPTION_PLANNED_VALUE); usage.append(" ] [ -").append(OPTION_QUIET_VALUE).append(" ]\n"); usage.append(" -").append(OPTION_SET).append(" name=value"); usage.append(" [ -").append(OPTION_CURRENT_VALUE); usage.append(" ] [ -").append(OPTION_PLANNED_VALUE); usage.append(" ] [ -").append(OPTION_QUIET_VALUE).append(" ]\n"); usage.append(" -").append(OPTION_UNSET).append(" name"); usage.append(" [ -").append(OPTION_CURRENT_VALUE); usage.append(" ] [ -").append(OPTION_PLANNED_VALUE); usage.append(" ] [ -").append(OPTION_QUIET_VALUE).append(" ]\n"); usage.append(" -").append(OPTION_LIST); usage.append(" [ -").append(OPTION_CURRENT_VALUE); usage.append(" | -").append(OPTION_PLANNED_VALUE).append(" ]\n");#else usage.append(" -").append(OPTION_GET).append(" name"); usage.append(" [ -").append(OPTION_CURRENT_VALUE); usage.append(" ] [ -").append(OPTION_DEFAULT_VALUE); usage.append(" ] [ -").append(OPTION_PLANNED_VALUE).append(" ]\n"); usage.append(" -").append(OPTION_SET).append(" name=value"); usage.append(" [ -").append(OPTION_CURRENT_VALUE); usage.append(" ] [ -").append(OPTION_PLANNED_VALUE).append(" ]\n"); usage.append(" -").append(OPTION_UNSET).append(" name"); usage.append(" [ -").append(OPTION_CURRENT_VALUE); usage.append(" ] [ -").append(OPTION_PLANNED_VALUE).append(" ]\n"); usage.append(" -").append(OPTION_LIST); usage.append(" [ -").append(OPTION_CURRENT_VALUE); usage.append(" | -").append(OPTION_PLANNED_VALUE).append(" ]\n");#endif usage.append(" -").append(OPTION_HELP).append("\n"); usage.append(" --").append(LONG_HELP).append("\n"); usage.append(" --").append(LONG_VERSION).append("\n"); usage.append("Options : \n"); usage.append(" -c - Use current configuration\n"); usage.append(" -d - Use default configuration\n"); usage.append(" -g - Get the value of specified configuration property\n"); usage.append(" -h, --help - Display this help message\n"); usage.append(" -l - Display all the configuration properties\n"); usage.append(" -p - Configuration used on next CIM Server start\n");#ifdef PEGASUS_OS_OS400 usage.append(" -q - Specify quiet mode, avoiding output to stdout or stderr\n");#endif usage.append(" -s - Add or Update configuration property value\n"); usage.append(" -u - Reset configuration property to its default value\n"); usage.append(" --version - Display CIM Server version number\n"); usage.append("\nUsage note: The cimconfig command can be used to update the next planned\n"); usage.append( "configuration without having the CIM Server running. All other options \n"); usage.append( "of the cimconfig command require that the CIM Server is running."); //l10n localize usage#ifdef PEGASUS_HAS_ICU #ifdef PEGASUS_OS_OS400 MessageLoaderParms menuparms("Clients.CIMConfig.CIMConfigCommand.MENU.PEGASUS_OS_OS400",usage); menuparms.msg_src_path = MSG_PATH; usage = MessageLoader::getMessage(menuparms); #else MessageLoaderParms menuparms("Clients.CIMConfig.CIMConfigCommand.MENU.STANDARD",usage); menuparms.msg_src_path = MSG_PATH; usage = MessageLoader::getMessage(menuparms); #endif#endif setUsage (usage);}/** Parses the command line, validates the options, and sets instance variables based on the option arguments.*/void CIMConfigCommand::setCommand (Uint32 argc, char* argv []){ unsigned int i = 0; Uint32 c = 0; String property = String (); String badOptionString = String (); String optString = String (); Uint32 equalsIndex = 0; // // Construct optString // optString.append(OPTION_GET); optString.append(GETOPT_ARGUMENT_DESIGNATOR); optString.append(OPTION_SET); optString.append(GETOPT_ARGUMENT_DESIGNATOR); optString.append(OPTION_UNSET); optString.append(GETOPT_ARGUMENT_DESIGNATOR); optString.append(OPTION_LIST); optString.append(OPTION_CURRENT_VALUE); optString.append(OPTION_PLANNED_VALUE); optString.append(OPTION_DEFAULT_VALUE);#ifdef PEGASUS_OS_OS400 optString.append(OPTION_QUIET_VALUE);#endif optString.append(OPTION_HELP); // // Initialize and parse options // getoopt options (""); options.addFlagspec(optString); //PEP#167 - adding long flag for options : 'help' and 'version' options.addLongFlagspec(LONG_HELP,getoopt::NOARG); options.addLongFlagspec(LONG_VERSION,getoopt::NOARG); options.parse (argc, argv); if (options.hasErrors ()) { CommandFormatException e (options.getErrorStrings () [0]); throw e; } _operationType = OPERATION_TYPE_UNINITIALIZED; // // Get options and arguments from the command line // for (i = options.first (); i < options.last (); i++) { if (options[i].getType () == Optarg::LONGFLAG) { if (options[i].getopt () == LONG_HELP) { if (_operationType != OPERATION_TYPE_UNINITIALIZED) { String param = String (LONG_HELP); // // More than one operation option was found // UnexpectedOptionException e (param); throw e; } _operationType = OPERATION_TYPE_HELP; } else if (options[i].getopt () == LONG_VERSION) { if (_operationType != OPERATION_TYPE_UNINITIALIZED) { String param = String (LONG_VERSION); // // More than one operation option was found // UnexpectedOptionException e (param); throw e; } _operationType = OPERATION_TYPE_VERSION; } } else if (options [i].getType () == Optarg::REGULAR) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -