Mercurial > hg > Applications > Calcon
diff calcon.pl @ 1:144819f5d2f6
Initial revision
author | kono |
---|---|
date | Fri, 24 Jan 2003 13:41:18 +0900 |
parents | |
children | 13949e4d6f18 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/calcon.pl Fri Jan 24 13:41:18 2003 +0900 @@ -0,0 +1,128 @@ +#!/usr/bin/perl + +use Calcon; + +use strict; +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK + $opt_f $opt_t $opt_n $opt_d $opt_h $opt_F $opt_O $opt_a $opt_c +); + +my %input = ( + 'Zaurus' => 'Calcon::Zaurus_read', + 'Backup Zaurus' => 'Calcon::Zaurus_backup_read', + 'Xcalendar' => 'Calcon::Xcalendar_read', + 'Vcard' => 'Calcon::Vcard_read', + 'SLA300' => 'Calcon::Sla300_read', + 'iApp' => 'Calcon::iApp_read', + 'Entourage' => 'Calcon::Entourage_read', + 'File' => 'Calcon::File_read', +); + +my %output = ( + 'Xcalendar' => 'Calcon::Xcalendar_write', + 'Vcard' => 'Calcon::Vcard_write', + 'SLA300' => 'Calcon::Sla300_write', + 'AppleScript' => 'Calcon::iApp_write', + 'iApp' => 'Calcon::iApp_write', + 'Entourage' => 'Calcon::Entourage_write', + 'Print' => 'Calcon::Print_write', + 'File' => 'Calcon::File_write', +); + +use Getopt::Std; + +getopts('f:t:ndhO:acF'); + +if ($opt_h) { + print "Usage: $0 [-d -n] -f input_type -t output_type inputfile\n"; + print " input type: ",join(" ",keys %input),"\n"; + print " output type: ",join(" ",keys %output),"\n"; + exit 0; +} + +# print "option: $opt_f $opt_t\n"; +my $from_opts; +my $to_opts; + +if (! @ARGV) { @ARGV = ('/dev/stdin'); } +foreach my $file ( @ARGV ) { + my ($obj,$out); + + $opt_f = 'file' if (!$opt_f); + $opt_t = 'file' if (!$opt_t); + + if ($opt_f =~ s/:.*//) { $from_opts = $&; } + $opt_f =~ s/(\W)/\\$1/g; + foreach my $key ( keys %input) { + if ($key =~ /^$opt_f/i) { + $obj = $input{$key}; + last; + } + } + $obj = $obj->new($from_opts); + + if ($opt_t =~ s/:.*//) { $to_opts = $&; } + $opt_t =~ s/(\W)/\\$1/g; + foreach my $key ( keys %output) { + if ($key =~ /^$opt_t/i) { + $out = $output{$key}; + last; + } + } + $out = $out->new($to_opts); +# print "$obj $out\n"; + $obj->set_output($out); + + $out->{'-file-out'} = $opt_n; + + foreach my $o ( $obj, $out) { + $o->set_debug(1) if ($opt_d); + $o->{'-address-only'} = 1 if ($opt_a); + $o->{'-calendar-only'} = 1 if ($opt_c); + $o->{'-future-only'} = 1 if ($opt_F); + } + +# print "option: $opt_f $opt_t\n"; + $obj -> decode($file); +} + +# + +__END__ + +=head1 NAME + +calcon.pl -- Convert Various Calendar/Address data format + +=head1 SYNOPSIS + + perl calcon.pl -f from -t form [-d] [-n] + +=head1 DESCRIPTION + + -f from-format + File format + Zaurus Read Zaurus MI C1 Compact Flast + Xcalendar + vCal/vCard + iApp via Applescript + Entourage via Applescript + + + -t from-format + File format + iCal and Addres Book Applescript execution (-f put result into files in script-out ) + vCal/vCard + Zaurus SLA-300 + Entourage via Applescript + + -a addres only + -c calendar only + -F future only + + -h show help + -d debug + -n non-execution mode for applescript + scripts are put into script-out directory + +=cut