1
|
1 #!/usr/bin/perl
|
|
2
|
|
3 use Calcon;
|
|
4
|
|
5 use strict;
|
|
6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK
|
|
7 $opt_f $opt_t $opt_n $opt_d $opt_h $opt_F $opt_O $opt_a $opt_c
|
|
8 );
|
|
9
|
|
10 my %input = (
|
|
11 'Zaurus' => 'Calcon::Zaurus_read',
|
|
12 'Backup Zaurus' => 'Calcon::Zaurus_backup_read',
|
|
13 'Xcalendar' => 'Calcon::Xcalendar_read',
|
|
14 'Vcard' => 'Calcon::Vcard_read',
|
|
15 'SLA300' => 'Calcon::Sla300_read',
|
|
16 'iApp' => 'Calcon::iApp_read',
|
|
17 'Entourage' => 'Calcon::Entourage_read',
|
|
18 'File' => 'Calcon::File_read',
|
|
19 );
|
|
20
|
|
21 my %output = (
|
|
22 'Xcalendar' => 'Calcon::Xcalendar_write',
|
|
23 'Vcard' => 'Calcon::Vcard_write',
|
|
24 'SLA300' => 'Calcon::Sla300_write',
|
|
25 'AppleScript' => 'Calcon::iApp_write',
|
|
26 'iApp' => 'Calcon::iApp_write',
|
8
|
27 'Address Book' => 'Calcon::Vcard_Apple_write',
|
1
|
28 'Entourage' => 'Calcon::Entourage_write',
|
|
29 'Print' => 'Calcon::Print_write',
|
|
30 'File' => 'Calcon::File_write',
|
|
31 );
|
|
32
|
|
33 use Getopt::Std;
|
|
34
|
|
35 getopts('f:t:ndhO:acF');
|
|
36
|
|
37 if ($opt_h) {
|
|
38 print "Usage: $0 [-d -n] -f input_type -t output_type inputfile\n";
|
|
39 print " input type: ",join(" ",keys %input),"\n";
|
|
40 print " output type: ",join(" ",keys %output),"\n";
|
|
41 exit 0;
|
|
42 }
|
|
43
|
|
44 # print "option: $opt_f $opt_t\n";
|
|
45 my $from_opts;
|
|
46 my $to_opts;
|
|
47
|
|
48 if (! @ARGV) { @ARGV = ('/dev/stdin'); }
|
|
49 foreach my $file ( @ARGV ) {
|
|
50 my ($obj,$out);
|
|
51
|
|
52 $opt_f = 'file' if (!$opt_f);
|
|
53 $opt_t = 'file' if (!$opt_t);
|
|
54
|
|
55 if ($opt_f =~ s/:.*//) { $from_opts = $&; }
|
|
56 $opt_f =~ s/(\W)/\\$1/g;
|
|
57 foreach my $key ( keys %input) {
|
|
58 if ($key =~ /^$opt_f/i) {
|
|
59 $obj = $input{$key};
|
|
60 last;
|
|
61 }
|
|
62 }
|
|
63 $obj = $obj->new($from_opts);
|
|
64
|
|
65 if ($opt_t =~ s/:.*//) { $to_opts = $&; }
|
7
|
66 $to_opts .= '-n' if ($opt_n);
|
1
|
67 $opt_t =~ s/(\W)/\\$1/g;
|
|
68 foreach my $key ( keys %output) {
|
|
69 if ($key =~ /^$opt_t/i) {
|
|
70 $out = $output{$key};
|
|
71 last;
|
|
72 }
|
|
73 }
|
|
74 $out = $out->new($to_opts);
|
|
75 # print "$obj $out\n";
|
|
76 $obj->set_output($out);
|
|
77
|
7
|
78 # $out->{'-file-out'} = $opt_n; too late
|
1
|
79
|
|
80 foreach my $o ( $obj, $out) {
|
|
81 $o->set_debug(1) if ($opt_d);
|
|
82 $o->{'-address-only'} = 1 if ($opt_a);
|
|
83 $o->{'-calendar-only'} = 1 if ($opt_c);
|
|
84 $o->{'-future-only'} = 1 if ($opt_F);
|
|
85 }
|
|
86
|
|
87 # print "option: $opt_f $opt_t\n";
|
|
88 $obj -> decode($file);
|
|
89 }
|
|
90
|
|
91 #
|
|
92
|
|
93 __END__
|
|
94
|
|
95 =head1 NAME
|
|
96
|
|
97 calcon.pl -- Convert Various Calendar/Address data format
|
|
98
|
|
99 =head1 SYNOPSIS
|
|
100
|
|
101 perl calcon.pl -f from -t form [-d] [-n]
|
|
102
|
|
103 =head1 DESCRIPTION
|
|
104
|
|
105 -f from-format
|
|
106 File format
|
|
107 Zaurus Read Zaurus MI C1 Compact Flast
|
|
108 Xcalendar
|
|
109 vCal/vCard
|
|
110 iApp via Applescript
|
|
111 Entourage via Applescript
|
|
112
|
|
113
|
|
114 -t from-format
|
|
115 File format
|
|
116 iCal and Addres Book Applescript execution (-f put result into files in script-out )
|
|
117 vCal/vCard
|
|
118 Zaurus SLA-300
|
|
119 Entourage via Applescript
|
8
|
120 Address Book (Mac OS X 10.4 Address Book)
|
1
|
121
|
|
122 -a addres only
|
|
123 -c calendar only
|
|
124 -F future only
|
|
125
|
|
126 -h show help
|
|
127 -d debug
|
|
128 -n non-execution mode for applescript
|
|
129 scripts are put into script-out directory
|
|
130
|
|
131 =cut
|