File: find-dns-calls

package info (click to toggle)
dnssec-tools 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 16,064 kB
  • sloc: perl: 44,399; ansic: 31,547; cpp: 21,306; sh: 15,813; xml: 2,113; makefile: 1,390; pascal: 836; python: 290; csh: 11
file content (28 lines) | stat: -rwxr-xr-x 601 bytes parent folder | download
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"