Exemplo n.º 1
0
void wdInit(World* W, float Width, float Height)
{
	lstInit(&W->Vertices);
	lstInit(&W->Elastics);
	lstInit(&W->Rigids);
	lstInit(&W->Polygons);

	W->Width = Width;
	W->Height = Height;
	W->prevdt = 0.5f;
	W->dt = 0.5f;
	float CellSize=128.f;
	gridInit(&W->CollisionGrid, Width/CellSize+1, Height/CellSize+1);
	gridSetCellSize(&W->CollisionGrid, CellSize);
}
Exemplo n.º 2
0
void hostTblInit (void)
    {

    if (!hostInitFlag)
	{
	hostInitFlag = TRUE;
	lstInit (&hostList);
	hostListSem = semMCreate (mutexOptionsHostLib);
	}
    }
Exemplo n.º 3
0
Arquivo: stack.c Projeto: mcy2w/CStack
int main () {
    Head h = lstInit();
    int a = 9;
    int b = 8;
    int i;
    for (i =0; i < 200; i ++) {
        push(h , &a);
    }
    for (i =0; i < 200; i ++) {
        int * ret = pop(h);
    }

}
Exemplo n.º 4
0
Object* cpyObject(Object* O)
{
	List CT;
	lstInit(&CT);
	Node* it = lstFirst(&O->CoordTex);
	while(!nodeEnd(it))
	{
		Vec2* CoordTex = newVec2();
		vec2Cp(CoordTex, *((Vec2*) nodeGetData(it)));
		lstAdd(&CT, CoordTex);
		it = nodeGetNext(it);
	}
	return newObject(cpyPolygon(O->Shape), O->Tex, CT);
}
BST_VOID BST_SYS_MntnInit( BST_VOID )
{
    BST_OS_LOCKCNT_T                    tThreadLockCnt;

    tThreadLockCnt                      = BST_OS_ThreadLock();
    g_stBstMntnEntity.stReportTimer     = BST_OS_TimerCreate
                                        ( BST_SYS_MntnTimerExpired,
                                          BST_NULL_PTR );
    lstInit( &g_stBstMntnEntity.stAppList );
    BST_OS_MEMSET( &g_stBstMntnEntity.aucLocalIp[0],
                   0, OM_BST_IP_ADDR_LEN );
    g_stBstMntnEntity.ucChanged         = BST_FALSE;
    g_stBstMntnEntity.ucIsInit          = BST_TRUE;
    BST_RLS_LOG( "[Mntn] Initial System" );
    BST_OS_ThreadUnLock( tThreadLockCnt );
    return;
}
Exemplo n.º 6
0
STATIC APIRET CreateApp(PXINI pXIni,         // in: profile opened with xprfOpenProfile
                        const char *pcszApp,
                        PXINIAPPDATA *ppAppData)
{
    PXINIAPPDATA pAppData;
    if (pAppData = (PXINIAPPDATA)malloc(sizeof(XINIAPPDATA)))
    {
        pAppData->pszAppName = strdup(pcszApp);
        lstInit(&pAppData->llKeys, FALSE);
        pAppData->cKeys = 0;

        // store in INI's apps list
        lstAppendItem(&pXIni->llApps, pAppData);

        *ppAppData = pAppData;
        return NO_ERROR;
    }

    return ERROR_NOT_ENOUGH_MEMORY;
}
Exemplo n.º 7
0
STATUS etherOutputHookAdd
(
    FUNCPTR outputHook  /* routine to receive Ethernet output */
)
{
    HOOK_ENTRY *pHookEnt;

    pHookEnt = malloc(sizeof(HOOK_ENTRY));
    if (pHookEnt == NULL)
        return (ERROR);

    if (etherOutputHookRtn == NULL)
    {
        etherOutputHookRtn = etherOutputHook;
        lstInit(&outputHookList);
    }
    pHookEnt->routine = outputHook;
    lstAdd(&outputHookList, &pHookEnt->node);
    return (OK);
}
BST_OS_MBX_T *BST_OS_CreateMbx( BST_VOID *pvArg, BST_UINT32 ulSize )
{
    BST_OS_MBX_T                       *pstMbx;

    pstMbx                              = BST_OS_MALLOC( BST_OS_SIZEOF(BST_OS_MBX_T) );
    BST_ASSERT_NULL_RTN( pstMbx, BST_NULL_PTR );
    pstMbx->hSem                        = BST_NULL_PTR;

    lstInit( &pstMbx->hList );
    pstMbx->hSem                        = BST_OS_CreateSem( pvArg, 0U );

    if( BST_NULL_PTR == pstMbx->hSem )
    {
        BST_DBG_LOG("Create Mail Box Fail.\n");
        lstFree( &pstMbx->hList );
        BST_OS_FREE(pstMbx);
        /*lint -e438*/
        return BST_NULL_PTR;
        /*lint +e438*/
    }
    return( pstMbx );
}
Exemplo n.º 9
0
Arquivo: endLib.c Projeto: ariavie/bcm
STATUS endObjInit
    (
    END_OBJ *   pEndObj,        /* object to be initialized */
    DEV_OBJ*    pDevice,        /* ptr to device struct */
    char *      pBaseName,      /* device base name, for example, "ln" */
    int         unit,           /* unit number */
    NET_FUNCS * pFuncTable,     /* END device functions */
    char*       pDescription
    )
    {
    int maxLen;

    pEndObj->devObject.pDevice = pDevice;

    /* Create the transmit semaphore. */

    pEndObj->txSem = semMCreate ( SEM_Q_PRIORITY  |
                                  SEM_DELETE_SAFE |
                                  SEM_INVERSION_SAFE);

    if (pEndObj->txSem == NULL)
        {
        return (ERROR);
        }

    /* Install data and functions into the network node. */

    pEndObj->flags = 0;

    /* initialize protocol table (empty) */

    pEndObj->pSnarf   = NULL;
    pEndObj->pTyped   = NULL;
    pEndObj->pPromisc = NULL;
    pEndObj->pStop    = NULL;
    pEndObj->nProtoSlots = 0;

    /* Don't modify the strings passed as arguments! */

    maxLen = sizeof(pEndObj->devObject.name) - 1;

    strncpy (pEndObj->devObject.name, pBaseName, maxLen);
    pEndObj->devObject.name [maxLen] = EOS;

    maxLen = sizeof(pEndObj->devObject.description) - 1;

    strncpy (pEndObj->devObject.description, pDescription, maxLen);
    pEndObj->devObject.description [maxLen] = EOS;

    pEndObj->devObject.unit = unit;
    
    pEndObj->pFuncTable = pFuncTable;

    /* Clear multicast info. */

    lstInit (&pEndObj->multiList);
    pEndObj->nMulti = 0;

    pEndObj->dummyBinding = pEndObj;

    return OK;
    }
STATUS usrNetBridgeInit
    (
    char*	pPortString, /* interfaces to be configured as bridge ports */ 
                             /* e.g., "fei0,fei1,elPci0" */
    char* 	pAddr,       /* IP address for this bridge */ 
    int		mask,        /* netmask for this bridge */
    char*	pAddrv6,     /* IPv6 address for this bridge */
    int		prefixLen    /* IPv6 prefix length for this bridge */
    )
    {
    LIST		bridgePortList; /* list of BRIDGE_NODEs */
    BRIDGE_NODE* 	pFirstNode;     /* first node in the list */

    /* Initialize the list */

    lstInit(&bridgePortList);

    /* Parse the port string and populate the list */

    if (portsStringParse(pPortString, &bridgePortList) != OK)
        {
        printf("portsStringParse failed!\n");
        lstFree(&bridgePortList);
        return ERROR;
        }

    /* Initialize the bridge */

    if (bridgeInit() != OK)
        {
        printf("bridgeInit failed!\n");
        lstFree(&bridgePortList);
        return ERROR;
        }

    /* Initialize the bridge ports */

    if (bridgePortsInit(&bridgePortList) != OK)
        {
        printf("bridgePortsInit failed!\n");
        lstFree(&bridgePortList);
        return ERROR;
        }

    /* Initialize the mirror interface.
     *
     * NOTE: The first bridge port's device name and number is used
     * to initialize the mirror interface.
     */

    pFirstNode = (BRIDGE_NODE*) lstFirst(&bridgePortList);
    if (mirrorInit(pFirstNode->devName, pFirstNode->unit, 
		   pAddr, mask, pAddrv6, prefixLen) != OK)
        {
        printf("mirrorInit failed!\n");
        lstFree(&bridgePortList);
        return ERROR;
        }

    /* Cleanup */

    lstFree(&bridgePortList);

    return OK;
    }
Exemplo n.º 11
0
APIRET xprfOpenProfile(const char *pcszFilename,    // in: profile name
                       PXINI *ppxini)               // out: profile handle
{
    APIRET  arc = NO_ERROR;
    PXINI   pXIni = NULL;
    ULONG   ulFilenameLen;

    if (    (!pcszFilename)
         || (!ppxini)
       )
        arc = ERROR_INVALID_PARAMETER;      // V1.0.0 (2002-09-17) [umoeller]
    else if (!(ulFilenameLen = strlen(pcszFilename)))
        arc = ERROR_INVALID_PARAMETER;      // V1.0.0 (2002-09-17) [umoeller]
    else if (ulFilenameLen >= CCHMAXPATH - 1)
        arc = ERROR_FILENAME_EXCED_RANGE;
    else
    {
        HFILE   hFile = NULLHANDLE;
        ULONG   ulAction = 0;
        // FHLOCK  hLock = 0;

        if (!(arc = DosOpen((PSZ)pcszFilename,
                            &hFile,
                            &ulAction,
                            1024,          // initial size
                            FILE_NORMAL,
                            /*OPEN_ACTION_CREATE_IF_NEW
                               |*/ OPEN_ACTION_OPEN_IF_EXISTS,
                            OPEN_FLAGS_FAIL_ON_ERROR
                               | OPEN_FLAGS_SEQUENTIAL
                               | OPEN_SHARE_DENYREADWRITE
                               | OPEN_ACCESS_READWRITE,
                            NULL)))
        {
            if (!(pXIni = (PXINI)malloc(sizeof(XINI))))
                arc = ERROR_NOT_ENOUGH_MEMORY;
            else
            {
                // OK: initialize XINI
                memset(pXIni, 0, sizeof(XINI));
                memcpy(pXIni->acMagic, XINI_MAGIC_BYTES, sizeof(XINI_MAGIC_BYTES));
                memcpy(pXIni->szFilename,
                       pcszFilename,
                       ulFilenameLen + 1);
                pXIni->hFile = hFile;
                // pXIni->hLock = hLock;

                lstInit(&pXIni->llApps, FALSE);

                if (ulAction == FILE_CREATED)
                    // file newly created: rewrite on close
                    pXIni->fDirty = TRUE;
                else
                    // file existed: read data
                    if (arc = ReadINI(pXIni))
                        // error:
                        FreeINI(pXIni);
            }

            if (!arc)
                *ppxini = pXIni;
            else
                DosClose(hFile);
        }
    }

    return arc;
}
Exemplo n.º 12
0
STATUS etherInputHookAdd
(
    FUNCPTR inputHook,   /* routine to receive Ethernet input */
    char* pName,         /* name of device if MUX/END is being used */
    int unit             /* unit of device if MUX/END is being used */
)
{
    HOOK_ENTRY *pHookEnt;
    HOOK_ENTRY *pHookCurr;
    void * pBinding = NULL;  /* Existing END device binding, if any. */

    BOOL tkDevice=FALSE;

    if (pName != NULL) /* We are dealing with an END. */
    {
        if (etherInputHookActive == FALSE)     /* First END driver hook? */
        {
            if (etherInputHookRtn == NULL)
            {
                /* Initialize list - first network driver of either type. */

                lstInit (&inputHookList);
            }
            etherInputHookActive = TRUE;
        }

        /* Check if bind is necessary and eliminate duplicate hook routine. */

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

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

            if (STREQ(pHookCurr->name, pName) && (pHookCurr->unit == unit))
            {
                if (pHookCurr->routine == inputHook)
                    return (ERROR);

                /* Additional hook for same device - reuse binding. */

                pBinding = pHookCurr->pCookie;
            }
        }
        pHookEnt = malloc (sizeof (HOOK_ENTRY));
        if (pHookEnt == NULL)
            return (ERROR);
        bzero ( (char *)pHookEnt, sizeof (HOOK_ENTRY));

        if (pBinding == NULL) 	/* No hook entry for this END device? */
        {
            /* Attach Ethernet input hook handler for this device. */

            tkDevice = muxTkDrvCheck (pName);
            if (tkDevice)
            {
                pBinding = muxTkBind (pName, unit, nptEtherInputHookRtn,
                                      NULL, NULL, NULL, MUX_PROTO_SNARF,
                                      "etherInputHook", pHookEnt, NULL, NULL);
            }
            else
            {
                pBinding = muxBind (pName, unit, endEtherInputHookRtn,
                                    NULL, NULL, NULL, MUX_PROTO_SNARF,
                                    "etherInputHook", pHookEnt);
            }

            if (pBinding == NULL)
            {
                free (pHookEnt);
                return (ERROR);
            }
        }

        /*
         * Assign (new or existing) handler attachment for the device,
         * allowing hook deletion in any order.
         */

        pHookEnt->pCookie = pBinding;

        strcpy (pHookEnt->name, pName);
        pHookEnt->unit = unit;
        pHookEnt->routine = inputHook;
        lstAdd (&inputHookList, &pHookEnt->node);
    }
    else               /* Old style driver. */
    {
        /* Check for duplicate hook routine. */

        for (pHookCurr = (HOOK_ENTRY *)lstFirst(&inputHookList);
                pHookCurr != NULL;
                pHookCurr = (HOOK_ENTRY *)lstNext(&pHookCurr->node))
        {
            if (pHookCurr->pCookie)    /* Ignore END device hook entries. */
                continue;

            if (pHookCurr->routine == inputHook)
                return (ERROR);
        }

        pHookEnt = malloc(sizeof(HOOK_ENTRY));
        if (pHookEnt == NULL)
            return (ERROR);
        bzero ( (char *)pHookEnt, sizeof (HOOK_ENTRY));

        if (etherInputHookRtn == NULL)    /* First BSD driver hook? */
        {
            etherInputHookRtn = etherInputHook;

            if (!etherInputHookActive)
            {
                /* Initialize list - first network driver of either type. */

                lstInit (&inputHookList);
            }
        }
        pHookEnt->routine = inputHook;
        lstAdd(&inputHookList, &pHookEnt->node);
    }
    return (OK);
}