void ExternalizeInt64L(const TInt64& aInt, RWriteStream& aStream) { TInt32 low = I64LOW( aInt ); TInt32 high = I64HIGH( aInt ); aStream.WriteInt32L(low); aStream.WriteInt32L(high); }
/** Config settings observer call-back. @see CLbsAdmin */ /*virtual*/ void CAutoClockAdjust::OnSettingUpdateEvent(TInt aError, const TLbsAdminSetting& aSetting) { LBSLOG(ELogP1, "CAutoClockAdjust::OnSettingUpdateEvent()\n"); LBSLOG4(ELogP3, "NEW EVENT: Setting: 0x%08X%08X changed. err: %d", I64HIGH(aSetting), I64LOW(aSetting), aError); if (aError == KErrNone) { // switch/case not used because of RVCT compiler problem (aSetting is TUint64) if (aSetting == KLbsSettingClockAdjust) { aError = iAdmin->Get(KLbsSettingClockAdjust, iClockAdjustSetting); LBSLOG2(ELogP2, "NEW EVENT: KLbsSettingClockAdjust changed to: %d\n", iClockAdjustSetting); } else if (aSetting == KLbsSettingClockAdjustThreshold) { aError = iAdmin->Get(KLbsSettingClockAdjustThreshold, iAdjustThreshold); LBSLOG2(ELogP2, "NEW EVENT: KLbsSettingClockAdjustThreshold changed to: %d\n", iAdjustThreshold); } else if (aSetting == KLbsSettingClockAdjustInterval) { aError = iAdmin->Get(KLbsSettingClockAdjustInterval, iAdjustInterval); LBSLOG2(ELogP2, "NEW EVENT: KLbsSettingClockAdjustInterval changed to: %d\n", iAdjustInterval); } else { ASSERT(EFalse); } } // Ignored on UREL ASSERT(aError == KErrNone); }
jlong Os::java_time_millis() { TTime NineteenSeventy(_L("19700000:000000.000000")); TTime now; now.UniversalTime(); TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(NineteenSeventy); TInt64 time = interval.Int64() / 1000; return ((jlong)I64HIGH(time) << 32) | (jlong)I64LOW(time); }
TInt CTestCrashDataSource::SetSimRegValues( const TUint32 aThreadId, RRegisterList & aRegisterList ) { RDebug::Print( _L("CTestCrashDataSource::SetSimRegValues()\n") ); if( aRegisterList.Count() > 0 ) { TUint8 val8 = (TUint8)(KRegValue8 + aThreadId); TUint16 val16 = (TUint16)(KRegValue16 + aThreadId); TUint32 val32 = (TUint32)(KRegValue32 + aThreadId); TUint64 val64 = (TUint64)(MAKE_TUINT64(0xFEDCBA98u,0x76543210u) + aThreadId); for( TInt i = 0; i < aRegisterList.Count(); i ++ ) { TRegisterData & reg = aRegisterList[i]; switch ( reg.iSize ) { case 0: reg.iValue8 = val8 + i; RDebug::Printf( " Setting reg[%d] iValue8=0x%X\n", i, reg.iValue8 ); break; case 1: reg.iValue16 = val16+ i; RDebug::Printf( " Setting reg[%d] iValue16=0x%X\n", i, reg.iValue16 ); break; case 2: reg.iValue32 = val32+ i; RDebug::Printf( " Setting reg[%d] iValue32=0x%X\n", i, reg.iValue32 ); break; case 3: reg.iValue64 = val64+ i; RDebug::Printf( " Setting reg[%d]=0x%X%X\n", i, I64HIGH(reg.iValue64), I64LOW(reg.iValue64) ); break; } //reg.iAvailable = i%8 ? ETrue : EFalse; /* if ( 0 == ((i+1) % 8) ) { RDebug::Printf( " setting reg[%d] as not available\n", i ); reg.iAvailable = EFalse; } */ } return KErrNone; } return KErrBadHandle; }
EXPORT_C void TE64Addr::SetAddr(const TInt64& aAddr) { #ifdef I64HIGH u.iAddr32[0] = I64HIGH(aAddr); u.iAddr32[1] = I64LOW(aAddr); #else u.iAddr32[0] = aAddr.High(); u.iAddr32[1] = aAddr.Low(); #endif }
// ----------------------------------------------------------------------------- // TAccPolGenericIDAccessor::SetDeviceAddress // Set device address for Generic ID. // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C void TAccPolGenericIDAccessor::SetDeviceAddress( TAccPolGenericID& aGenericID, const TUint64 aDeviceAddress ) { COM_TRACE_2( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetDeviceAddressL() H:0x%x, L:0x%x", I64HIGH( aDeviceAddress ), I64LOW( aDeviceAddress ) ); aGenericID.iStaticAttributes.iDeviceAddress = aDeviceAddress; COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetDeviceAddressL() - return void" ); }
// ----------------------------------------------------------------------------- // TAccPolGenericIDAccessor::SetHWDeviceID // Set hardware model ID for Generic ID. // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C void TAccPolGenericIDAccessor::SetHWDeviceID( TAccPolGenericID& aGenericID, const TUint64 aHWDeviceID ) { COM_TRACE_2( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetHWDeviceIDL() H:0x%x, L:0x%x", I64HIGH( aHWDeviceID ), I64LOW( aHWDeviceID ) ); aGenericID.iStaticAttributes.iHWDeviceID = aHWDeviceID; COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetHWDeviceIDL() - return void" ); }
void CBkmrkProperties::TransSaveL() { SetModified (); TUint32 indexBase = IndexBase(); TUint32 timeLo = I64LOW(iLastModified.Int64()); TUint32 timeHi = I64HIGH(iLastModified.Int64()); iRepository->Set(indexBase + KBkmrkLastModifiedLoIndex, static_cast<TInt>(timeLo)); iRepository->Set(indexBase + KBkmrkLastModifiedHiIndex, static_cast<TInt>(timeHi)); iRepository->Set(indexBase + KCmnDescriptionIndex, Description()); iRepository->Set(indexBase + KCmnIconIndex, static_cast<TInt>(iIconId)); iCustomProperties->TransSaveL(); }
/** Utility function for obtaining info on file close requests. @param aRequest File close request @param aPath The path of the file @return KErrNone */ LOCAL_C TInt FileCloseVars(CFsRequest* aRequest, TDes& aFileName) { __ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileSubClose,Fault(EBaseRequestMessage)); const TDes* fileName=(TDes*) I64HIGH(aRequest->ScratchValue64()); if(fileName == NULL) return(KErrBadName); aFileName = _L("?:"); aFileName[0] = TText('A' + aRequest->DriveNumber()); aFileName.Append(*fileName); return(KErrNone); }
/** Reading data @param aPos position to read @param aLength number of bytes to read @param aTrg targer buffer @return KErrNone or KErrOverflow in case of an error */ TInt CTestProxyDrive::Read(TInt64 aPos, TInt aLength, TDes8& aTrg) { __FNLOG ("CTestProxyDrive::Read"); // TInt64 is not supported by Copy() ASSERT (I64HIGH(aPos) == 0); if(!aLength) { return KErrNone; } if( (static_cast<TUint>(iMediaBuf.Length()) <= I64LOW(aPos)) && (static_cast<TUint>(iMediaBuf.Length()) <= I64LOW(aPos) + static_cast<TUint>(aLength)) ) { return KErrOverflow; } aTrg.Copy(&iMediaBuf[I64LOW(aPos)], aLength); return KErrNone; }
// ----------------------------------------------------------------------------- // TAccPolGenericIDAccessor::DebugPrint // Trace out the static header of Generic ID instance in debug build. // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C void TAccPolGenericIDAccessor::DebugPrint( const TAccPolGenericID& aGenericID ) { COM_TRACE_( "[AccFW: ACCPOLICY] START GenericID:" ); COM_TRACE_1(" DeviceType:0x%x", aGenericID.iStaticAttributes.iAccessoryDeviceType ); COM_TRACE_1( " PhysicalConnection:0x%x", aGenericID.iStaticAttributes.iPhysicalConnection ); COM_TRACE_1( " ApplicationProtocol :0x%x", aGenericID.iStaticAttributes.iApplicationProtocol ); COM_TRACE_2( " CapabilitiesSubblocks: HIGH:0x%x, LOW:0x%x" , I64HIGH( aGenericID.iStaticAttributes.iCapabilitiesSubblocks ), I64LOW( aGenericID.iStaticAttributes.iCapabilitiesSubblocks ) ); COM_TRACE_RAW_1( " HWModelID:", aGenericID.iStaticAttributes.iHWModelID ); COM_TRACE_2( " HWDeviceID: HIGH:0x%x, LOW:0x%x \n" , I64HIGH( aGenericID.iStaticAttributes.iHWDeviceID ), I64LOW( aGenericID.iStaticAttributes.iHWDeviceID ) ); COM_TRACE_2( " DeviceAddress: HIGH:0x%x, LOW:0x%x" , I64HIGH( aGenericID.iStaticAttributes.iDeviceAddress ), I64LOW( aGenericID.iStaticAttributes.iDeviceAddress )); COM_TRACE_1( " Unique Id: %d", aGenericID.iStaticAttributes.iDBID ); COM_TRACE_( "[AccFW: ACCPOLICY] GenericID END" ); }
/** Writing data @param aPos position to write @param aSrc source buffer @return KErrNone or KErrOverflow in case of an error */ TInt CTestProxyDrive::Write (TInt64 aPos, const TDesC8& aSrc) { __FNLOG ("CTestProxyDrive::Write"); // TInt64 is not supported by Copy() ASSERT(0 == I64HIGH(aPos)); if (!aSrc.Length()) { return KErrNone; } if ( (static_cast<TUint>(iMediaBuf.Length()) <= I64LOW(aPos)) && (static_cast<TUint>(iMediaBuf.Length()) <= I64LOW(aPos) + static_cast<TUint>(aSrc.Length())) ) { return KErrOverflow; } TPtr8 ptr (&iMediaBuf[I64LOW(aPos)], aSrc.Length(), aSrc.Length()); ptr.Copy(aSrc); return KErrNone; }
void CalcHotWarm(TUint8& aOut, TUint64 aTime) { TUint8 out = 0; if (aTime>0) { aTime /= TUint64(HotWarmUnit); if (I64HIGH(aTime)) out = 255; else { aTime *= aTime; out = __e32_find_ms1_64(aTime) + 1; } } aOut = (TUint8)out; }
/** Write local clock configuration. On UREL the method does not return and error/leave even if writing the time fails. */ void CAutoClockAdjust::WriteLastAutoAdjustTime() { LBSLOG(ELogP1, "CAutoClockAdjust::WriteLastAutoAdjustTime()\n"); TInt valHi = I64HIGH(iLastAdjustment.Int64()); TInt valLo = I64LOW(iLastAdjustment.Int64()); TInt err; err = iCenRep->Set(KLastAutoClockAdjustmentHi, valHi); // For OOM tests also KErrNoMemory is fine ASSERT((err == KErrNone) || (err == KErrNoMemory)); if (err != KErrNone) { err = iCenRep->Set(KLastAutoClockAdjustmentLo, valLo); ASSERT((err == KErrNone) || (err == KErrNoMemory)); } }
/** Make a streamed representation of this object to RWriteStream aStream. This method is typically by the core dump server when contructing a list of CProcessInfo for a client. Any modifications to this method should be synchronised with InternalizeL(). Also note that the methods used from RWriteStream (>> or WriteUint32L) can behave differently, especially for descriptors. @param aStream Stream to stream object onto @param buf Buffer onto the same stream, used to obtain the correct size of the externalised object @see InternalizeL @see RReadStream @see RWriteStream @post The stream contains an externalised version of this object. */ EXPORT_C void CProcessInfo::ExternalizeL( RWriteStream & aStream, CBufFlat* buf ) { const TUint32 idLow = I64LOW( iId ); const TUint32 idHigh = I64HIGH( iId ); // Take the size of the buffer before we add anything to it. TUint startBufSize = buf->Size(); aStream.WriteUint32L( idLow ); aStream.WriteUint32L( idHigh ); TUint nameLength = 0; if ( ( NULL != iName ) && ( iName->Des().Length() > 0 ) ) { nameLength = iName->Des().Length(); if( nameLength > 0 ) { // Write the number of character elements in the name. aStream.WriteUint32L( nameLength ); aStream << iName->Des(); } } if( nameLength == 0 ) { aStream.WriteUint32L( 0 ); } aStream.WriteUint32L( static_cast<TUint32>(iObserved) ); iSize = buf->Size() - startBufSize + 4; aStream.WriteUint32L( iSize ); }
// ----------------------------------------------------------------------------- // CAccConfigFileParser::bitNumber // Find a bit from aBitmask. // ----------------------------------------------------------------------------- // TInt CAccConfigFileParser::BitNumber( TUint64 aBitmask ) { API_TRACE_2( "[AccFW:SrvUtil] CAccConfigFileParser::BitNumber(HI:0x%x LO:0x%x)", I64HIGH( aBitmask ), I64LOW( aBitmask ) ); #ifdef _DEBUG _LIT( KZeroBitNumber, "ZeroBitNumber" ); if ( !aBitmask ) { COM_TRACE_( "[AccFW:SrvUtil] CAccConfigFileParser::BitNumber - Panics now" ); User::Panic( KZeroBitNumber, KErrArgument ); } #endif // _DEBUG TInt curBit(-1); while( ( aBitmask>> ++curBit ) > 1 ) API_TRACE_1( "[AccFW:SrvUtil] CAccConfigFileParser::BitNumber - return %d", curBit ); return curBit; }
void CTestCrashDataSource::PrintRegs( RRegisterList & aRegisterList ) { RDebug::Printf( "CTestCrashDataSource::PrintRegs()\n" ); if( aRegisterList.Count() > 0 ) { for( TInt i = 0; i < aRegisterList.Count(); i ++ ) { TRegisterData & reg = aRegisterList[i]; RDebug::Printf( " reg[%d] iRegClass=%d, iId=%d, iSubId=%d, iSize=%d, iAvailable=", i, reg.iRegClass, reg.iId, reg.iSubId, reg.iSize ); if(reg.iAvailable) RDebug::Printf( "ETrue\n" ); else RDebug::Printf( "EFalse\n" ); switch ( reg.iSize ) { case 0: RDebug::Printf( " iValue8=0x%X\n", reg.iValue8 ); break; case 1: RDebug::Printf( " iValue16=0x%X\n", reg.iValue16 ); break; case 2: RDebug::Printf( " iValue32=0x%X\n", reg.iValue32 ); break; case 3: RDebug::Printf( " iValue64=0x%X%X\n", I64HIGH(reg.iValue64), I64LOW(reg.iValue64) ); break; } } } else { RDebug::Printf( " No registers to print\n" ); } }
/** Output a table row to the html file @param colNames descriptor array containing rows to be written in the resulting html file */ void CDbDbmsDumper::OutputTableColDataToFileL(const CDesCArray& colNames) { TInt counter = 0; const TInt KNumberOfCols( (iDbTable.ColCount() )); iDbTable.GetL(); // get the row to be output // cols are from 1, to maxCols. not from 0 to KNumberOfCols-1. for (counter = 1; counter <= KNumberOfCols; ++counter) // for each column value in this row { iFile.Write(KCell); if (iDbTable.IsColNull(counter) ) { iBuffer->Des().Format(KNullCol); // write out 'NULL' to the file } else { switch ( iDbTable.ColType(counter) ) { case EDbColInt8: case EDbColInt16: case EDbColInt32: { TInt32 val = iDbTable.ColInt32(counter); iBuffer->Des().Format(KInt32String, val); } break; case EDbColBit: case EDbColUint8: case EDbColUint16: case EDbColUint32: { TUint32 val = iDbTable.ColUint32(counter); iBuffer->Des().Format(KUInt32String, val); } break; case EDbColInt64: { TInt64 val = iDbTable.ColInt64(counter); iBuffer->Des().Format(KUInt64String, I64HIGH(val), I64LOW(val) ); } break; case EDbColReal32: { TReal32 val = iDbTable.ColReal32(counter); iBuffer->Des().Format(KRealString, val); } break; case EDbColReal64: { TReal64 val = iDbTable.ColReal64(counter); iBuffer->Des().Format(KRealString, val); } break; case EDbColDateTime: { TTime val = iDbTable.ColTime(counter); TBuf<80> tmpBuffer; val.FormatL(tmpBuffer, KFormatDate); iBuffer->Des().Copy(tmpBuffer); } break; case EDbColBinary: case EDbColText8: { TPtrC8 val = iDbTable.ColDes8(counter); iBuffer->Des().Copy(val); } break; case EDbColText16: { TPtrC16 val = iDbTable.ColDes16(counter); iBuffer->Des().Copy(val); } break; case EDbColLongText8: iBuffer->Des().Format(KLongText8); break; case EDbColLongText16: LongBinaryL(counter); break; case EDbColLongBinary: if (colNames[counter-1] == KFieldHeaderColName) { FieldHeaderColL(counter); } else { LongBinaryL(counter); } break; default: iBuffer->Des().Format(KUnknownMessage); break; } // switch } // if iFile.Write(*iBuffer); iFile.Write(KCellEnd); } // for }
/** Write some data to the device. @param aPos media position in bytes @param aLength how many bytes to read @param aDataDes data descriptor @return KErrNone on success, standard Epoc error code otherwise */ TInt CWinImgFileDevice::Write(TInt64 aPos, TInt aLength, const TDesC8& aDataDes) { //__PRINT3(_L("#-- CWinImgFileDevice::Write, pos:%LU, len:%u, desLen:%u" ), aPos, aLength, aDataDes.Length()); ASSERT(HandleValid()); if(aLength == 0 || aDataDes.Length() == 0) return KErrNone; if(aLength > aDataDes.Length()) { ASSERT(0); return KErrArgument; } //-- check position on the volume const TInt64 maxPos = iDrvGeometry.TotalSizeInBytes(); if(aPos < 0 || aPos > maxPos) return KErrArgument; const TInt64 lastPos = aPos+aLength; if(lastPos > maxPos) return KErrArgument; TUint32 dataLen = aLength; DWORD dwRes; DWORD dwBytes = 0; const TUint8 *pData = aDataDes.Ptr(); try { //-- 1. position to the media LONG mediaPosHi = I64HIGH(aPos); const TUint32 mediaPosLo = I64LOW(aPos); dwRes = SetFilePointer(iDevHandle, mediaPosLo, &mediaPosHi, FILE_BEGIN); if(dwRes == INVALID_SET_FILE_POINTER) { throw KDiskOpError; } //-- 2. write data to the media //-- check if the pointer is word-aligned const DWORD dwPtrMask = 0x01; if( (DWORD)pData & dwPtrMask) {//-- data pointer isn't aligned, write non-aligned bytes through buffer ASSERT(dataLen); const int oddCnt = 1; ipScratchBuf[0] = *pData; ++pData; --dataLen; if(!WriteFile(iDevHandle, ipScratchBuf, oddCnt, &dwBytes, NULL)) throw KDiskOpError; } ASSERT(!((DWORD)pData & dwPtrMask)); if(dataLen > 0) { if(!WriteFile(iDevHandle, pData, dataLen, &dwBytes, NULL)) throw KDiskOpError; } } catch(TInt nErrId) {//-- some disk operation finished with the error (void)nErrId; ASSERT(nErrId == KDiskOpError); const DWORD dwWinErr = GetLastError(); const TInt epocErr = MapWinError(dwWinErr); __PRINT2(_L("#-- CWinImgFileDevice::Write() error! WinErr:%d, EpocErr:%d"), dwWinErr, epocErr); ASSERT(epocErr != KErrNone); return epocErr; } return KErrNone; }
/** Read a portion of data from the device. Note: at present it _APPENDS_ data to the aDataDes, so the caller must take care of setting its length @param aPos media position in bytes @param aLength how many bytes to read @param aDataDes data descriptor @return KErrNone on success, standard Epoc error code otherwise */ TInt CWinImgFileDevice::Read(TInt64 aPos,TInt aLength, TDes8& aDataDes) { //__PRINT3(_L("#-- CWinImgFileDevice::Read, pos:%LU, len:%u, desMaxLen:%u"), aPos, aLength, aDataDes.MaxLength()); ASSERT(HandleValid()); ASSERT(aLength <= aDataDes.MaxLength()); //-- check position on the volume const TInt64 maxPos = iDrvGeometry.TotalSizeInBytes(); if(aPos < 0 || aPos > maxPos) return KErrArgument; const TInt64 lastPos = aPos+aLength; if(lastPos > maxPos) return KErrArgument; TUint32 dataLen = aLength; if(dataLen == 0) return KErrNone; DWORD dwRes; DWORD dwBytesRead = 0; //aDataDes.SetLength(0); try { //-- 1. position to the media LONG mediaPosHi = I64HIGH(aPos); const TUint32 mediaPosLo = I64LOW(aPos); dwRes = SetFilePointer(iDevHandle, mediaPosLo, &mediaPosHi, FILE_BEGIN); if(dwRes == INVALID_SET_FILE_POINTER) throw KDiskOpError; //-- 2. read data to the scratch buffer and copy it to the descriptor. ASSERT(ipScratchBuf); TUint32 rem = dataLen; while(rem) { const TUint32 bytesToRead = Min(KScratchBufSz, rem); if(!ReadFile(iDevHandle, ipScratchBuf, bytesToRead, &dwBytesRead, NULL)) throw KDiskOpError; aDataDes.Append(ipScratchBuf, bytesToRead); rem-=bytesToRead; } } catch(TInt nErrId) {//-- some disk operation finished with the error (void)nErrId; ASSERT(nErrId == KDiskOpError); const DWORD dwWinErr = GetLastError(); const TInt epocErr = MapWinError(dwWinErr); __PRINT2(_L("#-- CWinImgFileDevice::Read() error! WinErr:%d, EpocErr:%d"), dwWinErr, epocErr); ASSERT(epocErr != KErrNone); return epocErr; } return KErrNone; }
/** Open the device and do some initalisation work. @param aParams device parameters @return Epoc error code, KErrNone if everything is OK */ TInt CWinImgFileDevice::Connect(const TMediaDeviceParams& aParams) { __PRINT(_L("#-- CWinImgFileDevice::Connect()")); if(!aParams.ipDevName) { __LOG(_L("#-- CWinImgFileDevice::Connect() device name is not set!")); return KErrBadName; } __PRINTF(aParams.ipDevName); ASSERT(!HandleValid()); //-- 1. try to locate an image file by given name. WIN32_FIND_DATAA wfd; iDevHandle = FindFirstFileA(aParams.ipDevName, &wfd); const TBool ImgFileAlreadyExists = HandleValid(iDevHandle); FindClose(iDevHandle); iDevHandle = NULL; //-- sector size we will use within image file const TUint32 sectorSizeToUse = (aParams.iDrvGeometry.iBytesPerSector == 0) ? KDefaultSectorSz : aParams.iDrvGeometry.iBytesPerSector; TUint32 fileSzInSectorsToUse = 0; const TUint32 reqSizeSec = aParams.iDrvGeometry.iSizeInSectors; //-- required size in sectors const DWORD dwAccessMode = (aParams.iReadOnly) ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE; if(ImgFileAlreadyExists) {//-- if the image file already exists, try to open it and optionally adjust its size const TInt64 ImgFileSize = MAKE_TINT64(wfd.nFileSizeHigh, wfd.nFileSizeLow); const TUint32 ImgFileSectors = (TUint32)(ImgFileSize / sectorSizeToUse); const TBool ImgFileIsRO = wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY; DWORD dwFileCreationMode = 0; TBool bNeedToAdjustFileSize = EFalse; if(reqSizeSec == 0 || reqSizeSec == ImgFileSectors) {//-- the required size is either not specified (auto) or the same as the existing file has. //-- we can just open this file dwFileCreationMode = OPEN_EXISTING; fileSzInSectorsToUse = ImgFileSectors; } else {//-- we will have to overwrite the image file if(ImgFileIsRO) {//-- we won't be able to overwrite existing file. __LOG(_L("#-- CWinImgFileDevice::Connect() unable to adjust image file size!")); return KErrAccessDenied; } fileSzInSectorsToUse = reqSizeSec; dwFileCreationMode = CREATE_ALWAYS; bNeedToAdjustFileSize = ETrue; } iDevHandle = CreateFileA(aParams.ipDevName, dwAccessMode, FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES)NULL, dwFileCreationMode, FILE_ATTRIBUTE_NORMAL, NULL); if(!HandleValid(iDevHandle)) { const DWORD winErr = GetLastError(); __LOG1(_L("#-- CWinImgFileDevice::Connect() Error opening/creating file! WinErr:%d"), winErr); return MapWinError(winErr); } //-- adjust file size if we need if(bNeedToAdjustFileSize) { const TInt64 newFileSize = (TInt64)reqSizeSec * sectorSizeToUse; ASSERT(newFileSize); LONG newFSzHi = I64HIGH(newFileSize); DWORD dwRes = SetFilePointer(iDevHandle, I64LOW(newFileSize), &newFSzHi, FILE_BEGIN); if(dwRes == INVALID_SET_FILE_POINTER || !SetEndOfFile(iDevHandle)) { const DWORD winErr = GetLastError(); Disconnect(); __LOG1(_L("#-- CWinImgFileDevice::Connect() unable to set file size! WinErr:%d"), winErr); return MapWinError(winErr); } } } else //if(ImgFileAlreadyExists) {//-- if the image file does not exist or its size differs from required. try to create it if(reqSizeSec == 0) { __LOG(_L("#-- CWinImgFileDevice::Connect() The image file doesn't exist ant its size isn't specified!")); return KErrArgument; } fileSzInSectorsToUse = reqSizeSec; //-- create a new image file iDevHandle = CreateFileA(aParams.ipDevName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES)NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(!HandleValid(iDevHandle)) { const DWORD winErr = GetLastError(); __LOG1(_L("#-- CWinImgFileDevice::Connect() can not create file! WinErr:%d"), winErr); return MapWinError(winErr); } //-- set its size const TInt64 newFileSize = (TInt64)reqSizeSec * sectorSizeToUse; ASSERT(newFileSize); LONG newFSzHi = I64HIGH(newFileSize); DWORD dwRes = SetFilePointer(iDevHandle, I64LOW(newFileSize), &newFSzHi, FILE_BEGIN); if(dwRes == INVALID_SET_FILE_POINTER || !SetEndOfFile(iDevHandle)) { const DWORD winErr = GetLastError(); Disconnect(); __LOG1(_L("#-- CWinImgFileDevice::Connect() unable to set file size! WinErr:%d"), winErr); return MapWinError(winErr); } //-- if parametrs require a read-only file, reopen it in RO mode, it doesn't make a lot of sense though... if(aParams.iReadOnly) { CloseHandle(iDevHandle); iDevHandle = NULL; iDevHandle = CreateFileA(aParams.ipDevName, GENERIC_READ , FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(!HandleValid(iDevHandle)) { const DWORD winErr = GetLastError(); __LOG1(_L("#-- CWinImgFileDevice::Connect() Can't reopen a file in RO mode! WinErr:%d"), winErr); return MapWinError(winErr); } }//if(aParams.iReadOnly) }//else if(ImgFileAlreadyExists) //-- here we must have the image file created/opened and with correct size ASSERT(HandleValid()); ASSERT(sectorSizeToUse); if(fileSzInSectorsToUse < KMinMediaSizeInSectors) { __LOG1(_L("#-- CWinImgFileDevice::Connect() Image file is too small! sectors:%d"), fileSzInSectorsToUse); Disconnect(); return KErrGeneral; } iDrvGeometry.iBytesPerSector = sectorSizeToUse; iDrvGeometry.iSizeInSectors = fileSzInSectorsToUse; //-- map the image file into memory. ASSERT(!HandleValid(ihFileMapping)); ASSERT(!ipImageFile); /* don't map image file, because it can be > 4G. ihFileMapping = CreateFileMapping(Handle(), NULL, aParams.iReadOnly ? PAGE_READONLY : PAGE_READWRITE, 0, 0, NULL); if(HandleValid(ihFileMapping)) { ipImageFile = (TUint8*)MapViewOfFile(ihFileMapping, aParams.iReadOnly ? FILE_MAP_READ : FILE_MAP_WRITE, 0,0,0); } if(!ipImageFile) { __PRINT1(_L("#-- CWinImgFileDevice::Connect() Error mapping file! WinErr:%d"), GetLastError()); Disconnect(); return KErrGeneral; } */ return KErrNone; }
/** Write some data to the device. @param aPos media position in bytes @param aLength how many bytes to read @param aDataDes data descriptor @return KErrNone on success, standard Epoc error code otherwise */ TInt CWinVolumeDevice::Write(TInt64 aPos, TInt aLength, const TDesC8& aDataDes) { //__PRINT2(_L("#-- CWinVolumeDevice::Write, pos:%LU, len:%u"), aPos, aLength); ASSERT(HandleValid()); if(aLength == 0 || aDataDes.Length() == 0) return KErrNone; if(aLength > aDataDes.Length()) { ASSERT(0); return KErrArgument; } //-- check position on the volume const TInt64 maxPos = iDrvGeometry.TotalSizeInBytes(); if(aPos < 0 || aPos > maxPos) return KErrArgument; const TInt64 lastPos = aPos+aLength; if(lastPos > maxPos) return KErrArgument; TUint32 dataLen = aLength; DWORD dwRes; DWORD dwBytes = 0; const TUint32 KSectorSize = BytesPerSector(); const TUint8 *pData = aDataDes.Ptr(); try { LONG mediaPosHi = I64HIGH(aPos); const TUint32 mediaPosLo = I64LOW(aPos); const TUint32 startPosOffset = mediaPosLo & (KSectorSize-1); const TUint32 sectorPos = mediaPosLo-startPosOffset; //-- 1. position to the media with sector size granularity dwRes = SetFilePointer(iDevHandle, sectorPos, &mediaPosHi, FILE_BEGIN); if(dwRes == INVALID_SET_FILE_POINTER) { throw KDiskOpError; } if(startPosOffset || dataLen <= KSectorSize) {//-- need a read-modify-write here. //-- 1.1 read first sector if(!ReadFile(iDevHandle, ipScratchBuf, KSectorSize, &dwBytes, NULL)) throw KDiskOpError; dwRes = SetFilePointer(iDevHandle, sectorPos, &mediaPosHi, FILE_BEGIN); if(dwRes == INVALID_SET_FILE_POINTER) { throw KDiskOpError; } if(dwRes == INVALID_SET_FILE_POINTER) throw KDiskOpError; //-- 1.2 copy chunk of data there const TUint32 firstChunkLen = Min(dataLen, KSectorSize - startPosOffset); Mem::Copy(ipScratchBuf+startPosOffset, pData, firstChunkLen); //-- 1.3 write sector if(!WriteFile(iDevHandle, ipScratchBuf, KSectorSize, &dwBytes, NULL)) throw KDiskOpError; dataLen-=firstChunkLen; pData+=firstChunkLen; if(dataLen == 0) return KErrNone; //-- no more data to write } //-- 2. write whole number of sectors to the media const TUint32 KBytesTail = dataLen & (KSectorSize-1); //-- number of bytes in the incomplete last sector TUint32 KMainChunkBytes = dataLen - KBytesTail; ASSERT((KMainChunkBytes % KSectorSize) == 0); //-- the pointer to the data shall be 2-bytes aligned, otherwise WriteFile will fail if(!((DWORD)pData & 0x01)) {//-- data pointer aligned, ok if(!WriteFile(iDevHandle, pData, KMainChunkBytes, &dwBytes, NULL)) throw KDiskOpError; pData+=KMainChunkBytes; dataLen-=KMainChunkBytes; } else {//-- data pointer is odd, we need to copy data to the aligned buffer TUint32 rem = KMainChunkBytes; while(rem) { const TUint32 nBytesToWrite = Min(KScratchBufSz, rem); Mem::Copy(ipScratchBuf, pData, nBytesToWrite); if(!WriteFile(iDevHandle, ipScratchBuf, nBytesToWrite, &dwBytes, NULL)) throw KDiskOpError; rem-=nBytesToWrite; pData+=nBytesToWrite; dataLen-=nBytesToWrite; } } //-- 3. write the rest of the bytes into the incomplete last sector if(KBytesTail) { //-- 3.1 read last sector if(!ReadFile(iDevHandle, ipScratchBuf, KSectorSize, &dwBytes, NULL)) throw KDiskOpError; LARGE_INTEGER liRelOffset; liRelOffset.QuadPart = -(LONG)KSectorSize; //dwRes = SetFilePointer(iDevHandle, -(LONG)KSectorSize, NULL, FILE_CURRENT); dwRes = SetFilePointer(iDevHandle, liRelOffset.LowPart, &liRelOffset.HighPart, FILE_CURRENT); if(dwRes == INVALID_SET_FILE_POINTER) throw KDiskOpError; //-- 1.2 copy chunk of data there Mem::Copy(ipScratchBuf, pData, KBytesTail); //-- 1.3 write sector if(!WriteFile(iDevHandle, ipScratchBuf, KSectorSize, &dwBytes, NULL)) throw KDiskOpError; } }//try catch(TInt nErrId) {//-- some disk operation finished with the error (void)nErrId; ASSERT(nErrId == KDiskOpError); const DWORD dwWinErr = GetLastError(); const TInt epocErr = MapWinError(dwWinErr); __PRINT2(_L("#-- CWinVolumeDevice::Write() error! WinErr:%d, EpocErr:%d"), dwWinErr, epocErr); ASSERT(epocErr != KErrNone); return epocErr; } return KErrNone; }
/** Read a portion of data from the device. Note: at present it _APPENDS_ data to the aDataDes, so the caller must take care of setting its length @param aPos media position in bytes @param aLength how many bytes to read @param aDataDes data descriptor @return KErrNone on success, standard Epoc error code otherwise */ TInt CWinVolumeDevice::Read(TInt64 aPos, TInt aLength, TDes8& aDataDes) { //__PRINT2(_L("#-- CWinVolumeDevice::Read, pos:%LU, len:%u"), aPos, aLength); ASSERT(HandleValid()); ASSERT(aLength <= aDataDes.MaxLength()); //-- check position on the volume const TInt64 maxPos = iDrvGeometry.TotalSizeInBytes(); if(aPos < 0 || aPos > maxPos) return KErrArgument; const TInt64 lastPos = aPos+aLength; if(lastPos > maxPos) return KErrArgument; //-- TUint32 dataLen = aLength; if(dataLen == 0) return KErrNone; DWORD dwRes; DWORD dwBytesRead = 0; //aDataDes.SetLength(0); const TUint32 KSectorSize = BytesPerSector(); try { LONG mediaPosHi = I64HIGH(aPos); const TUint32 mediaPosLo = I64LOW(aPos); const TUint32 startPosOffset = mediaPosLo & (KSectorSize-1); //-- 1. position to the media with sector size granularity and read 1st sector dwRes = SetFilePointer(iDevHandle, mediaPosLo-startPosOffset, &mediaPosHi, FILE_BEGIN); if(dwRes == INVALID_SET_FILE_POINTER) throw KDiskOpError; //-- 1.1 read 1st sector if(!ReadFile(iDevHandle, ipScratchBuf, KSectorSize, &dwBytesRead, NULL)) throw KDiskOpError; const TUint32 firstChunkLen = Min(dataLen, KSectorSize - startPosOffset); aDataDes.Append(ipScratchBuf+startPosOffset, firstChunkLen); dataLen-=firstChunkLen; if(dataLen == 0) return KErrNone; //-- no more data to read //-- 2. read whole number of sectors from the meida const TUint32 KBytesTail = dataLen & (KSectorSize-1); //-- number of bytes in the incomplete last sector ASSERT((KScratchBufSz % KSectorSize) == 0); TUint32 rem = dataLen - KBytesTail; while(rem) { const TUint32 bytesToRead = Min(KScratchBufSz, rem); if(!ReadFile(iDevHandle, ipScratchBuf, bytesToRead, &dwBytesRead, NULL)) throw KDiskOpError; aDataDes.Append(ipScratchBuf, bytesToRead); rem-=bytesToRead; } //-- 3. read the rest of the bytes in the incomplete last sector if(KBytesTail) { if(!ReadFile(iDevHandle, ipScratchBuf, KSectorSize, &dwBytesRead, NULL)) throw KDiskOpError; aDataDes.Append(ipScratchBuf, KBytesTail); } }//try catch(TInt nErrId) {//-- some disk operation finished with the error (void)nErrId; ASSERT(nErrId == KDiskOpError); const DWORD dwWinErr = GetLastError(); const TInt epocErr = MapWinError(dwWinErr); __PRINT2(_L("#-- CWinVolumeDevice::Read() error! WinErr:%d, EpocErr:%d"), dwWinErr, epocErr); ASSERT(epocErr != KErrNone); return epocErr; } return KErrNone; }
/** Obtain the thread list. If aProcessId is negative, we obtain the entire system thread list. If aProcessId is positive we get the thread list for that process */ void CServerCrashDataSource::GetThreadListL( const TUint64 aProcessId, RThreadPointerList & aThreadList, TUint & aTotalThreadListDescSize ) { LOG_MSG2( "->CServerCrashDataSource::GetThreadListL(aProcessId=%Lu)\n", aProcessId); // Delete any objects in the array, since we will replace them. aThreadList.ResetAndDestroy(); aTotalThreadListDescSize = 0; if( iThreadListBuffer.Size() != iLastThreadListSize ) { LOG_MSG2("CServerCrashDataSource::GetThreadListL -> iThreadListBuffer.ReAlloc(%d)\n", iLastThreadListSize ); iThreadListBuffer.ReAllocL( iLastThreadListSize ); } LOG_MSG( "CServerCrashDataSource::GetThreadListL -> DoGetListL()\n" ); DoGetListL( EThreads, (TUint)-1, aProcessId, iThreadListBuffer, iLastThreadListSize ); iLastThreadListSize = iThreadListBuffer.Size(); CThreadInfo * threadInfoPtr; RThread thread; TThreadStackInfo stackInfo; TThreadListEntry * entry; TUint usrStackSize; TLinAddr usrStackAddr; TLinAddr svcStackPtr; TLinAddr svcStackBase; TUint svcStackSize; TUint priority; TUint8* ptr = (TUint8*)( iThreadListBuffer.Ptr() ); const TUint8* ptrEnd = ptr + iLastThreadListSize; //LOG_MSG3( " Data start,end=(0x%x, 0x%x)\n", ptr, ptrEnd ); while( ptr < ptrEnd ) { entry = (TThreadListEntry*)ptr; if( !entry ) { LOG_MSG( " ERROR !* : TThreadListEntry is NULL\n" ); User::Leave(KErrBadHandle); } if( entry->iNameLength == 0 ) { LOG_MSG4( " Skipping Thread 0x%X%X : entry->iNameLength=%d", I64HIGH(entry->iThreadId), I64LOW(entry->iThreadId), entry->iNameLength ); ptr += Align4( entry->GetSize() ); continue; } //LOG_MSG3( " entry &=0x%X, size=%d\n", &(entry->iThreadId), entry->GetSize() ); //LOG_MSG3( " entry->iThreadId= 0x%X%X\n", I64HIGH(entry->iThreadId), I64LOW(entry->iThreadId) ); //LOG_MSG3( " found tid=%d, pid=%d\n", I64LOW(entry->iThreadId), I64LOW(entry->iProcessId) ); if( entry->iSupervisorStackPtrValid ) { svcStackPtr = entry->iSupervisorStackPtr; } else { svcStackPtr = 0; } if( entry->iSupervisorStackBaseValid ) { svcStackBase = entry->iSupervisorStackBase; } else { svcStackBase = 0; } if( entry->iSupervisorStackSizeValid ) { svcStackSize = entry->iSupervisorStackSize; } else { svcStackSize = 0; } if( KErrNone == thread.Open( entry->iThreadId ) ) { priority = (TUint)(thread.Priority()); if( KErrNone == thread.StackInfo( stackInfo ) ) { usrStackAddr = stackInfo.iLimit; usrStackSize = stackInfo.iBase - stackInfo.iLimit; } else { usrStackSize = 0; usrStackAddr = 0; } thread.Close(); } else { usrStackSize = 0; usrStackAddr = 0; priority = 0; } /* LOG_MSG3( " entry->iNameLength=%d, &(entry->iName[0])=0x%X\n", entry->iNameLength, &(entry->iName[0]) ); */ TPtrC entryName( &(entry->iName[0]), entry->iNameLength ); //LOG_MSG2( " -> threadInfoPtr = CThreadInfo::NewL( name.Size()=%d)\n", entryName.Size() ); threadInfoPtr = CThreadInfo::NewL( entry->iThreadId, entryName, entry->iProcessId, (TUint)priority, svcStackPtr, svcStackBase, svcStackSize, usrStackAddr, usrStackSize ); /* LOG_MSG3( " threadInfoPtr->iSvcStackAddr=0x%X, threadInfoPtr->iSvcStackSize=0x%X\n", threadInfoPtr->SvcStackAddr(), threadInfoPtr->SvcStackSize() ); */ TInt err = aThreadList.Append( threadInfoPtr ); if( err != KErrNone ) { // We use this id so as not to use Push(), AppendL(), Pop() delete threadInfoPtr; User::Leave( err ); } aTotalThreadListDescSize += threadInfoPtr->Size(); /* LOG_MSG3( " aTotalThreadListDescSize = %d after adding %d\n", aTotalThreadListDescSize, threadInfoPtr->Size() ); RBuf rPrintBuf; rPrintBuf.Create( threadInfoPtr->Name()); RDebug::Printf( " <- rPrintBuf.Create(), rPrintBuf.Length()=%d\n", rPrintBuf.Length() ); char* cl = (char*) rPrintBuf.Collapse().PtrZ(); RDebug::Printf(" name=%s\n", cl ); rPrintBuf.Close(); */ ptr += Align4( entry->GetSize() ); //LOG_MSG2( " ptr += Align4(entry->GetSize()) = 0x%X\n", ptr ); } // while }
// ----------------------------------------------------------------------------- // CAccConfigFileParser::ParseSubblocksL // Detecting subblocks and store them to destination array // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CAccConfigFileParser::ParseSubblocksL( const TUint64& aVal, RArray<TUint64>& aCaps ) { COM_TRACE_( "[AccFW:SrvUtil] CAccConfigFileParser::ParseSubblocksL()" ); TUint64 sum( 0 ); TUint64 curVal( 1 ); TInt curBit( 0 ); do { COM_TRACE_4( "[AccFW:SrvUtil] CAccConfigFileParser::(Cap) Binary for this roundtrip is HI:0x%x LO:0x%x, total sum is HI:0x%x LO:0x%x", I64HIGH( curVal ), I64LOW( curVal ), I64HIGH( sum ), I64LOW( sum ) ); COM_TRACE_2( "[AccFW:SrvUtil] CAccConfigFileParser::(Cap) & HI:0x%x LO:0x%x", I64HIGH( curVal & aVal ), I64LOW( curVal & aVal ) ); // Check if this subblock is defined in SB-def block if ( ( curVal & aVal ) == curVal ) { COM_TRACE_2( "[AccFW:SrvUtil] CAccConfigFileParser::(Cap) MATCH! HI:0x%x LO:0x%x", I64HIGH( curVal ), I64LOW( curVal ) ); aCaps.AppendL( curVal ); // Append to found caps array sum += curVal; } curBit++; curVal = 2 * curVal; } while ( sum < aVal && curBit < KAccConfigMaxCapabilityGroups ); COM_TRACE_( "[AccFW:SrvUtil] CAccConfigFileParser::ParseSubblocksL - return void" ); }
/** Required by RHashSet<TLookupEntry> to generate hash value. @see RHashSet */ TUint32 HashFunction(const TLookupEntry& aEntry) { return (DefaultHash::Integer(I64HIGH(aEntry.iPos)) + DefaultHash::Integer(I64LOW(aEntry.iPos))); }
// --------------------------------------------------------------------------- // For sending the frames. // --------------------------------------------------------------------------- // TInt CBTAudioStreamSender::SendThisBuffer(const TDesC8& aBuffer, TTimeIntervalMicroSeconds aTimestamp) { BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SendThisBuffer() ->"))); BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t Received timestamp low: %d"), I64LOW(aTimestamp.Int64()))); BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FPrint(_L("[BTAudioStreamer]\t Received timestamp high: %d"), I64HIGH(aTimestamp.Int64()))); // Store the buffer's address for later reference. iBuffer = &aBuffer; if(iChangingFrameLength != EFalse) { // Check the new framelength... if(aBuffer.Length() == iNewFrameLength) // Check if the buffer exactly of the new length. { // If we have data with previous frame length in buffer, send it first. if(iNonprocessedDataInBuffer != EFalse) { ProceedToPacketSending(); return KErrNone; } else // Else we can switch to new packet immediately and continue processing this buffer. { SwitchToNewSendPacket(); } } else if(aBuffer.Length() > iNewFrameLength) // Check if it's safe to peek at index iNewFrameLength. { if(aBuffer[iNewFrameLength] == 0x9c) // Check if the index iNewFrameLength the syncword. { // If we have data with previous frame length in buffer, send it first. if(iNonprocessedDataInBuffer != EFalse) { ProceedToPacketSending(); return KErrNone; } else // Else we can switch to new packet immediately and continue processing this buffer. { SwitchToNewSendPacket(); } } else { BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender: Still waiting for packets of the new frame length..."))); } } else { BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender: Still waiting for packets of the new frame length..."))); // Encoder has not yet started to use the new frame length. } } else if(iStreamerState != EBuffering) { // Previous sending is not yet completed or there is was an error that is not yet handled. // Just discard the incoming frame. BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender error: Previous buffer sending hasn't completed - discarding this buffer."))); iObserver.NotifyBufferSent(aBuffer); BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SendThisBuffer() <-"))); return KErrOverflow; } // Store the timestamp for later use. iTimestamp = aTimestamp.Int64(); iNonprocessedDataInBuffer = ETrue; ConsumeBuffer(); BT_AUDIO_STREAMER_TRACE_OPT( KPRINTFTRACE, FLOG(_L("[BTAudioStreamer]\t CBTAudioStreamSender::SendThisBuffer() <-"))); return KErrNone; }
// ----------------------------------------------------------------------------- // CAccConfigFileParser::FindL // Find a matching Generic ID for Hardware Device ID. // ----------------------------------------------------------------------------- // EXPORT_C void CAccConfigFileParser::FindL( CAccConGenericID* const aGenericID, TUint64 aHWDeviceID, const TDesC& aHWModelID ) { API_TRACE_2( "[AccFW:SrvUtil] CAccConfigFileParser::FindL(Device HI:0x%x LO:0x%x)", I64HIGH( aHWDeviceID ), I64LOW( aHWDeviceID ) ); CAccPolAccessoryPolicy* accPolicy = CAccPolAccessoryPolicy::NewL( NULL ); // This is not used in ParseGenericIDContent since last parameter is not EAccRule TBuf8<1> nullGidInt; CleanupStack::PushL( accPolicy ); accPolicy->ParseGenericIDContentL( aGenericID, aHWDeviceID, aHWModelID, nullGidInt, // We don't have GID integer EAccUnknown ); // unknown type. accPolicy does not use this value in search CleanupStack::PopAndDestroy( accPolicy ); API_TRACE_( "[AccFW:SrvUtil] CAccConfigFileParser:::FindL - return void" ); }
/** Outputs one row of a tables data. @param aTableIndex table index in the table array */ void CDbSqlDumper::OutputTableColDataToFileL(TInt aTableIndex) { TInt counter = 0; const TInt KNumberOfCols( iDbStructure->ColumnNo(aTableIndex) ); // cols are from 1, to maxCols. not from 0 to KNumberOfCols-1. for (counter = 0; counter < KNumberOfCols; ++counter) // for each column value in this row { iFile.Write(KCell); if (iSqlStatement.IsNull(counter) ) { iBuffer->Des().Format(KNullCol); // write out 'NULL' to the file } else { switch ( iSqlStatement.ColumnType(counter) ) { case ESqlInt: { TInt32 val = iSqlStatement.ColumnInt(counter); iBuffer->Des().Format(KInt32String, val); } break; case ESqlInt64: { TInt64 val = iSqlStatement.ColumnInt64(counter); iBuffer->Des().Format(KUInt64String, I64HIGH(val), I64LOW(val) ); } break; case ESqlReal: { TReal32 val = iSqlStatement.ColumnReal(counter); iBuffer->Des().Format(KRealString, val); } break; case ESqlText: { iBuffer->Des().Copy(iSqlStatement.ColumnTextL(counter)); } break; case ESqlBinary: if ((iDbStructure->Column(aTableIndex, counter) == KContactTextFieldHeader) || (iDbStructure->Column(aTableIndex, counter) == KContactBinaryFieldHeader)) { FieldHeaderColL(counter); } else { LongBinaryL(counter); } break; default: iBuffer->Des().Format(KUnknownMessage); break; } // switch } // if iFile.Write(*iBuffer); iFile.Write(KCellEnd); } // for }
void CServerCrashDataSource::GetProcessListL( RProcessPointerList & aProcessList, TUint & aTotalProcessListDescSize ) { //LOG_MSG( "CServerCrashDataSource::GetProcessListL()\n" ); // Delete any objects in the array, since we will replace them. aProcessList.ResetAndDestroy(); aTotalProcessListDescSize = 0; if( iProcListBuffer.Size() != iLastProcListSize ) { LOG_MSG2( " iProcListBuffer.ReAlloc( %d)\n", iLastProcListSize ); iProcListBuffer.ReAllocL( iLastProcListSize ); } DoGetListL( EProcesses, (TUint)(-1), (TUint)(-1), iProcListBuffer, iLastProcListSize ); iLastProcListSize = iProcListBuffer.Size(); TUint8* ptr = (TUint8*)( iProcListBuffer.Ptr() ); const TUint8* ptrEnd = ptr + iLastProcListSize; //LOG_MSG3( " Data start,end=(0x%x, 0x%x)\n", ptr, ptrEnd ); while( ptr < ptrEnd ) { TProcessListEntry *entry = (TProcessListEntry*)ptr; if( !entry ) { LOG_MSG( " ERROR !* : TProcessListEntry is NULL\n" ); User::Leave(KErrBadHandle); } TUint64 id = entry->iProcessId; if( entry->iFileNameLength == 0 ) { LOG_MSG4( " Skipping process 0x%X%X : entry->iFileNameLength=%d", I64HIGH(entry->iProcessId), I64LOW(entry->iProcessId), entry->iFileNameLength ); ptr += Align4( entry->GetSize() ); continue; } /* LOG_MSG4( " process 0x%X%X has iFileNameLength=%d", I64HIGH(entry->iProcessId), I64LOW(entry->iProcessId), entry->iFileNameLength ); */ TPtrC entryName(&(entry->iNames[0]), entry->iFileNameLength); CProcessInfo *procInfoPtr = CProcessInfo::NewL(id, entryName ); TInt err = aProcessList.Append( procInfoPtr ); if(err != KErrNone) { delete procInfoPtr; User::Leave(err); } aTotalProcessListDescSize += procInfoPtr->Size(); ptr += Align4( entry->GetSize() ); } }