Läsa vcard i FreeBSD
Anders Arnholm
anders at Arnholm.nu
Thu May 3 10:49:45 CEST 2007
On Wed, May 02, 2007 at 10:10:39PM +0200, G Hasse wrote:
> Hej!
>
> Min telefon har en massa "vcard" där alla telefonnummer och
> adresser finns. Känner någon till något program som kan läsa dessa,
> och som funkar under FreeBSD?
Jag har ett litet vcard progrem kopplat till mutt för att visa vcard
attacade i mail, :
#!/usr/bin/perl -W
#
# Copyright (2004) Anders Arnholm <anders at arnholm.nu>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#
use strict;
# Find data
my($debug) = 0;
my($name, $email, $homepage, $workphone, $homephone, $celluarphone, $fax);
while(<>) {
chomp;
my(@values) = split(":", $_);
if(uc($values[0]) eq "FN") {
print "Name (FN) -> $_\n" if($debug);
$name = $values[1];
} elsif(uc($values[0]) eq "N") {
unless($name) { # Perfere the FN form
print "Name (N) -> $_\n" if($debug);
my(@ntmp) = split(";", $values[1]);
$name = $ntmp[1] ." ". $ntmp[0];
print "Name (N) -> $name, $_\n" if($debug);
}
} elsif(uc($values[0]) =~ "^EMAIL") {
print "Email (N) -> $_\n" if($debug);
my($stmp) = uc($values[0]);
if($stmp =~ /INTERNET/) { # The only interesting mail type
if(! $email || $stmp =~ /PERF/) { # don't have mail or perfered.
$email = $values[1];
print "Email (N) -> $email [$_]\n" if($debug);
}
}
} elsif(uc($values[0]) =~ "^TEL") {
if(uc($values[0]) =~ /CEL/ && ! $celluarphone) {
$celluarphone = $values[1];
print "CellPhone (TEL) -> $celluarphone [$_]\n" if($debug);
}
if(uc($values[0]) =~ /WORK/ && ! $workphone) {
$workphone = $values[1];
print "Work phone (TEL) -> $workphone [$_]\n" if($debug);
}
if(uc($values[0]) =~ /HOME/ && ! $homephone) {
$homephone = $values[1];
print "Home phone (TEL) -> $homephone [$_]\n" if($debug);
}
if(uc($values[0]) =~ /FAX/ && ! $fax) {
$fax = $values[1];
print "Fax (TEL) -> $fax [$_]\n" if($debug);
}
} elsif(uc($values[0]) eq "URL") {
shift(@values);
$homepage = join(":", @values);
print "Homepage (URL) -> $homepage [$_]\n" if($debug);
}
}
# Display data
if($name) {
print " vCard: $name";
print " <$email>" if($email);
print "\n : $homepage" if($homepage);
print "\n : "if($workphone || $celluarphone || $fax);
print " $workphone (work) " if($workphone);
print " $celluarphone (home) " if($celluarphone);
print " $fax (fax)" if($fax);
print "\n";
}
exit;
--
o_ Anders Arnholm, HiQ - Consultant
o/ /\ anders at arnholm.nu Phone : +46-703-160969
/|_, \\ http://anders.arnholm.nu/ http://www.hiq.se
/
`
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.stacken.kth.se/pipermail/bus/attachments/20070503/ebeaaac9/attachment.bin
More information about the BUS
mailing list