This file is indexed.

/usr/share/perl5/SyncBBDB/pilotBBDBTranslate.pm is in syncbbdb 2.6-1.

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

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
#------------------------------------------------------------------------------
#   $Date: 2001/11/04 13:17:57 $
#   RCS: $Id: pilotBBDBTranslate.pm,v 1.1.1.1 2001/11/04 13:17:57 tdeweese Exp $
#------------------------------------------------------------------------------

package pilotBBDBTranslate;

use FileHandle;

use strict;

sub new {
    my $type = shift;
    my $self = {};

    bless($self, $type);

    $self->{'host'} = shift;
    $self->{'file'} = shift;

    $self->{'p2b'} = {};
    $self->{'b2p'} = {};

    $self->readFile();

    return $self;
}

sub readFile {
    my $self = shift;

    
    if ((! defined $self->{'file'}) || 
	(! -f      $self->{'file'})) {
	# Give them the most important stuff.
	$self->addMapping("E-mail", "net");
	$self->addMapping("Title",  "title");
	$self->addMapping("Note",   "notes");
	$self->addMapping("AKA",    "aka");
	$self->addMapping("WWW",    "www");
	return;
    }

    my $FILE = new FileHandle($self->{'file'});
    while (<$FILE>) {
	next if (/^\s*\#/);
	next if (/^\s*\$/);
	chop;

	if (/^\s*([^\s]*)\s+(.*[^\s])/) {
	    $self->addMapping($1, $2);
	}
    }
}

sub writeFile {
    my $self = shift;
    
    my $FILE =new FileHandle(">" .$self->{'file'});

    if (!defined $FILE) {
	$self->{'host'}->output("Unable to rewrite translations file: " .
				$self->{'file'} . "\n");
	return;
    }

    print $FILE "# This file describes the mapping between BBDB fields\n";
    print $FILE "# and pilot fields.\n\n";
    print $FILE "# The format is: <pilot field> <bbdb field>\n";
    print $FILE "# The pilot field may not contain a space,\n";

    my %used;
    foreach my $p (keys %{$self->{'p2b'}}) {
	print $FILE $p . " " . $self->{'p2b'}{$p} . "\n";
	$used{$self->{'p2b'}{$p}} = 1;
    }
    foreach my $b (keys %{$self->{'b2p'}}) {
	next if (defined $used{$b});
	print $FILE $self->{'b2p'}{$b} . " " . $b . "\n";
    }
}

sub addMapping {
    my $self = shift;
    my $pilot = shift;
    my $bbdb = shift;
    
    
    if (! defined $self->{'p2b'}{$pilot}) {
	$self->{'p2b'}{$pilot} = $bbdb;
    }

    if (! defined $self->{'b2p'}{$bbdb}) {
	$self->{'b2p'}{$bbdb} = $pilot;
    }
}

sub finish {
    my $self = shift;
}

sub getForBBDB {
    my $self = shift;
    my $pilot = shift;

    return $self->{'p2b'}{$pilot} || $pilot;
}

sub getForPilot {
    my $self = shift;
    my $bbdb = shift;

    # hack for old mapping scheme...
    return $' if ($bbdb =~ m/pilot-field-/);
    return $' if ($bbdb =~ m/pilot-phone-/);

    return $self->{'b2p'}{$bbdb} || $bbdb;
}

sub getBBDBName {
    my $self = shift;
    my $pbbdb = shift;
    my $field = shift;

    my $name;
    if ($field =~ m/^Field.:(.)/) {
	my $idx = $1;
	$name = $pbbdb->{'phoneLabels'}[$idx];
    } elsif ($field =~ m/^Custom(.)/) {
	my $idx = $1; $idx--;
	$name = $pbbdb->getCustLabel($idx);
    } else {
	$name = $field;
    }

    if (defined $self->{'p2b'}{$name}) {
	return $self->{'p2b'}{$name}
    } else {
	return $name;
    }
}

1;