
SCANFILE(1)                                                        SCANFILE(1)

NAME
     scanfile - scan arbitrary files for occurrences of subfiles

SYNOPSIS
     scanfile [-abdq] [-v vn] [-f fl] [-c cfl] [-s start] [-i incr] [-o of]
              bfile sfile

DESCRIPTION
     The scanfile utility scans a file bfile for occurrences of a file sfile.
     Neither bfile nor sfile needs to be text.

     Options:

     -a      Report on every match found.

     -b      After scanning all of bfile, report on the best possible occur-
             rence of sfile.

     -d      Report on the offset of all the failed character matches within
             an acceptable occurrence of sfile in bfile. All values are rela-
             tive to the start of sfile.

     -q      Quiet.  Don't write match reports on the standard output.  Useful
             for branching in shell scripts where only the return value is
             needed.  The -q option take precedence over any reporting called
             for by the -b, -d, and -a options.  However, the -o option will
             behave as expected when these options are set.  The -q option
             does not silence reporting called for by the -v option.

     -v      Report the current offset of the scan every vn increments.

     -f      A total failure count of no more than fl characters is considered
             acceptable at any scan point.  The default value of fl is 0.

     -c      A consecutive failure count of no more than cfl characters is
             considered acceptable at any scan point.  The default value of
             cfl is 0.

     -s      Start scanning start characters from the beginning of bfile. The
             default value of start is 0.

     -i      Set each consecutive scan to begin incr characters from the be-
             ginning of the previous scan.  The default value of incr is 1.

     -o      When reporting a match, also write a file with basename of and
             extension 0x# consisting of the portion of bfile that best
             matched sfile. The value of # will be the offset in bfile where
             the match occurred, and will be in hexadecimal.

     If -b is not set, the first match which satisfies the match criteria will
     generate a report and scanfile will exit.  Otherwise, scanfile will scan
     the entire file bfile until the end is reached.  The last match with the
     minimum number of failures and/or consecutive failures will be reported.

     If -c is set to cfl and -f is not set, then only consecutive character
     failures will be considered in the match criteria.  The total number of
     failures will be bounded only by the size of sfile. This implies that
     when -b is set, the criterion for the best match is the minimum over all
     scans of the maximum number of the consecutive failures.

     If -f is set to fl, then consecutive failures will only be considered if
     -c is also set to cfl. To disallow any consecutive failures, cfl must be
     set to 1.

CAVEATS
     If -b is selected, and sfile is much smaller than bfile, then scanfile
     can take a very long time to finish.

RETURN VALUES
     The scanfile utility exits 0 if an acceptable match was found, and 1 if
     not.  It returns -1 on error.

SEE ALSO
     extrfile(1)

                                 May 18, 1998                                2
