#! /bin/sh # # Script to provision a new application layer detector and parser. set -e function usage() { cat < This script will provision content inspection for app-layer decoded buffers. Examples: $0 DNP3 $0 Gopher EOF } fail_if_exists() { path="$1" if test -e "${path}"; then echo "error: ${path} already exists." exit 1 fi } function copy_template_file() { src="$1" dst="$2" echo "Creating ${dst}." sed -e "s/TEMPLATE/${protoname_upper}/g" \ -e "s/template/${protoname_lower}/g" \ -e "s/Template/${protoname}/g" > ${dst} < ${src} } function copy_templates() { detect_h_dst="src/detect-${protoname_lower}-buffer.h" detect_c_dst="src/detect-${protoname_lower}-buffer.c" detect_engine_h_dst="src/detect-engine-${protoname_lower}.h" detect_engine_c_dst="src/detect-engine-${protoname_lower}.c" fail_if_exists ${detect_h_dst} fail_if_exists ${detect_c_dst} fail_if_exists ${detect_engine_h_dst} fail_if_exists ${detect_engine_c_dst} copy_template_file "src/detect-template-buffer.h" ${detect_h_dst} copy_template_file "src/detect-template-buffer.c" ${detect_c_dst} copy_template_file "src/detect-engine-template.h" ${detect_engine_h_dst} copy_template_file "src/detect-engine-template.c" ${detect_engine_c_dst} } function patch_makefile_am() { filename="src/Makefile.am" echo "Patching ${filename}." ed -s ${filename} > /dev/null < /dev/null < /dev/null < /dev/null < /dev/null < /dev/null < /dev/null < /dev/null <