void ForwardingReferenceOverloadCheck::registerMatchers(MatchFinder *Finder) { // Forwarding references require C++11 or later. if (!getLangOpts().CPlusPlus11) return; auto ForwardingRefParm = parmVarDecl( hasType(qualType(rValueReferenceType(), references(templateTypeParmType(hasDeclaration( templateTypeParmDecl().bind("type-parm-decl")))), unless(references(isConstQualified()))))) .bind("parm-var"); DeclarationMatcher findOverload = cxxConstructorDecl( hasParameter(0, ForwardingRefParm), unless(hasAnyParameter( // No warning: enable_if as constructor parameter. parmVarDecl(hasType(isEnableIf())))), unless(hasParent(functionTemplateDecl(has(templateTypeParmDecl( // No warning: enable_if as type parameter. hasDefaultArgument(isEnableIf()))))))) .bind("ctor"); Finder->addMatcher(findOverload, this); }
void UseNodiscardCheck::registerMatchers(MatchFinder *Finder) { // If we use ``[[nodiscard]]`` attribute, we require at least C++17. Use a // macro or ``__attribute__`` with pre c++17 compilers by using // ReplacementString option. if ((NoDiscardMacro == "[[nodiscard]]" && !getLangOpts().CPlusPlus17) || !getLangOpts().CPlusPlus) return; auto FunctionObj = cxxRecordDecl(hasAnyName("::std::function", "::boost::function")); // Find all non-void const methods which have not already been marked to // warn on unused result. Finder->addMatcher( cxxMethodDecl( allOf(isConst(), isDefinitionOrInline(), unless(anyOf( returns(voidType()), isNoReturn(), isOverloadedOperator(), isVariadic(), hasTemplateReturnType(), hasClassMutableFields(), isConversionOperator(), hasAttr(clang::attr::WarnUnusedResult), hasType(isInstantiationDependentType()), hasAnyParameter(anyOf( parmVarDecl(anyOf(hasType(FunctionObj), hasType(references(FunctionObj)))), hasType(isNonConstReferenceOrPointer()), hasParameterPack())))))) .bind("no_discard"), this); }
void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) { const auto WrongUse = anyOf( hasParent( binaryOperator( anyOf(has(integerLiteral(equals(0))), allOf(anyOf(hasOperatorName("<"), hasOperatorName(">="), hasOperatorName(">"), hasOperatorName("<=")), hasEitherOperand(integerLiteral(equals(1)))))) .bind("SizeBinaryOp")), hasParent(implicitCastExpr( hasImplicitDestinationType(isBoolType()), anyOf( hasParent(unaryOperator(hasOperatorName("!")).bind("NegOnSize")), anything()))), hasParent(explicitCastExpr(hasDestinationType(isBoolType())))); Finder->addMatcher( memberCallExpr( on(expr(anyOf(hasType(namedDecl(stlContainer())), hasType(pointsTo(namedDecl(stlContainer()))), hasType(references(namedDecl(stlContainer()))))) .bind("STLObject")), callee(methodDecl(hasName("size"))), WrongUse).bind("SizeCallExpr"), this); }
void NonConstReferences::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( parmVarDecl( unless(isInstantiated()), hasType(references( qualType(unless(isConstQualified())).bind("referenced_type"))), unless(hasType(rValueReferenceType()))) .bind("param"), this); }
// Return the number of body int GLC_WorldHandle::numberOfBody() const { QList<GLC_StructReference*> referenceList(references()); const int size= referenceList.size(); int numberOfBody= 0; for (int i= 0; i < size; ++i) { numberOfBody+= referenceList.at(i)->numberOfBody(); } return numberOfBody; }
void StringReferenceMemberCheck::registerMatchers( ast_matchers::MatchFinder *Finder) { // Look for const references to std::string or ::string. auto String = anyOf(recordDecl(hasName("::std::basic_string")), recordDecl(hasName("::string"))); auto ConstString = qualType(isConstQualified(), hasDeclaration(String)); // Ignore members in template instantiations. Finder->addMatcher(fieldDecl(hasType(references(ConstString)), unless(isInstantiated())).bind("member"), this); }
int GLC_WorldHandle::representationCount() const { QList<GLC_StructReference*> referenceList(references()); const int size= referenceList.size(); int count= 0; for (int i= 0; i < size; ++i) { if (referenceList.at(i)->hasRepresentation()) ++count; } return count; }
void SlicingCheck::registerMatchers(MatchFinder *Finder) { // When we see: // class B : public A { ... }; // A a; // B b; // a = b; // The assignment is OK if: // - the assignment operator is defined as taking a B as second parameter, // or // - B does not define any additional members (either variables or // overrides) wrt A. // // The same holds for copy ctor calls. This also captures stuff like: // void f(A a); // f(b); // Helpers. const auto OfBaseClass = ofClass(cxxRecordDecl().bind("BaseDecl")); const auto IsDerivedFromBaseDecl = cxxRecordDecl(isDerivedFrom(equalsBoundNode("BaseDecl"))) .bind("DerivedDecl"); const auto HasTypeDerivedFromBaseDecl = anyOf(hasType(IsDerivedFromBaseDecl), hasType(references(IsDerivedFromBaseDecl))); const auto IsWithinDerivedCtor = hasParent(cxxConstructorDecl(ofClass(equalsBoundNode("DerivedDecl")))); // Assignement slicing: "a = b;" and "a = std::move(b);" variants. const auto SlicesObjectInAssignment = callExpr(callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(), isMoveAssignmentOperator()), OfBaseClass)), hasArgument(1, HasTypeDerivedFromBaseDecl)); // Construction slicing: "A a{b};" and "f(b);" variants. Note that in case of // slicing the letter will create a temporary and therefore call a ctor. const auto SlicesObjectInCtor = cxxConstructExpr( hasDeclaration(cxxConstructorDecl( anyOf(isCopyConstructor(), isMoveConstructor()), OfBaseClass)), hasArgument(0, HasTypeDerivedFromBaseDecl), // We need to disable matching on the call to the base copy/move // constructor in DerivedDecl's constructors. unless(IsWithinDerivedCtor)); Finder->addMatcher( expr(anyOf(SlicesObjectInAssignment, SlicesObjectInCtor)).bind("Call"), this); }
bool WorkbenchIntroManager::CloseIntro(IIntroPart::Pointer part) { if (!introPart || introPart != part) { return false; } IWorkbenchPart::Pointer introView = GetIntroAdapterPart(); if (introView) { //assumption is that there is only ever one intro per workbench //if we ever support one per window then this will need revisiting IWorkbenchPage::Pointer page = introView->GetSite()->GetPage(); if (IntroIsView()) { IViewReference::Pointer reference = page->FindViewReference( IntroConstants::INTRO_VIEW_ID); page->HideView(introView.Cast<IViewPart>()); if (!reference || reference->GetPart(false) == 0) { introPart = nullptr; return true; } return false; } else { QList<IEditorReference::Pointer> references(page->FindEditors(IEditorInput::Pointer(nullptr), IntroConstants::INTRO_EDITOR_ID, IWorkbenchPage::MATCH_ID)); Q_ASSERT(references.size() < 2); if (references.empty()) return false; if (page->CloseEditors(references, false)) { introPart = nullptr; return true; } return false; } } // if there is no part then null our reference introPart = nullptr; return true; }
void MoveConstArgCheck::registerMatchers(MatchFinder *Finder) { if (!getLangOpts().CPlusPlus) return; auto MoveCallMatcher = callExpr(callee(functionDecl(hasName("::std::move"))), argumentCountIs(1), unless(isInTemplateInstantiation())) .bind("call-move"); Finder->addMatcher(MoveCallMatcher, this); auto ConstParamMatcher = forEachArgumentWithParam( MoveCallMatcher, parmVarDecl(hasType(references(isConstQualified())))); Finder->addMatcher(callExpr(ConstParamMatcher).bind("receiving-expr"), this); Finder->addMatcher(cxxConstructExpr(ConstParamMatcher).bind("receiving-expr"), this); }
void Data::clone(){ if(hasData()){ int cnt = references(mData); // cnt == 0 data points to external, unmanaged data // cnt > 1 data points to another Data's cloned data // cnt == 1 data points to my own cloned data // allocate new memory if not sole owner of data if(cnt!=1){ Data old(*this); realloc(type()); assign(old); } } else{ realloc(type()); } }
void deleteFreeSymbol(SYMBOL * sPtr, int checkReferences) { SYMBOL * context; context = sPtr->context; root = (SYMBOL *)((CELL *)context->contents)->aux; if(!deleteSymbol(sPtr->name)) return; ((CELL *)context->contents)->aux = (UINT)root; /* root may have changed */ /* printf("deleting: %s\n", sPtr->name); */ deleteList((CELL *)sPtr->contents); if(checkReferences) references(sPtr, TRUE); freeMemory(sPtr->name); freeMemory(sPtr); }
/// @returns /// Offset to last unchanged character. Returns -1 if no change was possible. static int step(QString &content, QStringList &texts, int &baseOffset, int from) { QRegExp ref("<ref ?[^>]*>(.*)</ref>"); ref.setMinimal(true); QRegExp references("<references\\s*/?\\s*>", Qt::CaseInsensitive); int referencesOffs = references.indexIn(content, from); int refOffs = ref.indexIn(content, from); if (referencesOffs == -1) { if (refOffs == -1) return -1; addRef(ref, refOffs, content, texts, baseOffset); return refOffs; } else { if (refOffs != -1 && refOffs < referencesOffs) { addRef(ref, refOffs, content, texts, baseOffset); return refOffs; } QString text = "<ul><li>Notes:</li></ul>\n<ol>\n"; for (int i = 0; i < texts.length(); ++i) { text += QString("<li><span id=\"cite_note-%1\">[[#cite_ref-%1|^]] %2</span></li>\n") .arg(baseOffset + i + 1) .arg(texts[i]); } text += "</ol>\n"; content.remove(referencesOffs, references.matchedLength()); content.insert(referencesOffs, text); baseOffset += texts.length(); texts.clear(); return referencesOffs; } }
void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) { // Only register the matchers for C++; the functionality currently does not // provide any benefit to other languages, despite being benign. if (!getLangOpts().CPlusPlus) return; const auto ValidContainer = cxxRecordDecl(isSameOrDerivedFrom( namedDecl( has(cxxMethodDecl( isConst(), parameterCountIs(0), isPublic(), hasName("size"), returns(qualType(isInteger(), unless(booleanType())))) .bind("size")), has(cxxMethodDecl(isConst(), parameterCountIs(0), isPublic(), hasName("empty"), returns(booleanType())) .bind("empty"))) .bind("container"))); const auto WrongUse = anyOf( hasParent(binaryOperator( matchers::isComparisonOperator(), hasEitherOperand(ignoringImpCasts(anyOf( integerLiteral(equals(1)), integerLiteral(equals(0)))))) .bind("SizeBinaryOp")), hasParent(implicitCastExpr( hasImplicitDestinationType(booleanType()), anyOf( hasParent(unaryOperator(hasOperatorName("!")).bind("NegOnSize")), anything()))), hasParent(explicitCastExpr(hasDestinationType(booleanType())))); Finder->addMatcher( cxxMemberCallExpr(on(expr(anyOf(hasType(ValidContainer), hasType(pointsTo(ValidContainer)), hasType(references(ValidContainer)))) .bind("STLObject")), callee(cxxMethodDecl(hasName("size"))), WrongUse) .bind("SizeCallExpr"), this); }
void BleuScoreFeature::SetParameter(const std::string& key, const std::string& value) { if (key == "references") { vector<string> referenceFiles = Tokenize(value, ","); UTIL_THROW_IF2(referenceFiles.size() == 0, "No reference file"); vector<vector<string> > references(referenceFiles.size()); for (size_t i =0; i < referenceFiles.size(); ++i) { ifstream in(referenceFiles[i].c_str()); if (!in) { UTIL_THROW2("Unable to load references from " << referenceFiles[i]); } string line; while (getline(in,line)) { /* if (GetSearchAlgorithm() == ChartDecoding) { stringstream tmp; tmp << "<s> " << line << " </s>"; line = tmp.str(); } */ references[i].push_back(line); } if (i > 0) { if (references[i].size() != references[i-1].size()) { UTIL_THROW2("Reference files are of different lengths"); } } in.close(); } // for (size_t i =0; i < referenceFiles.size(); ++i) { //Set the references in the bleu feature LoadReferences(references); } else { StatefulFeatureFunction::SetParameter(key, value); } }
IWorkbenchPart::Pointer WorkbenchIntroManager::GetIntroAdapterPart() const { QList<IWorkbenchWindow::Pointer> windows(this->workbench->GetWorkbenchWindows()); for (int i = 0; i < windows.size(); i++) { IWorkbenchWindow::Pointer window = windows[i]; WorkbenchPage::Pointer page = window->GetActivePage().Cast<WorkbenchPage>(); if (!page) { continue; } if (IntroIsView()) { QList<IPerspectiveDescriptor::Pointer> perspDescs(page->GetOpenPerspectives()); for (int j = 0; j < perspDescs.size(); j++) { IPerspectiveDescriptor::Pointer descriptor = perspDescs[j]; IViewReference::Pointer reference = page->FindPerspective(descriptor)->FindView( IntroConstants::INTRO_VIEW_ID); if (reference) { return reference->GetView(false); } } } else { QList<IEditorReference::Pointer> references(page->FindEditors(IEditorInput::Pointer(nullptr), IntroConstants::INTRO_EDITOR_ID, IWorkbenchPage::MATCH_ID)); Q_ASSERT(references.size() < 2); if (references.size() == 1) return references.front()->GetEditor(false); } } return IWorkbenchPart::Pointer(nullptr); }
bool WriteMail::buildMail(bool includeSignature) { QMailAccountId accountId(m_accountSelection->itemData(m_accountSelection->currentIndex()).value<QMailAccountId>()); // Ensure the signature of the selected account is used if (accountId.isValid() && includeSignature) { m_composerInterface->setSignature(signature(accountId)); } // Extract the message from the composer QMailMessage newMail = m_composerInterface->message(); // Retain the old mail properties if they're configured newMail.setId(mail.id()); newMail.setParentFolderId(mail.parentFolderId()); newMail.setContentScheme(mail.contentScheme()); newMail.setContentIdentifier(mail.contentIdentifier()); newMail.setServerUid(mail.serverUid()); newMail.setCustomFields(mail.customFields()); newMail.setDate(QMailTimeStamp::currentDateTime()); newMail.setStatus(QMailMessage::Outgoing, true); newMail.setStatus(QMailMessage::ContentAvailable, true); newMail.setStatus(QMailMessage::PartialContentAvailable, true); newMail.setStatus(QMailMessage::Read, true); if (accountId.isValid()) { newMail.setParentAccountId(accountId); newMail.setFrom(QMailAccount(accountId).fromAddress()); } if (!newMail.parentFolderId().isValid()) { newMail.setParentFolderId(QMailFolder::LocalStorageFolderId); } if (m_precursorId.isValid()) { newMail.setInResponseTo(m_precursorId); newMail.setResponseType(m_replyAction); QMailMessage precursor(m_precursorId); // Set the In-Reply-To and References headers in our outgoing message QString references(precursor.headerFieldText("References")); if (references.isEmpty()) { references = precursor.headerFieldText("In-Reply-To"); } QString precursorId(precursor.headerFieldText("Message-ID")); if (!precursorId.isEmpty()) { newMail.setHeaderField("In-Reply-To", precursorId); if (!references.isEmpty()) { references.append(' '); } references.append(precursorId); } if (!references.isEmpty()) { // TODO: Truncate references if they're too long newMail.setHeaderField("References", references); } } mail = newMail; return true; }
/** * @brief Get all referenced data arrays associated with this tag. * * Always uses filter that accepts all sources. * * @return The filtered dimensions as a vector */ std::vector<DataArray> references() const { return references(util::AcceptAll<DataArray>()); }
/// The number of instances with the same shared contents including this one. inline Counter instances() const { return data->references(); }
void KDevelop::initReferenceCounting() { references(); oldReferences(); }
int main(int argc, char** argv) { const char* arg0 = System::findBaseName(argv[0]); #ifdef PEGASUS_OS_ZOS // for z/OS set stdout and stderr to EBCDIC setEBCDICEncoding(STDOUT_FILENO); setEBCDICEncoding(STDERR_FILENO); #endif #ifdef PEGASUS_OS_PASE // Allow user group name larger than 8 chars in PASE environemnt setenv("PASE_USRGRP_LIMITED","N",1); #endif // If no arguments, simply print usage message and terminate. MessageLoader::_useProcessLocale = true; if (argc == 1) { showUsage(); exit(0); } //****** Show the args diagnostic display if (strcmp(argv[1],"displayargs") == 0) { cout << "argc = " << argc << endl; for (int i = 0; i < argc; i++) cout << "argv[" << i << "] = " << argv[i] << endl; } // Get options (from command line and from configuration file); this // removes corresponding options and their arguments from the command // line. OptionManager om; Options opts; try { // assume that the config file is local to directory where called. String testHome = "."; om.setMessagePath("pegasus/pegasusCLI"); GetOptions(om, argc, argv, testHome); // Initialize all of the function input parameters. opts.location = String::EMPTY; #ifdef PEGASUS_HAS_SSL opts.ssl = false; opts.clientCert = String::EMPTY; opts.clientKey = String::EMPTY; #endif opts.nameSpace = "root/cimv2"; opts.cimCmd = "unknown"; opts.className = CIMName(); opts.objectName = "unknown"; opts.isXmlOutput = false; opts.outputFormatType = OUTPUT_MOF; opts.user = String::EMPTY; opts.password = String::EMPTY; opts.verboseTest = false; opts.localOnly = true; opts.deepInheritance = false; opts.includeQualifiers = true; opts.includeClassOrigin = false; opts.assocClassName = String::EMPTY; opts.assocClass = CIMName(); opts.resultClassName = String::EMPTY; opts.resultClass = CIMName(); opts.role = String::EMPTY; opts.resultRole = String::EMPTY; opts.propertyListText = String::EMPTY; opts.propertyList.clear(); opts.propertyName = String::EMPTY; opts.methodName = CIMName("unknown"); opts.delay = 0; opts.trace = 0; opts.count= 97832; opts.repeat = 0; opts.time = false; opts.termCondition = 0; opts.debug = false; opts.queryLanguage = "WQL"; // move any other input parameters left to the extraParams List CheckCommonOptionValues(om, argv, opts); /* note that this is in error since it assumes a fixed number of parameters will be used for all of the commands It needs to be expanded to allow for a variable minimum number of commands before it picks up any extras */ if (argc > 2) { for (int i = 2 ; i < argc ; i++ ) opts.extraParams.append(argv[i]); } } catch(CIMException& e) { cerr << argv[0] << " Caught CIMException during init: " << "\n" << e.getMessage() << endl; exit(1); } catch (Exception& e) { cerr << argv[0] << ": " << e.getMessage() << endl; exit(1); } catch(...) { cerr << argv[0] << " Caught General Exception During Init:" << endl; exit(1); } // if there is still an arg1, assume it is the command name. if (argc > 1) { opts.cimCmd = argv[1]; } else { cout << " Command name must be first parameter or --c parameter." << " \n ex. " << argv[0] << " enumerateclasses\n" << "Enter " << argv[0] << " -h for help." << endl; exit(1); } // if the trace option was set initialize the trace function. if (opts.trace != 0) { const char* tmpDir = getenv ("PEGASUS_TMP"); if (tmpDir == NULL) { tmpDir = "."; } String traceFile (tmpDir); traceFile.append("/cliTrace.trc"); Tracer::setTraceFile (traceFile.getCString()); Tracer::setTraceComponents("ALL"); Tracer::setTraceLevel(opts.trace); } // Find the command and save index in cmdIndex Uint32 cmdIndex = 0; if (opts.verboseTest && opts.debug) cout << "TEST Command = " << opts.cimCmd << endl; // Find the command or the short cut name for( ; cmdIndex < NUM_COMMANDS; cmdIndex++ ) { if ((String::equalNoCase(opts.cimCmd, CommandTable[cmdIndex].CommandName)) || (opts.cimCmd == CommandTable[cmdIndex].ShortCut)) // Break if found break; } Stopwatch totalElapsedExecutionTime; totalElapsedExecutionTime.start(); // Now try to open the connection to the cim server CIMClient client; try { if (CommandTable[cmdIndex].ID_Command != ID_ShowOptions) { String host; HostLocator addr; if (opts.location != String::EMPTY) { addr.setHostLocator(opts.location); if (!addr.isValid()) { throw InvalidLocatorException(opts.location); } host = addr.getHost(); } Uint32 portNumber = System::lookupPort( WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT ); // Set up SSL port and flag for verbose display // if SSL included in build String useSSL; #ifdef PEGASUS_HAS_SSL if (opts.ssl) { portNumber = System::lookupPort( WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT ); } useSSL = " ssl="; useSSL.append((opts.ssl)? "true" : "false"); #endif if (host != String::EMPTY && addr.isPortSpecified()) { portNumber = addr.getPort(); } //check whether we should use connect() or connectLocal() //an empty location option indicates to use connectLocal() if (String::equal(host, String::EMPTY)) { if (opts.verboseTest) { cout << "Connect with connectLocal" << endl; } client.connectLocal(); } else { if (opts.verboseTest) { cout << "Connect to " << host << " port=" << portNumber << useSSL << " for User="******"SSL options " << "Cert = " << opts.clientCert << "clientKey = " << opts.clientKey << endl; } client.connect(host, portNumber, SSLContext("", opts.clientCert, opts.clientKey, NULL, "ssl.rnd"), opts.user, opts.password); } else { client.connect(host, portNumber, SSLContext("", NULL, "ssl.rnd"), opts.user, opts.password); } } else //connect over HTTP { client.connect(host, portNumber, opts.user, opts.password); } #else client.connect(host, portNumber, opts.user, opts.password); #endif } } } catch(Exception &e) { cerr << "Pegasus Exception: " << e.getMessage() << " Trying to connect to " << opts.location << endl; exit(1); } // Register for Client statistics. ClientStatistics statistics = ClientStatistics(); client.registerClientOpPerformanceDataHandler(statistics); if (opts.delay != 0) { // This was a test because of some delay caused problems. Threads::sleep(opts.delay * 1000); } // If the timeout is not zero, set the timeout for this connection. if (opts.connectionTimeout != 0) { client.setTimeout(opts.connectionTimeout * 1000); } // Save the total connect time. double totalConnectTime = opts.elapsedTime.getElapsed(); double totalTime = 0; Uint32 repeatCount = opts.repeat; double maxTime = 0; double minTime = 10000000; Uint64 serverTotalTime = 0; Uint64 maxServerTime = 0; Uint64 minServerTime = 10000000; Uint64 rtTotalTime = 0; Uint64 maxRtTime = 0; Uint64 minRtTime = 10000000; // Process the input command within a try block. try { // Loop to repeat the command a number of times. do { // or exit with error through default of case logic switch(CommandTable[cmdIndex].ID_Command) { case ID_EnumerateInstanceNames : if (!_getClassNameInput(argc, argv, opts, true)) exit(1); enumerateInstanceNames(client, opts); break; case ID_EnumerateAllInstanceNames : if (!_getClassNameInput(argc, argv, opts, false)) exit(1); enumerateAllInstanceNames(client, opts); break; case ID_EnumerateInstances : if (!_getClassNameInput(argc, argv, opts, true)) exit(1); enumerateInstances(client, opts); break; case ID_GetInstance : if (!_getObjectNameInput(argc, argv, opts, true)) exit(1); getInstance(client, opts); break; case ID_EnumerateClassNames : if (!_getClassNameInput(argc, argv, opts, false)) exit(1); enumerateClassNames(client, opts); break; case ID_EnumerateClasses : if (!_getClassNameInput(argc, argv, opts, false)) exit(1); enumerateClasses(client, opts); break; case ID_GetClass : if (!_getClassNameInput(argc, argv, opts, true)) exit(1); getClass(client, opts); break; case ID_CreateInstance : if (!_getClassNameInput(argc, argv, opts, true)) exit(1); createInstance(client, opts); break; case ID_DeleteInstance : if (!_getObjectNameInput(argc, argv, opts, true)) exit(1); deleteInstance(client, opts); break; case ID_CreateClass : cerr << "CreateClass not implemented" << endl; break; case ID_DeleteClass : if (!_getClassNameInput(argc, argv, opts, true)) exit(1); deleteClass(client, opts); break; case ID_GetProperty : if (argc != 4) { cout << "Usage: " << arg0 << " getproperty <instancename> <propertyname>" << endl; exit(1); } opts.instanceName = argv[2]; opts.inputObjectName = argv[2]; opts.propertyName = argv[3]; getProperty(client, opts); break; case ID_SetProperty : if (argc != 5) cout <<"Usage: " << arg0 << " setproperty instancename propertyname value " << endl; setProperty(client, opts); break; case ID_EnumerateQualifiers : enumerateQualifiers(client, opts); break; case ID_SetQualifier : cerr << "SetQualifer not implemented" << endl; exit(1); break; case ID_GetQualifier : if (!_getQualifierNameInput(argc, argv, opts)) exit(1); getQualifier(client, opts); break; case ID_DeleteQualifier : if (!_getQualifierNameInput(argc, argv, opts)) exit(1); deleteQualifier(client, opts); break; /* Reference params are [IN] <objectName> ObjectName, [IN,OPTIONAL,NULL] <className> ResultClass = NULL, [IN,OPTIONAL,NULL] string Role = NULL, [IN,OPTIONAL] boolean IncludeQualifiers = false, [IN,OPTIONAL] boolean IncludeClassOrigin = false, [IN,OPTIONAL,NULL] string PropertyList [] = NULL */ case ID_References : if (!_getObjectNameInput(argc, argv, opts, true)) exit(1); references(client, opts); break; case ID_ReferenceNames : if (!_getObjectNameInput(argc, argv, opts, true)) exit(1); referenceNames(client, opts); break; case ID_Associators : if (!_getObjectNameInput(argc, argv, opts, true)) exit(1); associators(client, opts); break; case ID_AssociatorNames : if (!_getObjectNameInput(argc, argv, opts, true)) exit(1); associatorNames(client,opts); break; case ID_EnumerateNamespaces : // Note that the following constants are fixed here. We // should be getting them from the environment to assure // that others know that we are using them. opts.className = CIMName("CIM_Namespace"); if (argc > 2) { opts.nameSpace = argv[2]; opts.inputObjectName = argv[2]; } else // set nameSpace to interop namespace name opts.nameSpace = PEGASUS_NAMESPACENAME_INTEROP.getString(); enumerateNamespaces_Namespace(client,opts); break; /* CIMValue invokeMethod( const CIMNamespaceName& nameSpace, const CIMObjectPath& instanceName, const CIMName& methodName, const Array<CIMParamValue>& inParameters, Array<CIMParamValue>& outParameters */ case ID_InvokeMethod : if (argc < 4) { cout << "Usage: InvokeMethod requires that object and" " method names be specified.\n" "Input parameters are optional and can be" " specified with the -ip option or as" " additional parameters to this call. " "Enter each input parameter as name=value" " (no spaces around equal sign)." << endl; exit(1); } opts.objectName = argv[2]; opts.inputObjectName = argv[2]; opts.methodName = CIMName(argv[3]); // If there are any extra arguments they must be parameters // These parameters can be used in addtion to parameters // ifrom the -ip option setting. Parameters found here must // be key=value pairs or they will generate an exception. if (argc > 4) { // get input params from command line for (Sint32 i = 4 ; i < argc; i++) { CIMParamValue pv; String s = argv[i]; pv = _createMethodParamValue(s, opts); opts.inParams.append(pv); } } invokeMethod(client, opts); break; case ID_ShowOptions : showUsage(); break; case ID_ExecQuery: opts.query = argv[2]; if (argc==4) opts.queryLanguage = argv[3]; executeQuery(client, opts); break; case ID_StatisticsOn: setObjectManagerStatistics(client, true); break; case ID_StatisticsOff: setObjectManagerStatistics(client, false); break; //case ID_Unknown : default: cout << "Invalid Command. Command name must be first parm" " or --c parameter." << " \n ex. " << arg0 << " enumerateclasses\n" << "Enter " << argv[0] << " -h for help." << endl; exit(1); break; } if (opts.repeat > 0) { if (opts.verboseTest) { cout << "Repetitition " << opts.repeat << endl; } opts.repeat--; if (opts.time) { totalTime += opts.saveElapsedTime; maxTime = LOCAL_MAX(maxTime, opts.saveElapsedTime); minTime = LOCAL_MIN(minTime, opts.saveElapsedTime); rtTotalTime += (returnedPerformanceData.roundTripTime); maxRtTime = LOCAL_MAX(maxRtTime, returnedPerformanceData.roundTripTime); minRtTime = LOCAL_MIN(minRtTime, returnedPerformanceData.roundTripTime); if (returnedPerformanceData.serverTimeKnown) { serverTotalTime += (returnedPerformanceData.serverTime); maxServerTime = LOCAL_MAX(maxServerTime, returnedPerformanceData.serverTime); minServerTime = LOCAL_MIN(minServerTime, returnedPerformanceData.serverTime); } } } } while (opts.repeat > 0 ); if (opts.time) { if (repeatCount == 0) { cout << CommandTable[cmdIndex].CommandName << " " << opts.inputObjectName << " Time= " << opts.saveElapsedTime << " Sec " << " SvrTime= " << CIMValue(returnedPerformanceData.serverTime).toString() << " us " << " RtTime= " << CIMValue(returnedPerformanceData.roundTripTime). toString() << " us " << "Req size= " << CIMValue(returnedPerformanceData.requestSize).toString() << " b Resp size= " << CIMValue(returnedPerformanceData.responseSize).toString() << " b" << endl; } else { cout << CommandTable[cmdIndex].CommandName << " " << opts.inputObjectName << " Total Time " << totalTime << " for " << repeatCount << " ops. Avg= " << (totalTime * 1000000)/repeatCount << " us min= " << minTime * 1000000 << " us max= " << (maxTime * 1000000) << " us SvrTime avg= " << CIMValue(serverTotalTime/repeatCount).toString() << " us SvrTime min= " << CIMValue(minServerTime).toString() << " us SvrTime max= " << CIMValue(maxServerTime).toString() << " us" << " RtTime avg= " << CIMValue(rtTotalTime/repeatCount).toString() << " us RtTime min= " << CIMValue(minRtTime).toString() << " us RtTime max= " << CIMValue(maxRtTime).toString() << " us" << endl; } } } catch(CIMException& e) { cerr << argv[0] << " CIMException: "<<" Cmd= " << opts.cimCmd << " Object= " << opts.inputObjectName << "\n" << e.getMessage() << endl; opts.termCondition = 1; } catch(Exception& e) { PEGASUS_STD(cerr) << argv[0] << " Pegasus Exception: " << e.getMessage() << ". Cmd = " << opts.cimCmd << " Object = " << opts.inputObjectName << PEGASUS_STD(endl); opts.termCondition = 1; } catch(...) { cerr << argv[0] << " Caught General Exception:" << endl; opts.termCondition = 1; } totalElapsedExecutionTime.stop(); if (opts.time) { // if abnormal term, dump all times if (opts.termCondition == 1) { cout << "Exception" << endl; cout << "Prev Time " << opts.saveElapsedTime << " Sec" << endl; opts.saveElapsedTime = opts.elapsedTime.getElapsed(); cout << "Last Time " << opts.saveElapsedTime << " Sec" << endl; cout << "Total Time " << totalTime << " for " << repeatCount << " operations. Avg.= " << totalTime/repeatCount << " min= " << minTime << " max= " << maxTime << endl; } cout << "Total Elapsed Time= " << totalElapsedExecutionTime.getElapsed() << " Sec. Terminated at " << System::getCurrentASCIITime() << endl; } if (opts.delay != 0) { Threads::sleep(opts.delay * 1000); } return(opts.termCondition); }
void NewsArticle::assemble() { Headers::Base *h; QCString newHead = ""; //Message-ID if((h = messageID(false)) != 0) newHead += h->as7BitString() + "\n"; //Control if((h = control(false)) != 0) newHead += h->as7BitString() + "\n"; //Supersedes if((h = supersedes(false)) != 0) newHead += h->as7BitString() + "\n"; //From h = from(); // "From" is mandatory newHead += h->as7BitString() + "\n"; //Subject h = subject(); // "Subject" is mandatory newHead += h->as7BitString() + "\n"; //To if((h = to(false)) != 0) newHead += h->as7BitString() + "\n"; //Newsgroups if((h = newsgroups(false)) != 0) newHead += h->as7BitString() + "\n"; //Followup-To if((h = followUpTo(false)) != 0) newHead += h->as7BitString() + "\n"; //Reply-To if((h = replyTo(false)) != 0) newHead += h->as7BitString() + "\n"; //Mail-Copies-To if((h = mailCopiesTo(false)) != 0) newHead += h->as7BitString() + "\n"; //Date h = date(); // "Date" is mandatory newHead += h->as7BitString() + "\n"; //References if((h = references(false)) != 0) newHead += h->as7BitString() + "\n"; //Lines h = lines(); // "Lines" is mandatory newHead += h->as7BitString() + "\n"; //Organization if((h = organization(false)) != 0) newHead += h->as7BitString() + "\n"; //User-Agent if((h = userAgent(false)) != 0) newHead += h->as7BitString() + "\n"; //Mime-Version newHead += "MIME-Version: 1.0\n"; //Content-Type newHead += contentType()->as7BitString() + "\n"; //Content-Transfer-Encoding newHead += contentTransferEncoding()->as7BitString() + "\n"; //X-Headers int pos = h_ead.find("\nX-"); if(pos > -1) //we already have some x-headers => "recycle" them newHead += h_ead.mid(pos + 1, h_ead.length() - pos); else if(h_eaders && !h_eaders->isEmpty()) { for(h = h_eaders->first(); h; h = h_eaders->next()) { if(h->isXHeader() && (strncasecmp(h->type(), "X-KNode", 7) != 0)) newHead += h->as7BitString() + "\n"; } } h_ead = newHead; }
CELL * p_deleteSymbol(CELL * params) { SYMBOL * sPtr = NULL; CELL * cell; CELL * ctx; int checkReferences = TRUE; cell = evaluateExpression(params); if(cell->type != CELL_SYMBOL) return(errorProcExt(ERR_SYMBOL_EXPECTED, params)); sPtr = (SYMBOL*)cell->contents; if(sPtr == mainContext) return(nilCell); if(symbolType(sPtr) == CELL_CONTEXT) { ctx = (CELL*)sPtr->contents; if(ctx->contents == (UINT)sPtr) { sPtr->flags &= ~SYMBOL_PROTECTED; cell = ctx; } } if(sPtr->flags & (SYMBOL_PROTECTED | SYMBOL_BUILTIN) ) return(nilCell); /* nil as extra parameter deletes without reference checking. true as extra parameter deletes only if no references are found, No extra parameter assumes reference checking is on and if a reference is found it is replaced with nil. */ params = params->next; /* extra parameter is specified as nil */ if(params != nilCell && !getFlag(params)) checkReferences = FALSE; /* extra parameter is specified as true */ else if(getFlag(params)) { if(cell->type == CELL_CONTEXT) { if(externalReferences(sPtr, FALSE) > 0) { sPtr->flags |= SYMBOL_PROTECTED; return(nilCell); } checkReferences = FALSE; } else { if(references(sPtr, FALSE) > 1) return(nilCell); checkReferences = FALSE; } } if(cell->type == CELL_CONTEXT) { deleteContextSymbols(cell, checkReferences); cell->type = CELL_SYMBOL; /* demote */ deleteList((CELL *)sPtr->contents); sPtr->contents = (UINT)copyCell(nilCell); } else deleteFreeSymbol(sPtr, checkReferences); return(trueCell); }
void CanRunScriptChecker::registerMatchers(MatchFinder *AstMatcher) { auto Refcounted = qualType(hasDeclaration(cxxRecordDecl(isRefCounted()))); auto InvalidArg = // We want to find any expression, ignoreTrivials(expr( // which has a refcounted pointer type, anyOf( hasType(Refcounted), hasType(pointsTo(Refcounted)), hasType(references(Refcounted)) ), // and which is not this, unless(cxxThisExpr()), // and which is not a method call on a smart ptr, unless(cxxMemberCallExpr(on(hasType(isSmartPtrToRefCounted())))), // and which is not calling operator* on a smart ptr. unless( allOf( cxxOperatorCallExpr(hasOverloadedOperatorName("*")), callExpr(allOf( hasAnyArgument(hasType(isSmartPtrToRefCounted())), argumentCountIs(1) )) ) ), // and which is not a parameter of the parent function, unless(declRefExpr(to(parmVarDecl()))), // and which is not a MOZ_KnownLive wrapped value. unless(callExpr(callee(functionDecl(hasName("MOZ_KnownLive"))))), expr().bind("invalidArg"))); auto OptionalInvalidExplicitArg = anyOf( // We want to find any argument which is invalid. hasAnyArgument(InvalidArg), // This makes this matcher optional. anything()); // Please note that the hasCanRunScriptAnnotation() matchers are not present // directly in the cxxMemberCallExpr, callExpr and constructExpr matchers // because we check that the corresponding functions can run script later in // the checker code. AstMatcher->addMatcher( expr( anyOf( // We want to match a method call expression, cxxMemberCallExpr( // which optionally has an invalid arg, OptionalInvalidExplicitArg, // or which optionally has an invalid implicit this argument, anyOf( // which derefs into an invalid arg, on(cxxOperatorCallExpr( anyOf(hasAnyArgument(InvalidArg), anything()))), // or is an invalid arg. on(InvalidArg), anything()), expr().bind("callExpr")), // or a regular call expression, callExpr( // which optionally has an invalid arg. OptionalInvalidExplicitArg, expr().bind("callExpr")), // or a construct expression, cxxConstructExpr( // which optionally has an invalid arg. OptionalInvalidExplicitArg, expr().bind("constructExpr"))), anyOf( // We want to match the parent function. forFunction(functionDecl().bind("nonCanRunScriptParentFunction")), // ... optionally. anything())), this); }
///////////////////////////////////////////////////////////////////////////// // WMIReferenceProvider::referenceNames // // /////////////////////////////////////////////////////////////////////////// Array<CIMObjectPath> WMIReferenceProvider::referenceNames( const String& nameSpace, const String& userName, const String& password, const CIMObjectPath& objectName, const String& resultClass, const String& role) { Array<CIMObject> objects; Array<CIMObjectPath> objectNames; PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIReferenceProvider::referenceNames()"); // create an empty property list to save time... Array<CIMName> propNames; CIMPropertyList propertyList(propNames); // now get the objects objects = references( nameSpace, userName, password, objectName, resultClass, role, false, false, propertyList); // now get the names from the object Uint32 size = objects.size(); Uint32 i; //check if namespace is remote CIMNamespaceName oNamespace(nameSpace); String strNamespace = oNamespace.getString(); String strNamespaceLower = strNamespace; strNamespaceLower.toLower(); String strRemotePrefix = ""; if (strNamespaceLower.subString(0, 4) != "root") { Uint32 uiPos = strNamespaceLower.find("root"); if (uiPos == PEG_NOT_FOUND) throw CIMException(CIM_ERR_FAILED); strRemotePrefix = strNamespace.subString(0, uiPos); } for (i=0; i<size; i++) { CIMObjectPath oObjectPath = objects[i].getPath(); if (strRemotePrefix != "") { strNamespace = strRemotePrefix; oNamespace = strNamespace.append(oObjectPath.getNameSpace().getString()); oObjectPath.setNameSpace(oNamespace); } objectNames.append(oObjectPath); } PEG_METHOD_EXIT(); return objectNames; }