BOOL IISConfigUtil::FilterEnv()

in src/ServiceMonitor/IISConfigUtil.cpp [59:88]


BOOL IISConfigUtil::FilterEnv(const unordered_map<wstring, LPTSTR>& filter, LPCTSTR strEnvName, LPCTSTR strEnvValue)
{
    LPTSTR   strFilterValue;
    _ASSERT(strEnvName != NULL);
    _ASSERT(strEnvValue != NULL);

    auto value = filter.find(strEnvName);

    //
    // add this environment variable if the name does not match the block list
    //
    if (value == filter.end())
    {
        return FALSE;
    }
    
    strFilterValue = value->second;

    //
    //  filter out this environment variable if
    //  1. value match is not required (strFilterValue is NULL)
    //  2. require value match and value matches
    //
    if ((strFilterValue == NULL ) || (lstrcmpi(strEnvValue, strFilterValue) == 0))
    {
        return TRUE;
    }

    return FALSE;
}