├── .clang-format ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CMakeLists.txt ├── COPYING ├── LICENSE ├── README.md ├── ThirdPartyNotice.md ├── chimera ├── CMakeLists.txt ├── ch.h ├── ch_alloc.c ├── ch_alloc.h ├── ch_common.h ├── ch_compile.cpp ├── ch_compile.h ├── ch_database.c ├── ch_database.h ├── ch_internal.h ├── ch_runtime.c ├── ch_runtime.h ├── ch_scratch.c ├── ch_scratch.h └── libch.pc.in ├── cmake ├── arch.cmake ├── attrib.cmake ├── backtrace.cmake ├── boost.cmake ├── build_wrapper.sh ├── config.h.in ├── formatdate.py ├── keep.syms.in ├── pcre.cmake ├── platform.cmake ├── ragel.cmake └── sqlite3.cmake ├── doc └── dev-reference │ ├── CMakeLists.txt │ ├── _static │ └── hyperscan.css │ ├── api_constants.rst │ ├── api_files.rst │ ├── chimera.rst │ ├── compilation.rst │ ├── conf.py.in │ ├── copyright.rst │ ├── getting_started.rst │ ├── hyperscan.doxyfile.in │ ├── index.rst │ ├── intro.rst │ ├── performance.rst │ ├── preface.rst │ ├── runtime.rst │ ├── serialization.rst │ └── tools.rst ├── examples ├── CMakeLists.txt ├── README.md ├── patbench.cc ├── pcapscan.cc └── simplegrep.c ├── hs.def ├── hs_runtime.def ├── include └── boost-patched │ └── graph │ ├── dominator_tree.hpp │ └── reverse_graph.hpp ├── libhs.pc.in ├── src ├── alloc.c ├── allocator.h ├── compiler │ ├── asserts.cpp │ ├── asserts.h │ ├── compiler.cpp │ ├── compiler.h │ ├── error.cpp │ ├── error.h │ └── expression_info.h ├── crc32.c ├── crc32.h ├── database.c ├── database.h ├── dispatcher.c ├── fdr │ ├── engine_description.cpp │ ├── engine_description.h │ ├── fdr.c │ ├── fdr.h │ ├── fdr_compile.cpp │ ├── fdr_compile.h │ ├── fdr_compile_internal.h │ ├── fdr_compile_util.cpp │ ├── fdr_confirm.h │ ├── fdr_confirm_compile.cpp │ ├── fdr_confirm_runtime.h │ ├── fdr_dump.cpp │ ├── fdr_dump.h │ ├── fdr_engine_description.cpp │ ├── fdr_engine_description.h │ ├── fdr_internal.h │ ├── fdr_loadval.h │ ├── flood_compile.cpp │ ├── flood_runtime.h │ ├── teddy.c │ ├── teddy.h │ ├── teddy_avx2.c │ ├── teddy_compile.cpp │ ├── teddy_compile.h │ ├── teddy_engine_description.cpp │ ├── teddy_engine_description.h │ ├── teddy_internal.h │ └── teddy_runtime_common.h ├── grey.cpp ├── grey.h ├── hs.cpp ├── hs.h ├── hs_common.h ├── hs_compile.h ├── hs_internal.h ├── hs_runtime.h ├── hs_valid_platform.c ├── hs_version.c ├── hs_version.h.in ├── hwlm │ ├── hwlm.c │ ├── hwlm.h │ ├── hwlm_build.cpp │ ├── hwlm_build.h │ ├── hwlm_dump.cpp │ ├── hwlm_dump.h │ ├── hwlm_internal.h │ ├── hwlm_literal.cpp │ ├── hwlm_literal.h │ ├── noodle_build.cpp │ ├── noodle_build.h │ ├── noodle_engine.c │ ├── noodle_engine.h │ ├── noodle_engine_avx2.c │ ├── noodle_engine_avx512.c │ ├── noodle_engine_sse.c │ └── noodle_internal.h ├── nfa │ ├── accel.c │ ├── accel.h │ ├── accel_dfa_build_strat.cpp │ ├── accel_dfa_build_strat.h │ ├── accel_dump.cpp │ ├── accel_dump.h │ ├── accelcompile.cpp │ ├── accelcompile.h │ ├── callback.h │ ├── castle.c │ ├── castle.h │ ├── castle_dump.cpp │ ├── castle_dump.h │ ├── castle_internal.h │ ├── castlecompile.cpp │ ├── castlecompile.h │ ├── dfa_build_strat.cpp │ ├── dfa_build_strat.h │ ├── dfa_min.cpp │ ├── dfa_min.h │ ├── gough.c │ ├── gough.h │ ├── gough_internal.h │ ├── goughcompile.cpp │ ├── goughcompile.h │ ├── goughcompile_accel.cpp │ ├── goughcompile_dump.cpp │ ├── goughcompile_dump.h │ ├── goughcompile_internal.h │ ├── goughcompile_reg.cpp │ ├── goughdump.cpp │ ├── goughdump.h │ ├── lbr.c │ ├── lbr.h │ ├── lbr_common_impl.h │ ├── lbr_dump.cpp │ ├── lbr_dump.h │ ├── lbr_internal.h │ ├── limex.h │ ├── limex_64.c │ ├── limex_accel.c │ ├── limex_accel.h │ ├── limex_common_impl.h │ ├── limex_compile.cpp │ ├── limex_compile.h │ ├── limex_context.h │ ├── limex_dump.cpp │ ├── limex_exceptional.h │ ├── limex_internal.h │ ├── limex_limits.h │ ├── limex_native.c │ ├── limex_ring.h │ ├── limex_runtime.h │ ├── limex_runtime_impl.h │ ├── limex_shuffle.h │ ├── limex_simd128.c │ ├── limex_simd256.c │ ├── limex_simd384.c │ ├── limex_simd512.c │ ├── limex_state_impl.h │ ├── mcclellan.c │ ├── mcclellan.h │ ├── mcclellan_common_impl.h │ ├── mcclellan_internal.h │ ├── mcclellancompile.cpp │ ├── mcclellancompile.h │ ├── mcclellancompile_util.cpp │ ├── mcclellancompile_util.h │ ├── mcclellandump.cpp │ ├── mcclellandump.h │ ├── mcsheng.c │ ├── mcsheng.h │ ├── mcsheng_compile.cpp │ ├── mcsheng_compile.h │ ├── mcsheng_data.c │ ├── mcsheng_dump.cpp │ ├── mcsheng_dump.h │ ├── mcsheng_internal.h │ ├── mpv.c │ ├── mpv.h │ ├── mpv_dump.cpp │ ├── mpv_dump.h │ ├── mpv_internal.h │ ├── mpvcompile.cpp │ ├── mpvcompile.h │ ├── nfa_api.h │ ├── nfa_api_dispatch.c │ ├── nfa_api_queue.h │ ├── nfa_api_util.h │ ├── nfa_build_util.cpp │ ├── nfa_build_util.h │ ├── nfa_dump_api.h │ ├── nfa_dump_dispatch.cpp │ ├── nfa_dump_internal.cpp │ ├── nfa_dump_internal.h │ ├── nfa_internal.h │ ├── nfa_kind.h │ ├── nfa_rev_api.h │ ├── rdfa.cpp │ ├── rdfa.h │ ├── rdfa_graph.cpp │ ├── rdfa_graph.h │ ├── rdfa_merge.cpp │ ├── rdfa_merge.h │ ├── repeat.c │ ├── repeat.h │ ├── repeat_internal.h │ ├── repeatcompile.cpp │ ├── repeatcompile.h │ ├── sheng.c │ ├── sheng.h │ ├── sheng_defs.h │ ├── sheng_impl.h │ ├── sheng_impl4.h │ ├── sheng_internal.h │ ├── shengcompile.cpp │ ├── shengcompile.h │ ├── shengdump.cpp │ ├── shengdump.h │ ├── shufti.c │ ├── shufti.h │ ├── shufticompile.cpp │ ├── shufticompile.h │ ├── tamarama.c │ ├── tamarama.h │ ├── tamarama_dump.cpp │ ├── tamarama_dump.h │ ├── tamarama_internal.h │ ├── tamaramacompile.cpp │ ├── tamaramacompile.h │ ├── truffle.c │ ├── truffle.h │ ├── trufflecompile.cpp │ ├── trufflecompile.h │ ├── vermicelli.h │ ├── vermicelli_run.h │ └── vermicelli_sse.h ├── nfagraph │ ├── ng.cpp │ ├── ng.h │ ├── ng_anchored_acyclic.cpp │ ├── ng_anchored_acyclic.h │ ├── ng_anchored_dots.cpp │ ├── ng_anchored_dots.h │ ├── ng_asserts.cpp │ ├── ng_asserts.h │ ├── ng_builder.cpp │ ├── ng_builder.h │ ├── ng_calc_components.cpp │ ├── ng_calc_components.h │ ├── ng_cyclic_redundancy.cpp │ ├── ng_cyclic_redundancy.h │ ├── ng_depth.cpp │ ├── ng_depth.h │ ├── ng_dominators.cpp │ ├── ng_dominators.h │ ├── ng_dump.cpp │ ├── ng_dump.h │ ├── ng_edge_redundancy.cpp │ ├── ng_edge_redundancy.h │ ├── ng_equivalence.cpp │ ├── ng_equivalence.h │ ├── ng_execute.cpp │ ├── ng_execute.h │ ├── ng_expr_info.cpp │ ├── ng_expr_info.h │ ├── ng_extparam.cpp │ ├── ng_extparam.h │ ├── ng_fixed_width.cpp │ ├── ng_fixed_width.h │ ├── ng_fuzzy.cpp │ ├── ng_fuzzy.h │ ├── ng_haig.cpp │ ├── ng_haig.h │ ├── ng_holder.cpp │ ├── ng_holder.h │ ├── ng_is_equal.cpp │ ├── ng_is_equal.h │ ├── ng_lbr.cpp │ ├── ng_lbr.h │ ├── ng_limex.cpp │ ├── ng_limex.h │ ├── ng_limex_accel.cpp │ ├── ng_limex_accel.h │ ├── ng_literal_analysis.cpp │ ├── ng_literal_analysis.h │ ├── ng_literal_component.cpp │ ├── ng_literal_component.h │ ├── ng_literal_decorated.cpp │ ├── ng_literal_decorated.h │ ├── ng_mcclellan.cpp │ ├── ng_mcclellan.h │ ├── ng_mcclellan_internal.h │ ├── ng_misc_opt.cpp │ ├── ng_misc_opt.h │ ├── ng_netflow.cpp │ ├── ng_netflow.h │ ├── ng_prefilter.cpp │ ├── ng_prefilter.h │ ├── ng_prune.cpp │ ├── ng_prune.h │ ├── ng_puff.cpp │ ├── ng_puff.h │ ├── ng_redundancy.cpp │ ├── ng_redundancy.h │ ├── ng_region.cpp │ ├── ng_region.h │ ├── ng_region_redundancy.cpp │ ├── ng_region_redundancy.h │ ├── ng_repeat.cpp │ ├── ng_repeat.h │ ├── ng_reports.cpp │ ├── ng_reports.h │ ├── ng_restructuring.cpp │ ├── ng_restructuring.h │ ├── ng_revacc.cpp │ ├── ng_revacc.h │ ├── ng_sep.cpp │ ├── ng_sep.h │ ├── ng_small_literal_set.cpp │ ├── ng_small_literal_set.h │ ├── ng_som.cpp │ ├── ng_som.h │ ├── ng_som_add_redundancy.cpp │ ├── ng_som_add_redundancy.h │ ├── ng_som_util.cpp │ ├── ng_som_util.h │ ├── ng_split.cpp │ ├── ng_split.h │ ├── ng_squash.cpp │ ├── ng_squash.h │ ├── ng_stop.cpp │ ├── ng_stop.h │ ├── ng_uncalc_components.cpp │ ├── ng_uncalc_components.h │ ├── ng_utf8.cpp │ ├── ng_utf8.h │ ├── ng_util.cpp │ ├── ng_util.h │ ├── ng_vacuous.cpp │ ├── ng_vacuous.h │ ├── ng_violet.cpp │ ├── ng_violet.h │ ├── ng_width.cpp │ └── ng_width.h ├── parser │ ├── AsciiComponentClass.cpp │ ├── AsciiComponentClass.h │ ├── Component.cpp │ ├── Component.h │ ├── ComponentAlternation.cpp │ ├── ComponentAlternation.h │ ├── ComponentAssertion.cpp │ ├── ComponentAssertion.h │ ├── ComponentAtomicGroup.cpp │ ├── ComponentAtomicGroup.h │ ├── ComponentBackReference.cpp │ ├── ComponentBackReference.h │ ├── ComponentBoundary.cpp │ ├── ComponentBoundary.h │ ├── ComponentByte.cpp │ ├── ComponentByte.h │ ├── ComponentClass.cpp │ ├── ComponentClass.h │ ├── ComponentCondReference.cpp │ ├── ComponentCondReference.h │ ├── ComponentEUS.cpp │ ├── ComponentEUS.h │ ├── ComponentEmpty.cpp │ ├── ComponentEmpty.h │ ├── ComponentRepeat.cpp │ ├── ComponentRepeat.h │ ├── ComponentSequence.cpp │ ├── ComponentSequence.h │ ├── ComponentVisitor.cpp │ ├── ComponentVisitor.h │ ├── ComponentWordBoundary.cpp │ ├── ComponentWordBoundary.h │ ├── ConstComponentVisitor.cpp │ ├── ConstComponentVisitor.h │ ├── Parser.cpp │ ├── Parser.h │ ├── Parser.rl │ ├── Utf8ComponentClass.cpp │ ├── Utf8ComponentClass.h │ ├── buildstate.cpp │ ├── buildstate.h │ ├── check_refs.cpp │ ├── check_refs.h │ ├── control_verbs.cpp │ ├── control_verbs.h │ ├── control_verbs.rl │ ├── dump.cpp │ ├── dump.h │ ├── logical_combination.cpp │ ├── logical_combination.h │ ├── parse_error.cpp │ ├── parse_error.h │ ├── parser_util.cpp │ ├── position.h │ ├── position_dump.h │ ├── position_info.h │ ├── prefilter.cpp │ ├── prefilter.h │ ├── shortcut_literal.cpp │ ├── shortcut_literal.h │ ├── ucp_table.cpp │ ├── ucp_table.h │ ├── unsupported.cpp │ ├── unsupported.h │ ├── utf8_validate.cpp │ └── utf8_validate.h ├── report.h ├── rose │ ├── block.c │ ├── catchup.c │ ├── catchup.h │ ├── counting_miracle.h │ ├── infix.h │ ├── init.c │ ├── init.h │ ├── match.c │ ├── match.h │ ├── miracle.h │ ├── program_runtime.c │ ├── program_runtime.h │ ├── rose.h │ ├── rose_build.h │ ├── rose_build_add.cpp │ ├── rose_build_add_internal.h │ ├── rose_build_add_mask.cpp │ ├── rose_build_anchored.cpp │ ├── rose_build_anchored.h │ ├── rose_build_bytecode.cpp │ ├── rose_build_castle.cpp │ ├── rose_build_castle.h │ ├── rose_build_compile.cpp │ ├── rose_build_convert.cpp │ ├── rose_build_convert.h │ ├── rose_build_dedupe.cpp │ ├── rose_build_dump.cpp │ ├── rose_build_dump.h │ ├── rose_build_engine_blob.cpp │ ├── rose_build_engine_blob.h │ ├── rose_build_exclusive.cpp │ ├── rose_build_exclusive.h │ ├── rose_build_groups.cpp │ ├── rose_build_groups.h │ ├── rose_build_impl.h │ ├── rose_build_infix.cpp │ ├── rose_build_infix.h │ ├── rose_build_instructions.cpp │ ├── rose_build_instructions.h │ ├── rose_build_lit_accel.cpp │ ├── rose_build_lit_accel.h │ ├── rose_build_long_lit.cpp │ ├── rose_build_long_lit.h │ ├── rose_build_lookaround.cpp │ ├── rose_build_lookaround.h │ ├── rose_build_matchers.cpp │ ├── rose_build_matchers.h │ ├── rose_build_merge.cpp │ ├── rose_build_merge.h │ ├── rose_build_misc.cpp │ ├── rose_build_misc.h │ ├── rose_build_program.cpp │ ├── rose_build_program.h │ ├── rose_build_resources.h │ ├── rose_build_role_aliasing.cpp │ ├── rose_build_role_aliasing.h │ ├── rose_build_scatter.cpp │ ├── rose_build_scatter.h │ ├── rose_build_util.h │ ├── rose_build_width.cpp │ ├── rose_build_width.h │ ├── rose_common.h │ ├── rose_graph.h │ ├── rose_in_dump.cpp │ ├── rose_in_dump.h │ ├── rose_in_graph.h │ ├── rose_in_util.cpp │ ├── rose_in_util.h │ ├── rose_internal.h │ ├── rose_program.h │ ├── rose_types.h │ ├── runtime.h │ ├── stream.c │ ├── stream_long_lit.h │ ├── stream_long_lit_hash.h │ ├── validate_mask.h │ └── validate_shufti.h ├── runtime.c ├── scratch.c ├── scratch.h ├── scratch_dump.cpp ├── scratch_dump.h ├── smallwrite │ ├── smallwrite_build.cpp │ ├── smallwrite_build.h │ ├── smallwrite_dump.cpp │ ├── smallwrite_dump.h │ └── smallwrite_internal.h ├── som │ ├── slot_manager.cpp │ ├── slot_manager.h │ ├── slot_manager_dump.cpp │ ├── slot_manager_dump.h │ ├── slot_manager_internal.h │ ├── som.h │ ├── som_operation.h │ ├── som_runtime.c │ ├── som_runtime.h │ ├── som_stream.c │ └── som_stream.h ├── state.h ├── stream_compress.c ├── stream_compress.h ├── stream_compress_impl.h ├── ue2common.h └── util │ ├── accel_scheme.h │ ├── alloc.cpp │ ├── alloc.h │ ├── arch.h │ ├── bitfield.h │ ├── bitutils.h │ ├── boundary_reports.h │ ├── bytecode_ptr.h │ ├── charreach.cpp │ ├── charreach.h │ ├── charreach_util.h │ ├── clique.cpp │ ├── clique.h │ ├── compare.h │ ├── compile_context.cpp │ ├── compile_context.h │ ├── compile_error.cpp │ ├── compile_error.h │ ├── container.h │ ├── copybytes.h │ ├── cpuid_flags.c │ ├── cpuid_flags.h │ ├── cpuid_inline.h │ ├── depth.cpp │ ├── depth.h │ ├── determinise.h │ ├── dump_charclass.cpp │ ├── dump_charclass.h │ ├── dump_mask.cpp │ ├── dump_mask.h │ ├── dump_util.cpp │ ├── dump_util.h │ ├── exhaust.h │ ├── fatbit.h │ ├── fatbit_build.cpp │ ├── fatbit_build.h │ ├── flat_containers.h │ ├── graph.h │ ├── graph_range.h │ ├── graph_small_color_map.h │ ├── graph_undirected.h │ ├── hash.h │ ├── hash_dynamic_bitset.h │ ├── insertion_ordered.h │ ├── intrinsics.h │ ├── join.h │ ├── logical.h │ ├── make_unique.h │ ├── masked_move.c │ ├── masked_move.h │ ├── math.h │ ├── multibit.c │ ├── multibit.h │ ├── multibit_build.cpp │ ├── multibit_build.h │ ├── multibit_compress.h │ ├── multibit_internal.h │ ├── noncopyable.h │ ├── operators.h │ ├── order_check.h │ ├── pack_bits.h │ ├── partial_store.h │ ├── partitioned_set.h │ ├── popcount.h │ ├── pqueue.h │ ├── queue_index_factory.h │ ├── report.h │ ├── report_manager.cpp │ ├── report_manager.h │ ├── scatter.h │ ├── scatter_runtime.h │ ├── simd_arm.h │ ├── simd_types.h │ ├── simd_utils.c │ ├── simd_utils.h │ ├── simd_x86.h │ ├── small_vector.h │ ├── state_compress.c │ ├── state_compress.h │ ├── target_info.cpp │ ├── target_info.h │ ├── ue2_graph.h │ ├── ue2string.cpp │ ├── ue2string.h │ ├── unaligned.h │ ├── unicode_def.h │ ├── unicode_set.h │ ├── uniform_ops.h │ ├── unordered.h │ └── verify_types.h ├── tools ├── CMakeLists.txt ├── fuzz │ ├── aristocrats.py │ ├── completocrats.py │ ├── heuristocrats.py │ └── limited_dict.txt ├── hsbench │ ├── CMakeLists.txt │ ├── README.md │ ├── common.h │ ├── data_corpus.cpp │ ├── data_corpus.h │ ├── engine.cpp │ ├── engine.h │ ├── engine_chimera.cpp │ ├── engine_chimera.h │ ├── engine_hyperscan.cpp │ ├── engine_hyperscan.h │ ├── engine_pcre.cpp │ ├── engine_pcre.h │ ├── heapstats.cpp │ ├── heapstats.h │ ├── huge.cpp │ ├── huge.h │ ├── main.cpp │ ├── scripts │ │ ├── CorpusBuilder.py │ │ ├── gutenbergCorpus.py │ │ ├── linebasedCorpus.py │ │ └── pcapCorpus.py │ ├── sqldb.cpp │ ├── sqldb.h │ ├── sqldb_bind.h │ ├── thread_barrier.h │ └── timer.h ├── hscheck │ ├── CMakeLists.txt │ └── main.cpp ├── hscollider │ ├── BoundedQueue.h │ ├── CMakeLists.txt │ ├── ColliderCorporaParser.cpp │ ├── ColliderCorporaParser.h │ ├── ColliderCorporaParser.rl │ ├── Corpora.cpp │ ├── Corpora.h │ ├── DatabaseProxy.h │ ├── FileCorpora.cpp │ ├── FileCorpora.h │ ├── GraphTruth.cpp │ ├── GraphTruth.h │ ├── GroundTruth.cpp │ ├── GroundTruth.h │ ├── NfaGeneratedCorpora.cpp │ ├── NfaGeneratedCorpora.h │ ├── ResultSet.h │ ├── Thread.cpp │ ├── Thread.h │ ├── UltimateTruth.cpp │ ├── UltimateTruth.h │ ├── args.cpp │ ├── args.h │ ├── common.h │ ├── limit.cpp │ ├── limit.h │ ├── main.cpp │ ├── pcre_util.cpp │ ├── pcre_util.h │ ├── sig.cpp │ ├── sig.h │ ├── simple_timer.h │ └── test_cases │ │ ├── corpora │ │ ├── accel.txt │ │ ├── anchors.txt │ │ ├── approximate_matching.txt │ │ ├── asserts.txt │ │ ├── benefits.txt │ │ ├── capturing.txt │ │ ├── charclass.txt │ │ ├── comp.txt │ │ ├── comptree.txt │ │ ├── extparams.txt │ │ ├── highlander.txt │ │ ├── longlits.txt │ │ ├── lookaround.txt │ │ ├── mangle.txt │ │ ├── mcclellan.txt │ │ ├── metacharacters.txt │ │ ├── notbob.txt │ │ ├── options.txt │ │ ├── passthrough.txt │ │ ├── prefilter.txt │ │ ├── priority.txt │ │ ├── puff.txt │ │ ├── pug.txt │ │ ├── redundancy.txt │ │ ├── ucp.txt │ │ ├── utf8.txt │ │ └── vacuous.txt │ │ ├── pcre │ │ ├── accel.txt │ │ ├── anchors.txt │ │ ├── approximate_matching.txt │ │ ├── asserts.txt │ │ ├── benefits.txt │ │ ├── capturing.txt │ │ ├── charclass.txt │ │ ├── comp.txt │ │ ├── comptree.txt │ │ ├── extparams.txt │ │ ├── highlander.txt │ │ ├── longlits.txt │ │ ├── lookaround.txt │ │ ├── mangle.txt │ │ ├── mcclellan.txt │ │ ├── metacharacters.txt │ │ ├── notbob.txt │ │ ├── options.txt │ │ ├── passthrough.txt │ │ ├── prefilter.txt │ │ ├── priority.txt │ │ ├── puff.txt │ │ ├── pug.txt │ │ ├── redundancy.txt │ │ ├── ucp.txt │ │ ├── utf8.txt │ │ └── vacuous.txt │ │ └── signatures │ │ └── collider_tests.txt └── hsdump │ ├── CMakeLists.txt │ └── main.cpp ├── unit ├── CMakeLists.txt ├── chimera │ ├── allocators.cpp │ ├── arg_checks.cpp │ ├── bad_patterns.cpp │ ├── compat.cpp │ ├── main.cpp │ └── scan.cpp ├── gtest │ ├── gtest-all.cc │ └── gtest.h ├── hyperscan │ ├── allocators.cpp │ ├── arg_checks.cpp │ ├── bad_patterns.cpp │ ├── bad_patterns.txt │ ├── behaviour.cpp │ ├── expr_info.cpp │ ├── extparam.cpp │ ├── identical.cpp │ ├── literals.cpp │ ├── logical_combination.cpp │ ├── main.cpp │ ├── multi.cpp │ ├── order.cpp │ ├── scratch_in_use.cpp │ ├── scratch_op.cpp │ ├── serialize.cpp │ ├── single.cpp │ ├── som.cpp │ ├── stream_op.cpp │ ├── test_util.cpp │ └── test_util.h └── internal │ ├── bitfield.cpp │ ├── bitutils.cpp │ ├── charreach.cpp │ ├── compare.cpp │ ├── database.cpp │ ├── depth.cpp │ ├── fdr.cpp │ ├── fdr_flood.cpp │ ├── fdr_loadval.cpp │ ├── flat_map.cpp │ ├── flat_set.cpp │ ├── graph.cpp │ ├── graph_undirected.cpp │ ├── insertion_ordered.cpp │ ├── lbr.cpp │ ├── limex_nfa.cpp │ ├── main.cpp │ ├── masked_move.cpp │ ├── multi_bit.cpp │ ├── multi_bit_compress.cpp │ ├── nfagraph_common.h │ ├── nfagraph_comp.cpp │ ├── nfagraph_equivalence.cpp │ ├── nfagraph_find_matches.cpp │ ├── nfagraph_literal_analysis.cpp │ ├── nfagraph_redundancy.cpp │ ├── nfagraph_repeat.cpp │ ├── nfagraph_util.cpp │ ├── nfagraph_width.cpp │ ├── noodle.cpp │ ├── pack_bits.cpp │ ├── parser.cpp │ ├── partial.cpp │ ├── pqueue.cpp │ ├── repeat.cpp │ ├── rose_build_merge.cpp │ ├── rose_mask.cpp │ ├── rose_mask_32.cpp │ ├── rvermicelli.cpp │ ├── shuffle.cpp │ ├── shufti.cpp │ ├── simd_utils.cpp │ ├── state_compress.cpp │ ├── truffle.cpp │ ├── unaligned.cpp │ ├── unicode_set.cpp │ ├── uniform_ops.cpp │ ├── utf8_validate.cpp │ ├── util_string.cpp │ └── vermicelli.cpp └── util ├── CMakeLists.txt ├── ExpressionParser.cpp ├── ExpressionParser.h ├── ExpressionParser.rl ├── cross_compile.cpp ├── cross_compile.h ├── database_util.cpp ├── database_util.h ├── expression_path.h ├── expressions.cpp ├── expressions.h ├── ng_corpus_editor.cpp ├── ng_corpus_editor.h ├── ng_corpus_generator.cpp ├── ng_corpus_generator.h ├── ng_corpus_properties.cpp ├── ng_corpus_properties.h ├── ng_find_matches.cpp ├── ng_find_matches.h ├── string_util.h └── win_getopt.h /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | IndentWidth: 4 3 | UseTab: false 4 | AllowShortIfStatementsOnASingleLine: false 5 | IndentCaseLabels: false 6 | AccessModifierOffset: -4 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## 2 | ## There are some more .gitignore files in subdirs, but this is the main place 3 | ## to add new entries. These are mostly for the common case when ue2 is built 4 | ## in place 5 | ## 6 | 7 | # Autogenerated stuff that we don't want to know about 8 | .deps 9 | autom4te.cache 10 | autojunk 11 | .dirstamp 12 | 13 | # Temp and swap files 14 | *~ 15 | .*.swp 16 | .sw? 17 | 18 | # compiler output and binaries 19 | *.a 20 | *.o 21 | *.lo 22 | *.la 23 | *.so 24 | *.pyc 25 | .libs 26 | bin 27 | 28 | # Merge files created by git. 29 | *.orig 30 | 31 | # sigs dir is handled externally 32 | signatures 33 | # but not the regression tests 34 | !tools/hscollider/test_cases/signatures 35 | 36 | # ignore pcre symlink if it exists 37 | pcre 38 | # but not pcre subdirs! 39 | !pcre/ 40 | 41 | # ignore boost symlink if it exists 42 | include/boost 43 | 44 | # ignore sqlite3 symlink if it exists 45 | sqlite3 46 | 47 | # Generated files 48 | src/config.h 49 | src/config.h.in 50 | src/hs_version.h 51 | src/parser/Parser.cpp 52 | 53 | # Generated PCRE files 54 | pcre/pcre_chartables.c 55 | pcre/pcregrep 56 | pcre/pcretest 57 | 58 | # Autoconf/automake/libtool noise 59 | Makefile 60 | Makefile.in 61 | aclocal.m4 62 | config.cache 63 | config.log 64 | config.status 65 | configure 66 | libhs.pc 67 | libtool 68 | m4/libtool.m4 69 | m4/ltoptions.m4 70 | m4/ltsugar.m4 71 | m4/ltversion.m4 72 | m4/lt~obsolete.m4 73 | src/stamp-h1 74 | 75 | # Docs 76 | !doc/dev-reference/Makefile # not generated 77 | doc/dev-reference/doxygen_sqlite3.db 78 | doc/dev-reference/doxygen_xml/ 79 | doc/dev-reference/_build/ 80 | 81 | # Autotools noise in pcre 82 | pcre/INSTALL 83 | pcre/Makefile 84 | pcre/Makefile.in 85 | pcre/aclocal.m4 86 | pcre/ar-lib 87 | pcre/compile 88 | pcre/config.* 89 | pcre/configure 90 | pcre/depcomp 91 | pcre/install-sh 92 | pcre/*.pc 93 | pcre/libtool 94 | pcre/ltmain.sh 95 | pcre/missing 96 | pcre/pcre-config 97 | pcre/pcre.h 98 | pcre/pcre_stringpiece.h 99 | pcre/pcrecpparg.h 100 | pcre/stamp-h1 101 | pcre/test-driver 102 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: bionic 2 | 3 | os: 4 | - linux 5 | 6 | arch: 7 | - arm64 8 | - x86 9 | 10 | addons: 11 | apt: 12 | update: true 13 | hosts: 14 | - node2 15 | 16 | language: 17 | - c 18 | 19 | script: 20 | - cd .. 21 | - sudo apt-get install libboost-dev 22 | 23 | - wget http://www.colm.net/files/ragel/ragel-6.10.tar.gz 24 | - tar -zxf ragel-6.10.tar.gz 25 | - cd ./ragel-6.10 26 | - sudo ./configure 27 | - sudo make -j16 28 | - sudo make install 29 | 30 | - cd ../ 31 | - wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz 32 | - tar -zxvf pcre-8.41.tar.gz 33 | - sudo cp -rf ./pcre-8.41 ./hyperscan/pcre 34 | 35 | - cd ./hyperscan 36 | - rm -rf build 37 | - mkdir build 38 | - cd build 39 | - cmake .. 40 | - make -j8 41 | - sudo ./bin/unit-hyperscan 42 | - sudo ./bin/unit-chimera 43 | - sudo ./bin/hscheck -s ./../tools/hscollider/test_cases/signatures/collider_tests.txt 44 | - sudo make collide_quick_test 45 | - sudo make collide_quick_test_block -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Intel Corporation 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of Intel Corporation nor the names of its contributors 12 | may be used to endorse or promote products derived from this software 13 | without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | 27 | -------------------------------------------------------------------------------- /chimera/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Chimera lib 2 | 3 | include_directories(${PCRE_INCLUDE_DIRS}) 4 | 5 | # only set these after all tests are done 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}") 8 | 9 | SET(chimera_HEADERS 10 | ch.h 11 | ch_common.h 12 | ch_compile.h 13 | ch_runtime.h 14 | ) 15 | install(FILES ${chimera_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hs") 16 | 17 | SET(chimera_SRCS 18 | ${chimera_HEADERS} 19 | ch_alloc.c 20 | ch_alloc.h 21 | ch_compile.cpp 22 | ch_database.c 23 | ch_database.h 24 | ch_internal.h 25 | ch_runtime.c 26 | ch_scratch.h 27 | ch_scratch.c 28 | ) 29 | 30 | add_library(chimera STATIC ${chimera_SRCS}) 31 | add_dependencies(chimera hs pcre) 32 | target_link_libraries(chimera hs pcre) 33 | 34 | install(TARGETS chimera DESTINATION ${CMAKE_INSTALL_LIBDIR}) 35 | 36 | if (NOT WIN32) 37 | # expand out library names for pkgconfig static link info 38 | foreach (LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}) 39 | # this is fragile, but protects us from toolchain specific files 40 | if (NOT EXISTS ${LIB}) 41 | set(PRIVATE_LIBS "${PRIVATE_LIBS} -l${LIB}") 42 | endif() 43 | endforeach() 44 | set(PRIVATE_LIBS "${PRIVATE_LIBS} -L${LIBDIR} -lpcre") 45 | 46 | configure_file(libch.pc.in libch.pc @ONLY) # only replace @ quoted vars 47 | install(FILES ${CMAKE_BINARY_DIR}/chimera/libch.pc 48 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") 49 | endif() 50 | -------------------------------------------------------------------------------- /chimera/ch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef CH_H_ 30 | #define CH_H_ 31 | 32 | /** 33 | * @file 34 | * @brief The complete Chimera API definition. 35 | * 36 | * Chimera is a hybrid solution of Hyperscan and PCRE. 37 | * 38 | * This header includes both the Chimera compiler and runtime components. See 39 | * the individual component headers for documentation. 40 | */ 41 | 42 | #include "ch_compile.h" 43 | #include "ch_runtime.h" 44 | 45 | #endif /* CH_H_ */ 46 | -------------------------------------------------------------------------------- /chimera/libch.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ 4 | includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@ 5 | 6 | Name: libch 7 | Description: Intel(R) Chimera Library 8 | Version: @HS_VERSION@ 9 | Requires.private: libhs 10 | Libs: -L${libdir} -lchimera 11 | Libs.private: @PRIVATE_LIBS@ 12 | Cflags: -I${includedir}/hs 13 | -------------------------------------------------------------------------------- /cmake/attrib.cmake: -------------------------------------------------------------------------------- 1 | # tests for compiler properties 2 | 3 | # set -Werror so we can't ignore unused attribute warnings 4 | set (CMAKE_REQUIRED_FLAGS "-Werror") 5 | 6 | CHECK_C_SOURCE_COMPILES(" 7 | int foo(int) __attribute__ ((ifunc(\"foo_i\"))); 8 | int f1(int i) { return i; } 9 | void (*foo_i()) { return f1; } 10 | int main(void) { return 0; } 11 | " HAS_C_ATTR_IFUNC) 12 | 13 | unset(CMAKE_REQUIRED_FLAGS) 14 | -------------------------------------------------------------------------------- /cmake/build_wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # This is used for renaming symbols for the fat runtime, don't call directly 3 | # TODO: make this a lot less fragile! 4 | cleanup () { 5 | rm -f ${SYMSFILE} ${KEEPSYMS} 6 | } 7 | 8 | PREFIX=$1 9 | KEEPSYMS_IN=$2 10 | shift 2 11 | # $@ contains the actual build command 12 | OUT=$(echo "$@" | rev | cut -d ' ' -f 2- | rev | sed 's/.* -o \(.*\.o\).*/\1/') 13 | trap cleanup INT QUIT EXIT 14 | SYMSFILE=$(mktemp -p /tmp ${PREFIX}_rename.syms.XXXXX) 15 | KEEPSYMS=$(mktemp -p /tmp keep.syms.XXXXX) 16 | # find the libc used by gcc 17 | LIBC_SO=$("$@" --print-file-name=libc.so.6) 18 | cp ${KEEPSYMS_IN} ${KEEPSYMS} 19 | # get all symbols from libc and turn them into patterns 20 | nm -f p -g -D ${LIBC_SO} | sed -s 's/\([^ @]*\).*/^\1$/' >> ${KEEPSYMS} 21 | # build the object 22 | "$@" 23 | # rename the symbols in the object 24 | nm -f p -g ${OUT} | cut -f1 -d' ' | grep -v -f ${KEEPSYMS} | sed -e "s/\(.*\)/\1\ ${PREFIX}_\1/" >> ${SYMSFILE} 25 | if test -s ${SYMSFILE} 26 | then 27 | objcopy --redefine-syms=${SYMSFILE} ${OUT} 28 | fi 29 | -------------------------------------------------------------------------------- /cmake/formatdate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | import os 4 | import sys 5 | import datetime 6 | 7 | def usage(): 8 | print("Usage:", os.path.basename(sys.argv[0]), "") 9 | 10 | if len(sys.argv) != 2: 11 | usage() 12 | sys.exit(1) 13 | 14 | ts = sys.argv[1] 15 | 16 | build_date = datetime.datetime.utcfromtimestamp(int(ts)) 17 | 18 | print(build_date.strftime("%Y-%m-%d")) 19 | -------------------------------------------------------------------------------- /cmake/keep.syms.in: -------------------------------------------------------------------------------- 1 | # names to exclude 2 | hs_misc_alloc 3 | hs_misc_free 4 | hs_free_scratch 5 | hs_stream_alloc 6 | hs_stream_free 7 | hs_scratch_alloc 8 | hs_scratch_free 9 | hs_database_alloc 10 | hs_database_free 11 | ^_ 12 | -------------------------------------------------------------------------------- /cmake/platform.cmake: -------------------------------------------------------------------------------- 1 | # determine the target arch 2 | 3 | # really only interested in the preprocessor here 4 | CHECK_C_SOURCE_COMPILES("#if !(defined(__x86_64__) || defined(_M_X64))\n#error not 64bit\n#endif\nint main(void) { return 0; }" ARCH_X86_64) 5 | 6 | CHECK_C_SOURCE_COMPILES("#if !(defined(__i386__) || defined(_M_IX86))\n#error not 32bit\n#endif\nint main(void) { return 0; }" ARCH_IA32) 7 | 8 | CHECK_C_SOURCE_COMPILES("#if !(defined(__aarch64__))\n#error not 64bit\n#endif\nint main(void) { return 0; }" ARCH_AARCH64) 9 | 10 | if (ARCH_X86_64 OR ARCH_AARCH64) 11 | set(ARCH_64_BIT 1) 12 | elseif (ARCH_IA32) 13 | set(ARCH_32_BIT 1) 14 | endif() 15 | -------------------------------------------------------------------------------- /cmake/ragel.cmake: -------------------------------------------------------------------------------- 1 | # function for doing all the dirty work in turning a .rl into C++ 2 | 3 | function(ragelmaker src_rl) 4 | get_filename_component(src_dir ${src_rl} PATH) # old cmake needs PATH 5 | get_filename_component(src_file ${src_rl} NAME_WE) 6 | set(rl_out ${CMAKE_CURRENT_BINARY_DIR}/${src_dir}/${src_file}.cpp) 7 | add_custom_command( 8 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${src_dir}/${src_file}.cpp 9 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${src_dir} 10 | COMMAND ${RAGEL} ${CMAKE_CURRENT_SOURCE_DIR}/${src_rl} -o ${rl_out} 11 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${src_rl} 12 | ) 13 | add_custom_target(ragel_${src_file} DEPENDS ${rl_out}) 14 | set_source_files_properties(${rl_out} PROPERTIES GENERATED TRUE) 15 | endfunction(ragelmaker) 16 | 17 | # On the aarch64 platform, char is unsigned by default, so in order to be consistent with 18 | # the x86 platform, we will add -fsigned-char to the compile option to force the char type. 19 | # However, when the ragel generates c++ code, the char variable used will still be considered 20 | # unsigned, resulting in the overflow of the char variable value in the generated code, 21 | # resulting in some errors. 22 | # function for copying the previously modified code to the specified path 23 | 24 | function(ragelcopyer src_rl) 25 | get_filename_component(src_dir ${src_rl} PATH) # old cmake needs PATH 26 | get_filename_component(src_file ${src_rl} NAME_WE) 27 | set(rl_out ${CMAKE_CURRENT_BINARY_DIR}/${src_dir}/${src_file}.cpp) 28 | add_custom_command( 29 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${src_dir}/${src_file}.cpp 30 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${src_dir} 31 | COMMAND ${COPY} -f ${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}/${src_file}.cpp ${rl_out} 2>/dev/null ||: 32 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}/${src_file}.cpp 33 | ) 34 | add_custom_target(ragel_${src_file} DEPENDS ${rl_out}) 35 | set_source_files_properties(${rl_out} PROPERTIES GENERATED TRUE) 36 | endfunction(ragelcopyer) 37 | -------------------------------------------------------------------------------- /doc/dev-reference/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_program(DOXYGEN doxygen) 2 | 3 | if (DOXYGEN STREQUAL DOXYGEN-NOTFOUND) 4 | message(STATUS "Doxygen not found, unable to generate API reference") 5 | else() 6 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/hyperscan.doxyfile.in" 7 | "${CMAKE_CURRENT_BINARY_DIR}/hyperscan.doxyfile" @ONLY) 8 | 9 | add_custom_target(dev-reference-doxygen 10 | ${DOXYGEN} ${CMAKE_CURRENT_BINARY_DIR}/hyperscan.doxyfile 11 | COMMENT "Building doxygen XML for API reference") 12 | endif() 13 | 14 | find_program(SPHINX_BUILD sphinx-build) 15 | 16 | if (SPHINX_BUILD STREQUAL SPHINX_BUILD-NOTFOUND) 17 | message(STATUS "Sphinx not found, unable to generate developer reference") 18 | else() 19 | set(SPHINX_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build") 20 | set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees") 21 | set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html") 22 | 23 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" 24 | "${CMAKE_CURRENT_BINARY_DIR}/conf.py" @ONLY) 25 | 26 | add_custom_target(dev-reference 27 | ${SPHINX_BUILD} 28 | -b html 29 | -c "${CMAKE_CURRENT_BINARY_DIR}" 30 | -d "${SPHINX_CACHE_DIR}" 31 | "${CMAKE_CURRENT_SOURCE_DIR}" 32 | "${SPHINX_HTML_DIR}" 33 | DEPENDS dev-reference-doxygen 34 | COMMENT "Building HTML dev reference with Sphinx") 35 | endif() 36 | -------------------------------------------------------------------------------- /doc/dev-reference/_static/hyperscan.css: -------------------------------------------------------------------------------- 1 | /* Differentiate the way we display regex fragments. */ 2 | .regexp { 3 | color: darkred !important; 4 | } 5 | 6 | /* Avoid (the alabaster theme default) Goudy Old Style, which renders in 7 | * italics on some Mac/Safari systems. */ 8 | body { 9 | font-family: 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro', serif; 10 | } 11 | -------------------------------------------------------------------------------- /doc/dev-reference/api_constants.rst: -------------------------------------------------------------------------------- 1 | .. _api_constants: 2 | 3 | ######################## 4 | API Reference: Constants 5 | ######################## 6 | 7 | *********** 8 | Error Codes 9 | *********** 10 | 11 | .. doxygengroup:: HS_ERROR 12 | :content-only: 13 | :no-link: 14 | 15 | ***************** 16 | hs_expr_ext flags 17 | ***************** 18 | 19 | .. doxygengroup:: HS_EXT_FLAG 20 | :content-only: 21 | :no-link: 22 | 23 | ************* 24 | Pattern flags 25 | ************* 26 | 27 | .. doxygengroup:: HS_PATTERN_FLAG 28 | :content-only: 29 | :no-link: 30 | 31 | ************************* 32 | CPU feature support flags 33 | ************************* 34 | 35 | .. doxygengroup:: HS_CPU_FEATURES_FLAG 36 | :content-only: 37 | :no-link: 38 | 39 | **************** 40 | CPU tuning flags 41 | **************** 42 | 43 | .. doxygengroup:: HS_TUNE_FLAG 44 | :content-only: 45 | :no-link: 46 | 47 | ****************** 48 | Compile mode flags 49 | ****************** 50 | 51 | .. doxygengroup:: HS_MODE_FLAG 52 | :content-only: 53 | :no-link: 54 | -------------------------------------------------------------------------------- /doc/dev-reference/api_files.rst: -------------------------------------------------------------------------------- 1 | .. _api_files: 2 | 3 | #################### 4 | API Reference: Files 5 | #################### 6 | 7 | ********** 8 | File: hs.h 9 | ********** 10 | 11 | .. doxygenfile:: hs.h 12 | 13 | ***************** 14 | File: hs_common.h 15 | ***************** 16 | 17 | .. doxygenfile:: hs_common.h 18 | 19 | ****************** 20 | File: hs_compile.h 21 | ****************** 22 | 23 | .. doxygenfile:: hs_compile.h 24 | 25 | ****************** 26 | File: hs_runtime.h 27 | ****************** 28 | 29 | .. doxygenfile:: hs_runtime.h 30 | -------------------------------------------------------------------------------- /doc/dev-reference/copyright.rst: -------------------------------------------------------------------------------- 1 | .. include:: 2 | 3 | ######### 4 | Copyright 5 | ######### 6 | 7 | No license (express or implied, by estoppel or otherwise) to any intellectual 8 | property rights is granted by this document. 9 | 10 | Intel disclaims all express and implied warranties, including without 11 | limitation, the implied warranties of merchantability, fitness for a particular 12 | purpose, and non-infringement, as well as any warranty arising from course of 13 | performance, course of dealing, or usage in trade. 14 | 15 | This document contains information on products, services and/or processes in 16 | development. All information provided here is subject to change without 17 | notice. Contact your Intel representative to obtain the latest forecast, 18 | schedule, specifications and roadmaps. 19 | 20 | The products and services described may contain defects or errors known as 21 | errata which may cause deviations from published specifications. Current 22 | characterized errata are available on request. 23 | 24 | Copies of documents which have an order number and are referenced in this 25 | document, or other Intel literature, may be obtained by calling 1-800-548-4725, 26 | or go to: . 27 | 28 | Intel, and the Intel logo, are trademarks of Intel Corporation in the U.S. 29 | and/or other countries. 30 | 31 | \*Other names and brands may be claimed as the property of others. 32 | 33 | Copyright |copy| 2015-2018, Intel Corporation. All rights reserved. 34 | -------------------------------------------------------------------------------- /doc/dev-reference/index.rst: -------------------------------------------------------------------------------- 1 | ############################################### 2 | Hyperscan |version| Developer's Reference Guide 3 | ############################################### 4 | 5 | ------- 6 | |today| 7 | ------- 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | 12 | copyright 13 | preface 14 | intro 15 | getting_started 16 | compilation 17 | runtime 18 | serialization 19 | performance 20 | tools 21 | api_constants 22 | api_files 23 | chimera 24 | -------------------------------------------------------------------------------- /doc/dev-reference/preface.rst: -------------------------------------------------------------------------------- 1 | ####### 2 | Preface 3 | ####### 4 | 5 | ******** 6 | Overview 7 | ******** 8 | 9 | Hyperscan is a regular expression engine designed to offer high performance, the 10 | ability to match multiple expressions simultaneously and flexibility in 11 | scanning operation. 12 | 13 | Patterns are provided to a compilation interface which generates an immutable 14 | pattern database. The scan interface then can be used to scan a target data 15 | buffer for the given patterns, returning any matching results from that data 16 | buffer. Hyperscan also provides a streaming mode, in which matches that span 17 | several blocks in a stream are detected. 18 | 19 | This document is designed to facilitate code-level integration of the Hyperscan 20 | library with existing or new applications. 21 | 22 | :ref:`intro` is a short overview of the Hyperscan library, with more detail on 23 | the Hyperscan API provided in the subsequent sections: :ref:`compilation` and 24 | :ref:`runtime`. 25 | 26 | :ref:`perf` provides details on various factors which may impact the 27 | performance of a Hyperscan integration. 28 | 29 | :ref:`api_constants` and :ref:`api_files` provides a detailed summary of the 30 | Hyperscan Application Programming Interface (API). 31 | 32 | ******** 33 | Audience 34 | ******** 35 | 36 | This guide is aimed at developers interested in integrating Hyperscan into an 37 | application. For information on building the Hyperscan library, see the Quick 38 | Start Guide. 39 | 40 | *********** 41 | Conventions 42 | *********** 43 | 44 | * Text in a ``fixed-width font`` refers to a code element, e.g. type name; 45 | function or method name. 46 | * Text in a :regexp:`coloured fixed-width font` refers to a regular 47 | expression or a part of a regular expression. 48 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_library(PCAP_LIBRARY pcap) 2 | 3 | if (NOT PCAP_LIBRARY) 4 | message(STATUS "Could not find libpcap - some examples will not be built") 5 | endif() 6 | 7 | add_executable(simplegrep simplegrep.c) 8 | set_source_files_properties(simplegrep.c PROPERTIES COMPILE_FLAGS 9 | "-Wall -Wno-unused-parameter") 10 | target_link_libraries(simplegrep hs) 11 | 12 | if (PCAP_LIBRARY) 13 | add_executable(pcapscan pcapscan.cc) 14 | set_source_files_properties(pcapscan.cc PROPERTIES COMPILE_FLAGS 15 | "-Wall -Wno-unused-parameter") 16 | target_link_libraries(pcapscan hs pcap) 17 | endif() 18 | 19 | if (PCAP_LIBRARY) 20 | add_executable(patbench patbench.cc) 21 | set_source_files_properties(patbench.cc PROPERTIES COMPILE_FLAGS 22 | "-Wall -Wno-unused-parameter") 23 | target_link_libraries(patbench hs pcap) 24 | endif() 25 | 26 | install(FILES simplegrep.c pcapscan.cc patbench.cc README.md 27 | DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples) 28 | -------------------------------------------------------------------------------- /hs.def: -------------------------------------------------------------------------------- 1 | ; Hyperscan DLL export definitions 2 | 3 | LIBRARY hs 4 | 5 | EXPORTS 6 | hs_alloc_scratch 7 | hs_clone_scratch 8 | hs_close_stream 9 | hs_compile 10 | hs_compile_ext_multi 11 | hs_compile_multi 12 | hs_compress_stream 13 | hs_copy_stream 14 | hs_database_info 15 | hs_database_size 16 | hs_deserialize_database 17 | hs_deserialize_database_at 18 | hs_expand_stream 19 | hs_expression_ext_info 20 | hs_expression_info 21 | hs_free_compile_error 22 | hs_free_database 23 | hs_free_scratch 24 | hs_open_stream 25 | hs_populate_platform 26 | hs_reset_and_copy_stream 27 | hs_reset_and_expand_stream 28 | hs_reset_stream 29 | hs_scan 30 | hs_scan_stream 31 | hs_scan_vector 32 | hs_scratch_size 33 | hs_serialize_database 34 | hs_serialized_database_info 35 | hs_serialized_database_size 36 | hs_set_allocator 37 | hs_set_database_allocator 38 | hs_set_misc_allocator 39 | hs_set_scratch_allocator 40 | hs_set_stream_allocator 41 | hs_stream_size 42 | hs_valid_platform 43 | hs_version 44 | -------------------------------------------------------------------------------- /hs_runtime.def: -------------------------------------------------------------------------------- 1 | ; Hyperscan DLL export definitions 2 | 3 | LIBRARY hs_runtime 4 | 5 | EXPORTS 6 | hs_alloc_scratch 7 | hs_clone_scratch 8 | hs_close_stream 9 | hs_compress_stream 10 | hs_copy_stream 11 | hs_database_info 12 | hs_database_size 13 | hs_deserialize_database 14 | hs_deserialize_database_at 15 | hs_expand_stream 16 | hs_free_database 17 | hs_free_scratch 18 | hs_open_stream 19 | hs_reset_and_copy_stream 20 | hs_reset_and_expand_stream 21 | hs_reset_stream 22 | hs_scan 23 | hs_scan_stream 24 | hs_scan_vector 25 | hs_scratch_size 26 | hs_serialize_database 27 | hs_serialized_database_info 28 | hs_serialized_database_size 29 | hs_set_allocator 30 | hs_set_database_allocator 31 | hs_set_misc_allocator 32 | hs_set_scratch_allocator 33 | hs_set_stream_allocator 34 | hs_stream_size 35 | hs_valid_platform 36 | hs_version -------------------------------------------------------------------------------- /include/boost-patched/graph/reverse_graph.hpp: -------------------------------------------------------------------------------- 1 | #ifndef REVERSE_GRAPH_PATCHED_H_ 2 | #define REVERSE_GRAPH_PATCHED_H_ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #if defined(BOOST_REVGRAPH_PATCH) 9 | 10 | // Boost 1.62.0 does not implement degree() in reverse_graph which is required 11 | // by BidirectionalGraph, so add it. 12 | 13 | namespace boost { 14 | 15 | template 16 | inline typename graph_traits::degree_size_type 17 | degree(const typename graph_traits::vertex_descriptor u, 18 | const reverse_graph& g) 19 | { 20 | return degree(u, g.m_g); 21 | } 22 | 23 | } // namespace boost 24 | 25 | #endif // Boost 1.62.0 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libhs.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ 4 | includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@ 5 | 6 | Name: libhs 7 | Description: Intel(R) Hyperscan Library 8 | Version: @HS_VERSION@ 9 | Libs: -L${libdir} -lhs 10 | Libs.private: @PRIVATE_LIBS@ 11 | Cflags: -I${includedir}/hs 12 | -------------------------------------------------------------------------------- /src/crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef CRC32_H_36A5015B5840C1 30 | #define CRC32_H_36A5015B5840C1 31 | 32 | #include "ue2common.h" 33 | 34 | #ifdef __cplusplus 35 | extern "C" 36 | { 37 | #endif 38 | 39 | u32 Crc32c_ComputeBuf(u32 inCrc32, const void *buf, size_t bufLen); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* CRC32_H_36A5015B5840C1 */ 46 | 47 | -------------------------------------------------------------------------------- /src/fdr/fdr_dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief FDR literal matcher: dump API. 31 | */ 32 | 33 | #ifndef FDR_DUMP_H 34 | #define FDR_DUMP_H 35 | 36 | #if defined(DUMP_SUPPORT) 37 | 38 | #include 39 | 40 | struct FDR; 41 | 42 | namespace ue2 { 43 | 44 | void fdrPrintStats(const struct FDR *fdr, FILE *f); 45 | 46 | } // namespace ue2 47 | 48 | #endif // DUMP_SUPPORT 49 | #endif // FDR_DUMP_H 50 | -------------------------------------------------------------------------------- /src/hs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2020, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef HS_H_ 30 | #define HS_H_ 31 | 32 | /** 33 | * @file 34 | * @brief The complete Hyperscan API definition. 35 | * 36 | * Hyperscan is a high speed regular expression engine. 37 | * 38 | * This header includes both the Hyperscan compiler and runtime components. See 39 | * the individual component headers for documentation. 40 | */ 41 | 42 | /* The current Hyperscan version information. */ 43 | 44 | #define HS_MAJOR 5 45 | #define HS_MINOR 4 46 | #define HS_PATCH 2 47 | 48 | #include "hs_compile.h" 49 | #include "hs_runtime.h" 50 | 51 | #endif /* HS_H_ */ 52 | -------------------------------------------------------------------------------- /src/hs_valid_platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "hs_common.h" 30 | #include "util/cpuid_flags.h" 31 | #include "util/cpuid_inline.h" 32 | 33 | HS_PUBLIC_API 34 | hs_error_t HS_CDECL hs_valid_platform(void) { 35 | /* Hyperscan requires SSSE3, anything else is a bonus */ 36 | #if defined(__x86_64__) 37 | if (check_ssse3()) { 38 | return HS_SUCCESS; 39 | } 40 | #else 41 | if (check_neon()) { 42 | return HS_SUCCESS; 43 | } 44 | #endif 45 | else { 46 | return HS_ARCH_ERROR; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/hs_version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "ue2common.h" 30 | #include "hs_common.h" 31 | #include "hs_version.h" 32 | 33 | HS_PUBLIC_API 34 | const char * HS_CDECL hs_version(void) { 35 | return HS_VERSION_STRING; 36 | } 37 | -------------------------------------------------------------------------------- /src/hs_version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef HS_VERSION_H_C6428FAF8E3713 30 | #define HS_VERSION_H_C6428FAF8E3713 31 | 32 | /** 33 | * A version string to identify this release of Hyperscan. 34 | */ 35 | #define HS_VERSION_STRING "@HS_VERSION@ @BUILD_DATE@" 36 | 37 | #define HS_VERSION_32BIT ((@HS_MAJOR_VERSION@ << 24) | (@HS_MINOR_VERSION@ << 16) | (@HS_PATCH_VERSION@ << 8) | 0) 38 | 39 | #endif /* HS_VERSION_H_C6428FAF8E3713 */ 40 | 41 | -------------------------------------------------------------------------------- /src/hwlm/hwlm_dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Hamster Wheel Literal Matcher: dump API. 31 | */ 32 | 33 | #ifndef HWLM_DUMP_H 34 | #define HWLM_DUMP_H 35 | 36 | #ifdef DUMP_SUPPORT 37 | 38 | #include 39 | 40 | struct HWLM; 41 | 42 | namespace ue2 { 43 | 44 | /** \brief Dump some information about the give HWLM structure. */ 45 | void hwlmGenerateDumpFiles(const HWLM *h, const std::string &base); 46 | 47 | } // namespace ue2 48 | 49 | #endif // DUMP_SUPPORT 50 | #endif // HWLM_DUMP_H 51 | -------------------------------------------------------------------------------- /src/hwlm/noodle_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Data structures for Noodle literal matcher engine. 31 | */ 32 | 33 | #ifndef NOODLE_INTERNAL_H 34 | #define NOODLE_INTERNAL_H 35 | 36 | #include "ue2common.h" 37 | 38 | struct noodTable { 39 | u32 id; 40 | u64a msk; 41 | u64a cmp; 42 | u8 msk_len; 43 | u8 key_offset; 44 | u8 nocase; 45 | u8 single; 46 | u8 key0; 47 | u8 key1; 48 | }; 49 | 50 | #endif /* NOODLE_INTERNAL_H */ 51 | 52 | -------------------------------------------------------------------------------- /src/nfa/accel_dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Acceleration: dump code. 31 | */ 32 | 33 | #ifndef ACCEL_DUMP_H 34 | #define ACCEL_DUMP_H 35 | 36 | #if defined(DUMP_SUPPORT) 37 | 38 | #include 39 | 40 | union AccelAux; 41 | 42 | namespace ue2 { 43 | 44 | void dumpAccelInfo(FILE *f, const AccelAux &accel); 45 | 46 | } // namespace ue2 47 | 48 | #endif // DUMP_SUPPORT 49 | #endif // ACCEL_DUMP_H 50 | -------------------------------------------------------------------------------- /src/nfa/castle_dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef CASTLE_DUMP_H 30 | #define CASTLE_DUMP_H 31 | 32 | #if defined(DUMP_SUPPORT) 33 | 34 | #include 35 | 36 | struct NFA; 37 | 38 | namespace ue2 { 39 | 40 | void nfaExecCastle_dump(const NFA *nfa, const std::string &base); 41 | 42 | } // namespace ue2 43 | 44 | #endif // DUMP_SUPPORT 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/nfa/dfa_build_strat.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "dfa_build_strat.h" 30 | 31 | namespace ue2 { 32 | 33 | // prevent weak vtables for raw_report_info, dfa_build_strat 34 | raw_report_info::~raw_report_info() {} 35 | 36 | dfa_build_strat::~dfa_build_strat() {} 37 | 38 | } // namespace ue2 39 | -------------------------------------------------------------------------------- /src/nfa/dfa_min.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** 30 | * \file 31 | * \brief Build code for DFA minimization. 32 | */ 33 | 34 | #ifndef DFA_MIN_H 35 | #define DFA_MIN_H 36 | 37 | namespace ue2 { 38 | 39 | struct raw_dfa; 40 | struct Grey; 41 | 42 | void minimize_hopcroft(raw_dfa &rdfa, const Grey &grey); 43 | 44 | } // namespace ue2 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/nfa/goughdump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef GOUGH_DUMP_H 30 | #define GOUGH_DUMP_H 31 | 32 | #ifdef DUMP_SUPPORT 33 | 34 | #include "ue2common.h" 35 | 36 | #include 37 | 38 | struct NFA; 39 | 40 | namespace ue2 { 41 | 42 | void nfaExecGough8_dump(const NFA *nfa, const std::string &base); 43 | void nfaExecGough16_dump(const NFA *nfa, const std::string &base); 44 | 45 | } // namespace ue2 46 | 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/nfa/limex_limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef LIMEX_LIMITS_H 30 | #define LIMEX_LIMITS_H 31 | 32 | #define NFA_MAX_STATES 512 /**< max states in an NFA */ 33 | #define NFA_MAX_ACCEL_STATES 8 /**< max accel states in a NFA */ 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/nfa/mpv_dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef MPVDUMP_H 30 | #define MPVDUMP_H 31 | 32 | #if defined(DUMP_SUPPORT) 33 | 34 | #include 35 | 36 | struct NFA; 37 | 38 | namespace ue2 { 39 | 40 | void nfaExecMpv_dump(const struct NFA *nfa, const std::string &base); 41 | 42 | } // namespace ue2 43 | 44 | #endif 45 | 46 | #endif // MPVDUMP_H 47 | -------------------------------------------------------------------------------- /src/nfa/rdfa_graph.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef RDFA_GRAPH_H 30 | #define RDFA_GRAPH_H 31 | 32 | #include "ue2common.h" 33 | #include "util/ue2_graph.h" 34 | 35 | namespace ue2 { 36 | 37 | struct raw_dfa; 38 | 39 | struct RdfaVertexProps { 40 | size_t index = 0; 41 | }; 42 | 43 | struct RdfaEdgeProps { 44 | size_t index = 0; 45 | }; 46 | 47 | struct RdfaGraph : public ue2_graph { 48 | RdfaGraph(const raw_dfa &rdfa); 49 | }; 50 | 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/nfa/shengdump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016-2020, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef SHENGDUMP_H_ 30 | #define SHENGDUMP_H_ 31 | 32 | #ifdef DUMP_SUPPORT 33 | 34 | #include 35 | 36 | struct NFA; 37 | 38 | namespace ue2 { 39 | 40 | void nfaExecSheng_dump(const struct NFA *nfa, const std::string &base); 41 | void nfaExecSheng32_dump(const struct NFA *nfa, const std::string &base); 42 | void nfaExecSheng64_dump(const struct NFA *nfa, const std::string &base); 43 | 44 | } // namespace ue2 45 | 46 | #endif // DUMP_SUPPORT 47 | 48 | #endif /* SHENGDUMP_H_ */ 49 | -------------------------------------------------------------------------------- /src/nfa/tamarama_dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef TAMARAMA_DUMP_H 30 | #define TAMARAMA_DUMP_H 31 | 32 | #if defined(DUMP_SUPPORT) 33 | 34 | #include 35 | 36 | struct NFA; 37 | 38 | namespace ue2 { 39 | 40 | void nfaExecTamarama_dump(const NFA *nfa, const std::string &base); 41 | 42 | } // namespace ue2 43 | 44 | #endif // DUMP_SUPPORT 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/nfa/trufflecompile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef TRUFFLECOMPILE_H 30 | #define TRUFFLECOMPILE_H 31 | 32 | #include "ue2common.h" 33 | #include "util/charreach.h" 34 | 35 | namespace ue2 { 36 | 37 | void truffleBuildMasks(const CharReach &cr, u8 *mask1, u8 *mask2); 38 | CharReach truffle2cr(const u8 *lo_in, const u8 *hi_in); 39 | 40 | } 41 | 42 | #endif /* TRUFFLECOMPILE_H */ 43 | 44 | -------------------------------------------------------------------------------- /src/nfagraph/ng_anchored_dots.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Analysis pass to reform leading dots. 31 | */ 32 | 33 | #ifndef NG_ANCHORED_BOUNDED_REPEATS_H 34 | #define NG_ANCHORED_BOUNDED_REPEATS_H 35 | 36 | namespace ue2 { 37 | 38 | class NGHolder; 39 | 40 | /* should not be used if SoM is required */ 41 | void reformLeadingDots(NGHolder &g); 42 | 43 | } // namespace ue2 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/nfagraph/ng_asserts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Resolve special assert vertices. 31 | */ 32 | 33 | #ifndef NG_ASSERTS_H 34 | #define NG_ASSERTS_H 35 | 36 | namespace ue2 { 37 | 38 | struct BoundaryReports; 39 | class ExpressionInfo; 40 | class NGHolder; 41 | class ReportManager; 42 | 43 | void resolveAsserts(ReportManager &rm, NGHolder &g, const ExpressionInfo &expr); 44 | 45 | void ensureCodePointStart(ReportManager &rm, NGHolder &g, 46 | const ExpressionInfo &expr); 47 | 48 | } // namespace ue2 49 | 50 | #endif // NG_ASSERTS_H 51 | -------------------------------------------------------------------------------- /src/nfagraph/ng_cyclic_redundancy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Cyclic Path Redundancy pass. Removes redundant vertices on paths 31 | * leading to a cyclic repeat. 32 | */ 33 | 34 | #ifndef NG_CYCLIC_REDUNDANCY_H 35 | #define NG_CYCLIC_REDUNDANCY_H 36 | 37 | namespace ue2 { 38 | 39 | class NGHolder; 40 | 41 | bool removeCyclicPathRedundancy(NGHolder &g); 42 | 43 | } // namespace ue2 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/nfagraph/ng_dominators.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Calculate dominator and post-dominator trees. 31 | * 32 | * A small wrapper around the BGL's lengauer_tarjan_dominator_tree algorithm. 33 | */ 34 | 35 | #ifndef NG_DOMINATORS_H 36 | #define NG_DOMINATORS_H 37 | 38 | #include "ng_holder.h" 39 | 40 | #include 41 | 42 | namespace ue2 { 43 | 44 | std::unordered_map findDominators(const NGHolder &g); 45 | 46 | std::unordered_map findPostDominators(const NGHolder &g); 47 | 48 | } // namespace ue2 49 | 50 | #endif // NG_DOMINATORS_H 51 | -------------------------------------------------------------------------------- /src/nfagraph/ng_equivalence.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Equivalence class graph reduction pass. 31 | */ 32 | 33 | #ifndef NG_EQUIVALENCE_H_ 34 | #define NG_EQUIVALENCE_H_ 35 | 36 | namespace ue2 { 37 | 38 | class NGHolder; 39 | struct CompileContext; 40 | 41 | /** Attempt to make the NFA graph \p g smaller by performing a number of local 42 | * transformations. */ 43 | bool reduceGraphEquivalences(NGHolder &g, const CompileContext &cc); 44 | 45 | } // namespace ue2 46 | 47 | #endif /* NG_EQUIVALENCE_H_ */ 48 | -------------------------------------------------------------------------------- /src/nfagraph/ng_expr_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Code for discovering properties of an expression used by 31 | * hs_expression_info. 32 | */ 33 | 34 | #ifndef NG_EXPR_INFO_H 35 | #define NG_EXPR_INFO_H 36 | 37 | struct hs_expr_info; 38 | 39 | namespace ue2 { 40 | 41 | class ExpressionInfo; 42 | class NGHolder; 43 | class ReportManager; 44 | struct CompileContext; 45 | 46 | void fillExpressionInfo(ReportManager &rm, const CompileContext &cc, 47 | NGHolder &g, ExpressionInfo &expr, hs_expr_info *info); 48 | 49 | } // namespace ue2 50 | 51 | #endif // NG_EXPR_INFO_H 52 | -------------------------------------------------------------------------------- /src/nfagraph/ng_fixed_width.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Rose mask construction from NGHolder. 31 | */ 32 | 33 | #ifndef NG_FIXED_WIDTH_H 34 | #define NG_FIXED_WIDTH_H 35 | 36 | namespace ue2 { 37 | 38 | class RoseBuild; 39 | class NGHolder; 40 | struct Grey; 41 | 42 | bool handleFixedWidth(RoseBuild &build, const NGHolder &g, const Grey &grey); 43 | 44 | } // namespace ue2 45 | 46 | #endif // NG_FIXED_WIDTH_H 47 | -------------------------------------------------------------------------------- /src/nfagraph/ng_fuzzy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Graph fuzzer for approximate matching 31 | */ 32 | 33 | #ifndef NG_FUZZY_H 34 | #define NG_FUZZY_H 35 | 36 | #include "ue2common.h" 37 | 38 | namespace ue2 { 39 | struct Grey; 40 | class NGHolder; 41 | class ReportManager; 42 | 43 | void validate_fuzzy_compile(const NGHolder &g, u32 edit_distance, bool hamming, 44 | bool utf8, const Grey &grey); 45 | 46 | void make_fuzzy(NGHolder &g, u32 edit_distance, bool hamming, const Grey &grey); 47 | } 48 | 49 | #endif // NG_FUZZY_H 50 | -------------------------------------------------------------------------------- /src/nfagraph/ng_literal_component.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Literal Component Splitting. Identifies literals that span the 31 | * graph and moves them into Rose. 32 | */ 33 | 34 | #ifndef NG_LITERAL_COMPONENT_H 35 | #define NG_LITERAL_COMPONENT_H 36 | 37 | namespace ue2 { 38 | 39 | class NG; 40 | class NGHolder; 41 | 42 | /** \brief Split off literals. True if any changes were made to the graph. */ 43 | bool splitOffLiterals(NG &ng, NGHolder &g); 44 | 45 | } // namespace ue2 46 | 47 | #endif // NG_LITERAL_COMPONENT_H 48 | -------------------------------------------------------------------------------- /src/nfagraph/ng_netflow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Network flow (min flow, max cut) algorithms. 31 | */ 32 | #ifndef NG_NETFLOW_H 33 | #define NG_NETFLOW_H 34 | 35 | #include "ng_holder.h" 36 | #include "ue2common.h" 37 | 38 | #include 39 | 40 | namespace ue2 { 41 | 42 | class NGHolder; 43 | 44 | /** Returns a min cut (in \p cutset) for the graph in \p h. */ 45 | std::vector findMinCut(NGHolder &h, const std::vector &scores); 46 | 47 | } // namespace ue2 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/nfagraph/ng_prefilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Prefilter Reductions. 31 | */ 32 | 33 | #ifndef NG_PREFILTER_H 34 | #define NG_PREFILTER_H 35 | 36 | namespace ue2 { 37 | 38 | class NGHolder; 39 | struct CompileContext; 40 | 41 | void prefilterReductions(NGHolder &h, const CompileContext &cc); 42 | 43 | } // namespace ue2 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/nfagraph/ng_region_redundancy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Region Redundancy optimisation pass. 31 | * 32 | * Identifies and removes entire regions that are adjacent to a cyclic state 33 | * with a superset of their character reachability. 34 | */ 35 | 36 | #ifndef NG_REGION_REDUNDANCY_H 37 | #define NG_REGION_REDUNDANCY_H 38 | 39 | #include "som/som.h" 40 | 41 | namespace ue2 { 42 | 43 | class NGHolder; 44 | 45 | void removeRegionRedundancy(NGHolder &g, som_type som); 46 | 47 | } // namespace ue2 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/nfagraph/ng_sep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Short Exhaustible Passthroughs. 31 | */ 32 | 33 | #ifndef NG_SEP_H 34 | #define NG_SEP_H 35 | 36 | namespace ue2 { 37 | 38 | struct Grey; 39 | class NGHolder; 40 | class ReportManager; 41 | 42 | bool isSEP(const NGHolder &g, const ReportManager &rm, const Grey &grey); 43 | 44 | } // namespace ue2 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/nfagraph/ng_som_add_redundancy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Add redundancy to graph to assist in SOM analysis. 31 | */ 32 | 33 | #ifndef NG_SOM_ADD_REDUNDANCY_H 34 | #define NG_SOM_ADD_REDUNDANCY_H 35 | 36 | #include "util/depth.h" 37 | #include 38 | 39 | namespace ue2 { 40 | 41 | class NGHolder; 42 | 43 | bool addSomRedundancy(NGHolder &g, std::vector &depths); 44 | 45 | } // namespace ue2 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/nfagraph/ng_vacuous.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Build code for vacuous graphs. 31 | */ 32 | 33 | #ifndef NG_VACUOUS_H 34 | #define NG_VACUOUS_H 35 | 36 | namespace ue2 { 37 | 38 | struct BoundaryReports; 39 | class ExpressionInfo; 40 | class NGHolder; 41 | class ReportManager; 42 | 43 | // Returns true if a "vacuous" reporter was created. 44 | bool splitOffVacuous(BoundaryReports &boundary, ReportManager &rm, 45 | NGHolder &g, const ExpressionInfo &expr); 46 | 47 | } // namespace ue2 48 | 49 | #endif // NG_VACUOUS_H 50 | -------------------------------------------------------------------------------- /src/parser/control_verbs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** 30 | * \file 31 | * \brief Parser for control verbs that can occur at the beginning of a pattern. 32 | */ 33 | 34 | #ifndef CONTROL_VERBS_H 35 | #define CONTROL_VERBS_H 36 | 37 | #include "ue2common.h" 38 | 39 | namespace ue2 { 40 | 41 | struct ParseMode; 42 | 43 | const char *read_control_verbs(const char *ptr, const char *end, size_t start, 44 | ParseMode &mode); 45 | 46 | } // namespace ue2 47 | 48 | #endif // CONTROL_VERBS_H 49 | -------------------------------------------------------------------------------- /src/parser/dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef PARSER_DUMP_H_ 30 | #define PARSER_DUMP_H_ 31 | 32 | #ifdef DUMP_SUPPORT 33 | 34 | #include 35 | 36 | namespace ue2 { 37 | 38 | class Component; 39 | 40 | /** \brief Dump a text representation of the given component tree. Only 41 | * available in DUMP_SUPPORT builds. */ 42 | void dumpTree(std::ostream &os, const Component *const root); 43 | 44 | } // namespace ue2 45 | 46 | #endif // DUMP_SUPPORT 47 | 48 | #endif // PARSER_DUMP_H_ 49 | -------------------------------------------------------------------------------- /src/parser/parser_util.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Utilities (currently just ParseMode constructor) 31 | */ 32 | 33 | 34 | #include "hs.h" 35 | #include "Parser.h" 36 | #include "ue2common.h" 37 | 38 | namespace ue2 { 39 | 40 | ParseMode::ParseMode(u32 hs_flags) : 41 | caseless(hs_flags & HS_FLAG_CASELESS), 42 | dotall(hs_flags & HS_FLAG_DOTALL), 43 | ignore_space(false), 44 | multiline(hs_flags & HS_FLAG_MULTILINE), 45 | ucp(hs_flags & HS_FLAG_UCP), 46 | utf8(hs_flags & HS_FLAG_UTF8) {} 47 | 48 | } // namespace ue2 49 | -------------------------------------------------------------------------------- /src/parser/prefilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef PARSER_PREFILTER_H 30 | #define PARSER_PREFILTER_H 31 | 32 | #include 33 | 34 | namespace ue2 { 35 | 36 | class Component; 37 | struct ParseMode; 38 | 39 | /** 40 | * \brief Applies prefiltering transformations to the given component. 41 | * 42 | * May reseat the given Component pointer. 43 | */ 44 | void prefilterTree(std::unique_ptr &root, const ParseMode &mode); 45 | 46 | } // namespace ue2 47 | 48 | #endif // PARSER_PREFILTER_H 49 | -------------------------------------------------------------------------------- /src/parser/shortcut_literal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Shortcut literal pass: directly add literal components to Rose. 31 | */ 32 | 33 | #ifndef SHORTCUT_LITERAL_H 34 | #define SHORTCUT_LITERAL_H 35 | 36 | namespace ue2 { 37 | 38 | class NG; 39 | class ParsedExpression; 40 | 41 | /** \brief True if the literal expression \a expr could be added to Rose. */ 42 | bool shortcutLiteral(NG &ng, const ParsedExpression &expr); 43 | 44 | } // namespace ue2 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/parser/unsupported.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Checks component trees for unsupported components. 31 | */ 32 | #ifndef PARSER_UNSUPPORTED_H_ 33 | #define PARSER_UNSUPPORTED_H_ 34 | 35 | #include "parse_error.h" 36 | 37 | namespace ue2 { 38 | 39 | class Component; 40 | 41 | /** \brief Throws a ParseError if this component tree contains an unsupported 42 | * Component. */ 43 | void checkUnsupported(const Component &root); 44 | 45 | } // namespace 46 | 47 | #endif // PARSER_UNSUPPORTED_H_ 48 | -------------------------------------------------------------------------------- /src/parser/utf8_validate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef PARSER_UTF8_VALIDATE_H 30 | #define PARSER_UTF8_VALIDATE_H 31 | 32 | #include // size_t 33 | 34 | namespace ue2 { 35 | 36 | /** \brief Validate that the given expression is well-formed UTF-8. */ 37 | bool isValidUtf8(const char *expression, const size_t len); 38 | 39 | } // namespace ue2 40 | 41 | #endif // PARSER_UTF8_VALIDATE_H 42 | -------------------------------------------------------------------------------- /src/rose/init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef ROSE_INIT_H 30 | #define ROSE_INIT_H 31 | 32 | #include "rose_internal.h" 33 | #include "ue2common.h" 34 | #include "util/scatter_runtime.h" 35 | 36 | /* 37 | * Initialisation code common to streaming mode Rose (init.c) and block mode 38 | * Rose (block.c) code. 39 | */ 40 | 41 | static really_inline 42 | void init_state(const struct RoseEngine *t, char *state) { 43 | scatter(state, t, &t->state_init); 44 | } 45 | 46 | #endif // ROSE_INIT_H 47 | -------------------------------------------------------------------------------- /src/rose/rose_build_convert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef ROSE_BUILD_CONVERT_H 30 | #define ROSE_BUILD_CONVERT_H 31 | 32 | namespace ue2 { 33 | 34 | class RoseBuildImpl; 35 | 36 | void convertFloodProneSuffixes(RoseBuildImpl &tbi); 37 | void convertPrefixToBounds(RoseBuildImpl &tbi); 38 | void convertAnchPrefixToBounds(RoseBuildImpl &tbi); 39 | 40 | } // namespace ue2 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/rose/rose_build_misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef ROSE_BUILD_MISC_H 30 | #define ROSE_BUILD_MISC_H 31 | 32 | #include "ue2common.h" 33 | 34 | struct RoseEngine; 35 | 36 | namespace ue2 { 37 | 38 | struct RoseResources; 39 | 40 | /* used by heuristics to determine the small write engine. High numbers are 41 | * intended to indicate a lightweight rose. */ 42 | u32 roseQuality(const RoseResources &res, const RoseEngine *rose); 43 | 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/rose/rose_build_role_aliasing.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef ROSE_BUILD_ROLE_ALIASING_H 30 | #define ROSE_BUILD_ROLE_ALIASING_H 31 | 32 | /** \file 33 | * \brief Rose Build: functions for reducing the size of the Rose graph 34 | * through merging roles (RoseVertices) together. 35 | */ 36 | 37 | namespace ue2 { 38 | 39 | class RoseBuildImpl; 40 | 41 | void aliasRoles(RoseBuildImpl &build, bool mergeRoses); 42 | 43 | void mergeDupeLeaves(RoseBuildImpl &build); 44 | void uncalcLeaves(RoseBuildImpl &build); 45 | 46 | } // namespace ue2 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/rose/rose_in_dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef ROSE_IN_DUMP_H 30 | #define ROSE_IN_DUMP_H 31 | 32 | #include "rose_in_graph.h" 33 | 34 | namespace ue2 { 35 | 36 | struct Grey; 37 | 38 | #ifdef DUMP_SUPPORT 39 | void dumpPreRoseGraph(const RoseInGraph &ig, const Grey &grey, 40 | const char *filename = nullptr); 41 | #else 42 | static UNUSED 43 | void dumpPreRoseGraph(const RoseInGraph &, const Grey &, 44 | const char * = nullptr) { } 45 | #endif 46 | 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/scratch_dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef SCRATCH_DUMP_H 30 | #define SCRATCH_DUMP_H 31 | 32 | #if defined(DUMP_SUPPORT) 33 | 34 | #include 35 | 36 | struct hs_scratch; 37 | 38 | namespace ue2 { 39 | 40 | void dumpScratch(const struct hs_scratch *s, FILE *f); 41 | 42 | } // namespace ue2 43 | 44 | #endif // DUMP_SUPPORT 45 | #endif // SCRATCH_DUMP_H 46 | -------------------------------------------------------------------------------- /src/smallwrite/smallwrite_dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef SMWR_DUMP_H 30 | #define SMWR_DUMP_H 31 | #ifdef DUMP_SUPPORT 32 | 33 | #include 34 | #include 35 | 36 | struct SmallWriteEngine; 37 | 38 | namespace ue2 { 39 | 40 | void smwrDumpText(const SmallWriteEngine *smwr, FILE *f); 41 | void smwrDumpNFA(const SmallWriteEngine *smwr, bool dump_raw, 42 | const std::string &base); 43 | 44 | } // namespace ue2 45 | 46 | #endif 47 | #endif 48 | -------------------------------------------------------------------------------- /src/som/slot_manager_dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef SLOT_MANAGER_DUMP_H 30 | #define SLOT_MANAGER_DUMP_H 31 | 32 | namespace ue2 { 33 | 34 | class SomSlotManager; 35 | struct Grey; 36 | 37 | #ifdef DUMP_SUPPORT 38 | 39 | void dumpSomSlotManager(const SomSlotManager &ssm, const Grey &grey); 40 | 41 | #else 42 | 43 | static inline UNUSED 44 | void dumpSomSlotManager(const SomSlotManager &, const Grey &) { 45 | } 46 | 47 | #endif 48 | 49 | } // namespace ue2 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/som/som.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** 30 | * \file 31 | * \brief Common SOM definitions. 32 | */ 33 | 34 | #ifndef UE2_SOM_H 35 | #define UE2_SOM_H 36 | 37 | namespace ue2 { 38 | 39 | /** \brief Enumeration specifying a start of match behaviour. */ 40 | enum som_type { 41 | SOM_NONE, //!< No SOM required 42 | SOM_LEFT //!< Exact leftmost SOM 43 | }; 44 | 45 | } // namespace ue2 46 | 47 | #endif // UE2_SOM_H 48 | -------------------------------------------------------------------------------- /src/util/accel_scheme.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef ACCEL_SCHEME_H 30 | #define ACCEL_SCHEME_H 31 | 32 | #include "util/charreach.h" 33 | #include "util/flat_containers.h" 34 | 35 | #include 36 | 37 | namespace ue2 { 38 | 39 | #define MAX_ACCEL_DEPTH 4 40 | 41 | struct AccelScheme { 42 | flat_set> double_byte; 43 | CharReach cr = CharReach::dot(); 44 | CharReach double_cr; 45 | u32 offset = MAX_ACCEL_DEPTH + 1; 46 | u32 double_offset = 0; 47 | }; 48 | 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/util/compile_context.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Global compile context, describes compile environment. 31 | */ 32 | #include "compile_context.h" 33 | #include "grey.h" 34 | 35 | namespace ue2 { 36 | 37 | CompileContext::CompileContext(bool in_isStreaming, bool in_isVectored, 38 | const target_t &in_target_info, 39 | const Grey &in_grey) 40 | : streaming(in_isStreaming || in_isVectored), 41 | vectored(in_isVectored), 42 | target_info(in_target_info), 43 | grey(in_grey) { 44 | } 45 | 46 | } // namespace ue2 47 | -------------------------------------------------------------------------------- /src/util/cpuid_flags.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef UTIL_CPUID_H_ 30 | #define UTIL_CPUID_H_ 31 | 32 | #include "ue2common.h" 33 | 34 | #if !defined(_WIN32) && !defined(CPUID_H_) 35 | #if defined(__x86_64__) 36 | #include 37 | #endif 38 | /* system header doesn't have a header guard */ 39 | #define CPUID_H_ 40 | #endif 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | /* returns HS_CPU_FEATURES_* mask. */ 48 | u64a cpuid_flags(void); 49 | 50 | u32 cpuid_tune(void); 51 | 52 | #ifdef __cplusplus 53 | } /* extern "C" */ 54 | #endif 55 | 56 | #endif /* UTIL_CPUID_H_ */ 57 | 58 | -------------------------------------------------------------------------------- /src/util/dump_util.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "dump_util.h" 30 | 31 | #include 32 | #include 33 | 34 | using namespace std; 35 | 36 | namespace ue2 { 37 | 38 | FILE *fopen_or_throw(const char *path, const char *mode) { 39 | FILE *f = fopen(path, mode); 40 | if (!f) { 41 | throw runtime_error(string("Unable to open file: ") + path); 42 | } 43 | return f; 44 | } 45 | 46 | } // namespace ue2 47 | -------------------------------------------------------------------------------- /src/util/exhaust.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Inline functions for manipulating exhaustion vector. 31 | */ 32 | 33 | #ifndef EXHAUST_H 34 | #define EXHAUST_H 35 | 36 | #include "ue2common.h" 37 | 38 | /** Index meaning a given exhaustion key is invalid. */ 39 | #define INVALID_EKEY (~(u32)0) 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/util/fatbit_build.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "fatbit_build.h" 30 | 31 | #include "fatbit.h" 32 | #include "multibit_build.h" 33 | 34 | #include 35 | 36 | using namespace std; 37 | 38 | namespace ue2 { 39 | 40 | u32 fatbit_size(u32 total_bits) { 41 | return max(u32{sizeof(struct fatbit)}, mmbit_size(total_bits)); 42 | } 43 | 44 | } // namespace ue2 45 | -------------------------------------------------------------------------------- /src/util/fatbit_build.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Fatbit: build code 31 | */ 32 | 33 | #ifndef FATBIT_BUILD_H 34 | #define FATBIT_BUILD_H 35 | 36 | #include "ue2common.h" 37 | 38 | namespace ue2 { 39 | 40 | /** 41 | * \brief Return the size in bytes of a fatbit that can store the given 42 | * number of bits. 43 | */ 44 | u32 fatbit_size(u32 total_bits); 45 | 46 | } // namespace ue2 47 | 48 | #endif // FATBIT_BUILD_H 49 | -------------------------------------------------------------------------------- /src/util/join.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef JOIN_H 30 | 31 | #define JOIN(x, y) JOIN_AGAIN(x, y) 32 | #define JOIN_AGAIN(x, y) x ## y 33 | 34 | #define JOIN3(x, y, z) JOIN_AGAIN3(x, y, z) 35 | #define JOIN_AGAIN3(x, y, z) x ## y ## z 36 | 37 | #define JOIN4(w, x, y, z) JOIN_AGAIN4(w, x, y, z) 38 | #define JOIN_AGAIN4(w, x, y, z) w ## x ## y ## z 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/util/make_unique.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef UTIL_MAKE_UNIQUE_H 30 | #define UTIL_MAKE_UNIQUE_H 31 | 32 | #if (defined(_WIN32) || defined(_WIN64)) && (_MSC_VER > 1700) 33 | // VC++ 2013 onwards has make_unique in the STL 34 | #define USE_STD 35 | #include 36 | #else 37 | #include 38 | #endif 39 | 40 | namespace ue2 { 41 | #if defined(USE_STD) 42 | using std::make_unique; 43 | #else 44 | using boost::make_unique; 45 | #endif 46 | } 47 | 48 | #undef USE_STD 49 | #endif // UTIL_MAKE_UNIQUE_H 50 | -------------------------------------------------------------------------------- /src/util/math.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef UTIL_MATH_H_ 30 | #define UTIL_MATH_H_ 31 | 32 | #include "arch.h" 33 | #include "intrinsics.h" 34 | 35 | #include 36 | 37 | static really_inline 38 | double our_pow(double x, double y) { 39 | #if defined(HAVE_AVX) 40 | /* 41 | * Clear the upper half of AVX registers before calling into the math lib. 42 | * On some versions of glibc this can save thousands of AVX-to-SSE 43 | * transitions. 44 | */ 45 | _mm256_zeroupper(); 46 | #endif 47 | return pow(x, y); 48 | } 49 | 50 | #endif // UTIL_MATH_H_ 51 | -------------------------------------------------------------------------------- /src/util/order_check.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /* for implementing operator<, assumes objects are a and b */ 30 | #define ORDER_CHECK(field) do { \ 31 | if (a.field < b.field) { \ 32 | return 1; \ 33 | } \ 34 | if (b.field < a.field) { \ 35 | return 0; \ 36 | } \ 37 | } while (0) 38 | -------------------------------------------------------------------------------- /src/util/simd_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2021, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef SIMD_UTILS 30 | #define SIMD_UTILS 31 | 32 | #if defined(__x86_64__) 33 | #include "simd_x86.h" 34 | #elif defined(__aarch64__) 35 | #include "simd_arm.h" 36 | #endif 37 | 38 | #endif -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Threads) 2 | 3 | # remove some warnings 4 | if(CMAKE_CXX_FLAGS MATCHES "-Wmissing-declarations" ) 5 | string(REPLACE "-Wmissing-declarations" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 6 | endif() 7 | 8 | include_directories(${PROJECT_SOURCE_DIR}) 9 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) 10 | include_directories(${PROJECT_SOURCE_DIR}/util) 11 | 12 | if (WIN32) 13 | add_subdirectory(hscheck) 14 | add_subdirectory(hsbench) 15 | add_subdirectory(hsdump) 16 | add_subdirectory(hscollider) 17 | else() 18 | # add any subdir with a cmake file 19 | file(GLOB dirents RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *) 20 | foreach(e ${dirents}) 21 | if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${e} AND 22 | EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${e}/CMakeLists.txt) 23 | add_subdirectory(${e}) 24 | endif () 25 | endforeach () 26 | endif() 27 | -------------------------------------------------------------------------------- /tools/fuzz/aristocrats.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from random import choice,randint 4 | from optparse import OptionParser 5 | 6 | def generateRandomOptions(): 7 | if options.hybrid: 8 | allflags = "smiH8W" 9 | else: 10 | # Maintain an ordering for consistency. 11 | allflags = "smiHV8WLP" 12 | flags = "" 13 | for f in allflags: 14 | flags += choice(['', f]) 15 | return flags 16 | 17 | parser = OptionParser() 18 | parser.add_option("-d", "--depth", 19 | action="store", type="int", dest="depth", default=200, 20 | help="Depth of generation (akin to maximum length)") 21 | parser.add_option("-c", "--count", 22 | action="store", type="int", dest="count", default=1000, 23 | help="Number of expressions to generate") 24 | parser.add_option("-f", "--full", 25 | action="store_true", dest="full", default=False, 26 | help="Use a full character set including unprintables") 27 | parser.add_option("-H", "--hybrid", 28 | action="store_true", dest="hybrid", 29 | help="Generate random flags for hybrid mode") 30 | 31 | (options, args) = parser.parse_args() 32 | if len(args) != 0: 33 | parser.error("incorrect number of arguments") 34 | 35 | if (options.full): 36 | crange = range(0,256) 37 | crange.remove(ord('\n')) 38 | else: 39 | crange = range(32, 127) 40 | 41 | for i in xrange(0, options.count): 42 | len = randint(1, options.depth) 43 | s = [ chr(choice(crange)) for x in xrange(len) ] 44 | line = str(i) + ":/" + "".join(s) + "/" + generateRandomOptions() 45 | print line 46 | -------------------------------------------------------------------------------- /tools/fuzz/completocrats.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from itertools import * 4 | from optparse import OptionParser 5 | 6 | LIMITED_ALPHABET = "abc[](){}*?+^$|:=.\\-" 7 | 8 | parser = OptionParser() 9 | parser.add_option("-d", "--depth", 10 | action="store", type="int", dest="depth", default=200, 11 | help="Depth of generation (akin to maximum length)") 12 | 13 | parser.add_option("-f", "--full", 14 | action="store_true", dest="full", default=False, 15 | help="Use a full character set including unprintables") 16 | 17 | parser.add_option("-l", "--limited", 18 | action="store_true", dest="limited", default=False, 19 | help="Use a very limited character set: just " + LIMITED_ALPHABET) 20 | 21 | (options, args) = parser.parse_args() 22 | if len(args) != 0: 23 | parser.error("incorrect number of arguments") 24 | 25 | if (options.full): 26 | crange = range(0,256) 27 | crange.remove(ord('\n')) 28 | elif (options.limited): 29 | crange = [ ord(c) for c in LIMITED_ALPHABET ] 30 | else: 31 | crange = range(32, 127) 32 | 33 | srange = [ chr(c) for c in crange ] 34 | 35 | i = 0 36 | for x in product(srange, repeat = options.depth): 37 | line = str(i) + ":/" + "".join(x) + "/" 38 | print line 39 | i += 1 40 | -------------------------------------------------------------------------------- /tools/fuzz/limited_dict.txt: -------------------------------------------------------------------------------- 1 | hatstand 2 | teakettle 3 | badgerbrush 4 | mnemosyne 5 | rapscallion 6 | acerbic 7 | blackhat 8 | rufous 9 | echolalia 10 | -------------------------------------------------------------------------------- /tools/hsbench/README.md: -------------------------------------------------------------------------------- 1 | Hyperscan Benchmarker: hsbench 2 | ============================== 3 | 4 | The `hsbench` tool provides an easy way to measure Hyperscan's performance 5 | for a particular set of patterns and corpus of data to be scanned. 6 | 7 | Documentation describing its operation is available in the Tools section of the 8 | [Developer Reference Guide](http://intel.github.io/hyperscan/dev-reference/). 9 | -------------------------------------------------------------------------------- /tools/hsbench/engine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "engine.h" 30 | 31 | EngineContext::~EngineContext() { } 32 | 33 | EngineStream::~EngineStream() { } 34 | 35 | Engine::~Engine() { } 36 | -------------------------------------------------------------------------------- /tools/hsbench/heapstats.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef HEAPSTATS_H 30 | #define HEAPSTATS_H 31 | 32 | #include // for size_t 33 | 34 | size_t getPeakHeap(void); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /tools/hsbench/huge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef HUGE_H 30 | #define HUGE_H 31 | 32 | #include "hs.h" 33 | 34 | hs_database_t *get_huge(hs_database_t *db); 35 | void release_huge(hs_database_t *db); 36 | 37 | #endif /* HUGE_H */ 38 | -------------------------------------------------------------------------------- /tools/hsbench/scripts/CorpusBuilder.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | ''' 4 | A module to construct corpora databases for the Hyperscan benchmarker 5 | (hsbench). 6 | 7 | After construction, simply add blocks with the add_chunk() method, then call 8 | finish() when you're done. 9 | ''' 10 | 11 | import os.path 12 | 13 | try: 14 | from sqlite3 import dbapi2 as sqlite 15 | except: 16 | from pysqlite2 import dbapi2 as sqlite 17 | 18 | class CorpusBuilder: 19 | SCHEMA = ''' 20 | CREATE TABLE chunk ( 21 | id integer primary key, 22 | stream_id integer not null, 23 | data blob 24 | ); 25 | ''' 26 | 27 | def __init__(self, outfile): 28 | if os.path.exists(outfile): 29 | raise RuntimeError("Database '%s' already exists" % outfile) 30 | self.outfile = outfile 31 | self.db = sqlite.connect(self.outfile) 32 | self.db.executescript(CorpusBuilder.SCHEMA) 33 | self.current_chunk_id = 0; 34 | 35 | def add_chunk(self, stream_id, data): 36 | chunk_id = self.current_chunk_id; 37 | c = self.db.cursor() 38 | q = 'insert into chunk (id, stream_id, data) values (?, ?, ?)' 39 | c.execute(q, (chunk_id, stream_id, sqlite.Binary(data))) 40 | self.current_chunk_id += 1 41 | return chunk_id 42 | 43 | def finish(self): 44 | self.db.commit() 45 | 46 | c = self.db.cursor() 47 | q = 'create index chunk_stream_id_idx on chunk(stream_id)' 48 | c.execute(q) 49 | 50 | c = self.db.cursor() 51 | q = 'vacuum' 52 | c.execute(q) 53 | 54 | c = self.db.cursor() 55 | q = 'analyze' 56 | c.execute(q) 57 | 58 | self.db.commit() 59 | -------------------------------------------------------------------------------- /tools/hsbench/scripts/linebasedCorpus.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | ''' 4 | Simple script to take a file full of lines of text and push them into a 5 | Hyperscan benchmarking corpus database, one block per line. 6 | ''' 7 | 8 | import sys, getopt, os.path 9 | from CorpusBuilder import CorpusBuilder 10 | 11 | def lineCorpus(inFN, outFN): 12 | ''' 13 | Read lines from file name @inFN and write them as blocks to a new db with 14 | name @outFN. 15 | ''' 16 | 17 | if not os.path.exists(inFN): 18 | print >> sys.stderr, "Input file '%s' does not exist. Exiting." % outFN 19 | sys.exit(-1) 20 | 21 | lines = open(inFN).readlines() 22 | 23 | if len(lines) == 0: 24 | print >> sys.stderr, "Input file contained no lines. Exiting." 25 | sys.exit(0) 26 | 27 | builder = CorpusBuilder(outFN) 28 | 29 | # write a single stream to contain everything 30 | streamId = 0 31 | 32 | for l in lines: 33 | builder.add_chunk(streamId, l.rstrip()) 34 | 35 | builder.finish() 36 | 37 | def usage(exeName): 38 | errmsg = "Usage: %s -i -o " 39 | errmsg = errmsg % exeName 40 | print >> sys.stderr, errmsg 41 | sys.exit(-1) 42 | 43 | if __name__ == '__main__': 44 | args = getopt.getopt(sys.argv[1:], 'i:o:c:') 45 | args = dict(args[0]) 46 | 47 | requiredKeys = [ '-i', '-o' ] 48 | for k in requiredKeys: 49 | if not args.has_key(k): 50 | usage(os.path.basename(sys.argv[0])) 51 | 52 | fnArgs = tuple([args[k] for k in requiredKeys]) 53 | lineCorpus(*fnArgs) 54 | -------------------------------------------------------------------------------- /tools/hscheck/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # only set these after all tests are done 2 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}") 3 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}") 4 | 5 | SET(hscheck_SOURCES 6 | main.cpp 7 | ) 8 | 9 | if (BUILD_CHIMERA) 10 | include_directories(${PCRE_INCLUDE_DIRS}) 11 | add_definitions(-DHS_HYBRID) 12 | add_executable(hscheck ${hscheck_SOURCES}) 13 | if(NOT WIN32) 14 | target_link_libraries(hscheck hs chimera ${PCRE_LDFLAGS} expressionutil pthread) 15 | else() 16 | target_link_libraries(hscheck hs chimera pcre expressionutil) 17 | endif() 18 | else() 19 | if(WIN32 AND (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)) 20 | add_executable(hscheck ${hscheck_SOURCES} $ $) 21 | else() 22 | add_executable(hscheck ${hscheck_SOURCES}) 23 | endif() 24 | if(NOT WIN32) 25 | target_link_libraries(hscheck hs expressionutil pthread) 26 | else() 27 | target_link_libraries(hscheck hs expressionutil) 28 | endif() 29 | endif() 30 | -------------------------------------------------------------------------------- /tools/hscollider/ColliderCorporaParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef FILECORPORAPARSER_H 30 | #define FILECORPORAPARSER_H 31 | 32 | #include 33 | 34 | struct Corpus; 35 | 36 | // parse an escaped string into a real data buffer 37 | bool parseCorpus(const std::string &line, Corpus &c, unsigned int &id); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /tools/hscollider/Corpora.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "Corpora.h" 30 | 31 | CorporaSource::~CorporaSource() { } 32 | -------------------------------------------------------------------------------- /tools/hscollider/args.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef ARGS_H 30 | #define ARGS_H 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | namespace ue2 { 37 | struct Grey; 38 | } 39 | struct hs_platform_info; 40 | class CorpusProperties; 41 | 42 | void processArgs(int argc, char *argv[], CorpusProperties &corpus_gen_prop, 43 | std::vector *corpora, ue2::Grey *grey, 44 | std::unique_ptr *plat_out); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /tools/hscollider/limit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef LIMIT_H 30 | #define LIMIT_H 31 | 32 | #include 33 | 34 | void setMemoryLimit(size_t mbytes); 35 | 36 | #endif // LIMIT_H 37 | -------------------------------------------------------------------------------- /tools/hscollider/pcre_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2018, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef PCRE_UTIL_H 30 | #define PCRE_UTIL_H 31 | 32 | /** Translates the given hyperscan flags into pcre flags (where appropriate) 33 | * and other bools (for flags which are not directly translateable). 34 | * 35 | * Returns false if an unknown hyperscan flag is encountered. 36 | */ 37 | bool getPcreFlags(unsigned int hs_flags, unsigned int *pcre_flags, 38 | bool *highlander, bool *prefilter, bool *som, 39 | bool *combination = nullptr, bool *quiet = nullptr); 40 | 41 | #endif /* PCRE_UTIL_H */ 42 | 43 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/corpora/accel.txt: -------------------------------------------------------------------------------- 1 | 2000:abcdefxxxxxxxxxxxxxxxxxxxxxxxxxxAfoobarxxxxxxxxxxxxxx 2 | 2001:/w------Ue0-J-vNU-----C9---k--M---1S-x-----g-----A---\n 3 | 2002:mJpPthD\xf0\x95\x93\xa1hq\xf4\x8b\xb9\x9cbrp\xe2\x84\xaahB\xee\x80\x80\xee\x80\x80\xee\x80\x80\xee\x80\x80\xe8\x86\x95\xee\x80\x80\xee\x80\x80\xee\x80\x80\xee\x80\x80\xee\x80\x80\xee\x80\x80\xee\x80\x80\xee\x80\x80 4 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/corpora/comptree.txt: -------------------------------------------------------------------------------- 1 | 1000="foobar": 2 | 1000="foofoobar": 9 3 | 1000="foofoofoobar": 12 4 | 1000="foofoofoofoobar": 15 5 | 1000="xfoobar": 6 | 1000="xfoofoobar": 10 7 | 1000="xfoofoofoobar": 13 8 | 1000="xfoofoofoofoobar": 16 9 | 1001="foobar": 10 | 1001="foofoobar": 9 11 | 1001="foofoofoobar": 12 12 | 1001="foofoofoofoobar": 15 13 | 1001="xfoobar": 14 | 1001="xfoofoobar": 10 15 | 1001="xfoofoofoobar": 13 16 | 1001="xfoofoofoofoobar": 16 17 | 1002="foobar": 18 | 1002="foofoobar": 9 19 | 1002="foofoofoobar": 12 20 | 1002="foofoofoofoobar": 15 21 | 1002="xfoobar": 22 | 1002="xfoofoobar": 23 | 1002="xfoofoofoobar": 24 | 1002="xfoofoofoofoobar": 25 | 1003="foobar": 26 | 1003="foofoobar": 9 27 | 1003="foofoofoobar": 12 28 | 1003="foofoofoofoobar": 29 | 1003="xfoobar": 30 | 1003="xfoofoobar": 31 | 1003="xfoofoofoobar": 32 | 1003="xfoofoofoofoobar": 33 | 1004="foobar": 34 | 1004="foofoobar": 9 35 | 1004="foofoofoobar": 12 36 | 1004="foofoofoofoobar": 15 37 | 1004="xfoobar": 38 | 1004="xfoofoobar": 10 39 | 1004="xfoofoofoobar": 13 40 | 1004="xfoofoofoofoobar": 16 41 | 1005="foobar": 42 | 1005="foofoobar": 9 43 | 1005="foofoofoobar": 12 44 | 1005="foofoofoofoobar": 15 45 | 1005="xfoobar": 46 | 1005="xfoofoobar": 10 47 | 1005="xfoofoofoobar": 13 48 | 1005="xfoofoofoofoobar": 16 49 | 1006="foobar": 50 | 1006="foofoobar": 51 | 1006="foofoofoobar": 12 52 | 1006="foofoofoofoobar": 15 53 | 1006="xfoobar": 54 | 1006="xfoofoobar": 55 | 1006="xfoofoofoobar": 13 56 | 1006="xfoofoofoofoobar": 16 57 | 1007="foobar": 58 | 1007="foofoobar": 59 | 1007="foofoofoobar": 12 60 | 1007="foofoofoofoobar": 15 61 | 1007="xfoobar": 62 | 1007="xfoofoobar": 63 | 1007="xfoofoofoobar": 13 64 | 1007="xfoofoofoofoobar": 16 65 | 1008="foobar": 66 | 1008="foofoobar": 9 67 | 1008="foofoofoobar": 12 68 | 1008="foofoofoofoobar": 15 69 | 1008="xfoobar": 70 | 1008="xfoofoobar": 10 71 | 1008="xfoofoofoobar": 13 72 | 1008="xfoofoofoofoobar": 16 73 | 1009="foobar": 74 | 1009="foofoobar": 9 75 | 1009="foofoofoobar": 12 76 | 1009="foofoofoofoobar": 15 77 | 1009="xfoobar": 78 | 1009="xfoofoobar": 10 79 | 1009="xfoofoofoobar": 13 80 | 1009="xfoofoofoofoobar": 16 81 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/corpora/lookaround.txt: -------------------------------------------------------------------------------- 1 | 27000:AAAAAAAAAAAAABCDfoobaraaaaaabcdfoobarzzzzzzzzzzzzzzzzzzz 2 | 27000:aaaaaaaaaaaABCDfoobaraaaaaabcdfoobarzzzzzzzzzzzz 3 | 27000:aaaaaaaaaaLMNOfoobarzzzzzzzzzzzzzzzzzzz 4 | 27000:aaaaaaaaaaaaafoobarLLLLLLLLfoobarzzzzzzzzzzzz 5 | 27000:aaaaaaaaaaaAAfoobarzzzzzzzzzzzzzzzzzzzzzzzzzzzz 6 | 27000:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaNNfoobaraaaaaaNNNfoobarzzzzzzzzzzzzzzzzzzzzzzzzzz 7 | 27001:aaaaaaaaaaaaaarFOOBARfoobarFOOBARRRRfoobarfoobarzzzzzzzzzzzzzzzzzz 8 | 27001:foobarfoobarfoobarFfoobarFfoobarfoobarfoobarzzzzzzzzzzzzzzz 9 | 27002:aaaaaaaaaaaaFFaafoobaraaaaaaaaaafoobarzzzzzzzzzzzzzzzz 10 | 27002:aaaaaaaaaaaaa:afoobar aaaaaaafoobarzzzzzzzzzz 11 | 27002:bbbbbaaaaaAfoobar 12 | 27002:bbbbbaaaaafoobar 13 | 27002:bbbbbaaaaaaAAAAAAAAfoobarzzzzzzzzzz 14 | 27003:aaaaaaaaaaaaaaaaaaafoobarzzzzzzzzzzzzzzzzzzzz 15 | 27003:aaaaaabcdefghKKKKKKKKKKKKfoobarKKKKKKKKKKKKKKKKKK 16 | 27003:aaaaaabcdefghiKKKKKKKKKKKKfoobarKKKKKKKKKKKKKKKKK 17 | 27003:aaaaaabcdefghiiiiiiiiiiiifoobarKKKKKKKKKKKKKK 18 | 27004:abcdefghijklmnofoobarabcdefghijklmnopqfoobarfoobar 19 | 27004:abcdefghijklmnfoobarfoobarabcdefghijklfoobar 20 | 27004:aaabcdefghikl__fffffoobarABCDEFGHIKLM_____foobar 21 | 27004:aaaaaacdefghiklmnopfoobarzzzzzzzzzzfoobar 22 | 27005: %foobfoobar d foobar______EEEEfoobar BEEfoobar 23 | 27005:ddddddddddededefoobar foobar foobar 24 | 27005: _foobar1111115WWWfoobarzzzzzzzzzzzzz 25 | 27006:0123012301230123012301230123foobar012301230123 26 | 27006:00000000000000A0cdDEEEEE00foobar0000 27 | 27006:00000000AABaaEEEEEfoobarfoobar 28 | 27006:00000000ddddDEEEEEEEfoobar 29 | 27007:c\xa1CCCCC[cdCAKDDDd\xc7vbEaaCC 30 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/corpora/options.txt: -------------------------------------------------------------------------------- 1 | 24500="foo bar": 7 2 | 24500="foo\nbar": 7 3 | 24500="foobar": 6 4 | 24501="foo bar baz": 11 5 | 24501="foo bar\nbaz": 11 6 | 24501="foo\nbar baz": 7 | 24501="foobar\x01baz": 10 8 | 24502="foo bar": 7 9 | 24502="foo\nbar": 10 | 24502="foobar": 6 11 | 24503="foo bar": 7 12 | 24503="foo\nbar": 13 | 24503="foobar": 6 14 | 24504="foo bar baz": 11 15 | 24504="foo bar\nbaz": 11 16 | 24504="foo\nbar baz": 17 | 24504="foo\nbar\nbaz": 18 | 24504="foo__bar\x01c___xbaz": 17 19 | 24504="foobarbaz": 9 20 | 24600="FOOBAR": 6 21 | 24600="fOoBaR": 6 22 | 24600="fooBAR": 6 23 | 24600="foobar": 6 24 | 24601="FOOBAR": 6 25 | 24601="fOoBaR": 6 26 | 24601="fooBAR": 6 27 | 24601="foobar": 6 28 | 24602="FOOBAR": 29 | 24602="fOoBaR": 30 | 24602="fooBAR": 31 | 24602="foobar": 6 32 | 24603="FOOBAR": 33 | 24603="FOObar": 6 34 | 24603="foobar": 6 35 | 24604="FOOBAR": 36 | 24604="fooBAR": 6 37 | 24604="foobar": 6 38 | 24605="FOOBAR": 39 | 24605="FOObar": 6 40 | 24605="foobar": 6 41 | 24700="__foobar": 8 42 | 24700="firstline\nfoobar\nfoobar": 16,23 43 | 24700="foobar": 6 44 | 24701="__foobar": 8 45 | 24701="firstline\nfoobar\nfoobar": 23 46 | 24701="foobar": 6 47 | 24800="foo bar": 48 | 24800="foobar": 6 49 | 24801="foo bar baz": 50 | 24801="foobar baz": 10 51 | 24801="foobarbaz": 52 | 24900="firstline\nfoobarbaz": 19 53 | 24900="foo\nbar\nbaz": 11 54 | 24900="foobarbaz": 9 55 | 24901="ABBREVIATION": 6,12 56 | 24901="aBBr": 57 | 24901="abbrev": 6 58 | 24901="abbreviation": 6,12 59 | 24902="foo\nBAR": 7 60 | 24902="foo\nbaR": 7 61 | 24902="foo_bar": 7 62 | 24903="foo\nBAR": 63 | 24903="foo\nbaR": 64 | 24903="foo_bar": 7 65 | 24904="fooBaRbaz": 9 66 | 24904="foobarBAZ": 67 | 24905="nestedCASELESScaSEfulCASELESSliteral": 68 | 24905="nestedCASELESScasefulCASELESSliteral": 36 69 | 24905="nestedcaselesscasefulcaselessliteral": 36 70 | 24906="ab aB ac aC": 2,5,8,11 71 | 24907="hatstand teakettle HATSTAND TEAKETTLE Hatstand Teakettle": 8,18,27,37,46,56 72 | 24908="foo BAR baz bing": 16 73 | 24908="foo BAR\nbaz bing": 74 | 24908="foo bar baz bing": 16 75 | 24908="foo bar\nbaz bing": 76 | 24908="foo\nBAR baz\nbing": 16 77 | 24908="foo\nBAR\nbaz\nbing": 78 | 24908="foo\nbar baz\nbing": 16 79 | 24908="foo\nbar\nbaz\nbing": 80 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/accel.txt: -------------------------------------------------------------------------------- 1 | 2000:/abcdef[^X].*[^X](A|B(CDE)?F)Y?foobar/s 2 | 2001:/[^abab]+\Z/si 3 | 2002:/mj(?:[pajl]|o)[tplh]thd.hq.b[frt]pk(\b)hb/i8L 4 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/approximate_matching.txt: -------------------------------------------------------------------------------- 1 | # patterns that should produce matches 2 | 40000:/^(012)*test$/ms{edit_distance=1} 3 | 40001:/[^k]{3}$/ms{edit_distance=2} 4 | 40002:/^test$/ms{edit_distance=1} 5 | 40003:/^test/s{edit_distance=2} 6 | 40004:/test/s{edit_distance=2} 7 | 40005:/test|^lit/s{edit_distance=2} 8 | 40006:/tta+tt/s{edit_distance=2} 9 | 40007:/^ab(..)+bc/s{edit_distance=2} 10 | 40008:/a( bc|d)e/s{edit_distance=1} 11 | 40009:/abc|def$/s{edit_distance=2} 12 | 40010:/abc|def$/ms{edit_distance=2} 13 | 14 | 40050:/^(012)*test$/ms{hamming_distance=1} 15 | 40051:/[^k]{3}$/ms{hamming_distance=2} 16 | 40052:/^test$/ms{hamming_distance=1} 17 | 40053:/^test/s{hamming_distance=2} 18 | 40054:/test/s{hamming_distance=2} 19 | 40055:/test|^lit/s{hamming_distance=2} 20 | 40056:/tta+tt/s{hamming_distance=2} 21 | 40057:/^ab(..)+bc/s{hamming_distance=2} 22 | 40058:/a( bc|d)e/s{hamming_distance=1} 23 | 40059:/abc|def$/s{hamming_distance=2} 24 | 40060:/abc|def$/ms{hamming_distance=2} 25 | 40061:/^a?/m{hamming_distance=1} 26 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/asserts.txt: -------------------------------------------------------------------------------- 1 | 23000:/foo.*\bbar/s 2 | 23001:/foo\b.*bar/s 3 | 23002:/\bfoo/ 4 | 23003:/\Bfoo/O 5 | 23004:/(word|nonword~).*\balpha/s 6 | 23005:/\B~/ 7 | 23006:/foo\b/ 8 | 23007:/foo\B/ 9 | 23008:/foo\b$/ 10 | 23009:/foo\b\z/O 11 | 23010:/foo.*\b\bbar/s 12 | 23011:/foo.*\b\b\bbar/s 13 | 23012:/foo\b.*\bbar/s 14 | 23013:/foo\B.*\Bbar/s 15 | 23014:/foo\b.*\Bbar/s 16 | 23015:/\b\bfoo/ 17 | 23016:/\B\Bfoo/O 18 | 23017:/\B\B~/ 19 | 23018:/foo\b\b/ 20 | 23019:/foo\B\B/ 21 | 23020:/foo\b\b$/ 22 | 23021:/foo\b\b\z/O 23 | 23022:/a[b~]+\b/ 24 | 23023:/\b[b~]+a/ 25 | 23024:/\ba/ 26 | 23025:/\b/ 27 | 23026:/\B/ 28 | 23027:/\b\z/ 29 | 23028:/\B\z/ 30 | 23029:/^\b/ 31 | 23030:/^\B/ 32 | 23031:/(a|\A\b)/ 33 | 23032:/(^a|\b)/ 34 | 23033:/^\bfoo/O 35 | 23034:/^\Bfoo/O 36 | 23035:/^\b\bfoo/O 37 | 23036:/^\B\Bfoo/O 38 | 23037:/foo.*(\b|\B)bar/O 39 | 23038:/three.*\b\b\basserts/ 40 | 23039:/three.*\B\B\Basserts/ 41 | 23040:/can't_match\b\B/O 42 | 23041:/\b\Bcan't_match/O 43 | 23042:/\b(.*)\b/s 44 | 23043:/\b(foo|bar|baz)\b/ 45 | 46 | # More tests: repeats 47 | 23044:/((\b){2,})+/ 48 | 23045:/((\b){10,})+/ 49 | 23046:/((\b|a){2,})+/ 50 | 23047:/(\b[a-f]\b)+/ 51 | 23048:/(((\b[a-f]+\b) ?))+/ 52 | 53 | # multiline bi-anchored boundaries 54 | 23049:/^(\B)/m 55 | 23050:/^(\b)/m 56 | 23051:/^\b$/m 57 | 23052:/^\b\Z/m 58 | 23053:/^\b\z/mO 59 | 23054:/\A\b$/m 60 | 23055:/\A\b\Z/m 61 | 23056:/\A\b\z/m 62 | 23057:/^\B$/m 63 | 23058:/^\B\Z/m 64 | 23059:/^\B\z/m 65 | 23060:/\A\B$/m 66 | 23061:/\A\B\Z/m 67 | 23062:/\A\B\z/m 68 | 23063:/\b.*\b/s 69 | 23064:/\B.*\B/s 70 | 23065:/\b.*\B/s 71 | 23066:/\B.*\b/s 72 | 23067:/\b.+\b/s 73 | 23068:/\B.+\B/s 74 | 23069:/\b.+\B/s 75 | 23070:/\B.+\b/s 76 | 23071:/l(\B.)*/i 77 | 23072:/(a?.\b){4,}bbabb/ 78 | 23073:/\A\B/ 79 | 23074:/\A\b/ 80 | 81 | 23075:/\b[a-f]+\b/ 82 | 83 | # Asserts near repeats. 84 | 23076:/godzilla\b.{0,10}mothra/s 85 | 23077:/godzilla.{0,10}\bmothra/s 86 | 23078:/godzilla\b.{0,10}\bmothra/s 87 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/benefits.txt: -------------------------------------------------------------------------------- 1 | 19501:/a..b/sO 2 | 19502:/a..bc/sO 3 | 19503:/ab..c/sO 4 | 19504:/ab..c../sO 5 | 19505:/ab..c../siO 6 | 19506:/.ab..c../siO 7 | 19507:/abcdefgh....abcd....efgh/sO 8 | 19508:/foo..ba/sO 9 | 19509:/foo..ba\z/sO 10 | 11 | # Longer masks 12 | 19510:/[a-f]{3}-[a-f]{3}-[a-f]{4}/ 13 | 14 | # Mixed-sensitivity literals can use masks. 15 | 19511:/ab(?i)cdef(?-i)ghi/ 16 | 17 | # Fixed width pattern that's too long to use a benefits mask. 18 | 19512:/a{10}b{10}[Cc]{10}d{10}/ 19 | 20 | # Mixed sensitivity and dot mask 21 | 19513:/f[Yy][mPiU].W/ 22 | 23 | # Short mixed-case literals to stress literal matchers 24 | 19514:/(?i)godzill(?-i)a/ 25 | 19515:/g(?i)odzilla/ 26 | 19516:/G(?i)odzilla/ 27 | 19517:/(?i)god(?-i)z(?i)illa/ 28 | 19518:/g(?i)od(?-i)z(?i)illa/ 29 | 30 | # Masks and mixed-case 31 | 19519:/^nqt(?-i)qkf{14}bdr+k.t(?i)r[cp]q{3}\z/is 32 | 33 | # More mixed-case 34 | 19520:/[Bb][Cc][Aa][CDc]abaaEbcd/ 35 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/capturing.txt: -------------------------------------------------------------------------------- 1 | 25000:/((e[dcb]ce(\B)a|.*b(d.|d|c|.|ad)ad[acd]b|a{4,10}|d)[cd]|ba[bcbc].b.ebcd{0,})/m 2 | 25001:/(a[^aaaa]aaaaa..aaa{0,}|.aaa)/ 3 | 25002:/(\A[aab]{1}|^a.|[aca](\B)baacccc(\b).((b|a)){1,}|aa[bc]cc.\z|\A[aa].cabc.|a(b|[bca]|c|c))/s 4 | 25003:/aaaaaa(a?|aaaa|a|.?)a+(.a.a.(\b)([aaa]|[aa]|.)aaaaa{4,}[aaa]aaa(a|[aa]))?/mi 5 | 25004:/(aaa{14,16}aa.a.a|[aaaa]aaa[aa]|(aa|a|a|[aaaa]|a)a[^aaaa]aaaaa)/smi 6 | 25005:/((aaaa[^\n]*aaaaa)|(aa)|(aa))/s 7 | 25006:/((abaaa.+a)|(aa))/s 8 | 25007:/[^p]b{3,20}/ 9 | 25008:/((acbddbdcccc)|(cc))/s 10 | 25009:/(aa(a|a|a|a|a|[aa])){1,7}/s 11 | 25010:/aa(a|a+)/s 12 | 25011:/bba*/i 13 | 25012:/hg[hkjs]*/s 14 | 25013:/ke+/i 15 | 25014:/.(a|.)a?/m 16 | 25015:/(\b)../i 17 | 25016:/../ 18 | 25017:/a/s 19 | 25018:/(a{5}$|(a|[aaa]|[aaaa])aaa[^aaa])/sm 20 | 25019:/(\B)..a*/i 21 | 25020:/(.bb|bbaababb|\Aba.*|b?(b|[ab]|a)[aab]b([ba]b?|bb)|\Abaaaaaa(a|a|.))/smi 22 | 25021:/foobar/ 23 | 25022:/foobar/i 24 | 25023:/foo_bar/ 25 | 25024:/foo_bar/i 26 | 25025:/[fg]oobar/ 27 | 25026:/[fg]oobar/i 28 | 25027:/f[0o]obar/i 29 | 25028:/foo(?i)bar/ 30 | 25029:/[Ff]oobar/ 31 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/comp.txt: -------------------------------------------------------------------------------- 1 | 15800:/^.*(foo.*bar|baz.*baz)/sO 2 | 15801:/^.*(foo.*bar|baz.*baz)a/s 3 | 15802:/^.{1,6}(foo.*bar|baz.*baz)/sO 4 | 15803:/.{1,6}(foo.*bar|baz.*baz)/sO 5 | 15804:/.{1,6}(foo.*bar|........baz.*baz)/sO 6 | 15805:/^.{1,}(foo.*bar|........baz.*baz)/sO 7 | 15806:/anorak.*trainspotter|ANORAK.*trainspotter/iO 8 | 15807:/anorak.*trainspotter/iO 9 | 15808:/anorak.*trainspotter\z|ANORAK.*trainspotter/iO 10 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/comptree.txt: -------------------------------------------------------------------------------- 1 | 1000:/(foo){2,}bar/ 2 | 1001:/(foo){2,3}bar/ 3 | 1002:/^(foo){2,}bar/ 4 | 1003:/^(foo){2,3}bar/ 5 | 1004:/x?(foo){2,}bar/ 6 | 1005:/x?(foo){2,3}bar/ 7 | 1006:/(foo){2,}bar/{min_length=10} 8 | 1007:/(foo){2,3}bar/{min_length=10} 9 | 1008:/(foo){2,}bar/L 10 | 1009:/(foo){2,3}bar/L 11 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/highlander.txt: -------------------------------------------------------------------------------- 1 | 15300:/foo/HO 2 | 15301:/foo.*bar/sHO 3 | 15302:/foo.*bar/HO 4 | 15303:/foo[^X]{15}/sHO 5 | 15304:/foo[^X]{16}/sHO 6 | 15305:/foo[^X]{17}/sHO 7 | 15306:/foo.*[^X]{17}/sH 8 | 15307:/foo[^X]{17}blah/sHO 9 | 15308:/foo[^XY]{17}/sHO 10 | 15309:/foo[^X]{17}$/sH 11 | 15310:/[^X]{17}/sH 12 | 15311:/^[^X]{17}/sHO 13 | 15312:/fo.*o[^X]{15}/sH 14 | 15313:/fo.*o[^X]{16}/sH 15 | 15314:/fo.*o[^X]{17}/sH 16 | 15315:/[fb][oa][or][^X]{15}/sH 17 | 15316:/[fb][oa][or][^X]{16}/sH 18 | 15317:/[fb][oa][or][^X]{17}/sH 19 | 15318:/foo|bar/HO 20 | # for people who are unsure of highlander semantics 21 | 15319:/foo.|bar./HO 22 | 15320:/^(a[^aa]..aa|a*)/mHV 23 | 24 | # highlander pruning 25 | 15321:/(foo.*bar)|(foo.*bar.*baz)/H 26 | 15322:/foo.*bar(.*baz)?/H 27 | 15323:/foo.*bar+/H 28 | 15324:/(foo.*bar)|(foo.*bar.*baz)|(foo.*bar.*eod\z)/H 29 | 15325:/foo.*eod+\z/H 30 | 15326:/foo.*eod+$/H 31 | 32 | # SEP patterns 33 | 15327:/[a-f]/iH 34 | 15328:/a|b|c/H 35 | 36 | # Longer, run-prone literals 37 | 15329:/(p{100})|(q{100})/H 38 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/longlits.txt: -------------------------------------------------------------------------------- 1 | # Alternation of ten long literals. 2 | 50000:/ukdnsybecoqlszhxiwfcpvmnoqobdfuoovmotdeefiwdoxukyxldjxthcmnxqebsiyvwwtadafmibpxnwuxqtpcndwzaiwurnvbkgzpfutisauyagfwacajrcmjlgmomzdakzjgpgnlepnjcynzhptporgjcrjkrnhvnucgvjjgfboisxjfaywypljihrstqvmwsqdvq|ihcntajbgquaruyfimiabusvmmqcpaxpowhhucnzlpfxzmmbcqahdmposiymqscqugtmictrnomnccfcdxzlksyuqkbjvgekaebwmcmzydebtltpcfbmckvwoqtinlplzopauzkcyiinbcjrfjkncggcowuifvwvoavxrkuaxuwjhnnyotkgbrkggwkafzvzmkgijnsr|vtymzjxeeyazemvcwsvcacdzihfbgiaqwjxmcncgdzafmhtvbvnmjrpfudnflcvfbkwcfsmdfaqtawqqcbigfrnjzwrdvndstesayfgjsiofshzvtabtgblrgbksqechctlngykpladacvwiffqwjktuosdjvdonjixekrlvvxeeqenylwjgqicdpgjhojsyyhuhtphc|oxqvlanpjsnxnoodzpjhsnmgkwjfyqxmqlbqmteabqdbnwtvnpeodvvkukcxqfczyrftogophbmkeuzcxmpyqfigkynftdstdudfynmfxhssbrpdhebywvnpltqxtvdthpppdllyofyktnrwzhbiklpfrclizidkkqbgimzmdrznwkmbledtmsazljcvmfzdlpzgwymm|jtaanwnxkvwesndylwqcnsqlccnikybengkimrxauuvytagyasdomvupykaagpcthrrnkzjnysqywwyqpfbyqclabrcftwgvfcxdrhkgxlngnsxmkrvguvfugbgqruspkzojxrhqkrgjrybyoqktjrexxodbcdlfiyhclsvhsaysihhoycnpksoivyxxbglvyzhkbajh|ntafhsdlngeeeqphxqspxswcmubcwycbzusxunxrmqgmdktwblavcrdgjhecpfnqsyckxuxaboljmrvetofhgbeydypoeyydrxhordcgqafbnoylylqnvxynfcoygtiwiniwlctwmwornplgfpjbretneadneemlzzodtkkdmcyqrggrmjzlkzzjxoirfilosenpjexy|ckalndydcrodvvmyyuqbihprzzgnqympoeinwewgfqpzuhyygivfdhdxnnatccuaghjrddogabtgmcvpspptpicpftxdfdfsiilngteqvqjjsoevnqfiztgcvolmpqkemqeizzmlingcuyxyidvrlczmiifutjljifxiramtoxvtbkwzsrczyzdgbtkboudipjonydtt|fbbeioibbkbiiupjzcqrwjuvqjmbavnkvtogebhltedefahasbnvvvspugdtecfpstxsbtfluycxzfxgcvzhfyhgbgzyfcwltvyyoofolnolasemxqqywlrikjocwvhpqofufqyuhcisckvoveaeectwodmmcodisfwynzcctloqyheedjfpwcuwrixkdznnefgizrap|eosktuskzdokmshljlcazpmahliwzzmhmpzmsiymtvpctaqwdpmffcnkmkypkcrclmlcxmnysqhslegqetflncttxqiprjddowzkhyjlzytudxqnvcctpebufelzmxnzsfwqbahrgwbjrpbobfdwjfsbfjrhjsbqdlsurllezccluashcrywxhnbqqclikrnefkyutdo|gvoiwjevplfxkeempnspkgljnqdckunshelsuogizffvbplhbyhxnjfabmjiigideullxtxbnjxczvaoveafcechrilvdkyzehhuhlohtjxiocfvjzdrjosuawxqmlbcwsnfnpxusoqldoumsedxbbwummwtbqrwkcjxkvyukcxekpjacjlezesaihhpqdatiosxgbbb/ 3 | 4 | # Long flood literals. 5 | 50001:/a{300}/ 6 | 50002:/A{300}/ 7 | 50003:/a{300}/i 8 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/lookaround.txt: -------------------------------------------------------------------------------- 1 | 27000:/a[A-L]?[B-M]?[C-N]?[D-O]?foobar/ 2 | 27001:/ar[A-Z]{1,9}foobar/ 3 | 27002:/a{5}\w{1,8}foobar/ 4 | 27003:/(ab|bc|cd|de|ef|fg|gh|hi)[\w]{12}foobar/ 5 | 27004:/(abcdef|bcdefg|cdefgh|defghi|efghij|fghijk|ghijkl|hijklm)[\w]{8}foobar/ 6 | 27005:/[\x20\x31\x42\x53\x64][\x20\x25\x31\x35\x42\x45\x53\x55\x64\x65][\w]{1,7}foobar/ 7 | 27006:/[\dABcd][\dABCd][\dAbcd][\dabcd][\dabCD][\dEFGH][\dEFGh][\dEfgh][0-5B-Iw-z][\dA-Z]{1,6}foobar/ 8 | 27007:/ec.((c|C|d){3}|.BEe|...|dE.[bdC]A.Ac[Aa]|ca)CC.cdCA.D{1,}[Dd]..b(dbe{16,18}|E|b)aaC(c|d*|e|[Da]|C|a)/s 9 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/mcclellan.txt: -------------------------------------------------------------------------------- 1 | 15900:/foo.+ba[rR]/sO 2 | 15901:/foo.*ba[rR]/sO 3 | 15902:/foo.*ba[rR].*tea/sO 4 | 15903:/fo(|o.*ba[rR].*tea)/s 5 | 15904:/fo($|o.*ba[rR].*tea)/s 6 | 15905:/foo.*ba[rR]|tea.*cof[^f]ee/s 7 | 15906:/(foo|bar).*gaz/sO 8 | 15907:/foo.*(bar|gaz)/sO 9 | 15908:/foo.*(bar|gaz).*tea/sO 10 | 15909:/foo.*a(bar|gaz).*tea/sO 11 | 15910:/foo.*a(bar|gaz).*(tea|aet)/sO 12 | 15911:/foo(b[^a]r|g[^a]z).*tea/s 13 | 15912:/foo(b[^a]r|g[^a]z).*(tea|aet)/s 14 | 15913:/^p;;.*[_;]*.*:/sO 15 | 15914:/p;;.*[_;]*.*:/sO 16 | 15915:/p;;.*[_;]*.*:/O 17 | 15916:/^AA.*(a.*(Z|XX)|b.*(Z|YY))/s 18 | 15917:/^AA.*(a.*(Z|XX)|b.*Z)/s 19 | 15918:/^pppp;;.*[_;]*.*:/sO 20 | 15919:/pppp;;.*[_;]*.*:/sO 21 | 15920:/pppp;;.*[_;]*.*:/O 22 | 15921:/^AAAAA.*(a.*(Z|XX)|b.*(Z|YY))/s 23 | 15922:/^AAAAAA.*(a.*(Z|XX)|b.*Z)/s 24 | 15923:/(bdcd{26}|([kjrs]|b|b)+){2,4}/s 25 | 15924:/literal\w{0,7}\d+/s 26 | 15925:/literal\w{0,10}\d+/s 27 | 15926:/literal\w{0,10}/s 28 | 15927:/literal\w{5,}/s 29 | 15928:/[ab][^ab]a.a/s8 30 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/metacharacters.txt: -------------------------------------------------------------------------------- 1 | # Some tests for specific special metacharacters 2 | 3 | # matches any byte 4 | 24000:/\C/ 5 | 6 | # alarm, that is, the BEL character (hex 07) 7 | 24001:/\a/O 8 | 9 | # "control-x", where x is any character 10 | 24002:/\cz/O 11 | 24003:/\c{/O 12 | 24004:/\c;/O 13 | 24005:/\ca/O 14 | 24006:/\c0/O 15 | 16 | # escape (hex 1B) 17 | 24007:/\e/O 18 | 19 | # formfeed (hex 0C) 20 | 24008:/\f/O 21 | 22 | # linefeed (hex 0A) 23 | 24009:/\n/O 24 | 25 | # carriage return (hex 0D) 26 | 24010:/\r/O 27 | 28 | # tab (hex 09) 29 | 24011:/\t/O 30 | 31 | # real hex escapes 32 | 24012:/\xdc\x{dc}\x00\x{ff}/O 33 | 34 | # broken hex escape, interpreted as a null followed by some chars 35 | 24013:/\x{dc/O 36 | 37 | # more control 38 | 24015:/\cA/O 39 | 24016:/[\cz]/O 40 | 24017:/[\c{]/O 41 | 24018:/[\c;]/O 42 | 24019:/[\ca]/O 43 | 24020:/[\c0]/O 44 | 24021:/[\cA]/O 45 | 24022:/\c\n/O 46 | 47 | # \8 and \9 are not back-references, they are simply the literals 8 and 9. 48 | 24023:/\8 literal \9/ 49 | 50 | # Big numbers 51 | 24024:/bignum \1111111111/ 52 | 24025:/bignum \2147483639/ 53 | 24026:/bignum \18888/ 54 | 24027:/bignum \128888/ 55 | 24028:/bignum \1238888/ 56 | 24029:/bignum \3778888/ 57 | 58 | # Octal escapes 59 | 24030:/\060/ 60 | 24031:/\60/ 61 | 24032:/\12/ 62 | 24033:/\012/ 63 | 24034:/\0120/ 64 | 24035:/\120/ 65 | 24036:/\377/ 66 | 24037:/\80/ 67 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/options.txt: -------------------------------------------------------------------------------- 1 | # Patterns that set/unset various options 2 | 3 | # DOTALL 4 | 24500:/(?s)foo.*bar/O 5 | 24501:/foo.*bar(?s).baz/O 6 | 24502:/(?-s)foo.*bar/sO 7 | 24503:/(?-s)foo.*bar/O 8 | 24504:/(?-s)foo.*bar(?s).*baz/sO 9 | 10 | # CASELESS 11 | 24600:/(?i)foobar/O 12 | 24601:/(?i)foobar/iO 13 | 24602:/(?-i)foobar/iO 14 | 24603:/foo(?-i)bar/iO 15 | 24604:/(?-i)foo(?i)bar/iO 16 | 24605:/(?i)foo(?-i)bar/O 17 | 18 | # MULTILINE 19 | 24700:/(?m)foobar$/ 20 | 24701:/(?-m)foobar$/m 21 | 22 | # EXTENDED 23 | 24800:/(?x)foo bar/O 24 | 24801:/(?x)foo bar(?-x) baz/O 25 | 26 | # EPIC COMBOS 27 | 24900:/(?imsx)^ foo .* bar .* baz/O 28 | 29 | # MORE COMPLEX CASES 30 | 24901:/^(?i:(?:abbr(?:ev(?:iation)?)))/ 31 | 24902:/(?s)foo(?i).bar/ 32 | 24903:/(?s)foo(?i-s).bar/ 33 | 24904:/foo(?i:bar)baz/ 34 | 24905:/nested(?i:caseless(?-i:caseful)caseless)literal/ 35 | 24906:/(a(?i)b|c)/ 36 | 24907:/(?i:hatstand|teakettle)/ 37 | 24908:/foo.*(?i-s:bar.*baz).*bing/s 38 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/passthrough.txt: -------------------------------------------------------------------------------- 1 | 9000:/(abc|def)(xxx|yyyy)/O 2 | 9001:/^(abc|def)(xxx|yyyy)/O 3 | 9002:/(^anchored|floating)(XXX|YYY)/O 4 | 5 | # Some long literals. 6 | 9005:/a{40}/ 7 | 9006:/a{48}/ 8 | 9007:/a{49}/ 9 | 9008:/a{50}/ 10 | 9009:/q{1000}/ 11 | 9010:/coagulateshyperinnervationagitationreassuranceexchangeability/ 12 | 9011:/nonplasticerythematoussnakebitesjubilatedworklessnesses/ 13 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/pug.txt: -------------------------------------------------------------------------------- 1 | 5000:/[^X]:.{111,}pug/s 2 | 5001:/[^X]:.{111,}[pugPUGxyz]{3}/s 3 | 5002:/aaa:.{111,}pug/s 4 | 5003:/aaa:.{111,}[pugPUGxyz]{3}/s 5 | 5004:/[^X]:.{112,}pug/s 6 | 5005:/[^X]:.{112,}[pugPUGxyz]{3}/s 7 | 5006:/aaa:.{112,}pug/s 8 | 5007:/aaa:.{112,}[pugPUGxyz]{3}/s 9 | 5008:/[^X]:.{113,}pug/s 10 | 5009:/[^X]:.{113,}[pugPUGxyz]{3}/s 11 | 5010:/aaa:.{113,}pug/s 12 | 5011:/aaa:.{113,}[pugPUGxyz]{3}/s 13 | 5012:/[^X]:.{127,}pug/s 14 | 5013:/[^X]:.{127,}[pugPUGxyz]{3}/s 15 | 5014:/aaa:.{127,}pug/s 16 | 5015:/aaa:.{127,}[pugPUGxyz]{3}/s 17 | 5016:/[^X]:.{128,}pug/s 18 | 5017:/[^X]:.{128,}[pugPUGxyz]{3}/s 19 | 5018:/aaa:.{128,}pug/s 20 | 5019:/aaa:.{128,}[pugPUGxyz]{3}/s 21 | 5020:/[^X]:.{129,}pug/s 22 | 5021:/[^X]:.{129,}[pugPUGxyz]{3}/s 23 | 5022:/aaa:.{129,}pug/s 24 | 5023:/aaa:.{129,}[pugPUGxyz]{3}/s 25 | 5024:/[^X]:[a-z]{111,}pug/s 26 | 5025:/[^X]:[a-z]{111,}[pugPUGxyz]{3}/s 27 | 5026:/aaa:[a-z]{111,}pug/s 28 | 5027:/aaa:[a-z]{111,}[pugPUGxyz]{3}/s 29 | 5028:/[^X]:[a-z]{112,}pug/s 30 | 5029:/[^X]:[a-z]{112,}[pugPUGxyz]{3}/s 31 | 5030:/aaa:[a-z]{112,}pug/s 32 | 5031:/aaa:[a-z]{112,}[pugPUGxyz]{3}/s 33 | 5032:/[^X]:[a-z]{113,}pug/s 34 | 5033:/[^X]:[a-z]{113,}[pugPUGxyz]{3}/s 35 | 5034:/aaa:[a-z]{113,}pug/s 36 | 5035:/aaa:[a-z]{113,}[pugPUGxyz]{3}/s 37 | 5036:/[^X]:[a-z]{127,}pug/s 38 | 5037:/[^X]:[a-z]{127,}[pugPUGxyz]{3}/s 39 | 5038:/aaa:[a-z]{127,}pug/s 40 | 5039:/aaa:[a-z]{127,}[pugPUGxyz]{3}/s 41 | 5040:/[^X]:[a-z]{128,}pug/s 42 | 5041:/[^X]:[a-z]{128,}[pugPUGxyz]{3}/s 43 | 5042:/aaa:[a-z]{128,}pug/s 44 | 5043:/aaa:[a-z]{128,}[pugPUGxyz]{3}/s 45 | 5044:/[^X]:[a-z]{129,}pug/s 46 | 5045:/[^X]:[a-z]{129,}[pugPUGxyz]{3}/s 47 | 5046:/aaa:[a-z]{129,}pug/s 48 | 5047:/aaa:[a-z]{129,}[pugPUGxyz]{3}/s 49 | 5048:/([^X]:|:[^Y]).{120,}[pugPUGxyz]{3}/s 50 | 5049:/([^X]:|:[^Y])[a-z]{120,}[pugPUGxyz]{3}/s 51 | 5900:/[^X][^Xx][defg][^:*][deDE][^bcC][deAE]/ 52 | 5901:/(^|[x\- B])(a|[bBbB]|cc)[^A-Z0-9]{112,}[deDE][^bcC][geAE]/s 53 | 5902:/(^|[x\- B])(a|bb|cc).{113,}[deDE][^bcC][geAE]/s 54 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/redundancy.txt: -------------------------------------------------------------------------------- 1 | 15100:/hatstand.*a?teakettle/sO 2 | 15101:/foo(A|A)bar/O 3 | 15102:/foo(1|2|3|4)bar/O 4 | 15103:/^.*a+bc/ 5 | 15104:/foo[Aa]+a+bar/ 6 | 15105:/foo[Aa]+[aB]+bar/ 7 | 15106:/foo[AaB]+[aB]+bar/ 8 | 15107:/foo[Aa]*[aB]+bar/ 9 | 15108:/foo[AaB]*[aB]+bar/ 10 | 15109:/a(b|c.+)d+e/ 11 | 15110:/a(b|c.*)d+e/ 12 | 13 | # cases specifically aimed at the cyclic-dom redundancy code 14 | 15120:/foo.*a*bar/O 15 | 15121:/fooa*.*bar/O 16 | 15122:/fooa?.*bar/O 17 | 15123:/foo.*a?bar/O 18 | 15124:/foo.*a+bar/O 19 | 15125:/fooa+.*bar/O 20 | 15126:/foo.+a*bar/O 21 | 15127:/fooa*.+bar/O 22 | 15128:/fooa?.+bar/O 23 | 15129:/foo.+a?bar/O 24 | 15130:/foo.+a+bar/O 25 | 15131:/fooa+.+bar/O 26 | 27 | # edge redun 28 | 15132:/abc(a|\B){6}def/sO 29 | 15133:/AAA([A-Z]_?)+(([\x00-\x3d]|[\x3f-\xff])\x00?)+ZZZ/s 30 | 31 | # misc opt 32 | 15134:/(Y.|X.+)a[^a]*foo/s 33 | 15135:/oof[^a]*a(.+X|.Y)/s 34 | 15136:/foo.*<[^<]*bar/s 35 | 15137:/foo[^<]*<.*bar/s 36 | 15138:/foo\b.*bar/s 37 | 15139:/foo.*\bbar/s 38 | 15140:/foo[^<]*<[^>]*bar/s 39 | 15141:/foo[^<]*>[^>]*bar/s 40 | 15142:/foo[^<=]*[<=][^>=]*bar/s 41 | 15143:/foo[^<=]*[>=][^>=]*bar/s 42 | 43 | # rev misc opt 44 | 15144:/aa+.aaaa/si 45 | 46 | # needs cyclic path redundancy followed by other redundancy passes. 47 | 15145:/^abc.(.*|foo)\Sa..a...\S./s 48 | -------------------------------------------------------------------------------- /tools/hscollider/test_cases/pcre/vacuous.txt: -------------------------------------------------------------------------------- 1 | # A selection of fine vacuous patterns (patterns that match the empty string). 2 | # Only true FIREHOSE patterns need the /V flag. 3 | 4 | 22000:/.*/V 5 | 22001:/.?/V 6 | 22002:/.{0,16}/V 7 | 22003:/.*/sV 8 | 22004:/.?/sV 9 | 22005:/.{0,16}/sV 10 | 22006:/(foo|)/V 11 | 22007:/(foo|.?)/sV 12 | 22008:/(foo|.*)/sV 13 | 22009:/(foo|.{0,16})/sV 14 | 22010:/^.*/ 15 | 22011:/^.?/ 16 | 22012:/^.{0,16}/ 17 | 22013:/^.*/s 18 | 22014:/^.?/s 19 | 22015:/^.{0,16}/s 20 | 22016:/^(foo|)/ 21 | 22017:/^(foo|.?)/s 22 | 22018:/^(foo|.*)/s 23 | 22019:/^(foo|.{0,16})/s 24 | 25 | 22020:/^$/ 26 | 22021:/^\z/ 27 | 28 | 22022:/(foo|$)/ 29 | 22023:/(foo|\z)/ 30 | 22024:/(.?|$)/sV 31 | 22025:/(.?|\z)/sV 32 | 22026:/(^|\z)/ 33 | 34 | # Tricky mix of vacuous and multiline 35 | 22027:/^a?/m 36 | 22028:/^$/m 37 | 38 | # We handle /./s as a firehose with a min start offset of zero, now. 39 | 22029:/./s 40 | 41 | # For completeness, some other cases (especially multiline) 42 | 22030:/^/m 43 | 22031:/$/m 44 | 22032:/\z/m 45 | 22033:/\Z/m 46 | 22034:/^\z/m 47 | 22035:/^./sm 48 | 22036:/^.?/sm 49 | 22037:/(foo|$)/m 50 | 51 | # Messy cases 52 | 22038:/((?:d|C|B|D|B*|.)){1,4}/VP 53 | -------------------------------------------------------------------------------- /tools/hsdump/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # dump support is required 2 | if (NOT DUMP_SUPPORT) 3 | return() 4 | endif () 5 | 6 | include_directories(${PROJECT_SOURCE_DIR}) 7 | include_directories(${PROJECT_SOURCE_DIR}/util) 8 | 9 | # only set these after all tests are done 10 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}") 11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}") 12 | 13 | if(WIN32 AND (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)) 14 | add_executable(hsdump main.cpp $ $) 15 | else() 16 | add_executable(hsdump main.cpp) 17 | endif() 18 | target_link_libraries(hsdump hs expressionutil crosscompileutil) 19 | 20 | -------------------------------------------------------------------------------- /unit/chimera/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "gtest/gtest.h" 30 | 31 | // Driver: run all the tests (defined in other source files in this directory) 32 | int main(int argc, char **argv) { 33 | testing::InitGoogleTest(&argc, argv); 34 | return RUN_ALL_TESTS(); 35 | } 36 | -------------------------------------------------------------------------------- /unit/hyperscan/bad_patterns.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunpengcompute/hyperscan/ffae257207264b7c320a790e5d07473d231c05ff/unit/hyperscan/bad_patterns.txt -------------------------------------------------------------------------------- /unit/hyperscan/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "gtest/gtest.h" 30 | 31 | // Driver: run all the tests (defined in other source files in this directory) 32 | int main(int argc, char **argv) { 33 | testing::InitGoogleTest(&argc, argv); 34 | 35 | return RUN_ALL_TESTS(); 36 | } 37 | -------------------------------------------------------------------------------- /unit/internal/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "gtest/gtest.h" 30 | #include "hs_common.h" 31 | 32 | // Driver: run all the tests (defined in other source files in this directory) 33 | int HS_CDECL main(int argc, char **argv) { 34 | testing::InitGoogleTest(&argc, argv); 35 | 36 | return RUN_ALL_TESTS(); 37 | } 38 | -------------------------------------------------------------------------------- /util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # utility libs 2 | 3 | CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP) 4 | 5 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS} ${HS_CXX_FLAGS}") 6 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} 7 | ${PROJECT_SOURCE_DIR}) 8 | 9 | set_source_files_properties( 10 | ${CMAKE_BINARY_DIR}/tools/ExpressionParser.cpp 11 | PROPERTIES 12 | COMPILE_FLAGS "${RAGEL_C_FLAGS}") 13 | 14 | if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|i386") 15 | ragelmaker(ExpressionParser.rl) 16 | endif() 17 | 18 | if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64") 19 | ragelcopyer(ExpressionParser.rl) 20 | endif() 21 | 22 | set(expressionutil_SRCS 23 | expressions.cpp 24 | expressions.h 25 | ExpressionParser.h 26 | ExpressionParser.cpp 27 | ) 28 | add_library(expressionutil STATIC ${expressionutil_SRCS}) 29 | add_dependencies(expressionutil ragel_ExpressionParser) 30 | 31 | SET(corpusomatic_SRCS 32 | ng_corpus_editor.h 33 | ng_corpus_editor.cpp 34 | ng_corpus_generator.h 35 | ng_corpus_generator.cpp 36 | ng_corpus_properties.h 37 | ng_corpus_properties.cpp 38 | ng_find_matches.h 39 | ng_find_matches.cpp 40 | ) 41 | add_library(corpusomatic STATIC ${corpusomatic_SRCS}) 42 | 43 | set(databaseutil_SRCS 44 | database_util.cpp 45 | database_util.h 46 | ) 47 | add_library(databaseutil STATIC ${databaseutil_SRCS}) 48 | 49 | set(crosscompileutil_SRCS 50 | cross_compile.cpp 51 | cross_compile.h 52 | ) 53 | add_library(crosscompileutil STATIC ${crosscompileutil_SRCS}) 54 | -------------------------------------------------------------------------------- /util/ExpressionParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2017, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef EXPRESSIONPARSER_H 30 | #define EXPRESSIONPARSER_H 31 | 32 | #include "hs_common.h" 33 | 34 | #include 35 | 36 | struct hs_expr_ext; 37 | 38 | bool HS_CDECL readExpression(const std::string &line, std::string &expr, 39 | unsigned int *flags, hs_expr_ext *ext, 40 | bool *must_be_ordered = nullptr); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /util/cross_compile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef CROSS_COMPILE_H 30 | #define CROSS_COMPILE_H 31 | 32 | #include 33 | #include 34 | 35 | struct hs_platform_info; 36 | 37 | std::unique_ptr xcompileReadMode(const char *s); 38 | std::string xcompileUsage(void); 39 | 40 | std::string to_string(const hs_platform_info &p); 41 | 42 | #endif /* CROSS_COMPILE_H */ 43 | -------------------------------------------------------------------------------- /util/database_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef DATABASE_UTIL_H 30 | #define DATABASE_UTIL_H 31 | 32 | struct hs_database; 33 | 34 | bool saveDatabase(const hs_database *db, const char *filename, 35 | bool verbose = false); 36 | 37 | hs_database *loadDatabase(const char *filename, bool verbose = false); 38 | 39 | #endif /* DATABASE_UTIL_H */ 40 | -------------------------------------------------------------------------------- /util/ng_corpus_editor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Intel Corporation nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** \file 30 | * \brief Corpus Editor: applies random transformation to a corpus. 31 | */ 32 | 33 | #ifndef CORPUS_EDITOR_H 34 | #define CORPUS_EDITOR_H 35 | 36 | #include 37 | #include 38 | 39 | #include "ue2common.h" 40 | #include "util/unicode_def.h" 41 | 42 | class CorpusProperties; 43 | 44 | void editCorpus(std::string *corpus, CorpusProperties &props); 45 | void editCorpus(std::vector *corpus, CorpusProperties &props); 46 | 47 | #endif 48 | --------------------------------------------------------------------------------