⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ss_rtr.c

📁 中国石油二期加油站IC系统后台通讯软件
💻 C
字号:


/********************************************************************20**
 
     Name:     System Services -- Router
 
     Type:     C source file
 
     Desc:     Source code for router support in System Services.
 
     File:     ss_rtr.c
 
     Sid:      ss_rtr.c 1.1  -  10/14/98 14:19:54
 
     Prg:      kp
 
*********************************************************************21*/



/* header include files (.h) */

#include "envopt.h"        /* environment options */
#include "envdep.h"        /* environment dependent */
#include "envind.h"        /* environment independent */

#include "gen.h"           /* general layer */
#include "ssi.h"           /* system services */

#include "ss_err.h"        /* errors */
#include "ss_dep.h"        /* implementation-specific */
#include "ss_queue.h"      /* queues */
#include "ss_task.h"       /* tasking */
#include "ss_msg.h"        /* messaging */
#include "ss_mem.h"        /* memory management interface */
#include "ss_gen.h"        /* general */



/* header/extern include files (.x) */

#include "gen.x"           /* general layer */
#include "ssi.x"           /* system services */

#include "ss_dep.x"        /* implementation-specific */
#include "ss_queue.x"      /* queues */
#include "ss_task.x"       /* tasking */
#include "ss_timer.x"      /* timers */
#include "ss_strm.x"       /* STREAMS */
#include "ss_msg.x"        /* messaging */
#include "ss_mem.x"        /* memory management interface */
#include "ss_drvr.x"       /* driver tasks */
#include "ss_gen.x"        /* general */


#ifdef SS_RTR_SUPPORT



/*
*
*       Fun:   SRegRtrTsk
*
*       Desc:  This function is used to register a router task.
*
*       Ret:   ROK      - ok
*              RFAILED  - failed, general (optional)
*              ROUTRES  - failed, out of resources (optional)
*
*       Notes:
*
*       File:  ss_rtr.c
*
*/
    #ifdef ANSI
PUBLIC S16 SRegRtrTsk
(
Route *routes,                  /* route IDs */
Cntr count,                     /* number of route IDs */
ActvTsk rtrTsk                  /* router activation task */
)
    #else
PUBLIC S16 SRegRtrTsk(routes, count, rtrTsk)
Route *routes;                  /* route IDs */
Cntr count;                     /* number of route IDs */
ActvTsk rtrTsk;                 /* router activation task */
    #endif
{
    S16 i;


    TRC1(SRegRtrTsk);


#if (ERRCLASS & ERRCLS_INT_PAR)
    for (i = 0;  i < count;  i++)
    {

        /* check for valid route ID */
        if (routes[i] == RTENC)
        {
            SSLOGERROR(ERRCLS_INT_PAR, ESS424, ERRZERO, "Invalid route ID");
            RETVALUE(RFAILED);
        }

        /* add by shang */
        if (routes[i] >= SS_MAX_RTRTSKS)
        {
            SSLOGERROR(ERRCLS_INT_PAR, ESS424, ERRZERO,
                       "Invalid route ID");
            RETVALUE(RFAILED);
        }
        /* add by shang over */

        /* check if route already registered */
        if (osCp.rtrTskTbl[routes[i]] != NULLP)
        {
            SSLOGERROR(ERRCLS_INT_PAR, ESS425, ERRZERO,
                       "Route already registered");
            RETVALUE(RFAILED);
        }
    }

    /* check activation function */
    if (rtrTsk == NULLP)
    {
        SSLOGERROR(ERRCLS_INT_PAR, ESS426, ERRZERO, "Null pointer");
        RETVALUE(RFAILED);
    }
#endif


    /* install this router task, for all requested routes */
    for (i = 0;  i < count;  i++)
    {
        if (SInitLock(&osCp.rtrTskLocks[routes[i]], SS_RTRENTRY_LOCK) != ROK)
        {

#if (ERRCLASS & ERRCLS_DEBUG)
            SSLOGERROR(ERRCLS_DEBUG, ESS427, ERRZERO,
                       "Could not initialize router task lock");
#endif

            break;
        }

        osCp.rtrTskTbl[routes[i]] = rtrTsk;
    }

    if (i != count)
    {
        for (--i;  i >= 0;  i--)
        {
            SDestroyLock(&osCp.rtrTskLocks[routes[i]]);
            osCp.rtrTskTbl[routes[i]] = NULLP;
        }


        RETVALUE(RFAILED);
    }


    RETVALUE(ROK);
}


/*
*
*       Fun:   SDeregRtrTsk
*
*       Desc:  This function is used to deregister a router task.
*
*       Ret:   ROK      - ok
*              RFAILED  - failed, general (optional)
*              ROUTRES  - failed, out of resources (optional)
*
*       Notes:
*
*       File:  ss_rtr.c
*
*/
    #ifdef ANSI
PUBLIC S16 SDeregRtrTsk
(
Route *routes,                  /* route IDs */
Cntr count                     /* number of route IDs */
)
    #else
PUBLIC S16 SDeregRtrTsk(routes, count)
Route *routes;                  /* route IDs */
Cntr count;                     /* number of route IDs */
    #endif
{
    S16 i;


    TRC1(SDeregRtrTsk);

    /* install this router task, for all requested routes */
    for (i = 0;  i < count;  i++)
    {
        if (routes[i] >= SS_MAX_RTRTSKS)
        {
#if (ERRCLASS & ERRCLS_DEBUG)
            SSLOGERROR(ERRCLS_DEBUG, ESS427, ERRZERO,
                       "invalid route parameters ");
#endif
            RETVALUE(RFAILED);
        }

        if (ROK != SLock(&osCp.rtrTskLocks[routes[i]]))
        {
#if (ERRCLASS & ERRCLS_DEBUG)
            SSLOGERROR(ERRCLS_DEBUG, ESS427, ERRZERO,
                       "Slock error");
#endif
            RETVALUE(RFAILED);
        }

        osCp.rtrTskTbl[routes[i]] = NULLP;
        SDestroyLock(&osCp.rtrTskLocks[routes[i]]);
    }

    RETVALUE(ROK);
}



#endif /* SS_RTR_SUPPORT */



/********************************************************************30**
  
         End of file: ss_rtr.c 1.1  -  10/14/98 14:19:54
  
*********************************************************************31*/

  
/********************************************************************40**
  
        Notes: 
  
*********************************************************************41*/

/********************************************************************50**

*********************************************************************51*/

   
/********************************************************************60**
  
        Revision history:
  
*********************************************************************61*/

/********************************************************************90**
 
     ver       pat    init                  description
------------ -------- ---- ----------------------------------------------
1.1          ---      kp   1. initial release

*********************************************************************91*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -