This file is indexed.

/usr/bin/dbfcstocs is in cstocs 1:3.42-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/perl -w

eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
    if 0; # not running under some shell
	eval 'exec perl -S $0 "$@"'
		if 0;


use vars qw( $running_under_some_shell );

=head1 NAME

dbfcstocs -- charset conversion of dbf files

=head1 FORMAT

	dbfcstocs [options] src_encoding dst_encoding [file.dbf outfile.dbf...]

=head1 SYNOPSIS

	dbfcstocs il2 1250 table.dbf table1.dbf

Please see the

	dbfcstocs --help

for short usage info.

=head1 DESCRIPTION

This script is a wrapper around the cstocs utility, please see its man
page first. This program converts charsets in dbf database files. You
can also use the --field-names-charset option which will specify to
which charset to convert the field names. So you can convert file in
Windows-1250 to IOS-8859-2, but have its field names converted to
US-ASCII:

	dbfcstocs --field-names-charset-ascii 1250 il2 table.dbf table1.dbf

After the encoding specifications, pass couples of input dbf file,
output destination file names.

=head1 SEE ALSO

cstocs(1).

=head1 AUTHOR

Jan Pazdziora, adelton@fi.muni.cz.

=cut

use strict;
use Cz::Cstocs;
use Cz::Cstocs::Getopt;
use XBase;

my ($convert, $options) = Cz::Cstocs::Getopt::process_argv(
	{
	'field-names-charset=s' => 'field-names-charset',
	'memofile=s' => 'memofile',
	'memosep=s' => 'memosep',
	'nomemo' => 'ignorememo',
	'help' => sub {
		print "This is dbfcstocs version $Cz::Cstocs::VERSION.\n";
		print STDERR <<EOF;
Usage: dbftocstocs [options] inputenc outputenc [ in.dbf out.dbf ... ]
  where options can be
    --field-names-charset=charset	Convert field names to this charset.
    --memofile=str	Name of the memo (dbt, fpt) file.
    --nomemo		Do not open the memo file.
    --memosep		See dbfdump(1), you probably don't need this.
  and reasonable options of cstocs (see cstocs --help), most notably
  -i doesn't work in dbfcstocs. After the encoding specifications,
  pairs of input and output dbf file names should follow.
Available encodings are:
  @{[ &Cz::Cstocs::available_enc() ]}
EOF
		exit;
		},
	}
	);

my $names_convert;
if (defined $options->{'field-names-charset'}) {
	$names_convert = new Cz::Cstocs 
		$options->{'inputenc'}, $options->{'field-names-charset'}, 'one-by-one' => 1 or die "Error initializing field names conversion: $Cz::Cstocs::errstr.\n";
	}

### use Data::Dumper; print "Options: ", Dumper $options;

if (not defined $convert) {
	print STDERR $@;
	exit(1);
	}

my $length_of_argv = @ARGV;
if ($length_of_argv == 0) {
	die "Need file names to convert.\n";
	}
elsif ($length_of_argv > 2 and (($length_of_argv % 2) == 1)) {
	die "Need output file name for the last dbf.\n";
	}

while (@ARGV) {
	my $filename = shift @ARGV;
	my $outfilename = shift @ARGV;
	$outfilename = 'out_' . $filename unless defined $outfilename;

	my %other_options = ();
	for (qw!memofile memosep ignorememo!) {
		$other_options{$_} = $options->{$_} if defined $options->{$_};
		}

	my $table = new XBase $filename, %other_options;
	unless (defined $table) {
		print "Error reading $filename: $XBase::errstr";
		next;
		}

	%other_options = ();
	if (defined $names_convert) {
		$other_options{'field_names'} = [ map { &$names_convert($_) } $table->field_names ];
		}

	my $out = $table->create("name" => $outfilename, %other_options)
		or die "Error creating output file: $outfilename: $XBase::errstr";

	my @types = $table->field_types;
	my @convert_fields = ();
	for (my $i = 0; $i < @types; $i++) {
		push @convert_fields, $i if $types[$i] eq 'C' or $types[$i] eq 'M';
		}
	for my $i (0 .. $table->last_record) {
		my @data = $table->get_record($i);
		my $deleted = shift @data;
		for (@data[@convert_fields]) {
		### print STDERR "Converting $_ ";
			$_ = &$convert($_);
		### print STDERR "to $_\n";
			}
		$out->set_record($i, @data);
		$out->delete_record($i) if $deleted;
		}
	$out->close;
	$table->close;
	}