35 const char *fname,
int fnamelen,
36 char *canonname,
int canonnamelen);
47 static bool done_tzdir =
false;
85 orignamelen = fullnamelen = strlen(fullname);
97 if (canonname == NULL)
101 fullname[fullnamelen] =
'/';
103 strcpy(fullname + fullnamelen + 1,
name);
104 result = open(fullname, O_RDONLY |
PG_BINARY, 0);
108 fullname[fullnamelen] =
'\0';
118 const char *slashptr;
121 slashptr = strchr(fname,
'/');
123 fnamelen = slashptr - fname;
125 fnamelen = strlen(fname);
127 fullname + fullnamelen + 1,
130 fullname[fullnamelen++] =
'/';
131 fullnamelen += strlen(fullname + fullnamelen);
133 fname = slashptr + 1;
141 return open(fullname, O_RDONLY |
PG_BINARY, 0);
152 char *canonname,
int canonnamelen)
166 if (direntry->
d_name[0] ==
'.')
169 if (strlen(direntry->
d_name) == fnamelen &&
237 struct state tzstate;
273 if (strcmp(uppername,
"GMT") == 0)
275 if (!
tzparse(uppername, &tzstate,
true))
278 elog(
ERROR,
"could not initialize GMT time zone");
281 strcpy(canonname, uppername);
283 else if (
tzload(uppername, canonname, &tzstate,
true) != 0)
285 if (uppername[0] ==
':' || !
tzparse(uppername, &tzstate,
false))
291 strcpy(canonname, uppername);
302 memcpy(&tzp->
tz.
state, &tzstate,
sizeof(tzstate));
322 long absoffset = (gmtoffset < 0) ? -gmtoffset : gmtoffset;
326 snprintf(offsetstr,
sizeof(offsetstr),
331 snprintf(offsetstr + strlen(offsetstr),
332 sizeof(offsetstr) - strlen(offsetstr),
336 snprintf(offsetstr + strlen(offsetstr),
337 sizeof(offsetstr) - strlen(offsetstr),
338 ":%02ld", absoffset);
341 snprintf(tzname,
sizeof(tzname),
"<-%s>+%s",
342 offsetstr, offsetstr);
344 snprintf(tzname,
sizeof(tzname),
"<+%s>-%s",
345 offsetstr, offsetstr);
383 #define MAX_TZDIR_DEPTH 10
402 ret->
baselen = strlen(startdir) + 1;
409 errmsg(
"could not open directory \"%s\": %m", startdir)));
416 while (dir->
depth >= 0)
428 while (dir->
depth >= 0)
444 if (direntry->
d_name[0] ==
'.')
447 snprintf(fullname,
sizeof(fullname),
"%s/%s",
462 errmsg(
"could not open directory \"%s\": %m",
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
int errmsg_internal(const char *fmt,...)
int errcode_for_file_access(void)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
struct dirent * ReadDir(DIR *dir, const char *dirname)
struct dirent * ReadDirExtended(DIR *dir, const char *dirname, int elevel)
DIR * AllocateDir(const char *dirname)
PGFileType get_dirent_type(const char *path, const struct dirent *de, bool look_through_symlinks, int elevel)
char my_exec_path[MAXPGPATH]
int tzload(const char *name, char *canonname, struct state *sp, bool doextend)
bool tzparse(const char *name, struct state *sp, bool lastditch)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
bool pg_tz_acceptable(pg_tz *tz)
static HTAB * timezone_cache
pg_tz * pg_tzset_offset(long gmtoffset)
void pg_timezone_initialize(void)
int pg_open_tzfile(const char *name, char *canonname)
static bool scan_directory_ci(const char *dirname, const char *fname, int fnamelen, char *canonname, int canonnamelen)
pg_tz * pg_tzset(const char *tzname)
pg_tz * pg_tzenumerate_next(pg_tzenum *dir)
static bool init_timezone_hashtable(void)
void pg_tzenumerate_end(pg_tzenum *dir)
pg_tzenum * pg_tzenumerate_start(void)
static const char * pg_TZDIR(void)
void get_share_path(const char *my_exec_path, char *ret_path)
unsigned char pg_toupper(unsigned char ch)
size_t strlcpy(char *dst, const char *src, size_t siz)
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
char TZname[TZ_STRLEN_MAX+1]
char * dirname[MAX_TZDIR_DEPTH]
DIR * dirdesc[MAX_TZDIR_DEPTH]