Skip to content

Commit e7b0d35

Browse files
committed
Added some code to vzic to make it output symlinks for all timezone links specified in the Olson database, not only some of them.
- Legacy-Id: 6498
1 parent 2ea1fb8 commit e7b0d35

6 files changed

Lines changed: 112 additions & 4 deletions

File tree

vzic/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# You will need to set this to the directory that the Olson timezone data
44
# files are in.
55
#
6-
OLSON_DIR = /usr/share/olson-icalendar/
6+
OLSON_DIR = /usr/share/olson
77

88

99
# This is used as the PRODID property on the iCalendar files output.
@@ -23,8 +23,8 @@ PRODUCT_ID = -//IETF Tools//NONSGML ietf-agenda-ical 1.03//EN
2323
# gets expanded to today's date. There is also a vzic-merge.pl which can be
2424
# used to merge changes into a master set of VTIMEZONEs. If a VTIMEZONE has
2525
# changed, it bumps the version number on the end of this prefix. */
26-
TZID_PREFIX = /tools.ietf.org/Olson_%D_1/
27-
#TZID_PREFIX = /
26+
#TZID_PREFIX = /tools.ietf.org/Olson_%D_1/
27+
TZID_PREFIX =
2828

2929
# This is what libical-evolution uses.
3030
#TZID_PREFIX = /softwarestudio.org/Olson_%D_1/

vzic/vzic

11.5 KB
Binary file not shown.

vzic/vzic-parse.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#include <limits.h>
2727
#include <stdio.h>
2828
#include <string.h>
29+
#include <stdlib.h>
30+
#include <unistd.h>
31+
#include <libgen.h>
2932

3033
#include "vzic.h"
3134
#include "vzic-parse.h"
@@ -36,6 +39,7 @@
3639
/* The maximum number of fields on a line. */
3740
#define MAX_FIELDS 12
3841

42+
#define CREATE_SYMLINK 1
3943

4044
typedef enum
4145
{
@@ -487,6 +491,34 @@ parse_link_line (ParsingData *data)
487491
printf ("LINK FROM: %s\tTO: %s\n", from, to);
488492
#endif
489493

494+
#if CREATE_SYMLINK
495+
{
496+
int len = strnlen(to,254);
497+
int dirs = 0;
498+
int i;
499+
for (i = 0; i < len; i++) {
500+
dirs += to[i] == '/' ? 1 : 0;
501+
}
502+
if (dirs) {
503+
char rel_from[255];
504+
char to_dir[255];
505+
char to_path[255];
506+
if (dirs == 1) {
507+
sprintf(rel_from, "../%s.ics", from);
508+
} else if (dirs == 2) {
509+
sprintf(rel_from, "../../%s.ics", from);
510+
} else {
511+
return;
512+
}
513+
sprintf(to_path, "%s/%s.ics", VzicOutputDir, to);
514+
strncpy(to_dir, to_path, 254);
515+
ensure_directory_exists(dirname(to_dir));
516+
//printf("Creating symlink from %s to %s\n", rel_from, to_path);
517+
symlink(rel_from, to_path);
518+
}
519+
}
520+
#else
521+
490522
if (g_hash_table_lookup_extended (data->link_data, from,
491523
(gpointer) &old_from,
492524
(gpointer) &zone_list)) {
@@ -499,6 +531,7 @@ parse_link_line (ParsingData *data)
499531
zone_list = g_list_prepend (zone_list, g_strdup (to));
500532

501533
g_hash_table_insert (data->link_data, from, zone_list);
534+
#endif
502535
}
503536

504537

@@ -537,7 +570,7 @@ parse_year (ParsingData *data,
537570
year = year * 10 + *p - '0';
538571
}
539572

540-
if (year < 1000 || year > 2037) {
573+
if (year < 1000 || year > 2038) {
541574
fprintf (stderr, "%s:%i: Strange year: %s\n%s\n", data->filename,
542575
data->line_number, field, data->line);
543576
exit (1);

vzic/vzic.1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
." Text automatically generated by txt2man-1.4.7
2+
.TH VZIC 1 "October 27, 2013" "vzic-1.3" "Linux Reference Manual"
3+
.SH NAME
4+
\fBvzic \fP- convert Olson timezone database files to iCalendar format
5+
\fB
6+
.SH SYNOPSIS
7+
.nf
8+
.fam C
9+
\fBvzic\fP [\fB--dump\fP] [\fB--dump-changes\fP] [\fB--no-rrules\fP] [\fB--no-rdates\fP] [\fB--pure\fP]
10+
[\fB--output-dir\fP <directory>] [\fB--url-prefix\fP <url>] [\fB--olson-dir\fP <directory>]
11+
.fam T
12+
.fi
13+
.SH DESCRIPTION
14+
\fBvzic\fP is a program to convert the Olson timezone database files into
15+
VTIMEZONE files compatible with the iCalendar specification (RFC2445).
16+
.SH OPTIONS
17+
.TP
18+
.B
19+
\fB--pure\fP
20+
Output the perfect VCALENDAR data, which Outlook won't parse
21+
as it has problems with certain iCalendar constructs.
22+
.TP
23+
.B
24+
\fB--output-dir\fP
25+
specify where to output all the files beneath. The
26+
default is the current directory.
27+
.TP
28+
.B
29+
\fB--url-prefix\fP
30+
Used as the base for the TZURL property in each
31+
VTIMEZONE. The default is to not output TZURL properties.
32+
.PP
33+
Debugging Options:
34+
.TP
35+
.B
36+
\fB--dump\fP
37+
Dump the Rule and Zone data that we parsed from the Olson
38+
timezone files. This is used to test the parsing code.
39+
.TP
40+
.B
41+
\fB--dump-changes\fP
42+
Dumps a list of times when each timezone changed,
43+
and the new local time offset from UTC.
44+
.TP
45+
.B
46+
\fB--no-rrules\fP
47+
Don't output RRULE properties in the VTIMEZONEs. Instead
48+
it will just output RDATEs for each year up to a certain year.
49+
.TP
50+
.B
51+
\fB--no-rdates\fP
52+
Don't output multiple RDATEs in a single VTIMEZONE
53+
component. Instead they will be output separately.
54+
.SH COPYRIGHT
55+
56+
Copyright (C) 2000-2001 Ximian, Inc.
57+
Copyright (C) 2003 Damon Chaplin.
58+
.PP
59+
Author: Damon Chaplin <damon@gnome.org>
60+
.PP
61+
This program is free software; you can redistribute it and/or modify
62+
it under the terms of the GNU General Public License as published by
63+
the Free Software Foundation; either version 2 of the License, or
64+
(at your option) any later version.
65+
.PP
66+
This program is distributed in the hope that it will be useful,
67+
but WITHOUT ANY WARRANTY; without even the implied warranty
68+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69+
GNU General Public License for more details.
70+
.PP
71+
You should have received a copy of the GNU General Public License
72+
along with this program; if not, write to the Free Software
73+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

vzic/vzic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <stdio.h>
2626
#include <string.h>
27+
#include <stdlib.h>
2728

2829
#include "vzic.h"
2930
#include "vzic-parse.h"

vzic/vzic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extern gboolean VzicDumpZoneTranslatableStrings;
4343
extern gboolean VzicNoRRules;
4444
extern gboolean VzicNoRDates;
4545
extern char* VzicUrlPrefix;
46+
extern char* VzicOutputDir;
4647

4748
extern GList* VzicTimeZoneNames;
4849

0 commit comments

Comments
 (0)