#define SC_CLASS_CONF_DEF_CONF_FILEPATH CONFIG_DIR "/classification.config"
#endif
-/* Holds a pointer to the default path for the classification.config file */
-static const char *default_file_path = SC_CLASS_CONF_DEF_CONF_FILEPATH;
static pcre *regex = NULL;
static pcre_extra *regex_study = NULL;
void SCClassConfClasstypeHashFree(void *ch);
static char *SCClassConfGetConfFilename(void);
+void SCClassConfInit(void)
+{
+ const char *eb = NULL;
+ int eo;
+ int opts = 0;
+
+ regex = pcre_compile(DETECT_CLASSCONFIG_REGEX, opts, &eb, &eo, NULL);
+ if (regex == NULL) {
+ SCLogDebug("Compile of \"%s\" failed at offset %" PRId32 ": %s",
+ DETECT_CLASSCONFIG_REGEX, eo, eb);
+ return;
+ }
+
+ regex_study = pcre_study(regex, 0, &eb);
+ if (eb != NULL) {
+ pcre_free(regex);
+ regex = NULL;
+ SCLogDebug("pcre study failed: %s", eb);
+ return;
+ }
+ return;
+}
+
+void SCClassConfDeinit(void)
+{
+ if (regex != NULL) {
+ pcre_free(regex);
+ regex = NULL;
+ }
+ if (regex_study != NULL) {
+ pcre_free(regex_study);
+ regex_study = NULL;
+ }
+}
+
+
/**
* \brief Inits the context to be used by the Classification Config parsing API.
*
FILE *SCClassConfInitContextAndLocalResources(DetectEngineCtx *de_ctx, FILE *fd)
{
char *filename = NULL;
- const char *eb = NULL;
- int eo;
- int opts = 0;
/* init the hash table to be used by the classification config Classtypes */
de_ctx->class_conf_ht = HashTableInit(128, SCClassConfClasstypeHashFunc,
}
}
- regex = pcre_compile(DETECT_CLASSCONFIG_REGEX, opts, &eb, &eo, NULL);
- if (regex == NULL) {
- SCLogDebug("Compile of \"%s\" failed at offset %" PRId32 ": %s",
- DETECT_CLASSCONFIG_REGEX, eo, eb);
- goto error;
- }
-
- regex_study = pcre_study(regex, 0, &eb);
- if (eb != NULL) {
- SCLogDebug("pcre study failed: %s", eb);
- goto error;
- }
-
return fd;
error:
fd = NULL;
}
- if (regex != NULL) {
- pcre_free(regex);
- regex = NULL;
- }
- if (regex_study != NULL) {
- pcre_free(regex_study);
- regex_study = NULL;
- }
-
return NULL;
}
char *log_filename = NULL;
if (ConfGet("classification-file", &log_filename) != 1) {
- log_filename = (char *)default_file_path;
+ log_filename = (char *)SC_CLASS_CONF_DEF_CONF_FILEPATH;
}
return log_filename;
fclose(fd);
fd = NULL;
}
-
- default_file_path = SC_CLASS_CONF_DEF_CONF_FILEPATH;
- if (regex != NULL) {
- pcre_free(regex);
- regex = NULL;
- }
- if (regex_study != NULL) {
- pcre_free(regex_study);
- regex_study = NULL;
- }
-
- return;
}
/**