Wireshark-dev: Re: [Wireshark-dev] Problems with r40742
From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
Date: Thu, 16 Feb 2012 17:47:52 -0500
Stephen Fisher wrote:
r40742 is causing compilation problems on FreeBSD (64-bit 9.0-RELEASE):

    packet-smpp.c: In function 'smpp_mktime':
    packet-smpp.c:1189: error: invalid operands to binary -

With reference to this code:

	*secs -= timezone;

... for which Jeff had concerns about its portability in the commit comment:

"1) subtract the 'timezone' (or '_timezone' on Windows) back out after calling
   mktime()

...

(I *think* (1) is portable: POSIX says that variable should exist...)"

Shoot.

Looks like FreeBSD provides a timezone() function which they admit[1] is not POSIX compliant[2]. And their time.h[3] doesn't seem to have any kind of variable that gives the same functionality...

I guess what's needed is to:
- check for the variable at configure time
- if we don't have it, call localtime() to get a struct tm, and pull the timezone offset out of there

Maybe the first step can just be skipped for simplicity, though. I'll try to get to that tonight unless someone beats me to it.


[1] http://lists.freebsd.org/pipermail/freebsd-standards/2011-January/002111.html
[2] http://pubs.opengroup.org/onlinepubs/009695399/functions/timezone.html
[3] http://svnweb.freebsd.org/base/head/include/time.h?revision=HEAD&view=markup