/usr/share/perl5/bbdb/bbdbPhone.pm is in syncbbdb 2.3-6.2.
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 | #------------------------------------------------------------------------------
# $Date: 2000/08/07 13:07:00 $
# RCS: $Id: bbdbPhone.pm,v 1.7 2000/08/07 13:07:00 deweese Exp $
#------------------------------------------------------------------------------
package bbdbPhone;
use strict;
use bbdb::bbdb;
sub new {
my $type = shift;
my $self = {};
my $str = shift;
my $ver = shift || $bbdb::DEFAULT_VERSION;
bless ($self, $type);
$self->parse($str, $ver);
$self;
}
sub parse
{
my $self = shift;
my $str = shift;
my $ver = shift || $bbdb::DEFAULT_VERSION;
my ($title, $area, $exch, $num, $ext);
($title, $area, $exch, $num)=
($str =~ /^\"((?:[^\\\"]|\\.)*)\"\s+(\d+)\s+(\d+)\s+(\d+)/);
## didn't match above so it's two strings...
if (defined $area)
{
## Extension may be 'nil'...
if ($' =~ m/(\d+)/) {
$ext = $1;
}
$self->{'title'} = $title;
if ((defined $area) && ($area ne "0")) {
$self->{'area'} = bbdb::mkStr($area);
}
$self->{'exch'} = bbdb::mkStr($exch);
$self->{'num'} = bbdb::mkStr($num);
if ((defined $ext) && ($ext ne "0")) {
$self->{'ext'} = bbdb::mkStr($ext);
}
}
else
{
$str =~ /^\"((?:[^\\\"]|\\.)*)\"\s+\"((?:[^\\\"]|\\.)*)\"$/;
($title, $num) = ($1, $2);
$self->{'title'} = $title;
$self->{'num'} = $num;
}
$self;
}
sub toString
{
my $self = shift;
return $self->{'title'} . ": " . $self->phoneString();
}
sub phoneString
{
my $self = shift;
if (defined $self->{'exch'})
{
my $ret;
$ret = sprintf ("(%03d) ",$self->{'area'}) if (defined $self->{'area'});
$ret .= sprintf ("%03d-%04d", $self->{'exch'}, $self->{'num'});
$ret .= " x" . $self->{'ext'} if (defined $self->{'ext'});
return $ret;
}
return $self->{'num'};
}
sub print
{
my $self = shift;
my $file = shift || \*STDOUT;
print $file $self->toString() . "\n";
}
sub ePStr
{
my $self = shift;
my $ver = shift || $bbdb::DEFAULT_VERSION;
my $ret = "[";
$ret .= bbdb::eStr($self->{'title'}) . " ";
if (not defined $self->{'exch'})
{
$ret .= bbdb::eStr($self->{'num'});
}
else
{
if (defined $self->{'area'}) {
$ret .= sprintf("%03d ", $self->{'area'});
} else {
$ret .= "0 ";
}
$ret .= sprintf("%03d %04d ", $self->{'exch'}, $self->{'num'});
if (defined $self->{'ext'}) {
$ret .= $self->{'ext'};
} else {
$ret .= "nil";
}
}
return $ret . "]";
}
1;
|