comparison calcon.pl @ 1:144819f5d2f6

Initial revision
author kono
date Fri, 24 Jan 2003 13:41:18 +0900
parents
children 13949e4d6f18
comparison
equal deleted inserted replaced
0:111809a2ea45 1:144819f5d2f6
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',
27 'Entourage' => 'Calcon::Entourage_write',
28 'Print' => 'Calcon::Print_write',
29 'File' => 'Calcon::File_write',
30 );
31
32 use Getopt::Std;
33
34 getopts('f:t:ndhO:acF');
35
36 if ($opt_h) {
37 print "Usage: $0 [-d -n] -f input_type -t output_type inputfile\n";
38 print " input type: ",join(" ",keys %input),"\n";
39 print " output type: ",join(" ",keys %output),"\n";
40 exit 0;
41 }
42
43 # print "option: $opt_f $opt_t\n";
44 my $from_opts;
45 my $to_opts;
46
47 if (! @ARGV) { @ARGV = ('/dev/stdin'); }
48 foreach my $file ( @ARGV ) {
49 my ($obj,$out);
50
51 $opt_f = 'file' if (!$opt_f);
52 $opt_t = 'file' if (!$opt_t);
53
54 if ($opt_f =~ s/:.*//) { $from_opts = $&; }
55 $opt_f =~ s/(\W)/\\$1/g;
56 foreach my $key ( keys %input) {
57 if ($key =~ /^$opt_f/i) {
58 $obj = $input{$key};
59 last;
60 }
61 }
62 $obj = $obj->new($from_opts);
63
64 if ($opt_t =~ s/:.*//) { $to_opts = $&; }
65 $opt_t =~ s/(\W)/\\$1/g;
66 foreach my $key ( keys %output) {
67 if ($key =~ /^$opt_t/i) {
68 $out = $output{$key};
69 last;
70 }
71 }
72 $out = $out->new($to_opts);
73 # print "$obj $out\n";
74 $obj->set_output($out);
75
76 $out->{'-file-out'} = $opt_n;
77
78 foreach my $o ( $obj, $out) {
79 $o->set_debug(1) if ($opt_d);
80 $o->{'-address-only'} = 1 if ($opt_a);
81 $o->{'-calendar-only'} = 1 if ($opt_c);
82 $o->{'-future-only'} = 1 if ($opt_F);
83 }
84
85 # print "option: $opt_f $opt_t\n";
86 $obj -> decode($file);
87 }
88
89 #
90
91 __END__
92
93 =head1 NAME
94
95 calcon.pl -- Convert Various Calendar/Address data format
96
97 =head1 SYNOPSIS
98
99 perl calcon.pl -f from -t form [-d] [-n]
100
101 =head1 DESCRIPTION
102
103 -f from-format
104 File format
105 Zaurus Read Zaurus MI C1 Compact Flast
106 Xcalendar
107 vCal/vCard
108 iApp via Applescript
109 Entourage via Applescript
110
111
112 -t from-format
113 File format
114 iCal and Addres Book Applescript execution (-f put result into files in script-out )
115 vCal/vCard
116 Zaurus SLA-300
117 Entourage via Applescript
118
119 -a addres only
120 -c calendar only
121 -F future only
122
123 -h show help
124 -d debug
125 -n non-execution mode for applescript
126 scripts are put into script-out directory
127
128 =cut