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

📄 stafprocutil.cpp

📁 Software Testing Automation Framework (STAF)的开发代码
💻 CPP
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF)                              *//* (C) Copyright IBM Corp. 2001                                              *//*                                                                           *//* This software is licensed under the Common Public License (CPL) V1.0.     *//*****************************************************************************/#include "STAF.h"#include "STAFString.h"#include "STAFProcUtil.h"#include "STAFUtil.h"#include "STAFException.h"#include "STAFVariablePool.h"#include "STAFProc.h"#include "STAFHandleManager.h"#include "STAFCommandParser.h"bool isLocalMachine(const STAFString &machine, unsigned int fullCompare){    static STAFString sLocal = "local";    static STAFString sLocalLong = "local://local";    if (fullCompare)    {        if (machine.isEqualTo(sLocal, kSTAFStringCaseInsensitive) ||            machine.isEqualTo(sLocalLong, kSTAFStringCaseInsensitive) ||            machine.isEqualTo(*gMachinePtr, kSTAFStringCaseInsensitive))        {            return true;        }        else        {            return false;        }    }    return machine.isEqualTo(sLocal, kSTAFStringCaseInsensitive);}STAFRC_t resolveUIntIfExists(STAFCommandParseResultPtr &parseResult,    const STAFString &optionName, const STAFVariablePool *varPoolList[],    unsigned int varPoolListSize, unsigned int &result,    STAFString &errorBuffer, unsigned int defaultValue){    if (parseResult->optionTimes(optionName) == 0)        return kSTAFOk;    return resolveUInt(parseResult->optionValue(optionName), varPoolList,                       varPoolListSize, result, errorBuffer, defaultValue);}STAFRC_t resolveUInt(const STAFString &unresolved,     const STAFVariablePool *varPoolList[],     unsigned int varPoolListSize, unsigned int &result,     STAFString &errorBuffer, unsigned int defaultValue){    STAFString resultString;    STAFRC_t rc = STAFVariablePool::resolve(unresolved, varPoolList,                                            varPoolListSize, resultString);    if (rc != kSTAFOk)    {        errorBuffer = resultString;        return rc;    }    if (resultString.length() == 0)    {        result = defaultValue;    }    else if (!resultString.isDigits())    {        errorBuffer = STAFString("Invalid value because it is not an "                                 "integer: " + resultString);        return kSTAFInvalidValue;    }    else result = (unsigned int)resultString.asUInt();    return rc;}STAFRC_t resolveStringIfExists(STAFCommandParseResultPtr &parseResult,    const STAFString &optionName, const STAFVariablePool *varPoolList[],    unsigned int varPoolListSize, STAFString &result, STAFString &errorBuffer){    if (parseResult->optionTimes(optionName) == 0)        return kSTAFOk;    return resolveString(parseResult->optionValue(optionName), varPoolList,                         varPoolListSize, result, errorBuffer);}STAFRC_t resolveString(const STAFString &unresolved,                       const STAFVariablePool *varPoolList[],                       unsigned int varPoolListSize, STAFString &result,                       STAFString &errorBuffer){    STAFRC_t rc = STAFVariablePool::resolve(unresolved, varPoolList,                                            varPoolListSize, result);    if (rc != kSTAFOk)    {        errorBuffer = result;    }    return rc;}STAFRC_t validateTrust(unsigned int requiredTrustLevel,                       const STAFString &service,                       const STAFString &request,                       const STAFServiceRequest &requestInfo,                       STAFString &errorBuffer,                       unsigned int localOnly){    if (localOnly)    {        if (!requestInfo.fIsLocalRequest)        {            errorBuffer = service + " service's " + request + " request is "                "only valid if submitted to the local machine"                "\nLocal machine     : " + *gMachinePtr +                "\nRequesting machine: " + requestInfo.fLogicalInterfaceID;                         return kSTAFAccessDenied;        }    }    if (requestInfo.fTrustLevel < requiredTrustLevel)    {        errorBuffer = STAFString("Trust level ") +            STAFString(requiredTrustLevel) +            " required for the " + service + " service's " + request +            " request\nRequester has trust level " +            STAFString(requestInfo.fTrustLevel) + " on machine " +            *gMachinePtr + "\nRequesting machine: " + requestInfo.fInterface +            gSpecSeparator + requestInfo.fLogicalInterfaceID +            " (" + requestInfo.fInterface + gSpecSeparator +            requestInfo.fPhysicalInterfaceID + ")" +            "\nRequesting user   : " + requestInfo.fAuthenticator +            gSpecSeparator + requestInfo.fUserIdentifier;        return kSTAFAccessDenied;    }    return kSTAFOk;}

⌨️ 快捷键说明

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