Exemplo n.º 1
0
Bool updateMenu(struct Menu *mnu)
{
    Bool exit = False;
    uiShowCursor(False);
    int key = getch();
    switch( key )
    {
        case 10:
        case 13:
        case KEY_ENTER:
        {
            // exec menu
            struct MenuEntry* entry = (struct MenuEntry*)
                    lstGet(mnu->menuEntries, mnu->currentPos);
            if(entry && entry->exec)
            {
                exit = entry->exec(entry->text);
                // au cas ou le menu aurait modifier ces valeurs essentielles
                // à un bon rendu
                uiShowCursor(False);
                uiStatus(STATUS_INFO, "");
            }
            break;
        }
        case KEY_DOWN:
            ++mnu->currentPos;
            // wrap
            if( mnu->currentPos > lstCount(mnu->menuEntries) -1 )
                mnu->currentPos = 0;
            break;
        case KEY_UP:
            --mnu->currentPos;
            // wrap
            if( mnu->currentPos < 0 )
                mnu->currentPos = lstCount(mnu->menuEntries) -1;
            break;
        // F1: help
        case KEY_F0+1:
        {
            struct MenuEntry* entry = (struct MenuEntry*)
                lstGet(mnu->menuEntries, mnu->currentPos);
            uiStatus(STATUS_INFO, entry->helpText);
            break;
        }
        case 8: // backspace on windows
        case KEY_ESC:
            exit = True;
            break;
    }
    uiRefresh(ALL);
    uiShowCursor(True);
    return exit;
}
BST_UINT32 BST_CTaskSchdler::ChkTaskExist ( BST_CORE_CPTask *pC_PTask )
{
    BST_CORE_PTASK_NODE_STRU   *pstPtaskNode;

    if ( BST_NULL_PTR == pC_PTask )
    {
        BST_RLS_LOG( "BST_CTaskSchdler::ChkTaskExist pC_PTask=NULL" );
        return BST_FALSE;
    }

    if ( 0 == lstCount( &g_stPTaskList ) )
    {
        BST_RLS_LOG( "BST_CTaskSchdler::ChkTaskExist g_stPTaskList count=0" );
        return BST_FALSE;
    }

    /*
     * 遍历任务表,对比pcPtask,相等的记为找到
     */
    for ( pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList );
          pstPtaskNode!= BST_NULL_PTR;
          pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstNext((NODE *)pstPtaskNode) )
    {
        if ( BST_NULL_PTR == pstPtaskNode->pcTask )
        {
            continue;
        }
        if ( pC_PTask == pstPtaskNode->pcTask )
        {
            return BST_TRUE;
        }
    }
    return BST_FALSE;
}
BST_VOID BST_CTaskSchdler::Suspend ( BST_VOID )
{
    BST_CORE_PTASK_NODE_STRU   *pstPtaskNode;

    if ( 0 == lstCount( &g_stPTaskList ) )
    {
        BST_RLS_LOG( "BST_CTaskSchdler::Suspend g_stPTaskList count=0" );
        return;
    }
    /*
     * 遍历任务表,找到相关任务对齐进行挂起
     */
    for ( pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList );
          pstPtaskNode!= BST_NULL_PTR;
          pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstNext((NODE *)pstPtaskNode) )
    {
        if ( BST_NULL_PTR == pstPtaskNode->pcTask )
        {
            continue;
        }
        if ( BST_TASK_STATE_START == pstPtaskNode->pcTask->GetState () )
        {
            pstPtaskNode->pcTask->Suspend();
        }
    }
}
Exemplo n.º 4
0
Polygon* newPolygonL(List L)
{
	unsigned int i = 0, nbVx = lstCount(&L);
	Polygon* newPoly = (Polygon*) malloc(sizeof(Polygon));
	Node* it = lstFirst(&L);
	/*Initialisation des Dynamic Arrays */
	newPoly->Rigids = da();
	newPoly->Vertices = da();
	newPoly->InternalRigids = da();
	daReserve(&newPoly->Rigids, nbVx);
	daReserve(&newPoly->Vertices, nbVx);
	newPoly->Center = NULL;
	newPoly->Fixed = FALSE;
	newPoly->GridPos.Valid = FALSE;
	newPoly->Collided = FALSE;

	/* Ajoute les Vertices */
	while(!nodeEnd(it))
	{
		daAdd(&newPoly->Vertices, (Vertex*) nodeGetData(it));
		it = nodeGetNext(it);
	}

	/* Construit les limites, i.e. Créé un nouveau Rigid à partir de
	deux Vertices de la liste et la distance les séparant, puis l'ajoute
	 à la liste */
	for(i = 0; i < nbVx; i++)
		daAdd(&newPoly->Rigids, newRigid((Vertex*)daGet(&newPoly->Vertices, i),
			(Vertex*)daGet(&newPoly->Vertices, (i+1)%nbVx),
			vec2Length(vec2Sub(vxGetPosition((Vertex*)daGet(&newPoly->Vertices, i)),
					vxGetPosition((Vertex*)daGet(&newPoly->Vertices, (i+1)%nbVx))))));
	return newPoly;
}
Exemplo n.º 5
0
void etherOutputHookDelete
(
    FUNCPTR outputHook
)
{

    HOOK_ENTRY *pHookEnt;
    extern LIST outputHookList;
    NODE index;

    for (pHookEnt = (HOOK_ENTRY *)lstFirst(&outputHookList);
            pHookEnt != NULL;
            pHookEnt = (HOOK_ENTRY *)lstNext(&index))
    {
        index = pHookEnt->node;
        if (pHookEnt->routine == outputHook)
        {
            lstDelete(&outputHookList, &pHookEnt->node);
            free(pHookEnt);
        }
    }

    if (lstCount(&outputHookList) <= 0)
    {
        etherOutputHookRtn = NULL;
        lstFree(&outputHookList);
    }

}
Exemplo n.º 6
0
Arquivo: endLib.c Projeto: ariavie/bcm
int endMultiLstCnt
    (
    END_OBJ* pEnd
    )
    {
    return(lstCount(&pEnd->multiList));
    }
BST_ERR_ENUM_UINT8 BST_OS_DeleteMbx( BST_OS_MBX_T *pstMbx )
{
    BST_OS_MAIL_T                     *pstContent;
    BST_OS_LOCKCNT_T                    tThreadLockCnt;

    BST_ASSERT_NULL_RTN( pstMbx,        BST_ERR_INVALID_PTR );
    BST_ASSERT_NULL_RTN( pstMbx->hSem,  BST_ERR_INVALID_PTR );

    BST_OS_DeleteSem( pstMbx->hSem );

    tThreadLockCnt                      = BST_OS_ThreadLock();    
    for (;;)
    {
        if( 0 == lstCount( &pstMbx->hList ) )
        {
            break;
        }
        pstContent                      = (BST_OS_MAIL_T *)lstGet( &pstMbx->hList );
        BST_OS_FREE( pstContent );
    }

    lstFree( &pstMbx->hList);
    
    BST_OS_FREE( pstMbx );

    BST_OS_ThreadUnLock( tThreadLockCnt );
/*lint -e438*/
    return( BST_NO_ERROR_MSG );
/*lint +e438*/
}
BST_VOID BST_CTaskSchdler::TimerExpired(
    BST_OS_TIMERID_T    ulId,
    BST_VOID           *pvPara)
{
    BST_CORE_PTASK_NODE_STRU   *pstPtaskNode;
    BST_CORE_PTASK_NODE_STRU   *pstPtaskNodeNext;

    if ( !BST_OS_IsTimerValid (m_ulTimerId) )
    {
        BST_RLS_LOG1( "BST_CTaskSchdler::TimerExpired m_ulTimerId=%u is invalid",
                      m_ulTimerId );
        return;
    }
    if ( ulId != m_ulTimerId )
    {
        BST_RLS_LOG2( "BST_CTaskSchdler::TimerExpired ulId=%u,m_ulTimerId=%u",
                      ulId, m_ulTimerId );
        return;
    }
    /*
     * 如果没有任务,则直接返回,不做任何操作
     */
    if ( 0 == lstCount( &g_stPTaskList ) )
    {
        BST_RLS_LOG( "BST_CTaskSchdler::TimerExpired g_stPTaskList count=0" );
        return;
    }

    /*
     * 更新系统TICK值
     */
    m_ulSystemTick         += BST_TASK_SYS_TICKS;
    BST_DBG_LOG1 ( "BST_CTaskSchdler::TimerExpired Scheduler TimeOut, Tick=%d ",
                   m_ulSystemTick );

    /*
     * 遍历任务列表,获取任务并进行相应调度
     */
    for ( pstPtaskNode = ( BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList );
          pstPtaskNode!= BST_NULL_PTR;
          pstPtaskNode = pstPtaskNodeNext )
    {
        pstPtaskNodeNext    = ( BST_CORE_PTASK_NODE_STRU *)
                              lstNext((NODE *)pstPtaskNode);
        if ( BST_NULL_PTR == pstPtaskNode->pcTask )
        {
            continue;
        }
        /*
         * 如果任务不为空,则根据状态进行调度
         */
        ScheduleTask ( pstPtaskNode->pcTask );
    }
    /*
     * 再次启动系统TICK定时器
     */
    BST_OS_TimerStart ( m_ulTimerId, BST_TASK_SYS_BASE_TIMELEN );
}
Exemplo n.º 9
0
void objFree(Object* Obj)
{
	Node* N;
	while(lstCount(&Obj->CoordTex) > 0)
	{
		N = lstFirst(&Obj->CoordTex);
		delVec2((Vec2*) nodeGetData(N));
		lstRem(&Obj->CoordTex, N);
	}
	lstFree(&Obj->CoordTex); // Peu utile
	Obj->Shape = NULL;
	Obj->Tex = 0;
}
/*lint -e438*/
BST_VOID BST_CTaskSchdler::Detach ( BST_CORE_CPTask *pC_PTask )
{
    BST_CORE_PTASK_NODE_STRU   *pstPtaskNode;

    if ( !BST_OS_IsTimerValid (m_ulTimerId) )
    {
        BST_RLS_LOG1( "BST_CTaskSchdler::Detach m_ulTimerId=%u is invalid",
                      m_ulTimerId );
        return;
    }
    if ( BST_NULL_PTR == pC_PTask )
    {
        BST_RLS_LOG( "BST_CTaskSchdler::Detach pC_PTask=NULL" );
        return;
    }
    /*
     * 遍历列表,找到pctask相符的任务,从链表删除,释放资源
     */
    for ( pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList );
          pstPtaskNode!= BST_NULL_PTR;
          pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstNext((NODE *)pstPtaskNode) )
    {
        if( pstPtaskNode->pcTask != pC_PTask )
        {
            continue;
        }
        lstDelete( &g_stPTaskList, (NODE *)pstPtaskNode );
        BST_OS_FREE( pstPtaskNode );
        break;
    }
    /*
     * 注销后,如果认为列表为空,则直接关闭定时器,不进行任何调度
     */
    if ( 0 == lstCount( &g_stPTaskList ) )
    {
        BST_DBG_LOG( "BST_CTaskSchdler::Detach Stop Scheduler Timer" );
        BST_OS_TimerStop ( m_ulTimerId );
    }
}
BST_VOID BST_CTaskSchdler::UtranBlockInfoChgProc( BST_UINT32 *pulBlockInfo )
{
    BST_INT32                   lTaskCnt;
    BST_UINT32                  ulNextTickRemainTime;
    BST_UINT32                  ulBlockInfo;
    BST_CORE_PTASK_NODE_STRU   *pstPtaskNode;
    BST_CORE_PTASK_NODE_STRU   *pstPtaskNodeNext;
    BST_BOOL                    bTimerStop;

    if( BST_NULL_PTR == pulBlockInfo)
    {
        return;
    }
    ulBlockInfo     = (BST_UINT32 )*pulBlockInfo;
    BST_DBG_LOG2( "BST_CTaskSchdler::UtranBlockInfoChgProc blockold=u%, blockNew=u%",
                  m_ulBlockInfo,ulBlockInfo);

    if ( m_ulBlockInfo == ulBlockInfo )
    {
        return;
    }
    m_ulBlockInfo           = ulBlockInfo;

    if ( BST_AS_UNBLOCKED == m_ulBlockInfo )
    {

        BST_DBG_LOG1( "BST_CTaskSchdler::UtranBlockInfoChgProc :%d", m_bTaskMissExec );
        if(BST_FALSE == m_bTaskMissExec)
        {
            return;
        }
        lTaskCnt            = lstCount( &g_stPTaskList );

        BST_DBG_LOG1( "BST_CTaskSchdler::UtranBlockInfoChgProc TaskNum=u%", lTaskCnt );

        if ( 0 == lTaskCnt )
        {
            return;
        }
        ulNextTickRemainTime = 0;
        bTimerStop      = BST_OS_TimerIsStop( m_ulTimerId );
        if ( BST_FALSE == bTimerStop )
        {
            ulNextTickRemainTime      = BST_OS_TimeGetRemain( m_ulTimerId );
            BST_OS_TimerStop ( m_ulTimerId );
        }

        BST_DBG_LOG2( "BST_CTaskSchdler::UtranBlockInfoChgProc stop:%d,timerremain=u%", bTimerStop,ulNextTickRemainTime );
        /*
         * 遍历任务列表,获取任务并进行相应调度
         */
        for ( pstPtaskNode = ( BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList );
              pstPtaskNode!= BST_NULL_PTR;
              pstPtaskNode = pstPtaskNodeNext )
        {
            pstPtaskNodeNext    = ( BST_CORE_PTASK_NODE_STRU *)
                                  lstNext((NODE *)pstPtaskNode);
            if ( BST_NULL_PTR == pstPtaskNode->pcTask )
            {
                continue;
            }
            /*
             * 如果任务不为空,则根据状态进行调度
             */
            TrigScheduleTask ( pstPtaskNode->pcTask);
        }

        if((0 == ulNextTickRemainTime) || (ulNextTickRemainTime > BST_TASK_SYS_BASE_TIMELEN))
        {
            ulNextTickRemainTime = BST_TASK_SYS_BASE_TIMELEN;
        }

        BST_OS_TimerStart ( m_ulTimerId, ulNextTickRemainTime );

    }

}
Exemplo n.º 12
0
unsigned int wdGetRdCount(World* W)
{
	return lstCount(&W->Rigids);
}
Exemplo n.º 13
0
unsigned int wdGetElCount(World* W)
{
	return lstCount(&W->Elastics);
}
Exemplo n.º 14
0
unsigned int wdGetVxCount(World* W)
{
	return lstCount(&W->Vertices);
}
BST_UINT32 BST_OS_GetMailAmount( BST_OS_MBX_T *pstMbx )
{
    BST_ASSERT_NULL_RTN( pstMbx,        0U );
    BST_ASSERT_NULL_RTN( pstMbx->hSem,  0U );
    return( (BST_UINT32)lstCount( &pstMbx->hList ) );
}
Exemplo n.º 16
0
unsigned int wdGetPolyCount(World* W)
{
	return lstCount(&W->Polygons);
}
Exemplo n.º 17
0
void etherInputHookDelete
(
    FUNCPTR inputHook,
    char *pName,
    int unit
)
{
    HOOK_ENTRY *pHookEnt;
    HOOK_ENTRY *pTarget = NULL;

    BOOL unbindFlag = TRUE;    /* Remove handler if hook found? */

    if (pName != NULL)                       /* END case */
    {
        for (pHookEnt = (HOOK_ENTRY *)lstFirst(&inputHookList);
                pHookEnt != NULL;
                pHookEnt = (HOOK_ENTRY *)lstNext(&pHookEnt->node))
        {
            /* Ignore BSD device hook entries. */

            if (pHookEnt->pCookie == NULL)
                continue;

            if (STREQ(pHookEnt->name, pName) && (pHookEnt->unit == unit))
            {
                if (pHookEnt->routine == inputHook)
                {
                    /*
                     * Found matching hook entry to remove. Keep searching
                     * for other hooks on this device if needed.
                     */

                    pTarget = pHookEnt;
                    if (!unbindFlag)    /* Another hook already found? */
                        break;
                }
                else
                {
                    /*
                     * Different hook on same driver - do not unbind.
                     * Stop searching if target hook entry already found.
                     */

                    unbindFlag = FALSE;
                    if (pTarget)
                        break;
                }
            }
        }

        if (pTarget)    /* Remove hook entry if match found. */
        {
            if (unbindFlag)   /* Remove binding if last hook for device. */
            {
                if (muxTkDrvCheck (pName))
                {
                    muxUnbind (pTarget->pCookie, MUX_PROTO_SNARF,
                               nptEtherInputHookRtn);
                }
                else
                {
                    muxUnbind (pTarget->pCookie, MUX_PROTO_SNARF,
                               endEtherInputHookRtn);
                }
            }
            lstDelete (&inputHookList, &pTarget->node);
            free (pTarget);
        }
    }
    else                                     /* 4.4 case */
    {
        for (pHookEnt = (HOOK_ENTRY *)lstFirst(&inputHookList);
                pHookEnt != NULL; pHookEnt = pTarget)
        {
            if (pHookEnt->pCookie)    /* Ignore END device hook entries. */
                continue;

            pTarget = (HOOK_ENTRY *)lstNext(&pHookEnt->node);
            if (pHookEnt->routine == inputHook)
            {
                lstDelete(&inputHookList, &pHookEnt->node);
                free(pHookEnt);
            }
        }
    }

    if (lstCount(&inputHookList) <= 0)
    {
        etherInputHookActive = FALSE;     /* No END driver hooks installed. */
        etherInputHookRtn = NULL;         /* No BSD driver hooks installed. */
        lstFree (&inputHookList);
    }
}