const ListFormatInternal* ListFormatter::getListFormatInternal( const Locale& locale, const char *style, UErrorCode& errorCode) { if (U_FAILURE(errorCode)) { return NULL; } CharString keyBuffer(locale.getName(), errorCode); keyBuffer.append(':', errorCode).append(style, errorCode); UnicodeString key(keyBuffer.data(), -1, US_INV); ListFormatInternal* result = NULL; { Mutex m(&listFormatterMutex); if (listPatternHash == NULL) { initializeHash(errorCode); if (U_FAILURE(errorCode)) { return NULL; } } result = static_cast<ListFormatInternal*>(listPatternHash->get(key)); } if (result != NULL) { return result; } result = loadListFormatInternal(locale, style, errorCode); if (U_FAILURE(errorCode)) { return NULL; } { Mutex m(&listFormatterMutex); ListFormatInternal* temp = static_cast<ListFormatInternal*>(listPatternHash->get(key)); if (temp != NULL) { delete result; result = temp; } else { listPatternHash->put(key, result, errorCode); if (U_FAILURE(errorCode)) { return NULL; } } } return result; }
std::string KeyChangeRequest( uint8_t seq, uint32_t ksq, uint16_t user, const std::string& keyWrapData ) { Buffer buffer(DEFAULT_MAX_APDU_SIZE); APDURequest apdu(buffer.GetWSlice()); apdu.SetControl(AppControlField(true, true, false, false, seq)); apdu.SetFunction(FunctionCode::AUTH_REQUEST); HexSequence keyBuffer(keyWrapData); Group120Var6 rsp; rsp.keyChangeSeqNum = ksq; rsp.userNum = user; rsp.keyWrapData = keyBuffer.ToRSlice(); apdu.GetWriter().WriteFreeFormat(rsp); return ToHex(apdu.ToRSlice()); }
bool wxLuaSocketBase::WriteDebugData(const wxLuaDebugData& debugData) { // Debug data is written as // [wxInt32 debug data item count] then for each item // [wxInt32 item data length] // [{wxInt32 GetReference}{wxInt32 GetIndex}{wxInt32 GetFlag} // {char GetName \0}{char GetType \0}{char GetValue \0}{char GetSource \0}] wxInt32 idx, idxMax = debugData.GetCount(); wxLuaSocketDebugMsg(m_name + wxT(" wxLuaSocketBase::WriteDebugData"), wxString::Format(wxT("items %d"), idxMax)); bool ok = Write((const char*)&idxMax, sizeof(wxInt32)) == sizeof(wxInt32); for (idx = 0; ok && (idx < idxMax); ++idx) { const wxLuaDebugItem *item = debugData.Item(idx); wxLuaCharBuffer keyBuffer(item->GetKey()); wxLuaCharBuffer valueBuffer(item->GetValue()); wxLuaCharBuffer sourceBuffer(item->GetSource()); int keyLength = keyBuffer.Length() + 1; // add 1 for terminating \0 int valueLength = valueBuffer.Length() + 1; int sourceLength = sourceBuffer.Length() + 1; wxInt32 bufferLength = (5 * sizeof(wxInt32)) + keyLength + valueLength + sourceLength; unsigned char *pBuffer = new unsigned char[bufferLength]; unsigned char *pMemory = pBuffer; ok = Write((const char*)&bufferLength, sizeof(wxInt32)) == sizeof(wxInt32); if (!ok) break; *(wxInt32 *) pMemory = (wxInt32)item->GetRef(); pMemory += sizeof(wxInt32); *(wxInt32 *) pMemory = (wxInt32)item->GetIndex(); pMemory += sizeof(wxInt32); *(wxInt32 *) pMemory = (wxInt32)item->GetFlag(); pMemory += sizeof(wxInt32); *(wxInt32 *) pMemory = (wxInt32)item->GetKeyType(); pMemory += sizeof(wxInt32); *(wxInt32 *) pMemory = (wxInt32)item->GetValueType(); pMemory += sizeof(wxInt32); memcpy(pMemory, keyBuffer.GetData(), keyLength); pMemory += keyLength; memcpy(pMemory, valueBuffer.GetData(), valueLength); pMemory += valueLength; memcpy(pMemory, sourceBuffer.GetData(), sourceLength); ok = Write((const char *) pBuffer, bufferLength) == bufferLength; delete[] pBuffer; } return ok; }