#!/usr/bin/perl -w

#
# dbcoldefine
# Copyright (C) 1991-1998 by John Heidemann <johnh@isi.edu>
# $Id: dbcoldefine,v 1.14 1999/11/23 02:04:29 johnh Exp $
#
# This program is distributed under terms of the GNU general
# public license, version 2.  See the file COPYING
# in $dblibdir for details.
#
sub usage {
    print <<END;
usage: $0 columnName [columnName...]
	Writes a new header before the data with the specified column
	names.

Options:
    -F x    specify field-seperator code (S=double space)

Sample input:
102400	4937974.964736
102400	4585247.875904
102400	5098141.207123

Sample command:
cat DATA/http_bandwidth | dbcoldefine size bw

Sample output:
#h size bw
102400	4937974.964736
102400	4585247.875904
102400	5098141.207123
# | dbcoldefine size bw
END
	exit 1;
}

BEGIN {
    $dblibdir = "/usr/local/lib/jdb";
    push(@INC, $dblibdir);
}
use DbGetopt;
    require "$dblibdir/dblib.pl";

my($debug) = 0;
my($dbopts) = new DbGetopt("F:?", \@ARGV);
my($ch);
while ($dbopts->getopt) {
    $ch = $dbopts->opt;
    if ($ch eq 'F') {
	$fs_code = $dbopts->optarg;
	($fsre, $outfs) = fs_code_to_fsre_outfs($fs_code);
	push(@coloptions, "-F$fs_code");
    } else {
    	&usage;
    };
};
&usage if ($#ARGV < 0);

my(@orig_argv) = @ARGV;
my($prog) = &progname;
@colnames = @ARGV;
&write_header();

while (<STDIN>) {
	print $_;
};

print "#  | $prog ", join(" ", @orig_argv), "\n";
exit 0;

if (0) {
    my $x;
    $x = $coloptions[0] = $fsre = $outfs = $colnames[0];
};
