From: hyc Date: Sun, 21 Feb 2010 04:47:22 +0000 (+0000) Subject: Portability fixes X-Git-Tag: v2.4~258 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=75004066520cf2028df753ce3e6f7fe96ea2f121;p=rtmpdump Portability fixes git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@265 400ebc74-4327-4243-bc38-086b20814532 --- diff --git a/hashswf.c b/hashswf.c index 2e57f01..814a683 100644 --- a/hashswf.c +++ b/hashswf.c @@ -260,6 +260,11 @@ leave: return ret; } +static int tzoff; +static int tzchecked; + +#define JAN02_1980 318340800 + static const char *monthtab[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", @@ -321,12 +326,24 @@ make_unix_time(char *s) break; } time.tm_isdst = 0; /* daylight saving is never in effect in GMT */ + + /* this is normally the value of extern int timezone, but some + * braindead C libraries don't provide it. + */ + if (!tzchecked) + { + struct tm *tc; + time_t then = JAN02_1980; + tc = localtime(&then); + tzoff = (12 - tc->tm_hour) * 3600 + tc->tm_min * 60 + tc->tm_sec; + tzchecked = 1; + } res = mktime(&time); /* Unfortunately, mktime() assumes the input is in local time, * not GMT, so we have to correct it here. */ if (res != -1) - res += timezone; + res += tzoff; return res; } diff --git a/rtmpsrv.c b/rtmpsrv.c index 7026fe8..534d9c7 100644 --- a/rtmpsrv.c +++ b/rtmpsrv.c @@ -39,9 +39,12 @@ #include "thread.h" #ifdef linux +#include +#endif + +#ifndef WIN32 #include #include -#include #endif #define RD_SUCCESS 0