cmconfig.c

来自「基于h323协议的软phone」· C语言 代码 · 共 164 行

C
164
字号
/*

NOTICE:
This document contains information that is proprietary to RADVISION LTD..
No part of this publication may be reproduced in any form whatsoever without
written prior approval by RADVISION LTD..

RADVISION LTD. reserves the right to revise this publication and make changes
without obligation to notify any person of such revisions or changes.

*/

#ifdef __cplusplus
extern "C" {
#endif

#include "rvstdio.h"
#include "msg.h"
#include "cmConfig.h"


/************************************************************************
 *
 *                          Public functions
 *
 ************************************************************************/


/************************************************************************
 * cmiCreateLog
 * purpose: Create a log manager for use by a stack instance
 *          This function reads the information from a configuration
 *          manager and initializes the log manager with it.
 * input  : app     - Stack's application handle
 * output : none
 * return : none
 ************************************************************************/
void cmiCreateLog(IN cmElem* app)
{
    /* Create sources for the CM's log */
    RvLogSourceConstruct(RvLogGet(), &app->log,       RV_LOG_LIBCODE_H323, "CM",       "Conference Management");
    RvLogSourceConstruct(RvLogGet(), &app->logAPI,    RV_LOG_LIBCODE_H323, "CMAPI",    "Conference Management API");
    RvLogSourceConstruct(RvLogGet(), &app->logCB,     RV_LOG_LIBCODE_H323, "CMAPICB",  "Conference Management CallBack");
    RvLogSourceConstruct(RvLogGet(), &app->logERR,    RV_LOG_LIBCODE_H323, "CMERR",    "Conference Management Errors");
    RvLogSourceConstruct(RvLogGet(), &app->logTPKT,   RV_LOG_LIBCODE_H323, "TPKTCHAN", "TPKT Messages");
    RvLogSourceConstruct(RvLogGet(), &app->logConfig, RV_LOG_LIBCODE_H323, "CONFIG",   "Configuragtion settings");
    RvLogSourceConstruct(RvLogGet(), &app->logAppl,   RV_LOG_LIBCODE_H323, "APPL",     "User instigated messages");
    RvLogSourceConstruct(RvLogGet(), &app->logWatchdog, RV_LOG_LIBCODE_H323, "WATCHDOG", "Resource's data");

    msOpen();
}


/************************************************************************
 * cmiDestroyLog
 * purpose: Destroy a log manager and the CM's sources
 * input  : app     - Stack's application handle
 * output : none
 * return : none
 ************************************************************************/
void RVCALLCONV cmiDestroyLog(IN cmElem* app)
{
    RvLogSourceDestruct(RvLogGet(), &app->log);
    RvLogSourceDestruct(RvLogGet(), &app->logAPI);
    RvLogSourceDestruct(RvLogGet(), &app->logCB);
    RvLogSourceDestruct(RvLogGet(), &app->logERR);
    RvLogSourceDestruct(RvLogGet(), &app->logTPKT);
    RvLogSourceDestruct(RvLogGet(), &app->logConfig);
    RvLogSourceDestruct(RvLogGet(), &app->logAppl);
    RvLogSourceDestruct(RvLogGet(), &app->logWatchdog);

    msClose();
}


/************************************************************************
 * pvtLoadFromConfig
 * purpose: Convert information from a configuration instance (HCFG) to
 *          a value tree of a given syntax.
 * input  : hCfg        - Configuration instance handle
 *          hVal        - Value tree handle
 *          name        - Name of root from configuration to convert
 *          rootNodeId  - Syntax of configuration
 *          log         - Log handle to use for debug messages
 * output : none
 * return : Root ID of configuration created on success
 *          Negative value on failure
 ************************************************************************/
int pvtLoadFromConfig(HCFG hCfg, HPVT hVal, char* name, int rootNodeId, RvLogSource * log)
{
    static char tempBuff[1024];
    int tempLen;

    RvSize_t length = strlen(name);
    char next[256], svalue[256], *str;
    RvInt32 value;
    ci_str_type strtype;

    RV_UNUSED_ARG(log);

    strncpy(next, name, sizeof(next));

    for (;;)
    {
        int nodeId;

        if (ciNext(hCfg, next, next, sizeof(next)) == ERR_CI_NOTFOUND)
            break;

        if (strncmp(name, next, length))
            break;

        ciGetValueExt(hCfg, next, &strtype, &value);

        tempLen=RvSprintf(tempBuff,"%s= (%d)", nprn(next), value);

        if (strtype != ci_str_not)
        {
            switch (strtype)
            {
                case ci_str_regular:
                {
                    ciGetString(hCfg, next, svalue, sizeof(svalue));
                    tempLen+=RvSprintf(tempBuff+tempLen, " '%*.*s'", value, value, nprn(svalue));
                    break;
                }

                case ci_str_bit:
                {
                    ciGetBitString(hCfg, next, svalue, sizeof(svalue),
                        (unsigned int *)&value);
                    tempLen+=RvSprintf(tempBuff+tempLen, " bitstring, bits=%d", value);
                    break;
                }
            default:
                break;
            }
            str = (char *)svalue;
        }
        else
        {
            str = NULL;
        }

        if ((nodeId = pvtBuildByPath(hVal, rootNodeId, (RvChar*) strchr(next, '.') , value, str)) < 0)
        {
            RvLogError(log, (log, "Cannot create: %s", tempBuff));
        }

        RvLogDebug(log, (log, "%s", tempBuff));
    }
    /*vtCheckTree(hVal, rootNodeId, msa);*/
    return 0;
}



#ifdef __cplusplus
}
#endif



⌨️ 快捷键说明

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