timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb) { const unsigned char *tzf; timelib_tzinfo *tmp; int version; if (seek_to_tz_position(&tzf, timezone, tzdb)) { tmp = timelib_tzinfo_ctor(timezone); version = read_preamble(&tzf, tmp); read_header(&tzf, tmp); read_transistions(&tzf, tmp); read_types(&tzf, tmp); if (version == 2) { skip_64bit_preamble(&tzf, tmp); read_64bit_header(&tzf, tmp); skip_64bit_transistions(&tzf, tmp); skip_64bit_types(&tzf, tmp); skip_posix_string(&tzf, tmp); } read_location(&tzf, tmp); } else { tmp = NULL; } return tmp; }
timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb) { const unsigned char *tzf; char *memmap = NULL; size_t maplen; timelib_tzinfo *tmp; if (seek_to_tz_position(&tzf, timezone, &memmap, &maplen, tzdb)) { tmp = timelib_tzinfo_ctor(timezone); read_preamble(&tzf, tmp); read_header(&tzf, tmp); read_transistions(&tzf, tmp); read_types(&tzf, tmp); #ifdef HAVE_SYSTEM_TZDATA if (memmap) { const struct location_info *li; /* TZif-style - grok the location info from the system database, * if possible. */ if ((li = find_zone_info(system_location_table, timezone)) != NULL) { tmp->location.comments = strdup(li->comment); strncpy(tmp->location.country_code, li->code, 2); tmp->location.longitude = li->longitude; tmp->location.latitude = li->latitude; tmp->bc = 1; } else { strcpy(tmp->location.country_code, "??"); tmp->bc = 0; tmp->location.comments = strdup(""); } /* Now done with the mmap segment - discard it. */ munmap(memmap, maplen); } else #endif { /* PHP-style - use the embedded info. */ read_location(&tzf, tmp); } } else { tmp = NULL; } return tmp; }
timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb) { const unsigned char *tzf; timelib_tzinfo *tmp; if (seek_to_tz_position(&tzf, timezone, tzdb)) { tmp = timelib_tzinfo_ctor(timezone); read_header((char**) &tzf, tmp); read_transistions((char**) &tzf, tmp); read_types((char**) &tzf, tmp); } else { tmp = NULL; } return tmp; }
int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb) { const unsigned char *tzf; return (seek_to_tz_position(&tzf, timezone, tzdb)); }