From 4257622c56b567a940e66d132993249737c2c308 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 20 Aug 2008 01:55:43 +0000 Subject: [PATCH] add mod_timezone to msvc build git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9327 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- Freeswitch.2008.sln | 12 ++ .../mod_timezone/localtime_find.c | 67 +++---- .../mod_timezone/mod_timezone.2008.vcproj | 174 ++++++++++++++++++ .../applications/mod_timezone/mod_timezone.c | 20 +- 4 files changed, 223 insertions(+), 50 deletions(-) create mode 100644 src/mod/applications/mod_timezone/mod_timezone.2008.vcproj diff --git a/Freeswitch.2008.sln b/Freeswitch.2008.sln index d1f301c78d..eca2a0fb7c 100644 --- a/Freeswitch.2008.sln +++ b/Freeswitch.2008.sln @@ -966,6 +966,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_say_zh", "src\mod\say\m {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_timezone", "src\mod\applications\mod_timezone\mod_timezone.2008.vcproj", "{5CA0F863-CB0F-4250-A863-A5355BDAE224}" + ProjectSection(ProjectDependencies) = postProject + {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -1688,6 +1693,12 @@ Global {B6A9FB7A-1CC4-442B-812D-EC33E4E4A36E}.Release|Win32.ActiveCfg = Release|Win32 {B6A9FB7A-1CC4-442B-812D-EC33E4E4A36E}.Release|Win32.Build.0 = Release|Win32 {B6A9FB7A-1CC4-442B-812D-EC33E4E4A36E}.Release|x64.ActiveCfg = Release|Win32 + {5CA0F863-CB0F-4250-A863-A5355BDAE224}.Debug|Win32.ActiveCfg = Debug|Win32 + {5CA0F863-CB0F-4250-A863-A5355BDAE224}.Debug|Win32.Build.0 = Debug|Win32 + {5CA0F863-CB0F-4250-A863-A5355BDAE224}.Debug|x64.ActiveCfg = Debug|Win32 + {5CA0F863-CB0F-4250-A863-A5355BDAE224}.Release|Win32.ActiveCfg = Release|Win32 + {5CA0F863-CB0F-4250-A863-A5355BDAE224}.Release|Win32.Build.0 = Release|Win32 + {5CA0F863-CB0F-4250-A863-A5355BDAE224}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1717,6 +1728,7 @@ Global {65A6273D-FCAB-4C55-B09E-65100141A5D4} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {E3246D17-E29B-4AB5-962A-C69B0C5837BB} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {2A3D00C6-588D-4E86-81AC-9EF5EDE86E03} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} + {5CA0F863-CB0F-4250-A863-A5355BDAE224} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {07113B25-D3AF-4E04-BA77-4CD1171F022C} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} {A27CCA23-1541-4337-81A4-F0A6413078A0} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} {E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} diff --git a/src/mod/applications/mod_timezone/localtime_find.c b/src/mod/applications/mod_timezone/localtime_find.c index 3f25679646..2bbd2bf268 100644 --- a/src/mod/applications/mod_timezone/localtime_find.c +++ b/src/mod/applications/mod_timezone/localtime_find.c @@ -139,6 +139,9 @@ #endif /* defined __GNUC__ */ #endif /* !defined lint */ #endif /* !defined GNUC_or_lint */ +#ifdef WIN32 +#define GNUC_or_lint +#endif #ifndef INITIALIZE #ifdef GNUC_or_lint @@ -241,10 +244,9 @@ static const int year_lengths[2] = { character. */ -static const char *getzname(strp) -register const char * strp; +static const char *getzname(register const char *strp) { - register char c; + register char c; while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' && c != '+') @@ -260,11 +262,7 @@ register const char * strp; Otherwise, return a pointer to the first character not part of the number. */ -static const char *getnum(strp, nump, min, max) - register const char * strp; - int * const nump; - const int min; - const int max; +static const char *getnum(register const char *strp, int * const nump, const int min, const int max) { register char c; register int num; @@ -292,9 +290,7 @@ static const char *getnum(strp, nump, min, max) of seconds. */ -static const char *getsecs(strp, secsp) - register const char * strp; - long * const secsp; +static const char *getsecs(register const char *strp, long * const secsp) { int num; @@ -333,9 +329,7 @@ static const char *getsecs(strp, secsp) Otherwise, return a pointer to the first character not part of the time. */ -static const char *getoffset(strp, offsetp) - register const char * strp; - long * const offsetp; +static const char *getoffset(register const char *strp, long * const offsetp) { register int neg = 0; @@ -359,9 +353,7 @@ static const char *getoffset(strp, offsetp) Otherwise, return a pointer to the first character not part of the rule. */ -static const char *getrule(strp, rulep) - const char * strp; - register struct rule * const rulep; +static const char *getrule(const char *strp, register struct rule * const rulep) { if (*strp == 'J') { /* @@ -413,11 +405,7 @@ static const char *getrule(strp, rulep) calculate the Epoch-relative time that rule takes effect. */ -static time_t transtime(janfirst, year, rulep, offset) - const time_t janfirst; - const int year; - register const struct rule * const rulep; - const long offset; +static time_t transtime(const time_t janfirst, const int year, register const struct rule * const rulep, const long offset) { register int leapyear; register time_t value; @@ -509,10 +497,7 @@ static time_t transtime(janfirst, year, rulep, offset) appropriate. */ -static int tzparse(name, sp, lastditch) - const char * name; - register struct state * const sp; - const int lastditch; +static int tzparse(const char *name, register struct state * const sp, const int lastditch) { const char * stdname; const char * dstname; @@ -666,7 +651,7 @@ static int tzparse(name, sp, lastditch) */ for (i = 0; i < sp->timecnt; ++i) { j = sp->types[i]; - sp->types[i] = sp->ttis[j].tt_isdst; + sp->types[i] = (unsigned char)sp->ttis[j].tt_isdst; if (sp->ttis[j].tt_ttisgmt) { /* No adjustment to transition time */ } else { @@ -737,12 +722,13 @@ static int tzparse(name, sp, lastditch) /* ************************************************************************** ************************************************************************** */ +#if (_MSC_VER >= 1400) // VC8+ +#define switch_assert(expr) assert(expr);__analysis_assume( expr ) +#else +#define switch_assert(expr) assert(expr) +#endif -static void timesub(timep, offset, sp, tmp) - const time_t * const timep; - const long offset; - register const struct state * const sp; - register struct tm * const tmp; +static void timesub(const time_t * const timep, const long offset, register const struct state * const sp, register struct tm * const tmp) { register const struct lsinfo * lp; register long days; @@ -754,9 +740,9 @@ static void timesub(timep, offset, sp, tmp) register int hit; register int i; - assert(timep != NULL); - assert(sp != NULL); - assert(tmp != NULL); + switch_assert(timep != NULL); + switch_assert(sp != NULL); + switch_assert(tmp != NULL); corr = 0; hit = 0; @@ -782,7 +768,7 @@ static void timesub(timep, offset, sp, tmp) break; } } - days = *timep / SECSPERDAY; + days = (long)(*timep / SECSPERDAY); rem = *timep % SECSPERDAY; @@ -846,17 +832,16 @@ static void timesub(timep, offset, sp, tmp) tmp->tm_mday = (int) (days + 1); tmp->tm_isdst = 0; +#ifndef WIN32 tmp->tm_gmtoff = offset; +#endif } /* ************************************************************************** ************************************************************************** */ -void tztime( timep, tzstring, tmp ) - const time_t * const timep; - const char *tzstring; - struct tm * const tmp; +void tztime(const time_t * const timep, const char *tzstring, struct tm * const tmp ) { struct state *tzptr, *sp; @@ -903,7 +888,9 @@ void tztime( timep, tzstring, tmp ) { timesub( &t, ttisp->tt_gmtoff, sp, tmp); tmp->tm_isdst = ttisp->tt_isdst; +#ifndef WIN32 tmp->tm_zone = &sp->chars[ttisp->tt_abbrind]; +#endif } free(tzptr); diff --git a/src/mod/applications/mod_timezone/mod_timezone.2008.vcproj b/src/mod/applications/mod_timezone/mod_timezone.2008.vcproj new file mode 100644 index 0000000000..8c39c4d2e2 --- /dev/null +++ b/src/mod/applications/mod_timezone/mod_timezone.2008.vcproj @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/applications/mod_timezone/mod_timezone.c b/src/mod/applications/mod_timezone/mod_timezone.c index 287f23234c..cf0f00f872 100644 --- a/src/mod/applications/mod_timezone/mod_timezone.c +++ b/src/mod/applications/mod_timezone/mod_timezone.c @@ -34,9 +34,7 @@ and use switch_* functions for the output. */ -static void tm2switchtime( tm, xt ) - struct tm *tm; -switch_time_exp_t *xt; +static void tm2switchtime(struct tm * tm, switch_time_exp_t *xt ) { if (!xt || !tm) { @@ -53,7 +51,9 @@ switch_time_exp_t *xt; xt->tm_wday = tm->tm_wday; xt->tm_yday = tm->tm_yday; xt->tm_isdst = tm->tm_isdst; +#ifndef WIN32 xt->tm_gmtoff = tm->tm_gmtoff; +#endif return; } @@ -70,12 +70,12 @@ typedef struct { static switch_timezones_list_t TIMEZONES_LIST = { 0 }; static switch_event_node_t *NODE = NULL; -const char *switch_lookup_timezone( const char *tzname ) +const char *switch_lookup_timezone( const char *tz_name ) { char *value = NULL; - if ( tzname && (value = switch_core_hash_find(TIMEZONES_LIST.hash, tzname))==NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timezone '%s' not found!\n", tzname); + if ( tz_name && (value = switch_core_hash_find(TIMEZONES_LIST.hash, tz_name))==NULL ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timezone '%s' not found!\n", tz_name); } return value; @@ -135,7 +135,7 @@ SWITCH_STANDARD_API(strftime_tz_api_function) time_t timep; char *format = NULL; - const char *tzname; + const char *tz_name; const char *tzdef; switch_size_t retsize; @@ -150,15 +150,15 @@ SWITCH_STANDARD_API(strftime_tz_api_function) if (!switch_strlen_zero(cmd)) { format = strchr(cmd, ' '); - tzname = cmd; + tz_name = cmd; if (format) { *format++ = '\0'; } - tzdef = switch_lookup_timezone( tzname ); + tzdef = switch_lookup_timezone( tz_name ); } else { /* We set the default timezone to GMT. */ - tzname="GMT"; + tz_name="GMT"; tzdef="GMT"; }