1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#!/bin/bash
PATH=/bin:/usr/bin
DNSCALLS="[^a-zA-Z_](res_n*(query|search|send)|get(hostby|addrinfo|rrsetbyname))[a-zA-Z0-9_]*[ ]*\("
usage()
{
echo "Usage: $0 [path] ..."
echo " Search paths for C/C++ files with DNS calls."
echo " If no path is specified, the current directory is searched."
exit 1
}
while [ ! "x$1" = "x" ]
do
if [ -d "$1" ]; then
DIRS="$DIRS $1"
else
echo "Error: non-existant directory $1"
usage
fi
shift
done
if [ "x$DIRS" = "x" ]; then
DIRS="."
fi
find $DIRS -type f -print |egrep "\.(c|cc|C|CC|h|H)$"|xargs egrep -n "$DNSCALLS"
|