runmode: export running mode

This will permit to put some optimisation in different components.
This is done via the RunmodeGetActive() function.
remotes/origin/master-1.2.x
Eric Leblond 14 years ago
parent c908574545
commit ef3951d914

@ -81,6 +81,8 @@ TAILQ_HEAD(, RunModeOutput_) RunModeOutputs =
static RunModes runmodes[RUNMODE_MAX];
static char *active_runmode;
/**
* \internal
* \brief Translate a runmode mode to a printale string.
@ -141,6 +143,19 @@ static RunMode *RunModeGetCustomMode(int runmode, const char *custom_mode)
return NULL;
}
/**
* Return the running mode
*
* The returned string must not be freed.
*
* \return a string containing the current running mode
*/
char *RunmodeGetActive(void)
{
return active_runmode;
}
/**
* \brief Register all runmodes in the engine.
*/
@ -257,6 +272,10 @@ void RunModeDispatch(int runmode, const char *custom_mode, DetectEngineCtx *de_c
custom_mode, RunModeTranslateModeToName(runmode));
exit(EXIT_FAILURE);
}
/* Export the custom mode */
active_runmode = SCStrdup(custom_mode);
mode->RunModeFunc(de_ctx);
return;

@ -38,6 +38,8 @@ enum {
RUNMODE_MAX,
};
char *RunmodeGetActive(void);
void RunModeListRunmodes(void);
void RunModeDispatch(int, const char *, DetectEngineCtx *);
void RunModeRegisterRunModes(void);

Loading…
Cancel
Save