mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-30 19:47:43 +03:00
add new Literal API for pure literal expressions:
Design compile time api hs_compile_lit() and hs_compile_lit_multi() to handle pure literal pattern sets. Corresponding option --literal-on is added for hyperscan testing suites. Extended parameters and part of flags are not supported for this api.
This commit is contained in:
committed by
Chang, Harry
parent
8bfbf07f75
commit
23e5f06594
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2018, Intel Corporation
|
||||
* Copyright (c) 2015-2019, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -925,11 +925,22 @@ compileHyperscan(vector<const char *> &patterns, vector<unsigned> &flags,
|
||||
const unsigned count = patterns.size();
|
||||
hs_database_t *db = nullptr;
|
||||
hs_compile_error_t *compile_err;
|
||||
hs_error_t err;
|
||||
|
||||
hs_error_t err = hs_compile_multi_int(&patterns[0], &flags[0],
|
||||
&idsvec[0], ext.c_array(), count,
|
||||
mode, platform, &db,
|
||||
&compile_err, grey);
|
||||
if (use_literal_api) {
|
||||
// Compute length of each pattern.
|
||||
vector<size_t> lens(count);
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
lens[i] = strlen(patterns[i]);
|
||||
}
|
||||
err = hs_compile_lit_multi_int(&patterns[0], &flags[0], &idsvec[0],
|
||||
ext.c_array(), &lens[0], count, mode,
|
||||
platform, &db, &compile_err, grey);
|
||||
} else {
|
||||
err = hs_compile_multi_int(&patterns[0], &flags[0], &idsvec[0],
|
||||
ext.c_array(), count, mode, platform, &db,
|
||||
&compile_err, grey);
|
||||
}
|
||||
|
||||
if (err != HS_SUCCESS) {
|
||||
error = compile_err->message;
|
||||
|
Reference in New Issue
Block a user