コード例 #1
0
ファイル: kzoeoraa.c プロジェクト: arksoftgit/10c
/////////////////////////////// QuickSort ///////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void
QuickSort( zULONG ulRecord1,    // recursive
           zULONG ulRecord2 )
{
   static WORD wRecurseCnt = 0;
   wRecurseCnt++;
#ifdef DEBUG_ALL
   static WORD wMaxRecurse = 0;
   if ( wMaxRecurse < wRecurseCnt )
   {
      wMaxRecurse = wRecurseCnt;
   }
#endif

   if ( ulRecord1 < ulRecord2 )
   {
      zULONG ul = QuickSortPartition( ulRecord1, ulRecord2 );

      QuickSort( ulRecord1, ul );
      QuickSort( ul + 1, ulRecord2 );
   }

   wRecurseCnt--;

#ifdef DEBUG_ALL
   if ( wRecurseCnt == 0 )
   {
      ASSERT_TRACE( "Maximum quicksort recurse count = %d", wMaxRecurse, FALSE );
//    OutputDebugString( "Maximum recurse count = " );
//    ltoa( wMaxRecurse, szBuffer, 10 );
//    OutputDebugString( szBuffer );
//    OutputDebugString( "\n" );
   }
#endif
}
コード例 #2
0
// ---------------------------------------------------------------------------
// CSsmLangSelCmd::Execute
// ---------------------------------------------------------------------------
//
void CSsmLangSelCmd::Execute( const TDesC8& /*aParams*/, TRequestStatus& aRequest )
    {
    FUNC_LOG;
    
    ASSERT_TRACE( !iClientStatus );
    ASSERT_TRACE( !IsActive() );
    ASSERT_TRACE( iEnv );

    aRequest = KRequestPending;
    iClientStatus = &aRequest;

    RFs* fsSession = &( const_cast<RFs&>( iEnv->Rfs() ) );
    
    //Get the default language
    TInt errorCode = SysLangUtil::GetDefaultLanguage( iDefaultLanguage, fsSession );
    ERROR( errorCode, "Failed to get default language" );

    //Get the language selected
    TInt lastSelectedLang = GetLastSelectedLang();
    TInt lastSelectedRegion ( KErrNotFound );
    TInt lastSelectedCollation ( KErrNotFound );
    
    //Reset error code to KErrNotFound
    errorCode = KErrNotFound;
    
    if ( KSettingAutomatic == lastSelectedLang )
        {
        //Auto selection is enabled
        SetIndividualSettingsToCentRep( KSettingAutomatic, KSettingAutomatic );
        PrepareNextList();
        }
    else if ( ValidateAndGetSettings( lastSelectedLang, lastSelectedRegion, lastSelectedCollation ) )
        {
        //Validate and get the selected Language, Region and Collation code
        errorCode = UseLocale( lastSelectedLang , lastSelectedRegion, lastSelectedCollation );
        ERROR( errorCode, "Failed to load selected Language, Region and Collation" );
        }

    //Load the default Language, Region and Collation in case of loading selected codes failed 
    //and auto selection is disabled.
    if( KErrNone != errorCode && KSettingAutomatic != lastSelectedLang )
        {
        //Validate and use the default codes 
        errorCode = ValidateAndUseDefaultLanguage();
        ERROR( errorCode, "Failed to load default Language, Region and Collation" );
        }
    }
コード例 #3
0
// ---------------------------------------------------------------------------
// CSsmStatePolicyBase::Initialize
// ---------------------------------------------------------------------------
//
EXPORT_C void CSsmStatePolicyBase::Initialize( TRequestStatus& aStatus )
    {
    FUNC_LOG;
    ASSERT_TRACE( iCommandListResourceReader );

	// initialise command list resource reader.
	iCommandListResourceReader->Initialise( aStatus );
    }
// -----------------------------------------------------------------------------
// CSACommonIscServiceChannelListener::RunL
// This function is called by Kernel when ISC API completes outstanding request
// -----------------------------------------------------------------------------
//
void CSACommonIscServiceChannelListener::RunL()
    {
    OstTrace0( TRACE_NORMAL, SA_COMMON_ISC_SERVICE_CHANNEL_LISTENER_AUTOMATED_9, 
        "ISCSERVICE - CSACommonIscServiceChannelListener::RunL()" );
    INTERNAL_TRACE( ( _L( "ISCSERVICE - CSACommonIscServiceChannelListener::RunL()" ) ) );

    ASSERT_TRACE( _L( "ISCSERVICE - CSACommonIscServiceChannelListener::RunL" ),
        ( iStatus.Int() == KErrNone ) );
    ASSERT_TRACE( _L( "ISCSERVICE - CSACommonIscServiceChannelListener::RunL" ),
        ( iConnectionStatus == EIscConnectionNotOk ) );

    if(iConnectionStatus != EIscConnectionOk)
        {
        iAdaptation.ProcessConnectionClosedL( iConnectionStatus );
        INTERNAL_TRACE( ( 
            _L( "ISCSERVICE - CSACommonIscServiceChannelListener::RunL - Isc channel closed!" ) ) );
        }

    OstTrace0( TRACE_NORMAL, SA_COMMON_ISC_SERVICE_CHANNEL_LISTENER_AUTOMATED_10, 
        "ISCSERVICE - CSACommonIscServiceChannelListener::RunL - return void" );
    INTERNAL_TRACE( ( _L( "ISCSERVICE - CSACommonIscServiceChannelListener::RunL - return void" ) ) );
    }
コード例 #5
0
// ---------------------------------------------------------------------------
// CSsmLangSelCmd::PrepareNextList
//
// ---------------------------------------------------------------------------
//
void CSsmLangSelCmd::PrepareNextList()
    {
    FUNC_LOG;
    ASSERT_TRACE( iLangListPref >= EPrimaryLanguages &&
                  iLangListPref <= ETertiaryLanguages );
    INFO_1( "Trying preferred language list %d", iLangListPref );

    iState = EQueryListSize;
    iAdaptation.PrepareSimLanguages(
        static_cast<TSsmLanguageListPriority>( iLangListPref++ ),
        iLangListSize, iStatus );
    SetActive();
    }
コード例 #6
0
// ---------------------------------------------------------------------------
// CSsmShutdownPolicy::GetNextState
// ---------------------------------------------------------------------------
//
TBool CSsmShutdownPolicy::GetNextState(
    TSsmState aCurrentTransition,
    TInt aReason,
    TInt ERROR_PARAM( aError ),
    TInt ERROR_PARAM( aSeverity ),
    TSsmState& aNextState )
    {
    FUNC_LOG;
    INFO_3( "Current state %04x.%04x, reason %d",
        aCurrentTransition.MainState(), aCurrentTransition.SubState(), aReason );
    ERROR_1( aError, "State transition resulted in an error, severity %d", aSeverity );
	ASSERT_TRACE( aCurrentTransition.MainState() == ESsmShutdown );

	TBool moreToCome = EFalse;
    switch( aCurrentTransition.SubState() )
	    {
        case ESsmErrorShutdown:
        case KSsmAnySubState:
        case ESsmNormalShutdown: // Fall through
            aNextState = TSsmState( ESsmShutdown, ESsmShutdownSubStateCritical );
			moreToCome = ETrue;
			break;
		case ESsmShutdownSubStateCritical:
            aNextState = TSsmState( ESsmShutdown, ESsmShutdownSubStateNonCritical );
			moreToCome = ETrue;
			break;
        case ESsmShutdownSubStateNonCritical:
            aNextState = TSsmState( ESsmShutdown, ESsmShutdownSubStatePowerOff );
			moreToCome = ETrue;
			break;
        default:
		    break;
		}

    if ( aCurrentTransition.SubState() == ESsmErrorShutdown )
        {
        TRAPD_ERR( errorCode, StoreStartupReasonL( EUnknownReset ) );
        ERROR( errorCode, "Failed to store startup reason" );
        }
    else if ( aCurrentTransition.SubState() == KSsmAnySubState ||
              aCurrentTransition.SubState() == ESsmNormalShutdown )
        {
        // This needs to be done before Startup adaptation shutdown command
        TRAPD_ERR( errorCode, StoreStartupReasonL(
            FromStarterReasonToCenRep( aReason ) ) );
        ERROR( errorCode, "Failed to store startup reason" );
        }

	return moreToCome;
    }
コード例 #7
0
// ---------------------------------------------------------------------------
// CSsmUiSpecific::Release
// ---------------------------------------------------------------------------
//
EXPORT_C void CSsmUiSpecific::Release()
	{
    FUNC_LOG;

    TAny* tlsPtr = Dll::Tls();
	ASSERT_TRACE( tlsPtr );

    CSsmUiSpecific* self = static_cast<CSsmUiSpecific*>( tlsPtr );
    if ( --self->iReferenceCount == 0 )
        {
        Dll::FreeTls();
        delete self;
        }
	}
コード例 #8
0
// ---------------------------------------------------------------------------
// CSsmLangSelCmd::IsValid
//
// ---------------------------------------------------------------------------
//
TBool CSsmLangSelCmd::IsValid( const TInt aLanguage ) const
    {
    FUNC_LOG;
    ASSERT_TRACE( iValidLanguages );

    TBool valid( EFalse );
    TKeyArrayFix keyProp( 0, ECmpTInt );
    TInt index( KErrNotFound );
    // Returns zero if element is found.
    if ( 0 == iValidLanguages->Find( aLanguage, keyProp, index ) )
        {
        valid = ETrue;
        }
    
    return valid;
    }
コード例 #9
0
ファイル: kzoeoraa.c プロジェクト: arksoftgit/10c
////////////////////////////// Heapify //////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
zULONG
Heapify( LPSORTDATA       lpData,
         LPENTITYINSTANCE lpEI[],
         zULONG           ulRecordCnt,
         zULONG           k )
{
   ASSERT_TRACE( "Heapify error", 0, k <= ulRecordCnt );
   zULONG ulLeft = k << 1;
   zULONG ulLargest;

   if ( ulLeft > ulRecordCnt )
   {
      return( 0 );
   }

   ulLargest = k;
   if ( CompareRecords( ulLeft, ulLargest ) > 0 )
   {
      ulLargest = ulLeft;
   }

   ulLeft++;   // ulRight (use ulLeft to conserve stack space)
   if ( ulLeft <= ulRecordCnt )
   {
      if ( CompareRecords( ulLeft, ulLargest ) > 0 )
      {
         ulLargest = ulLeft;
      }
   }

   if ( k != ulLargest )
   {
      zULONG *p1;
      zULONG *p2;

      // Use uLeft to conserve stack.
      p1 = CSIMP_GETSORTIDX_PTR( k, m_pUseIdx->m_pxIdx );
      p2 = CSIMP_GETSORTIDX_PTR( ulLargest, m_pUseIdx->m_pxIdx );
      ulLeft = *p1;
      *p1 = *p2;
      *p2 = ulLeft;
      return( ulLargest );
   }

   return( 0 );
}  // end of:  Heapify
コード例 #10
0
// ---------------------------------------------------------------------------
// CSsmLangSelCmd::InitializeL
// ---------------------------------------------------------------------------
//
void CSsmLangSelCmd::InitializeL()
    {
    FUNC_LOG;
    ASSERT_TRACE( iEnv );

    iValidLanguages = new ( ELeave ) CArrayFixFlat<TInt>( KLanguageListGranularity );
    
    RFs* fsSession = &( const_cast<RFs&>( iEnv->Rfs() ) );
    
    //Get the list of installed languages
    TInt errorCode = SysLangUtil::GetInstalledLanguages( iValidLanguages,
                                                         fsSession );

    ERROR( errorCode, "Failed to get installed languages" );
    User::LeaveIfError( errorCode );
    
    //Initialize the Language and Region mapping hash set
    InitializeRegionMappingL();

    //Get the number of installed languages
    const TInt validLangCount = iValidLanguages->Count();
    TLinearOrder<TLanguageRegion> order(&CompareLanguageMapping);
    
    //Get the mapped regions for the installed languages
    for(TInt index = 0; index < validLangCount; ++index) 
        {
        TLanguageRegion region = iLangRegionMappingHashSet.FindL(TLanguageRegion(iValidLanguages->At(index)));
        INFO_2( "Found Region code = %d for language %d", region.iRegion, region.iLanguage );
        iRegionsArray.InsertInOrderL(region, order);
        }

    //Connect to Misc adaptation
    errorCode = iAdaptation.Connect();
    ERROR( errorCode, "Failed to connect to RSsmMiscAdaptation" );
    User::LeaveIfError( errorCode );
    }
コード例 #11
0
ファイル: kzoeoraa.c プロジェクト: arksoftgit/10c
/////////////////////////////// QuickSortNR /////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void
QuickSortNR( zULONG ulRecord1,    // non-recursive
             zULONG ulRecord2 )
{
   ASSERT_TRACE( "QuickSort argument error", 0, ulRecord1 <= ulRecord2 );
   zULONG m = ulRecord2 - ulRecord1;
   zULONG ulStackSize = 2;
   while ( m >>= 1 )
   {
      ulStackSize++;
   }

   ulStackSize <<= 2;     // two entries for each comparison
   zPULONG pulStack = (zPULONG)
                       m_pPoolVarData->Alloc( ulStackSize * sizeof( zULONG ) );
   zULONG ulStack = 0;
   zULONG uLeft;
   zULONG uRight;

#ifdef DEBUG_ALL
   zULONG ulStackMax = 0;
#endif

   pulStack[ ulStack++ ] = ulRecord1;
   pulStack[ ulStack++ ] = ulRecord2;
   while ( ulStack )
   {
      uRight = pulStack[ --ulStack ];
      uLeft = pulStack[ --ulStack ];
      m = QuickSortPartition( uLeft, uRight );

#ifdef DEBUG_ALL
      ShowArray( uLeft, uRight );
#endif

      if ( m + 1 < uRight )
      {
#ifdef DEBUG_ALL
         if ( ulStack > ulStackSize - 2 )
         {
            ASSERT_TRACE( "QuickSort stack overflow - %d", ulStackSize, FALSE );
            m_pPoolVarData->Free( pulStack );
            return;
         }
#endif

         pulStack[ ulStack++ ] = m + 1;
         pulStack[ ulStack++ ] = uRight;

#ifdef DEBUG_ALL
         if ( ulStack > ulStackMax )
         {
            ulStackMax = ulStack;
         }
#endif
      }

      if ( uLeft < m )
      {
#ifdef DEBUG_ALL
         if ( ulStack > ulStackSize - 2 )
         {
            ASSERT_TRACE( "QuickSort stack overflow - %d", ulStackSize, FALSE );
            m_pPoolVarData->Free( pulStack );
            return;
         }
#endif

         pulStack[ ulStack++ ] = uLeft;
         pulStack[ ulStack++ ] = m;

#ifdef DEBUG_ALL
         if ( ulStack > ulStackMax )
         {
            ulStackMax = ulStack;
         }
#endif
      }
   }

   m_pPoolVarData->Free( pulStack );

#ifdef DEBUG_ALL
   ASSERT_TRACE( "Max stack utilization = %d\tAllocated stacksize = %d",
                 (ulStackMax, ulStackSize), FALSE );
#endif
}