#!/usr/pkg/bin/perl -w

#
# dbfilevalidate.pm
# Copyright (C) 2007 by John Heidemann <johnh@isi.edu>
# $Id: 3136ba0e1e91c68aac840a76440e41e75b0e4666 $
#
# This program is distributed under terms of the GNU general
# public license, version 2.  See the file COPYING
# in $dblibdir for details.
#



=head1 NAME

dbfilevalidate - insure the source input is a well-formed Fsdb file

=head1 SYNOPSIS

    dbfilevalidate [-vc]

=head1 DESCRIPTION

Validates the input file to make sure it is a well-formed
fsdb file.  If the file is well-formed, it outputs the whole file
and exits with a good exit code.  For invalid files,
it exits with an error exit code and embedded error messages
in the stream as comments with "***" in them.

Currently this program checks for rows with missing or extra columns.

=head1 OPTIONS

=over 4

=item B<-v> or B<--errors-only>

Output only broken lines, not the whole thing.

=item B<-c> or B<--correct>

Correct errors, if possible.  Pad out rows with the empty value;
truncate rows with extra values.
If errors can be corrected the program exits with a good return code.

=item C<-e E> or C<--empty E>

give value E as the value for empty (null) records

=back

=for comment
begin_standard_fsdb_options

This module also supports the standard fsdb options:

=over 4

=item B<-d>

Enable debugging output.

=item B<-i> or B<--input> InputSource

Read from InputSource, typically a file name, or C<-> for standard input,
or (if in Perl) a IO::Handle, Fsdb::IO or Fsdb::BoundedQueue objects.

=item B<-o> or B<--output> OutputDestination

Write to OutputDestination, typically a file name, or C<-> for standard output,
or (if in Perl) a IO::Handle, Fsdb::IO or Fsdb::BoundedQueue objects.

=item B<--autorun> or B<--noautorun>

By default, programs process automatically,
but Fsdb::Filter objects in Perl do not run until you invoke
the run() method.
The C<--(no)autorun> option controls that behavior within Perl.

=item B<--help>

Show help.

=item B<--man>

Show full manual.

=back

=for comment
end_standard_fsdb_options


=head1 SAMPLE USAGE

=head2 Input:

    #fsdb sid cid
    1 10
    2
    1 12
    2 12

=head2 Command:

    cat TEST/dbfilevalidate_ex.in | dbvalidate

=head2 Output:

    #fsdb sid cid
    1 10
    2
    # *** line above is missing field cid.
    1 12
    2 12
    #  | dbfilevalidate 


=head1 SEE ALSO

L<Fsdb>.


=cut


# WARNING: This code is derived from dbfilevalidate.pm; that is the master copy.

use Fsdb::Filter::dbfilevalidate;
my $f = new Fsdb::Filter::dbfilevalidate(@ARGV);
$f->setup_run_finish;  # or could just --autorun
exit 0;


=head1 AUTHOR and COPYRIGHT

Copyright (C) 1991-2008 by John Heidemann <johnh@isi.edu>

This program is distributed under terms of the GNU general
public license, version 2.  See the file COPYING
with the distribution for details.

=cut

1;
