31 #define SQR(x) ((x) * (x)) 34 #define MAX_MSG_SCORE 15 104 static pthread_mutex_t fmutex = PTHREAD_MUTEX_INITIALIZER;
121 memset(&msg_eval, 0,
sizeof msg_eval);
129 switch (msg_eval.
func) {
164 decode_msg_eval_token(q, val)
286 q->function.vector.kbayes = k;
298 q->function.vector.kurlbl = k;
310 q->function.vector.koracle = k;
322 q->function.vector.kregex = k;
341 q->function.logit.kbayes = k;
353 q->function.logit.kurlbl = k;
365 q->function.logit.koracle = k;
377 q->function.logit.kregex = k;
396 q->function.sum.kbayes = k;
408 q->function.sum.kurlbl = k;
420 q->function.sum.koracle = k;
432 q->function.sum.kregex = k;
459 if (!msg_eval.
ok && !init_msg_eval())
466 if ((env = getenv(
"MSG_EVAL")) == NULL)
472 if ((env = getenv(
"MSG_SCALE")) == NULL)
482 strlcpy(buf, val,
sizeof (buf));
493 for (i = 0; i < argc; i++) {
494 if (!decode_msg_eval_token(q, argv[i])) {
520 if (!msg_eval.
ok && !init_msg_eval())
526 strlcpy(buf, val,
sizeof (buf));
536 for (i = 0; i < argc; i++) {
537 if (!decode_msg_eval_token(q, argv[i])) {
725 (
double) regex, (
double) scp->
oracle, (
double) scp->
urlbl,
747 char sr[16], su[16], so[16];
764 strlcpy(sout,
".",
sizeof (sout));
766 strlcat(sout,
"+",
sizeof (sout));
768 memset(sr, 0,
sizeof (sr));
769 memset(su, 0,
sizeof (su));
770 memset(so, 0,
sizeof (so));
773 n =
MIN(nx,
sizeof (sr) - 1);
780 n =
MIN(nx,
sizeof (su) - 1);
787 n =
MIN(nx,
sizeof (so) - 1);
793 if (buf != NULL && size > 0) {
795 hostname =
STRNULL(hostname,
"UNKNOWN");
798 "MSGID : %s on %s : ze-filter score : %s : R=%s U=%s O=%s B=%.3f -> S=%.3f",
799 id, hostname, sout, sr, su, so, scp->
bayes, score);
815 *scale = msg_eval.
scale;
840 scores->
bayes = bayes;
842 scores->
body = regex;
844 scores->
urlbl = urlbl;
874 #define MATCH_THRESHOLD 0 875 #define MATCH_REGEX 1 877 static bool ok_actions =
FALSE;
879 static pthread_mutex_t amutex = PTHREAD_MUTEX_INITIALIZER;
898 memset(msg_actions, 0,
sizeof msg_actions);
910 set_message_action(q, which, val)
916 char *p = NULL, *s = NULL;
920 memset(q, 0,
sizeof (*q));
921 if (val == NULL || strlen(val) == 0) {
927 strlcpy(q->buf, val, sizeof (q->buf));
928 strlcpy(buf, val,
sizeof (buf));
941 q->value.threshold = k;
950 strlcpy(q->value.regex, p, sizeof (q->value.regex));
975 if (!ok_actions && !init_msg_actions())
984 result = set_message_action(q, which, val);
987 if (msg_actions[i].action == which) {
990 result = set_message_action(q, which, val);
1013 bool result =
FALSE;
1015 if (!ok_actions && !init_msg_actions())
1021 if (msg_actions[i].action == action) {
bool register_msg_action(int which, char *val)
struct msg_eval_func_T::@7::@10 logit
struct msg_eval_func_T::@7::@9 sum
union msg_eval_action_T::@11 value
#define MUTEX_UNLOCK(mutex)
bool configure_msg_eval_function(char *val)
#define STRNCASEEQUAL(a, b, n)
#define MUTEX_LOCK(mutex)
#define ZE_LogMsgError(level,...)
bool zeStrRegex(char *, char *, long *, long *, bool)
int zeStr2Tokens(char *, int, char **, char *)
bool evaluate_msg_action(int action, msg_scores_T *scp, double score, char *str)
union msg_eval_func_T::@7 function
bool fill_msg_scale(scores_scale_T *scale)
bool create_msg_score_header(char *buf, size_t size, char *id, char *hostname, msg_scores_T *scp)
bool configure_msg_score_scales(char *val)
char * zeStrSet(char *, int, int)
#define ZE_MessageInfo(level,...)
#define ZE_MessageWarning(level,...)
bool fill_msg_scores(msg_scores_T *scores, bool do_bayes, double bayes, bool do_regex, int regex, bool do_urlbl, int urlbl, bool do_oracle, int oracle)
double logitinv(double x)
double compute_msg_score(msg_scores_T *scp)
struct msg_eval_func_T::@7::@8 vector
#define DEFAULT_MSG_SCALE