CefHandler::RetVal HandlerAdapter::HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser, CefRefPtr<CefRequest> request, CefString& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream, CefString& mimeType, int loadFlags) { IBeforeResourceLoad^ handler = _browserControl->BeforeResourceLoadHandler; if(handler != nullptr) { CefRequestWrapper^ wrapper = gcnew CefRequestWrapper(request); RequestResponse^ requestResponse = gcnew RequestResponse(wrapper); handler->HandleBeforeResourceLoad(_browserControl, requestResponse); if(requestResponse->Action == ResponseAction::Respond) { CefRefPtr<StreamAdapter> adapter = new StreamAdapter(requestResponse->ResponseStream); resourceStream = CefStreamReader::CreateForHandler(static_cast<CefRefPtr<CefReadHandler>>(adapter)); mimeType = convertFromString(requestResponse->MimeType); return RV_CONTINUE; } else if(requestResponse->Action == ResponseAction::Cancel) { return RV_HANDLED; } else if(requestResponse->Action == ResponseAction::Redirect) { redirectUrl = convertFromString(requestResponse->RedirectUrl); } } return RV_CONTINUE; }
// Check given 'reqToken' sent by 'reqId' is valid at 'when'. // 'when' is the point we received the validation request, in unix epoch (milliseconds, UTC) bool CClientAmxController::validateToken(const std::string& reqId, const std::string& reqToken, const int64_t when) { if (!HiddenUtility::RegexMatch(reqId, UUID_PATTERN) || !HiddenUtility::RegexMatch(reqToken, UUID_PATTERN)) { _log(LOG_TAG" validateToken() ID `%s` or token `%s` is not valid", reqId.c_str(), reqToken.c_str()); return false; } if (tokenCache.find(reqToken) != tokenCache.end()) { _log(LOG_TAG" validateToken() Token `%s` hit cache", reqToken.c_str()); auto& hitRecord = tokenCache[reqToken]; return hitRecord.userUuid.compare(reqId) == 0 && hitRecord.validFrom <= when && hitRecord.goodThrough >= when; } // cache miss list<map<string, string>> listRet; string strSQL = "SELECT t.time_start, t.time_end FROM amx_control_token as t, user as u " "WHERE u.uuid = '" + reqId + "' AND t.user_id = u.id AND t.token = '" + reqToken + "' AND t.valid = 1 AND u.valid = 1;"; bool bRet = HiddenUtility::selectFromDb(LOG_TAG" validateToken()", strSQL, listRet); if (!bRet) { return false; } else if (listRet.size() > 1) { _log(LOG_TAG" validateToken() db returned more than 1 result?"); } auto& retRow = *listRet.begin(); auto& strValidFrom = retRow["time_start"]; auto& strGoodThrough = retRow["time_end"]; int64_t tokenValidFrom, tokenGoodThrough; convertFromString(tokenValidFrom, strValidFrom); convertFromString(tokenGoodThrough, strGoodThrough); CachedTokenInfo newRecord; newRecord.userUuid = reqId; newRecord.validFrom = tokenValidFrom; newRecord.goodThrough = tokenGoodThrough; tokenCache[reqToken] = newRecord; // check token is valid at time given return when >= tokenValidFrom && when <= tokenGoodThrough; }
// ###################################################################### void TrackerHandController::start1() { // parse our config string and instantiate all our trackers: std::vector<std::string> tok; split(itsConfig.getVal(), ",", std::back_inserter(tok)); if (tok.empty()) LFATAL("I cannot run without at least one handtrace file."); for (uint i = 0; i < tok.size(); i ++) { std::vector<std::string> tt; split(tok[i], ":", std::back_inserter(tt)); if (tt.empty()) LFATAL("Invalid empty eye-tracker filename"); std::string fname = tt[0]; std::string extras = join(tt.begin() + 1, tt.end(), ":"); LINFO("Instantiating Tracker %03d with file '%s', extras '%s'", i, fname.c_str(), extras.c_str()); // the only extra we support for now is a color: //PixRGB<byte> color(128, 255, 255); // cyan color PixRGB<byte> color(255, 255, 128); // light yellow color if (tt.size() > 1) convertFromString(tt[1], color); // instantiate a new HandTrace object: rutz::shared_ptr<HandTrace> et(new HandTrace(fname, color)); itsHandTrace.push_back(et); itsHandSample.push_back(0); } HandController::start1(); }
TyErrorId extractConfigOption( const AnnotatorContext& crclConfig, const UnicodeString* cpclConfigGroup, const ConfigOptionInfo::StOptionInfo& crclOptionInfo, T& rclTargetVariable ) { assert(!crclOptionInfo.bOptionIsMultiValued); // assume the worst TyErrorId utErrId = UIMA_ERR_CONFIG_SECTION_NOT_FOUND; assert(crclOptionInfo.uiNbrOfValuesRequired <= 1); if (EXISTS(cpclConfigGroup)) { //utErrId = crclConfig.extractValue(crclOptionInfo.cpszOptionName, rclTargetVariable); utErrId = crclConfig.extractValue(*cpclConfigGroup, crclOptionInfo.cpszOptionName, rclTargetVariable); } else { utErrId = crclConfig.extractValue(crclOptionInfo.cpszOptionName, rclTargetVariable); } if (utErrId != UIMA_ERR_NONE) { // could not find option or value(s) if (crclOptionInfo.uiNbrOfValuesRequired != 0 || crclOptionInfo.cpszDefaultValueAsString == NULL) { // required value not there: return error we got from config return utErrId; } convertFromString((std::string) crclOptionInfo.cpszDefaultValueAsString, rclTargetVariable); // we used the provided default: this is not an error so we return OK utErrId = UIMA_ERR_NONE; } return utErrId; }
void idpBase::registCallback() { /* Environment Check & Read [ALTIBASE_]PROPNAME */ void *sValue; SChar *sEnvName; SChar *sEnvValue; UInt sLen; sLen = idlOS::strlen(IDP_PROPERTY_PREFIX) + idlOS::strlen(getName()) + 2; sEnvName = (SChar *)iduMemMgr::mallocRaw(sLen); IDE_ASSERT(sEnvName != NULL); idlOS::memset(sEnvName, 0, sLen); idlOS::snprintf(sEnvName, sLen, "%s%s", IDP_PROPERTY_PREFIX, getName()); sEnvValue = idlOS::getenv( (const SChar *)sEnvName); // Re-Validation of return-Value if (sEnvValue != NULL) { if (idlOS::strlen(sEnvValue) == 0) { sEnvValue = NULL; } } // If Exist, Read It. if (sEnvValue != NULL) { sValue = NULL; if (convertFromString(sEnvValue, &sValue) == IDE_SUCCESS) { mSrcValArr[IDP_VALUE_FROM_ENV].mVal[0] = sValue; mSrcValArr[IDP_VALUE_FROM_ENV].mCount++; } else { /* ------------------------------------------------ * 환경변수 프로퍼티의 값 스트링이 * Data Type이 맞지 않아 실패할 경우에는 * Default Value를 그대로 쓴다. * ----------------------------------------------*/ ideLog::log(IDE_SERVER_0, ID_TRC_PROPERTY_TYPE_INVALID, sEnvName, sEnvValue); } } iduMemMgr::freeRaw(sEnvName); }
/************************************************************************** * Description: aIn에 해당하는 값이 Property의 Min, Max사이에 있는지 조사한다. * * aIn - [IN] Input Value *************************************************************************/ IDE_RC idpBase::validate( SChar *aIn ) { void *sValue = NULL; idBool sLocked = ID_FALSE; IDE_ASSERT( idlOS::thread_mutex_lock(&mMutex) == 0); sLocked = ID_TRUE; // 변경 불가능한 경우 검사 IDE_TEST_RAISE( (mAttr & IDP_ATTR_RD_MASK) == IDP_ATTR_RD_READONLY, cant_modify_error); IDE_TEST(convertFromString(aIn, &sValue) != IDE_SUCCESS); /* Value Range Validation */ IDE_TEST(checkRange(sValue) != IDE_SUCCESS); // BUG-20486 iduMemMgr::freeRaw(sValue); sValue = NULL; sLocked = ID_FALSE; IDE_ASSERT( idlOS::thread_mutex_unlock(&mMutex) == 0); return IDE_SUCCESS; IDE_EXCEPTION(cant_modify_error); { IDE_SET(ideSetErrorCode(idERR_ABORT_idp_ReadOnlyEntry, getName())); } IDE_EXCEPTION_END; // BUG-20486 if(sValue != NULL) { iduMemMgr::freeRaw(sValue); sValue = NULL; } if ( sLocked == ID_TRUE ) { IDE_PUSH(); IDE_ASSERT( idlOS::thread_mutex_unlock(&mMutex) == 0); IDE_POP(); } return IDE_FAILURE; }
bool XMLWrapper::setAttr(xmlNodePtr node, const char *name, const char *value) { if (!node || !name) { return false; } xmlChar *xmlValue = NULL; if (!convertFromString(value, xmlValue)) { return false; } xmlAttrPtr xmlAttr = xmlSetProp (node, BAD_CAST name, xmlValue); xmlFree(xmlValue); return xmlAttr != NULL; }
bool XMLWrapper::setContent(xmlNodePtr node, const char *content) { if (!node) { return false; } xmlChar *xmlContent; if (!convertFromString(content, xmlContent)) { return false; } xmlNodeSetContent(node, xmlContent); xmlFree(xmlContent); return true; }
oret_t owatchConvertValue(const oval_t * src_val, oval_t * dst_val, char *data_buf, int data_buf_len) { oret_t rc = ERROR; char src_type, dst_type; int len; if (src_val == NULL || dst_val == NULL) return ERROR; src_type = src_val->type; dst_type = dst_val->type; if (dst_type == 's') { if (src_type == 's') { if (src_val->v.v_str == NULL) { dst_val->v.v_str = NULL; dst_val->len = 0; dst_val->time = src_val->time; if (data_buf && data_buf_len) *data_buf = 0; return OK; } if (src_val->len == 0) { dst_val->v.v_str = data_buf; dst_val->len = 0; dst_val->time = src_val->time; if (data_buf && data_buf_len) *data_buf = 0; return OK; } if (src_val->len < 0) return ERROR; if (data_buf == NULL || data_buf_len < src_val->len) return ERROR; oxbcopy(src_val->v.v_str, data_buf, src_val->len); if (src_val->len < data_buf_len) data_buf[src_val->len] = 0; dst_val->v.v_str = data_buf; dst_val->len = src_val->len; dst_val->time = src_val->time; return OK; } len = convertToString(src_type, src_val, data_buf, data_buf_len); if (len < 0) return ERROR; dst_val->v.v_str = data_buf; dst_val->len = len; dst_val->time = src_val->time; return OK; } switch (src_type) { case 'b': rc = convertSignedChar(src_val->v.v_char, dst_type, dst_val); break; case 'B': rc = convertUnsignedChar(src_val->v.v_uchar, dst_type, dst_val); break; case 'h': rc = convertSignedShort(src_val->v.v_short, dst_type, dst_val); break; case 'H': rc = convertUnsignedShort(src_val->v.v_ushort, dst_type, dst_val); break; case 'i': rc = convertSignedInt(src_val->v.v_int, dst_type, dst_val); break; case 'I': rc = convertUnsignedInt(src_val->v.v_uint, dst_type, dst_val); break; case 'l': rc = convertSignedLong(src_val->v.v_long, dst_type, dst_val); break; case 'L': rc = convertUnsignedLong(src_val->v.v_ulong, dst_type, dst_val); break; case 'f': rc = convertFloat(src_val->v.v_float, dst_type, dst_val); break; case 'd': rc = convertDouble(src_val->v.v_double, dst_type, dst_val); break; case 'E': rc = convertEnum(src_val->v.v_enum, dst_type, dst_val); break; case 's': rc = convertFromString(src_val->v.v_str, dst_type, dst_val); break; default: return ERROR; } if (rc == ERROR) return ERROR; switch (dst_val->type) { case 'b': dst_val->len = 1; break; case 'B': dst_val->len = 1; break; case 'h': dst_val->len = 2; break; case 'H': dst_val->len = 2; break; case 'i': dst_val->len = 4; break; case 'I': dst_val->len = 4; break; case 'l': dst_val->len = 4; break; case 'L': dst_val->len = 4; break; case 'q': dst_val->len = 16; break; case 'Q': dst_val->len = 16; break; case 'f': dst_val->len = 4; break; case 'd': dst_val->len = 8; break; case 'D': dst_val->len = 16; break; case 'p': dst_val->len = 4; break; case 'E': dst_val->len = 4; break; case 'v': return ERROR; case 's': return ERROR; default: return ERROR; } dst_val->time = src_val->time; return OK; }
IDE_RC idpBase::updateForce(SChar *aIn, UInt aNum, void *aArg) { void *sValue = NULL; void *sOldValue = NULL; UInt sUpdateValue = 0; idBool sLocked = ID_FALSE; IDE_ASSERT( idlOS::thread_mutex_lock(&mMutex) == 0); sLocked = ID_TRUE; // 카운트 검사 IDE_TEST_RAISE(aNum >= mMemVal.mCount, no_exist_error); /* 변경 불가능한 경우를 검사하지 않는다. IDE_TEST_RAISE( (mAttr & IDP_ATTR_RD_MASK) == IDP_ATTR_RD_READONLY, cant_modify_error); */ if ( ( mAttr & IDP_ATTR_SK_MASK ) != IDP_ATTR_SK_MULTI_BYTE ) { IDE_TEST(convertFromString(aIn, &sValue) != IDE_SUCCESS); } else { sValue = iduMemMgr::mallocRaw(idlOS::strlen((SChar *)aIn) + 1, IDU_MEM_FORCE); IDE_ASSERT(sValue != NULL); idlOS::strncpy((SChar *)sValue, (SChar *)aIn, idlOS::strlen((SChar *)aIn) + 1); } sOldValue = mMemVal.mVal[aNum]; /* Value Range Validation */ IDE_TEST(checkRange(sValue) != IDE_SUCCESS); IDE_TEST( mUpdateBefore(NULL, getName(), sOldValue, sValue, aArg) != IDE_SUCCESS); /* 기존 메모리 해제 & Set */ mMemVal.mVal[aNum] = sValue; /* 프로퍼티 값을 바꾸었다고 표시하고 에러발생시 원래값으로 원복한다. */ sUpdateValue = 1; IDE_TEST( mUpdateAfter(NULL, getName(), sOldValue, sValue, aArg) != IDE_SUCCESS); iduMemMgr::freeRaw(sOldValue); sLocked = ID_FALSE; IDE_ASSERT( idlOS::thread_mutex_unlock(&mMutex) == 0); return IDE_SUCCESS; /* 변경 불가능한 경우를 검사하지 않는다. IDE_EXCEPTION(cant_modify_error); { IDE_SET(ideSetErrorCode(idERR_ABORT_idp_ReadOnlyEntry, getName())); } */ IDE_EXCEPTION(no_exist_error); { IDE_SET(ideSetErrorCode(idERR_ABORT_idp_NameNotFound, getName())); } IDE_EXCEPTION_END; /* BUG-17763: idpBase::update()에서 FMR을 유발시키고 있습니다. * * 이전에 원래값을 에러발생시 Free시켜서 문제가 되었습니다. * Free시키고 않고 * 에러발생시 프로퍼티 값을 원래 값으로 원복해야 합니다. */ if( sUpdateValue == 1 ) { mMemVal.mVal[aNum] = sOldValue; } if (sValue != NULL) { iduMemMgr::freeRaw(sValue); } if ( sLocked == ID_TRUE ) { IDE_ASSERT( idlOS::thread_mutex_unlock(&mMutex) == 0); } return IDE_FAILURE; }
/****************************************************************************************** * * Description : * aSrc로 들어온 value source 위치에 스트링 형태의 aValue를 자신의 타입으로 변환하고, * 값을 복제하여 삽입한다. * * SChar *aValue, - [IN] 삽입하려고하는 값의 포인터 (String Format) * idpValueSource aSrc - [IN] 값을 삽입할 Source 위치 * (default/env/pfile/spfile by asterisk, spfile by sid) *******************************************************************************************/ IDE_RC idpBase::insertBySrc(SChar *aValue, idpValueSource aSrc) { void *sValue = NULL; UInt sValueIdx; // Multiple Flag Check IDE_TEST_RAISE(((mAttr & IDP_ATTR_ML_MASK) == IDP_ATTR_ML_JUSTONE) && mSrcValArr[aSrc].mCount == 1, only_one_error); // Store Count Check IDE_TEST_RAISE(mSrcValArr[aSrc].mCount >= IDP_MAX_VALUE_COUNT, no_more_insert); switch(aSrc) { case IDP_VALUE_FROM_PFILE: IDE_TEST_RAISE((mAttr & IDP_ATTR_SL_PFILE) != IDP_ATTR_SL_PFILE, err_cannot_set_from_pfile); break; case IDP_VALUE_FROM_SPFILE_BY_ASTERISK: IDE_TEST_RAISE((mAttr & IDP_ATTR_SL_SPFILE) != IDP_ATTR_SL_SPFILE, err_cannot_set_from_spfile); break; case IDP_VALUE_FROM_SPFILE_BY_SID: IDE_TEST_RAISE((mAttr & IDP_ATTR_SL_SPFILE) != IDP_ATTR_SL_SPFILE, err_cannot_set_from_spfile); break; case IDP_VALUE_FROM_ENV: IDE_TEST_RAISE((mAttr & IDP_ATTR_SL_ENV) != IDP_ATTR_SL_ENV, err_cannot_set_from_env); break; default: //IDP_VALUE_FROM_DEFAULT NO CHECK break; } IDE_TEST(convertFromString(aValue, &sValue) != IDE_SUCCESS); /* Value Range Validation */ IDE_TEST(checkRange(sValue) != IDE_SUCCESS); sValueIdx = mSrcValArr[aSrc].mCount++; mSrcValArr[aSrc].mVal[sValueIdx] = sValue; return IDE_SUCCESS; IDE_EXCEPTION(only_one_error); { idlOS::snprintf(mErrorBuf, IDP_ERROR_BUF_SIZE, "idp insertBySrc() Error : " "Property [%s] Can't Store Multiple Values.", getName()); } IDE_EXCEPTION(no_more_insert); { idlOS::snprintf(mErrorBuf, IDP_ERROR_BUF_SIZE, "idp insertBySrc() Error : " "Property [%s] Can't Store more than %"ID_UINT32_FMT " Values.", getName(), (UInt)IDP_MAX_VALUE_COUNT); } IDE_EXCEPTION(err_cannot_set_from_pfile); { idlOS::snprintf(mErrorBuf, IDP_ERROR_BUF_SIZE, "idp insertBySrc() Error : " "Property [%s] Can't set from PFILE.", getName()); } IDE_EXCEPTION(err_cannot_set_from_spfile); { idlOS::snprintf(mErrorBuf, IDP_ERROR_BUF_SIZE, "idp insertBySrc() Error : " "Property [%s] Can't set from SPFILE.", getName()); } IDE_EXCEPTION(err_cannot_set_from_env); { idlOS::snprintf(mErrorBuf, IDP_ERROR_BUF_SIZE, "idp insertBySrc() Error : " "Property [%s] Can't set from ENV.", getName()); } IDE_EXCEPTION_END; if (sValue != NULL) { iduMemMgr::freeRaw(sValue); } return IDE_FAILURE; }
TyErrorId extractConfigOptionListImpl( const AnnotatorContext& crclConfig, const UnicodeString* cpclConfigGroup, const ConfigOptionInfo::StOptionInfo& crclOptionInfo, ContainerType& rclTargetContainer, ElementType* /*not used, just for type information since ContainerType::value_type does not work with HP compiler*/ ) { assert(crclOptionInfo.bOptionIsMultiValued); TyErrorId utErrId = UIMA_ERR_NONE; size_t i; #if defined(__HPX_ACC__) || defined(__xlC__) || defined(__GNUC__) ElementType tTemp; #else ContainerType::value_type tTemp; #endif #if defined(__SUNPRO_CC) std::vector<ContainerType::value_type> elements; #else std::vector<ElementType> elements; #endif if (EXISTS(cpclConfigGroup)) { crclConfig.extractValue(*cpclConfigGroup, crclOptionInfo.cpszOptionName, elements); } else { crclConfig.extractValue(crclOptionInfo.cpszOptionName, elements); } for (i = 0; i < elements.size(); ++i) { rclTargetContainer.insert(rclTargetContainer.end(), elements[i]); } if (utErrId != UIMA_ERR_NONE || (elements.size() == 0)) { // could not find option or value(s) if (crclOptionInfo.uiNbrOfValuesRequired != 0 || crclOptionInfo.cpszDefaultValueAsString == NULL) { // required value not there: return error we got from config return utErrId; } std::vector<std::string> vecTmpStrings; delimitedString2Vector( vecTmpStrings, (std::string) crclOptionInfo.cpszDefaultValueAsString, ",", true, // trim strings false // insert empty strings ); // our default value too must have the required nbr of values assert(vecTmpStrings.size() >= crclOptionInfo.uiNbrOfValuesRequired); for (i = 0; i < vecTmpStrings.size(); ++i) { convertFromString(vecTmpStrings[i], tTemp); // assumes rclTargetContainer to be an STL container rclTargetContainer.insert(rclTargetContainer.end(), tTemp); } } if (i < crclOptionInfo.uiNbrOfValuesRequired) { /* taph 8/6/1999: ?? maybe we should have a more precise error id: UIMA_ERR_CONFIG_REQUIRED_OPTION_HAS_NOT_ENOUGH_VALUES */ return UIMA_ERR_CONFIG_REQUIRED_OPTION_IS_EMPTY; } return utErrId; }