📄 rvcore.c
字号:
#if (0)
******************************************************************************
Filename :
Description:
******************************************************************************
Copyright (c) 1999 RADVision Inc.
************************************************************************
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.
******************************************************************************
$Revision:$
$Date:$
$Author: S. Cipolli$
******************************************************************************
#endif
#include <stdio.h>
#include <assert.h>
#include "rvlog.h"
#include "rvmem.h"
#include "rvkernel.h"
#include "rvtransport.h"
#include "rvsnmpif.h"
#include "rvcore.h"
static int coreInitialized = 0;
/*$
{function scope="private":
{name: rvCoreMemHandler }
{superpackage: Core}
{include: core.h}
{description:
{p: This is the default memory handler for the core module.
All it does is log an error and return rvFalse.}
}
{proto:RvBool rvCoreMemHandler(size_t n);}
{returns: This method always returns rvFalse since it doesn't
try to free any memory.}
{see_also:
{n: RvMemHandler rvMemSetHandler(RvMemHandler h);}
}
}
$*/
RvBool rvCoreMemHandler(size_t n) {
rvLogFatal(&rvLog, "Out of Memory");
assert(rvFalse);
return rvFalse;
}
/*$
{function:
{name: rvCoreInit }
{superpackage: Core}
{include: core.h}
{description:
{p: This method initializes the core module. You should
call this method before using any core methods.}
}
{proto:RvBool rvCoreInit(void);}
{returns: rvTrue, if the Core module is successfully initialized.}
{notes:
{note: This method is not thread safe. Calls to this function
and rvCoreEnd() must not occur from multiple threads
"at the same time".}
}
{see_also:
{n: void rvCoreEnd(void);}
}
}
$*/
RvBool rvCoreInit(void) {
if (coreInitialized == 0) {
/* Count up here to minimize window of multi-thread access */
++coreInitialized;
/* Initialize the memory trace (in debug mode)*/
rvMemTraceConstruct();
/* Initialize the kernel */
if (!rvKernelInit())
return rvFalse;
/* Install a memory handler */
/* Must be done after rvKernelInit, since logging must up */
rvMemSetHandler(rvCoreMemHandler);
/* Initialize the memory trace (in debug mode)*/
rvMemTraceConstruct();
/* Initialize the transport */
if (!rvTransportInit())
return rvFalse;
/* Initialize the snmp */
if (!rvSnmpIfInit())
return rvFalse;
} else
++coreInitialized;
return rvTrue;
}
/*$
{function:
{name: rvCoreEnd }
{superpackage: Core}
{include: core.h}
{description:
{p: This function de-initializes the core module. This method
should be called once for each time the method rvCoreInit()
was called. After this call is made no core module methods
should be called.}
}
{proto:void rvCoreEnd(void);}
{notes:
{note: This method is not thread safe. Calls to this function
and rvCoreInit() must not occur from multiple threads
"at the same time".}
}
{see_also:
{n: RvBool rvCoreInit(void);}
}
}
$*/
void rvCoreEnd(void) {
--coreInitialized;
if (coreInitialized == 0) {
rvSnmpIfEnd();
rvTransportEnd();
rvKernelEnd();
rvMemTraceDestruct();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -