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

📄 stafqueueservice.cpp

📁 Software Testing Automation Framework (STAF)的开发代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
         (index <= optionCount) && !rc; ++index)    {        rc = RESOLVE_INDEXED_UINT_OPTION("HANDLE", index, theHandle);        if (!rc) handleList.push_back(theHandle);    }    STAFString machine;    for (index = 1, optionCount = parsedResult->optionTimes("MACHINE");         (index <= optionCount) && !rc; ++index)    {        rc = RESOLVE_INDEXED_STRING_OPTION("MACHINE", index, machine);        if (!rc) machineList.push_back(machine.toLowerCase());    }    STAFString name;    for (index = 1, optionCount = parsedResult->optionTimes("NAME");         (index <= optionCount) && !rc; ++index)    {        rc = RESOLVE_INDEXED_STRING_OPTION("NAME", index, name);        if (!rc) nameList.push_back(name.toLowerCase());    }    STAFString user;    for (index = 1, optionCount = parsedResult->optionTimes("USER");         (index <= optionCount) && !rc; ++index)    {        rc = RESOLVE_INDEXED_STRING_OPTION("USER", index, user);        if (!rc)        {            // Check if authenticator was specified in the user value            unsigned int sepIndex = user.find(gSpecSeparator);            if (sepIndex == STAFString::kNPos)            {                // No authenticator specified                // Use lower-cased default authenticator                user = gServiceManagerPtr->getDefaultAuthenticator().                    toLowerCase() + gSpecSeparator + user;            }            else            {                // User specified in form of Authenticator://UserIdentifier                // Change authenticator to lower-case.                user = user.subString(0, sepIndex).toLowerCase() +                       user.subString(sepIndex);            }            userList.push_back(user);        }    }    STAFString type;    for (index = 1, optionCount = parsedResult->optionTimes("TYPE");         (index <= optionCount) && !rc; ++index)    {        rc = RESOLVE_INDEXED_STRING_OPTION("TYPE", index, type);        if (!rc) typeList.push_back(type.toLowerCase());    }        STAFString contains;    for (index = 1, optionCount = parsedResult->optionTimes("CONTAINS");         (index <= optionCount) && !rc; ++index)    {        rc = RESOLVE_INDEXED_STRING_OPTION("CONTAINS", index, contains);        if (!rc) containsList.push_back(contains);    }    STAFString icontains;    for (index = 1, optionCount = parsedResult->optionTimes("ICONTAINS");         (index <= optionCount) && !rc; ++index)    {        rc = RESOLVE_INDEXED_STRING_OPTION("ICONTAINS", index, icontains);        if (!rc) icontainsList.push_back(icontains.toLowerCase());    }    unsigned int timeout = 0;    if (!rc) rc = RESOLVE_DEFAULT_UINT_OPTION("WAIT", timeout,                                              STAF_EVENT_SEM_INDEFINITE_WAIT);    if (rc) return STAFServiceResult(rc, errorBuffer);    STAFHandleQueue::Message message;    unsigned int doWait = 0;    STAFEventSemPtr event;    if (parsedResult->optionTimes("WAIT") != 0)    {        STAFMutexSemLock queueLock(handleQueue->fQueueSem);        event = handleQueue->fNotify;        doWait = 1;    }    // We enter into a loop here waiting for an appropriate queue element    // to become available.  The event->wait() condition on the end of the    // for loop is safe because we only do multiple loops if we are in    // WAIT mode    STAFTimestamp startTime = STAFTimestamp::now();    unsigned int currTimeout = timeout;    for (int foundIt = 0; !foundIt; foundIt ? 0 : event->wait(currTimeout))    {        STAFMutexSemLock queueLock(handleQueue->fQueueSem);        STAFHandleQueue::HandleQueue::iterator iter;        for (iter = handleQueue->fQueue.begin();             (iter != handleQueue->fQueue.end()) && !foundIt;)        {            foundIt = 1;            if (priorityList.size() != 0)            {                unsigned int checkPriority = iter->second.priority;                for (foundIt = 0, index = 0;                     index < priorityList.size(); ++index)                {                    if (priorityList[index] == checkPriority)                        foundIt = 1;                }            }            if (foundIt && (handleList.size() != 0))            {                STAFHandle_t checkHandle = iter->second.handle;                for (foundIt = 0, index = 0;                     index < handleList.size(); ++index)                {                    if (handleList[index] == checkHandle)                        foundIt = 1;                }            }            if (foundIt && (machineList.size() != 0))            {                STAFString lowerMachine = iter->second.machine.toLowerCase();                for (foundIt = 0, index = 0;                     index < machineList.size(); ++index)                {                    // Do a wildcard match                    if (lowerMachine.matchesWildcards(machineList[index]))                    {                        foundIt = 1;                    }                }            }            if (foundIt && (nameList.size() != 0))            {                STAFString lowerName = iter->second.process.toLowerCase();                for (foundIt = 0, index = 0; index < nameList.size(); ++index)                {                    if (nameList[index] == lowerName)                        foundIt = 1;                }            }            if (foundIt && (userList.size() != 0))            {                STAFString user = iter->second.authenticator.toLowerCase() +                     gSpecSeparator + iter->second.userIdentifier;                for (foundIt = 0, index = 0; index < userList.size(); ++index)                {                    // Do a wildcard match                    // if (user.matchesWildcards(userList[index]))                    if (userList[index] == user)                    {                        foundIt = 1;                    }                }            }            if (foundIt && (typeList.size() != 0))            {                STAFString lowerType = iter->second.type.toLowerCase();                for (foundIt = 0, index = 0; index < typeList.size(); ++index)                {                    if (typeList[index] == lowerType)                    {                        foundIt = 1;                    }                }            }            if (foundIt && (containsList.size() != 0))            {                STAFString &checkMessage = iter->second.message;                for (foundIt = 0, index = 0;                     index < containsList.size(); ++index)                {                       if (checkMessage.find(containsList[index]) !=                        STAFString::kNPos)                    {                        foundIt = 1;                    }                }            }            if (foundIt && (icontainsList.size() != 0))            {                STAFString checkMessage = iter->second.message.toLowerCase();                for (foundIt = 0, index = 0;                     index < icontainsList.size(); ++index)                {                    if (checkMessage.find(icontainsList[index]) !=                        STAFString::kNPos)                    {                        foundIt = 1;                    }                }            }            if (!foundIt) ++iter;        }        if (!foundIt)        {            if (doWait)            {                unsigned int deltaTime = (STAFTimestamp::now() -                                         startTime) * 1000;                if (deltaTime >= timeout)                {                    return kSTAFTimeout;                }                else                {                    currTimeout = timeout - deltaTime;                    event->reset();                }            }            else return STAFServiceResult(kSTAFNoQueueElement);        }        else        {            message = iter->second;            if (isGet) handleQueue->fQueue.erase(iter);        }    }   // found an appropriate entry    // Create a marshalled map containing information for the entry    // found in the queue    STAFObjectPtr mc = STAFObject::createMarshallingContext();    mc->setMapClassDefinition(fQueueEntryMapClass->reference());    STAFObjectPtr queueEntryMap = fQueueEntryMapClass->createInstance();    queueEntryMap->put("priority", STAFString(message.priority));    queueEntryMap->put("timestamp", message.timestamp.asString());    queueEntryMap->put("machine", message.machine);    if (message.process.length() == 0)        queueEntryMap->put("handleName", STAFObject::createNone());    else        queueEntryMap->put("handleName", message.process);    queueEntryMap->put("handle", STAFString(message.handle));    queueEntryMap->put("user", message.authenticator +                       gSpecSeparator + message.userIdentifier);    if (message.type.length() != 0)        queueEntryMap->put("type", message.type);    queueEntryMap->put("message", message.message);    mc->setRootObject(queueEntryMap);    return STAFServiceResult(kSTAFOk, mc->marshall());}STAFServiceResult STAFQueueService::handleDelete(    const STAFServiceRequest &requestInfo){    // Verify that this request came from the local machine    // No check of trust is needed since these commands are only valid    // with respect to the submitting process' queue so just set    // required trust level to 0.    IVALIDATE_LOCAL_TRUST(0, "DELETE");    // Parse the request    STAFCommandParseResultPtr parsedResult = fDeleteParser.parse(        requestInfo.fRequest);    if (parsedResult->rc != kSTAFOk)    {        return STAFServiceResult(kSTAFInvalidRequestString,                                 parsedResult->errorBuffer, 0);    }    STAFString errorBuffer;    unsigned int checkPriority  = parsedResult->optionTimes("PRIORITY");    unsigned int checkMachine   = parsedResult->optionTimes("MACHINE");    unsigned int checkName      = parsedResult->optionTimes("NAME");    unsigned int checkHandle    = parsedResult->optionTimes("HANDLE");    unsigned int checkUser      = parsedResult->optionTimes("USER");    unsigned int checkType      = parsedResult->optionTimes("TYPE");    unsigned int checkContains  = parsedResult->optionTimes("CONTAINS");    unsigned int checkIContains = parsedResult->optionTimes("ICONTAINS");    DEFINE_VAR_POOL_LIST(varPoolList, varPoolListSize, requestInfo);    STAFHandleQueuePtr handleQueue;    STAFRC_t rc = gHandleManagerPtr->handleQueue(requestInfo.fHandle,                                                 handleQueue);

⌨️ 快捷键说明

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