hs_error_t err = hs_valid_platform();
if (err == HS_ARCH_ERROR) {
fprintf(stderr, "%s\n", "the system does not support Hyperscan");
return -1;
}
return 0;
}
include
include
include <hs/hs.h>
include <hs/hs_runtime.h>
int eventHandler(unsigned int id, unsigned long long from, unsigned long long to, unsigned int flags, void context) {
fprintf(stderr, "%u:%llu:%llu:%u\n", id, from, to, flags);
((int*)context) = 1;
return 0;
}
概述
Hyperscan是Intel开发的正则表达式匹配库,基于X86平台以PCRE为原型而开发的。以BSD协议开源。通常被用于网络防护上。
代码:https://github.com/intel/hyperscan 例子:https://github.com/intel/hyperscan/blob/develop/examples/simplegrep.c 文档:http://intel.github.io/hyperscan/dev-reference/ 相关介绍:https://www.sdnlab.com/18773.html
安装
macOSX: 直接brew install hyperscan
例子
int main(void) { const char *version = hs_version(); fprintf(stderr, "hs version: %s\n", version);
}
include
include
include <hs/hs.h>
include <hs/hs_runtime.h>
int eventHandler(unsigned int id, unsigned long long from, unsigned long long to, unsigned int flags, void context) { fprintf(stderr, "%u:%llu:%llu:%u\n", id, from, to, flags); ((int*)context) = 1; return 0; }
int main(void) { const char *version = hs_version(); fprintf(stderr, "hs version: %s\n", version);
}
总结