⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cimcrlcommand.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                        throw e;                    }                    _operationType = _OPERATION_TYPE_ADD;                    break;                }                case _OPTION_REMOVE:                {                    if (_operationType != _OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        UnexpectedOptionException e (_OPTION_REMOVE);                        throw e;                    }                    if (getOpts.isSet (_OPTION_REMOVE) > 1)                    {                        //                        // More than one remove option was found                        //                        DuplicateOptionException e (_OPTION_REMOVE);                        throw e;                    }                    _operationType = _OPERATION_TYPE_REMOVE;                    break;                }                case _OPTION_LIST:                {                    if (_operationType != _OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        UnexpectedOptionException e (_OPTION_LIST);                        throw e;                    }                    if (getOpts.isSet (_OPTION_LIST) > 1)                    {                        //                        // More than one list option was found                        //                        DuplicateOptionException e (_OPTION_LIST);                        throw e;                    }                    _operationType = _OPERATION_TYPE_LIST;                    break;                }                case _OPTION_CRLFILE:                {                    if (getOpts.isSet (_OPTION_CRLFILE) > 1)                    {                        //                        // More than one cert file option was found                        //                        DuplicateOptionException e (_OPTION_CRLFILE);                        throw e;                    }                    _crlFile = getOpts [i].Value ();                    _crlFileSet = true;                    break;                }                case _OPTION_ISSUERNAME:                {                    if (getOpts.isSet (_OPTION_ISSUERNAME) > 1)                    {                        //                        // More than one issuer name option was found                        //                        DuplicateOptionException e (_OPTION_ISSUERNAME);                        throw e;                    }                    _issuer = getOpts [i].Value ();                    _issuerSet = true;                    break;                }                default:                {                    PEGASUS_ASSERT(false);                }            }        }    }    if ( _operationType == _OPERATION_TYPE_UNINITIALIZED )    {        //        // No operation type was specified        // Show the usage        //        CommandFormatException e ( localizeMessage ( MSG_PATH,            REQUIRED_ARGS_MISSING_KEY, REQUIRED_ARGS_MISSING ) );        throw e;    }    if ( _operationType == _OPERATION_TYPE_ADD )    {        //        // For -a option, the required option is -f,        // make sure it is set.        //        if ( !_crlFileSet )        {            //            // A required option is missing            //            MissingOptionException e (_OPTION_CRLFILE);            throw e;        }    }    if ( _operationType == _OPERATION_TYPE_REMOVE )    {        //        // For -r option, the required option is -i,        // make sure it is set.        //        if ( !_issuerSet )        {            //            // A required option is missing            //            MissingOptionException e (_OPTION_ISSUERNAME);            throw e;        }    }}/**    Executes the command and writes the results to the PrintWriters.    @param   outPrintWriter     the ostream to which output should be                                written    @param   errPrintWriter     the ostream to which error output should be                                written    @return  0                  if the command is successful             1                  if an error occurs in executing the command */Uint32 CIMCRLCommand::execute (    ostream& outPrintWriter,    ostream& errPrintWriter){    //    // Options HELP and VERSION    // CIMServer need not be running for these options to work    //    if (_operationType == _OPERATION_TYPE_HELP)    {        errPrintWriter << _usage << endl;        return (RC_SUCCESS);    }    if(_operationType == _OPERATION_TYPE_VERSION)    {        errPrintWriter << "Version " << PEGASUS_PRODUCT_VERSION << endl;        return (RC_SUCCESS);    }    CIMClient client;    client.setTimeout( _timeout );    client.setRequestDefaultLanguages(); //l10n    try    {        client.connectLocal();    }    catch(const CannotConnectException& cce)    {        errPrintWriter << localizeMessage( MSG_PATH,                                 CANNOT_CONNECT_CIMSERVER_NOT_RUNNING_KEY,                                 CANNOT_CONNECT_CIMSERVER_NOT_RUNNING) << endl;        return ( RC_CONNECTION_FAILED );    }    catch(const Exception& e)    {        //l10n        errPrintWriter << e.getMessage() << endl;        return (RC_ERROR);    }    //    // Perform the requested operation    //    switch ( _operationType )    {        case _OPERATION_TYPE_ADD:            try            {                _addCRL( client, outPrintWriter );            }            catch (const CIMException& e)            {                CIMStatusCode code = e.getCode();                if (code == CIM_ERR_INVALID_CLASS)                {                    errPrintWriter << localizeMessage(MSG_PATH,                       CERT_SCHEMA_NOT_LOADED_KEY,                       CERT_SCHEMA_NOT_LOADED) << endl;                }                else                {                    errPrintWriter << e.getMessage() << endl;                }                return ( RC_ERROR );            }            catch (const ConnectionTimeoutException& cte)            {                                       errPrintWriter << localizeMessage(MSG_PATH,                                           CONNECTION_TIMEOUT_KEY,                                           CONNECTION_TIMEOUT);                return ( RC_CONNECTION_TIMEOUT );            }            catch (const Exception& e)            {                errPrintWriter << e.getMessage() << endl;                return ( RC_ERROR );            }            break;        case _OPERATION_TYPE_REMOVE:            try            {                _removeCRL ( client, outPrintWriter );            }            catch (const CIMException& e)            {                CIMStatusCode code = e.getCode();                if (code == CIM_ERR_NOT_FOUND)                {                    errPrintWriter << localizeMessage(MSG_PATH,                            CRL_NOT_FOUND_KEY, CRL_NOT_FOUND) << endl;                    errPrintWriter << e.getMessage()  << endl;                    return ( RC_CRL_DOES_NOT_EXIST );                }                else if (code == CIM_ERR_INVALID_CLASS)                {                    errPrintWriter << localizeMessage(MSG_PATH,                        CERT_SCHEMA_NOT_LOADED_KEY,                        CERT_SCHEMA_NOT_LOADED) << endl;                }                else                {                    errPrintWriter << e.getMessage() << endl;                }                return ( RC_ERROR );            }            catch (const ConnectionTimeoutException& cte)            {                errPrintWriter << localizeMessage(MSG_PATH,                                           CONNECTION_TIMEOUT_KEY,                                           CONNECTION_TIMEOUT);                return ( RC_CONNECTION_TIMEOUT );            }            catch (const Exception& e)            {                errPrintWriter << e.getMessage() << endl;                return ( RC_ERROR );            }            break;        case _OPERATION_TYPE_LIST:            try            {                _listCRL ( client, outPrintWriter );            }            catch (const CIMException& e)            {                CIMStatusCode code = e.getCode();                if (code == CIM_ERR_NOT_FOUND)                {                    errPrintWriter << localizeMessage(MSG_PATH,                            CRL_NOT_FOUND_KEY, CRL_NOT_FOUND) << endl;                    errPrintWriter << e.getMessage()  << endl;                    return ( RC_CRL_DOES_NOT_EXIST );                }                else if (code == CIM_ERR_INVALID_CLASS)                {                    errPrintWriter << localizeMessage(MSG_PATH,                        CERT_SCHEMA_NOT_LOADED_KEY,                        CERT_SCHEMA_NOT_LOADED) << endl;                }                else                {                    errPrintWriter << e.getMessage() << endl;                }                return ( RC_ERROR );            }            catch (const ConnectionTimeoutException& cte)            {                errPrintWriter << localizeMessage(MSG_PATH,                                           CONNECTION_TIMEOUT_KEY,                                           CONNECTION_TIMEOUT);                return ( RC_CONNECTION_TIMEOUT );            }            catch (const Exception& e)            {                errPrintWriter << e.getMessage() << endl;                return ( RC_ERROR );            }            break;    }    return (RC_SUCCESS);}PEGASUS_NAMESPACE_END// exclude main from the Pegasus NamespacePEGASUS_USING_PEGASUS;PEGASUS_USING_STD;////////////////////////////////////////////////////////////////////////////**    Parses the command line, and executes the command.    @param   argc  the number of command line arguments    @param   argv  the string vector of command line arguments    @return  0                  if the command is successful             1                  if an error occurs in executing the command *////////////////////////////////////////////////////////////////////////////int main (int argc, char* argv []){    //l10n set message loading to process locale    MessageLoader::_useProcessLocale = true;    CIMCRLCommand    command = CIMCRLCommand();    int            retCode;    try    {        command.setCommand (argc, argv);    }    catch (const CommandFormatException& cfe)    {        cerr << CIMCRLCommand::COMMAND_NAME << ": " << cfe.getMessage ()             << endl;        cerr << "Use '--help' to obtain command syntax." << endl;        exit (Command::RC_ERROR);    }    retCode = command.execute (cout, cerr);    exit (retCode);    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -