34 #define WHITESPACE " \t\n\r"
42 tzEntry **base,
int *arraysize,
int n);
60 GUC_check_errmsg(
"time zone abbreviation \"%s\" is too long (maximum %d characters) in time zone file \"%s\", line %d",
69 if (tzentry->
offset > 14 * 60 * 60 ||
70 tzentry->
offset < -14 * 60 * 60)
72 GUC_check_errmsg(
"time zone offset %d is out of range in time zone file \"%s\", line %d",
81 for (p = (
unsigned char *) tzentry->
abbrev; *p; p++)
111 GUC_check_errmsg(
"missing time zone abbreviation in time zone file \"%s\", line %d",
120 GUC_check_errmsg(
"missing time zone offset in time zone file \"%s\", line %d",
126 if (isdigit((
unsigned char) *offset) || *offset ==
'+' || *offset ==
'-')
128 tzentry->
zone = NULL;
129 tzentry->
offset = strtol(offset, &offset_endptr, 10);
130 if (offset_endptr == offset || *offset_endptr !=
'\0')
132 GUC_check_errmsg(
"invalid number for time zone offset in time zone file \"%s\", line %d",
166 if (remain[0] !=
'#')
204 int mid = (low + high) >> 1;
205 tzEntry *midptr = arrayptr + mid;
218 if ((midptr->
zone == NULL && entry->
zone == NULL &&
221 (midptr->
zone != NULL && entry->
zone != NULL &&
222 strcmp(midptr->
zone, entry->
zone) == 0))
238 GUC_check_errdetail(
"Entry in time zone file \"%s\", line %d, conflicts with entry in file \"%s\", line %d.",
254 arrayptr = *base + low;
256 memmove(arrayptr + 1, arrayptr, (n - low) *
sizeof(
tzEntry));
258 memcpy(arrayptr, entry,
sizeof(
tzEntry));
276 tzEntry **base,
int *arraysize,
int n)
285 bool override =
false;
296 if (!isalpha((
unsigned char) *p))
319 snprintf(file_path,
sizeof(file_path),
"%s/timezonesets/%s",
330 int save_errno = errno;
333 snprintf(file_path,
sizeof(file_path),
"%s/timezonesets",
340 GUC_check_errhint(
"This may indicate an incomplete PostgreSQL installation, or that the file \"%s\" has been moved away from its proper location.",
351 if (errno != ENOENT || depth > 0)
358 while (!feof(tzFile))
361 if (fgets(tzbuf,
sizeof(tzbuf), tzFile) == NULL)
373 if (strlen(tzbuf) ==
sizeof(tzbuf) - 1)
384 while (*line && isspace((
unsigned char) *line))
395 char *includeFile =
pstrdup(line + strlen(
"@INCLUDE"));
397 includeFile = strtok(includeFile,
WHITESPACE);
398 if (!includeFile || !*includeFile)
400 GUC_check_errmsg(
"@INCLUDE without file name in time zone file \"%s\", line %d",
428 n =
addToArray(base, arraysize, n, &tzentry,
override);
TimeZoneAbbrevTable * ConvertTimeZoneAbbrevs(struct tzEntry *abbrevs, int n)
FILE * AllocateFile(const char *name, const char *mode)
DIR * AllocateDir(const char *dirname)
char my_exec_path[MAXPGPATH]
#define GUC_check_errdetail
#define GUC_check_errhint
char * pstrdup(const char *in)
MemoryContext CurrentMemoryContext
void * repalloc(void *pointer, Size size)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_SMALL_SIZES
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
void get_share_path(const char *my_exec_path, char *ret_path)
int pg_strcasecmp(const char *s1, const char *s2)
unsigned char pg_tolower(unsigned char ch)
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
static int cmp(const chr *x, const chr *y, size_t len)
static bool validateTzEntry(tzEntry *tzentry)
static bool splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry)
TimeZoneAbbrevTable * load_tzoffsets(const char *filename)
static int addToArray(tzEntry **base, int *arraysize, int n, tzEntry *entry, bool override)
static int ParseTzFile(const char *filename, int depth, tzEntry **base, int *arraysize, int n)