#!/usr/bin/env awk
#
# Return true if 'val' contains 'txt'.
# If 'ign' is 1, perform a case insensitive comparison.
#
# Parameters:
#   - val   : the value to analyze
#   - txt   : the value to search for in 'val'
#   - [ign] : if set and != 0, perform a case insensitive comparison
#
# Dependencies:
#   - None
#
# See also:
#   - containsi
#   - cvalcontains
#   - cvalcontainsi
#   - rvalcontains
#   - rvalcontainsi
#   - valcontains
#   - valcontainsi
#
# Examples:
#   - tawk 'contains($httpURL, "php")' file.txt
#   - tawk 'contains($httpURL, "admin) { print $httpURL }' file.txt

@include "hdr"

function contains(val, txt, ign) {
    if (hdr()) return __PRIHDR__
    if (ign) {
        val = tolower(val)
        txt = tolower(txt)
    }
    return index(val, txt)
}
