コード例 #1
0
ファイル: mmnormalize.c プロジェクト: TheodoreLizard/rsyslog
/* to be called to build the libee part of the instance ONCE ALL PARAMETERS ARE CORRECT
 * (and set within pData!).
 */
static rsRetVal
buildInstance(instanceData *pData)
{
	DEFiRet;
	if((pData->ctxee = ee_initCtx()) == NULL) {
		errmsg.LogError(0, RS_RET_ERR_LIBEE_INIT, "error: could not initialize libee "
				"ctx, cannot activate action");
		ABORT_FINALIZE(RS_RET_ERR_LIBEE_INIT);
	}

	if((pData->ctxln = ln_initCtx()) == NULL) {
		errmsg.LogError(0, RS_RET_ERR_LIBLOGNORM_INIT, "error: could not initialize "
				"liblognorm ctx, cannot activate action");
		ee_exitCtx(pData->ctxee);
		ABORT_FINALIZE(RS_RET_ERR_LIBLOGNORM_INIT);
	}
	ln_setEECtx(pData->ctxln, pData->ctxee);
	if(ln_loadSamples(pData->ctxln, (char*) pData->rulebase) != 0) {
		errmsg.LogError(0, RS_RET_NO_RULEBASE, "error: normalization rulebase '%s' "
				"could not be loaded cannot activate action", cs.rulebase);
		ee_exitCtx(pData->ctxee);
		ln_exitCtx(pData->ctxln);
		ABORT_FINALIZE(RS_RET_ERR_LIBLOGNORM_SAMPDB_LOAD);
	}
finalize_it:
	RETiRet;
}
コード例 #2
0
ファイル: liblognormalize.c プロジェクト: beave/sagan
void Liblognorm_Load(char *infile)
{

    SaganNormalizeLiblognorm = malloc(sizeof(struct _SaganNormalizeLiblognorm));

    if ( SaganNormalizeLiblognorm == NULL )
        {
            Sagan_Log(ERROR, "[%s, line %d] Failed to allocate memory for SaganNormalizeLiblognorm. Abort!", __FILE__, __LINE__);
        }

    memset(SaganNormalizeLiblognorm, 0, sizeof(_SaganNormalizeLiblognorm));

    if((ctx = ln_initCtx()) == NULL)
        {
            Sagan_Log(ERROR, "[%s, line %d] Cannot initialize liblognorm context.", __FILE__, __LINE__);
        }

    Sagan_Log(NORMAL, "Loading %s for normalization.", infile);

    /* Remember - On reload,  file access will be by the "sagan" user! */

    if (stat(infile, &liblognorm_fileinfo))
        {
            Sagan_Log(ERROR, "[%s, line %d] Error accessing '%s'. Abort.", __FILE__, __LINE__, infile);
        }

    ln_loadSamples(ctx, infile);

}