set -e
+# Fail if "ed" is not available.
+if ! which ed > /dev/null 2>&1; then
+ echo "error: the program \"ed\" is required for this script"
+ exit 1
+fi
+
function usage() {
cat <<EOF
EOF
}
+# Make sure we are running from the correct directory.
+set_dir() {
+ if [ -e ./suricata.c ]; then
+ cd ..
+ elif [ -e ./src/suricata.c ]; then
+ # Do nothing.
+ true
+ else
+ echo "error: this does not appear to be a suricata source directory."
+ exit 1
+ fi
+}
+
fail_if_exists() {
path="$1"
if test -e "${path}"; then
EOF
}
+set_dir
+
protoname="$1"
buffername="$2"
exit 1
fi
+# Make sure the protocol name looks like a proper name (starts with a
+# capital letter).
+case "${protoname}" in
+
+ [[:upper:]]*)
+ # OK.
+ ;;
+
+ "")
+ usage
+ exit 1
+ ;;
+
+ *)
+ echo "error: protocol name must beging with an upper case letter"
+ exit 1
+ ;;
+
+esac
+
protoname_lower=$(printf ${protoname} | tr '[:upper:]' '[:lower:]')
protoname_upper=$(printf ${protoname} | tr '[:lower:]' '[:upper:]')
buffername_lower=$(printf ${buffername} | tr '[:upper:]' '[:lower:]')
set -e
+# Fail if "ed" is not available.
+if ! which ed > /dev/null 2>&1; then
+ echo "error: the program \"ed\" is required for this script"
+ exit 1
+fi
+
function usage() {
cat <<EOF
EOF
}
+# Make sure we are running from the correct directory.
+set_dir() {
+ if [ -e ./suricata.c ]; then
+ cd ..
+ elif [ -e ./src/suricata.c ]; then
+ # Do nothing.
+ true
+ else
+ echo "error: this does not appear to be a suricata source directory."
+ exit 1
+ fi
+}
+
fail_if_exists() {
path="$1"
if test -e "${path}"; then
EOF
}
+set_dir
+
protoname="$1"
-if [ "${protoname}" = "" ]; then
- usage
- exit 1
-fi
+# Make sure the protocol name looks like a proper name (starts with a
+# capital letter).
+case "${protoname}" in
+
+ [[:upper:]]*)
+ # OK.
+ ;;
+
+ "")
+ usage
+ exit 1
+ ;;
+
+ *)
+ echo "error: protocol name must beging with an upper case letter"
+ exit 1
+ ;;
+
+esac
protoname_lower=$(printf ${protoname} | tr '[:upper:]' '[:lower:]')
protoname_upper=$(printf ${protoname} | tr '[:lower:]' '[:upper:]')
EOF
}
+# Make sure we are running from the correct directory.
+set_dir() {
+ if [ -e ./suricata.c ]; then
+ cd ..
+ elif [ -e ./src/suricata.c ]; then
+ # Do nothing.
+ true
+ else
+ echo "error: this does not appear to be a suricata source directory."
+ exit 1
+ fi
+}
+
fail_if_exists() {
path="$1"
if test -e "${path}"; then
EOF
}
+# Main...
+
+set_dir
+
protoname="$1"
# Make sure the protocol name looks like a proper name (starts with a
echo
}
+# Make sure we are running from the correct directory.
+set_dir() {
+ if [ -e ./suricata.c ]; then
+ # Do nothing.
+ true
+ elif [ -e ./src/suricata.c ]; then
+ cd src
+ else
+ echo "error: this does not appear to be a suricata source directory."
+ exit 1
+ fi
+}
+
if [ $# -ne "1" ]; then
Usage
echo "ERROR: call with one argument"
#echo $FILE_C
#echo $FILE_H
-if [ ! -e ../configure.ac ] || [ ! -e Makefile.am ]; then
- Usage
- echo "ERROR: call from src/ directory"
- exit 1
-fi
+set_dir
+
if [ ! -e decode-template.c ] || [ ! -e decode-template.h ]; then
Usage
echo "ERROR: input files decode-template.c and/or decode-template.h are missing"
echo
}
+# Make sure we are running from the correct directory.
+set_dir() {
+ if [ -e ./suricata.c ]; then
+ # Do nothing.
+ true
+ elif [ -e ./src/suricata.c ]; then
+ cd src
+ else
+ echo "error: this does not appear to be a suricata source directory."
+ exit 1
+ fi
+}
+
if [ $# -ne "1" ]; then
Usage
echo "ERROR: call with one argument"
#echo $FILE_C
#echo $FILE_H
-if [ ! -e ../configure.ac ] || [ ! -e Makefile.am ]; then
- Usage
- echo "ERROR: call from src/ directory"
- exit 1
-fi
+set_dir
+
if [ ! -e detect-template.c ] || [ ! -e detect-template.h ]; then
Usage
echo "ERROR: input files detect-template.c and/or detect-template.h are missing"