mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
remove start argument in literal matcher callbacks
This commit is contained in:
committed by
Matthew Barr
parent
482e1ef931
commit
ebb1b0006b
@@ -88,7 +88,7 @@ void confWithBit(const struct FDRConfirm *fdrc, const struct FDR_Runtime_Args *a
|
||||
}
|
||||
|
||||
*last_match = li->id;
|
||||
*control = a->cb(loc - buf, i, li->id, a->ctxt);
|
||||
*control = a->cb(i, li->id, a->ctxt);
|
||||
out:
|
||||
oldNext = li->next; // oldNext is either 0 or an 'adjust' value
|
||||
li++;
|
||||
|
@@ -56,7 +56,6 @@ struct FDRFlood {
|
||||
|
||||
u32 ids[FDR_FLOOD_MAX_IDS]; //!< the ids
|
||||
hwlm_group_t groups[FDR_FLOOD_MAX_IDS]; //!< group ids to go with string ids
|
||||
u32 len[FDR_FLOOD_MAX_IDS]; //!< lengths to go with the string ids
|
||||
};
|
||||
|
||||
/** \brief FDR structure.
|
||||
|
@@ -82,7 +82,6 @@ void addFlood(vector<FDRFlood> &tmpFlood, u8 c, const hwlmLiteral &lit,
|
||||
fl.ids[fl.idCount] = lit.id;
|
||||
fl.allGroups |= lit.groups;
|
||||
fl.groups[fl.idCount] = lit.groups;
|
||||
fl.len[fl.idCount] = suffix;
|
||||
// when idCount gets to max_ids this flood no longer happens
|
||||
// only incremented one more time to avoid arithmetic overflow
|
||||
DEBUG_PRINTF("Added Flood for char '%c' suffix=%u len[%hu]=%u\n",
|
||||
|
@@ -196,120 +196,110 @@ const u8 * floodDetect(const struct FDR * fdr,
|
||||
for (u32 t = 0; t < floodSize && (*control & fl->allGroups);
|
||||
t += 4) {
|
||||
DEBUG_PRINTF("aaa %u %llx\n", t, fl->groups[0]);
|
||||
u32 len0 = fl->len[0] - 1;
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t + 0 - len0, i + t + 0, fl->ids[0], ctxt);
|
||||
*control = cb(i + t + 0, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t + 1 - len0, i + t + 1, fl->ids[0], ctxt);
|
||||
*control = cb(i + t + 1, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t + 2 - len0, i + t + 2, fl->ids[0], ctxt);
|
||||
*control = cb(i + t + 2, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t + 3 - len0, i + t + 3, fl->ids[0], ctxt);
|
||||
*control = cb(i + t + 3, fl->ids[0], ctxt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (u32 t = 0; t < floodSize && (*control & fl->allGroups); t += 4) {
|
||||
u32 len0 = fl->len[0] - 1;
|
||||
u32 len1 = fl->len[1] - 1;
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t - len0, i + t, fl->ids[0], ctxt);
|
||||
*control = cb(i + t, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[1]) {
|
||||
*control = cb(i + t - len1, i + t, fl->ids[1], ctxt);
|
||||
*control = cb(i + t, fl->ids[1], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[0]) {
|
||||
*control =
|
||||
cb(i + t + 1 - len0, i + t + 1, fl->ids[0], ctxt);
|
||||
cb(i + t + 1, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[1]) {
|
||||
*control = cb(i + t + 1 - len1, i + t + 1, fl->ids[1], ctxt);
|
||||
*control = cb(i + t + 1, fl->ids[1], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t + 2 - len0, i + t + 2, fl->ids[0], ctxt);
|
||||
*control = cb(i + t + 2, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[1]) {
|
||||
*control = cb(i + t + 2 - len1, i + t + 2, fl->ids[1], ctxt);
|
||||
*control = cb(i + t + 2, fl->ids[1], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t + 3 - len0, i + t + 3, fl->ids[0], ctxt);
|
||||
*control = cb(i + t + 3, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[1]) {
|
||||
*control = cb(i + t + 3 - len1, i + t + 3, fl->ids[1], ctxt);
|
||||
*control = cb(i + t + 3, fl->ids[1], ctxt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for (u32 t = 0; t < floodSize && (*control & fl->allGroups); t += 2) {
|
||||
u32 len0 = fl->len[0] - 1;
|
||||
u32 len1 = fl->len[1] - 1;
|
||||
u32 len2 = fl->len[2] - 1;
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t - len0, i + t, fl->ids[0], ctxt);
|
||||
*control = cb(i + t, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[1]) {
|
||||
*control = cb(i + t - len1, i + t, fl->ids[1], ctxt);
|
||||
*control = cb(i + t, fl->ids[1], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[2]) {
|
||||
*control = cb(i + t - len2, i + t, fl->ids[2], ctxt);
|
||||
*control = cb(i + t, fl->ids[2], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t + 1 - len0, i + t + 1, fl->ids[0], ctxt);
|
||||
*control = cb(i + t + 1, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[1]) {
|
||||
*control = cb(i + t + 1 - len1, i + t + 1, fl->ids[1], ctxt);
|
||||
*control = cb(i + t + 1, fl->ids[1], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[2]) {
|
||||
*control = cb(i + t + 1 - len2, i + t + 1, fl->ids[2], ctxt);
|
||||
*control = cb(i + t + 1, fl->ids[2], ctxt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// slow generalized loop
|
||||
for (u32 t = 0; t < floodSize && (*control & fl->allGroups); t += 2) {
|
||||
u32 len0 = fl->len[0] - 1;
|
||||
u32 len1 = fl->len[1] - 1;
|
||||
u32 len2 = fl->len[2] - 1;
|
||||
u32 len3 = fl->len[3] - 1;
|
||||
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t - len0, i + t, fl->ids[0], ctxt);
|
||||
*control = cb(i + t, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[1]) {
|
||||
*control = cb(i + t - len1, i + t, fl->ids[1], ctxt);
|
||||
*control = cb(i + t, fl->ids[1], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[2]) {
|
||||
*control = cb(i + t - len2, i + t, fl->ids[2], ctxt);
|
||||
*control = cb(i + t, fl->ids[2], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[3]) {
|
||||
*control = cb(i + t - len3, i + t, fl->ids[3], ctxt);
|
||||
*control = cb(i + t, fl->ids[3], ctxt);
|
||||
}
|
||||
|
||||
for (u32 t2 = 4; t2 < fl->idCount; t2++) {
|
||||
if (*control & fl->groups[t2]) {
|
||||
*control = cb(i + t - (fl->len[t2] - 1), i + t, fl->ids[t2], ctxt);
|
||||
*control = cb(i + t, fl->ids[t2], ctxt);
|
||||
}
|
||||
}
|
||||
|
||||
if (*control & fl->groups[0]) {
|
||||
*control = cb(i + t + 1 - len0, i + t + 1, fl->ids[0], ctxt);
|
||||
*control = cb(i + t + 1, fl->ids[0], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[1]) {
|
||||
*control = cb(i + t + 1 - len1, i + t + 1, fl->ids[1], ctxt);
|
||||
*control = cb(i + t + 1, fl->ids[1], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[2]) {
|
||||
*control = cb(i + t + 1 - len2, i + t + 1, fl->ids[2], ctxt);
|
||||
*control = cb(i + t + 1, fl->ids[2], ctxt);
|
||||
}
|
||||
if (*control & fl->groups[3]) {
|
||||
*control = cb(i + t + 1 - len3, i + t + 1, fl->ids[3], ctxt);
|
||||
*control = cb(i + t + 1, fl->ids[3], ctxt);
|
||||
}
|
||||
|
||||
for (u32 t2 = 4; t2 < fl->idCount; t2++) {
|
||||
if (*control & fl->groups[t2]) {
|
||||
*control = cb(i + t + 1 - (fl->len[t2] - 1), i + t + 1, fl->ids[t2], ctxt);
|
||||
*control = cb(i + t + 1, fl->ids[t2], ctxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -320,7 +310,7 @@ const u8 * floodDetect(const struct FDR * fdr,
|
||||
for (u32 t = 0; t < floodSize && (*control & fl->allGroups); t++) {
|
||||
for (u32 t2 = 0; t2 < fl->idCount; t2++) {
|
||||
if (*control & fl->groups[t2]) {
|
||||
*control = cb(i + t - (fl->len[t2] - 1), i + t, fl->ids[t2], ctxt);
|
||||
*control = cb(i + t, fl->ids[t2], ctxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user