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
This commit is contained in:
Henrik Levkowetz 2013-10-27 19:54:31 +00:00
parent 2ea1fb8438
commit e7b0d357b7
6 changed files with 112 additions and 4 deletions

View file

@ -3,7 +3,7 @@
# You will need to set this to the directory that the Olson timezone data
# files are in.
#
OLSON_DIR = /usr/share/olson-icalendar/
OLSON_DIR = /usr/share/olson
# 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
# gets expanded to today's date. There is also a vzic-merge.pl which can be
# used to merge changes into a master set of VTIMEZONEs. If a VTIMEZONE has
# changed, it bumps the version number on the end of this prefix. */
TZID_PREFIX = /tools.ietf.org/Olson_%D_1/
#TZID_PREFIX = /
#TZID_PREFIX = /tools.ietf.org/Olson_%D_1/
TZID_PREFIX =
# This is what libical-evolution uses.
#TZID_PREFIX = /softwarestudio.org/Olson_%D_1/

BIN
vzic/vzic

Binary file not shown.

View file

@ -26,6 +26,9 @@
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <libgen.h>
#include "vzic.h"
#include "vzic-parse.h"
@ -36,6 +39,7 @@
/* The maximum number of fields on a line. */
#define MAX_FIELDS 12
#define CREATE_SYMLINK 1
typedef enum
{
@ -487,6 +491,34 @@ parse_link_line (ParsingData *data)
printf ("LINK FROM: %s\tTO: %s\n", from, to);
#endif
#if CREATE_SYMLINK
{
int len = strnlen(to,254);
int dirs = 0;
int i;
for (i = 0; i < len; i++) {
dirs += to[i] == '/' ? 1 : 0;
}
if (dirs) {
char rel_from[255];
char to_dir[255];
char to_path[255];
if (dirs == 1) {
sprintf(rel_from, "../%s.ics", from);
} else if (dirs == 2) {
sprintf(rel_from, "../../%s.ics", from);
} else {
return;
}
sprintf(to_path, "%s/%s.ics", VzicOutputDir, to);
strncpy(to_dir, to_path, 254);
ensure_directory_exists(dirname(to_dir));
//printf("Creating symlink from %s to %s\n", rel_from, to_path);
symlink(rel_from, to_path);
}
}
#else
if (g_hash_table_lookup_extended (data->link_data, from,
(gpointer) &old_from,
(gpointer) &zone_list)) {
@ -499,6 +531,7 @@ parse_link_line (ParsingData *data)
zone_list = g_list_prepend (zone_list, g_strdup (to));
g_hash_table_insert (data->link_data, from, zone_list);
#endif
}
@ -537,7 +570,7 @@ parse_year (ParsingData *data,
year = year * 10 + *p - '0';
}
if (year < 1000 || year > 2037) {
if (year < 1000 || year > 2038) {
fprintf (stderr, "%s:%i: Strange year: %s\n%s\n", data->filename,
data->line_number, field, data->line);
exit (1);

73
vzic/vzic.1 Normal file
View file

@ -0,0 +1,73 @@
." Text automatically generated by txt2man-1.4.7
.TH VZIC 1 "October 27, 2013" "vzic-1.3" "Linux Reference Manual"
.SH NAME
\fBvzic \fP- convert Olson timezone database files to iCalendar format
\fB
.SH SYNOPSIS
.nf
.fam C
\fBvzic\fP [\fB--dump\fP] [\fB--dump-changes\fP] [\fB--no-rrules\fP] [\fB--no-rdates\fP] [\fB--pure\fP]
[\fB--output-dir\fP <directory>] [\fB--url-prefix\fP <url>] [\fB--olson-dir\fP <directory>]
.fam T
.fi
.SH DESCRIPTION
\fBvzic\fP is a program to convert the Olson timezone database files into
VTIMEZONE files compatible with the iCalendar specification (RFC2445).
.SH OPTIONS
.TP
.B
\fB--pure\fP
Output the perfect VCALENDAR data, which Outlook won't parse
as it has problems with certain iCalendar constructs.
.TP
.B
\fB--output-dir\fP
specify where to output all the files beneath. The
default is the current directory.
.TP
.B
\fB--url-prefix\fP
Used as the base for the TZURL property in each
VTIMEZONE. The default is to not output TZURL properties.
.PP
Debugging Options:
.TP
.B
\fB--dump\fP
Dump the Rule and Zone data that we parsed from the Olson
timezone files. This is used to test the parsing code.
.TP
.B
\fB--dump-changes\fP
Dumps a list of times when each timezone changed,
and the new local time offset from UTC.
.TP
.B
\fB--no-rrules\fP
Don't output RRULE properties in the VTIMEZONEs. Instead
it will just output RDATEs for each year up to a certain year.
.TP
.B
\fB--no-rdates\fP
Don't output multiple RDATEs in a single VTIMEZONE
component. Instead they will be output separately.
.SH COPYRIGHT
Copyright (C) 2000-2001 Ximian, Inc.
Copyright (C) 2003 Damon Chaplin.
.PP
Author: Damon Chaplin <damon@gnome.org>
.PP
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.PP
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.PP
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

View file

@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "vzic.h"
#include "vzic-parse.h"

View file

@ -43,6 +43,7 @@ extern gboolean VzicDumpZoneTranslatableStrings;
extern gboolean VzicNoRRules;
extern gboolean VzicNoRDates;
extern char* VzicUrlPrefix;
extern char* VzicOutputDir;
extern GList* VzicTimeZoneNames;