PostgreSQL Source Code: src/timezone/pgtz.h File Reference (original) (raw)

#include "[pgtime.h](pgtime%5F8h%5Fsource.html)"
#include "[tzfile.h](tzfile%5F8h%5Fsource.html)"

Go to the source code of this file.

Data Structures
struct ttinfo
struct lsinfo
struct state
struct pg_tz
Functions
int pg_open_tzfile (const char *name, char *canonname)
int tzload (const char *name, char *canonname, struct state *sp, bool doextend)
bool tzparse (const char *name, struct state *sp, bool lastditch)

BIGGEST

| #define BIGGEST | ( | | a, | | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ----------------------------------------------------- | | | b | | | | | ) | (((a) > (b)) ? (a) : (b)) | | |

Definition at line 24 of file pgtz.h.

SMALLEST

| #define SMALLEST | ( | | a, | | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ----------------------------------------------------- | | | b | | | | | ) | (((a) < (b)) ? (a) : (b)) | | |

Definition at line 23 of file pgtz.h.

pg_open_tzfile()

int pg_open_tzfile ( const char * name,
char * canonname
)

Definition at line 65 of file findtimezone.c.

66{

68

69 if (canonname)

71

73 if (strlen(fullname) + 1 + strlen(name) >= MAXPGPATH)

74 return -1;

75 strcat(fullname, "/");

76 strcat(fullname, name);

77

78 return open(fullname, O_RDONLY | PG_BINARY, 0);

79}

static const char * pg_TZDIR(void)

size_t strlcpy(char *dst, const char *src, size_t siz)

References MAXPGPATH, name, PG_BINARY, pg_TZDIR(), scan_directory_ci(), strlcpy(), and TZ_STRLEN_MAX.

Referenced by tzloadbody().

tzload()

int tzload ( const char * name,
char * canonname,
struct state * sp,
bool doextend
)

Definition at line 586 of file localtime.c.

587{

589

590 if (!lsp)

591 return errno;

592 else

593 {

595

597 return err;

598 }

599}

void err(int eval, const char *fmt,...)

static int tzloadbody(char const *name, char *canonname, struct state *sp, bool doextend, union local_storage *lsp)

References err(), free, malloc, name, and tzloadbody().

Referenced by gmtload(), pg_load_tz(), pg_tzenumerate_next(), and pg_tzset().

tzparse()

bool tzparse ( const char * name,
struct state * sp,
bool lastditch
)

Definition at line 936 of file localtime.c.

937{

938 const char *stdname;

939 const char *dstname = NULL;

940 size_t stdlen;

941 size_t dstlen;

945 char *cp;

946 bool load_ok;

947

948 stdname = name;

949 if (lastditch)

950 {

951

952 stdlen = strlen(name);

953 name += stdlen;

954 stdoffset = 0;

955 }

956 else

957 {

958 if (*name == '<')

959 {

961 stdname = name;

963 if (*name != '>')

964 return false;

965 stdlen = name - stdname;

967 }

968 else

969 {

971 stdlen = name - stdname;

972 }

973 if (*name == '\0')

974 return false;

976 if (name == NULL)

977 return false;

978 }

981 return false;

982

983

984

985

986

987

988

989

990

991

992 load_ok = false;

993 sp->goback = sp->goahead = false;

994 sp->leapcnt = 0;

995

996 if (*name != '\0')

997 {

998 if (*name == '<')

999 {

1000 dstname = ++name;

1002 if (*name != '>')

1003 return false;

1004 dstlen = name - dstname;

1006 }

1007 else

1008 {

1009 dstname = name;

1011 dstlen = name - dstname;

1012 }

1013 if (!dstlen)

1014 return false;

1017 return false;

1018 if (*name != '\0' && *name != ',' && *name != ';')

1019 {

1021 if (name == NULL)

1022 return false;

1023 }

1024 else

1026 if (*name == '\0' && !load_ok)

1028 if (*name == ',' || *name == ';')

1029 {

1031 struct rule end;

1032 int year;

1033 int yearlim;

1036 int32 janoffset = 0;

1037 int yearbeg;

1038

1041 return false;

1042 if (*name++ != ',')

1043 return false;

1045 return false;

1046 if (*name != '\0')

1047 return false;

1048 sp->typecnt = 2;

1049

1050

1051

1052

1054 init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1);

1057 janfirst = 0;

1059

1060 do

1061 {

1064

1065 yearbeg--;

1067 {

1068 janoffset = -yearsecs;

1069 break;

1070 }

1072

1074 for (year = yearbeg; year < yearlim; year++)

1075 {

1078 endtime = transtime(year, &end, dstoffset);

1082 bool reversed = endtime < starttime;

1083

1084 if (reversed)

1085 {

1086 int32 swap = starttime;

1087

1088 starttime = endtime;

1089 endtime = swap;

1090 }

1091 if (reversed

1092 || (starttime < endtime

1093 && (endtime - starttime

1094 < (yearsecs

1095 + (stdoffset - dstoffset)))))

1096 {

1098 break;

1102 janoffset + starttime))

1107 janoffset + endtime))

1108 {

1111 }

1112 }

1114 (&janfirst, janoffset + yearsecs))

1115 break;

1116 janoffset = 0;

1117 }

1120 {

1122 sp->typecnt = 1;

1123 }

1126 }

1127 else

1128 {

1129 int32 theirstdoffset;

1130 int32 theirdstoffset;

1131 int32 theiroffset;

1132 bool isdst;

1133 int i;

1134 int j;

1135

1136 if (*name != '\0')

1137 return false;

1138

1139

1140

1141

1142 theirstdoffset = 0;

1144 {

1147 {

1148 theirstdoffset =

1150 break;

1151 }

1152 }

1153 theirdstoffset = 0;

1155 {

1158 {

1159 theirdstoffset =

1161 break;

1162 }

1163 }

1164

1165

1166

1167

1168 isdst = false;

1169 theiroffset = theirstdoffset;

1170

1171

1172

1173

1174

1176 {

1180 {

1181

1182 }

1183 else

1184 {

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1197 {

1198 sp->ats[i] += dstoffset -

1199 theirdstoffset;

1200 }

1201 else

1202 {

1203 sp->ats[i] += stdoffset -

1204 theirstdoffset;

1205 }

1206 }

1209 theirdstoffset = theiroffset;

1210 else

1211 theirstdoffset = theiroffset;

1212 }

1213

1214

1215

1216

1218 init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1);

1221 }

1222 }

1223 else

1224 {

1225 dstlen = 0;

1226 sp->typecnt = 1;

1230 }

1233 memcpy(cp, stdname, stdlen);

1234 cp += stdlen;

1235 *cp++ = '\0';

1236 if (dstlen != 0)

1237 {

1238 memcpy(cp, dstname, dstlen);

1239 *(cp + dstlen) = '\0';

1240 }

1241 return true;

1242}

if(TABLE==NULL||TABLE_index==NULL)

static const char * getqzname(const char *strp, const int delim)

static int32 transtime(const int year, const struct rule *const rulep, const int32 offset)

static bool increment_overflow_time(pg_time_t *tp, int32 j)

static void init_ttinfo(struct ttinfo *s, int32 utoff, bool isdst, int desigidx)

static const char * getzname(const char *strp)

static const char * getoffset(const char *strp, int32 *const offsetp)

static const int year_lengths[2]

static const char * getrule(const char *strp, struct rule *const rulep)

struct ttinfo ttis[TZ_MAX_TYPES]

char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS+1, 4),(2 *(TZ_STRLEN_MAX+1)))]

pg_time_t ats[TZ_MAX_TIMES]

unsigned char types[TZ_MAX_TIMES]

References state::ats, state::charcnt, charcnt, state::chars, state::defaulttype, EPOCH_YEAR, getoffset(), getqzname(), getrule(), getzname(), state::goahead, state::goback, i, if(), increment_overflow_time(), init_ttinfo(), isleap, j, state::leapcnt, name, SECSPERDAY, SECSPERHOUR, start, state::timecnt, timecnt, transtime(), ttinfo::tt_isdst, ttinfo::tt_ttisstd, ttinfo::tt_ttisut, ttinfo::tt_utoff, state::ttis, state::typecnt, state::types, TZ_MAX_TIMES, TZDEFRULESTRING, year_lengths, and YEARSPERREPEAT.

Referenced by gmtload(), pg_load_tz(), pg_tzset(), and tzloadbody().