Logo Search packages:      
Sourcecode: libical version File versions  Download package

static void icaltimezone_load_builtin_timezone ( icaltimezone *  zone  )  [static]

Loads the builtin VTIMEZONE data for the given timezone.

Definition at line 1738 of file icaltimezone.c.

References icaltimezone_get_vtimezone_properties().

Referenced by icaltimezone_get_builtin_timezone_from_offset(), icaltimezone_get_component(), icaltimezone_get_tzid(), and icaltimezone_get_tznames().

{
    icalcomponent *subcomp;

          /* If the location isn't set, it isn't a builtin timezone. */
    if (!zone->location || !zone->location[0])
      return;

#ifdef USE_BUILTIN_TZDATA
    {
    char *filename;
    icalcomponent *comp;
    unsigned int filename_len;
    FILE *fp;
    icalparser *parser;

    filename_len = strlen (get_zone_directory()) + strlen (zone->location) + 6;

    filename = (char*) malloc (filename_len);
    if (!filename) {
      icalerror_set_errno(ICAL_NEWFAILED_ERROR);
      return;
    }

    snprintf (filename, filename_len, "%s/%s.ics", get_zone_directory(),
            zone->location);

    fp = fopen (filename, "r");
    free (filename);
    if (!fp) {
      icalerror_set_errno(ICAL_FILE_ERROR);
      return;
    }

      
      /* ##### B.# Sun, 11 Nov 2001 04:04:29 +1100 
      this is where the MALFORMEDDATA error is being set, after the call to 'icalparser_parse'
      fprintf(stderr, "** WARNING ** %s: %d %s\n", __FILE__, __LINE__, icalerror_strerror(icalerrno));
      */

    parser = icalparser_new ();
      icalparser_set_gen_data (parser, fp);
      comp = icalparser_parse (parser, icaltimezone_load_get_line_fn);
    icalparser_free (parser);
      fclose (fp);

    /* Find the VTIMEZONE component inside the VCALENDAR. There should be 1. */
    subcomp = icalcomponent_get_first_component (comp,
                                     ICAL_VTIMEZONE_COMPONENT);
#else
      subcomp = icaltzutil_fetch_timezone (zone->location);
#endif      

    if (!subcomp) {
      icalerror_set_errno(ICAL_PARSE_ERROR);
      return;
    }

    icaltimezone_get_vtimezone_properties (zone, subcomp);

#ifdef USE_BUILTIN_TZDATA
    icalcomponent_remove_component(comp,subcomp);
    icalcomponent_free(comp);
    }
#endif    

}


Generated by  Doxygen 1.6.0   Back to index