Skip to content

Commit

Permalink
check for timegm()
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Oct 1, 2023
1 parent fe49e9b commit 28bebfa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ set(CMAKE_REQUIRED_LIBRARIES pthread rt)
check_function_exists(pthread_setname_np HAVE_PTHREAD_SETNAME_NP)
check_function_exists(pselect HAVE_PSELECT)
check_function_exists(ppoll HAVE_PPOLL)
check_function_exists(timegm HAVE_TIMEGM)
check_include_file(linux/serial.h HAVE_LINUX_SERIAL -DHAVE_LINUX_SERIAL=1)
check_include_file(dev/usb/uftdiio.h HAVE_FREEBSD_UFTDI -DHAVE_FREEBSD_UFTDI=1)

Expand Down
3 changes: 3 additions & 0 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
/* Defined if time.h is available. */
#cmakedefine HAVE_TIME_H

/* Defined if timegm() is available. */
#cmakedefine HAVE_TIMEGM

/* Defined if syslog.h is available. */
#cmakedefine HAVE_SYSLOG_H

Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ AC_CHECK_HEADERS([arpa/inet.h \
time.h \
termios.h])

AC_CHECK_FUNC([timegm], [AC_DEFINE(HAVE_TIMEGM, [1], [Defined if timegm() is available.])])
AC_CHECK_FUNC([cfsetspeed], [AC_DEFINE(HAVE_CFSETSPEED, [1], [Defined if cfsetspeed() is available.])])

AC_CHECK_LIB([pthread], [pthread_setname_np],
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/httpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ bool* repeatable, time_t* time) {
string headers = result.substr(0, pos+2); // including final \r\n
const char* hdrs = headers.c_str();
*response = result.substr(pos+4);
#ifdef HAVE_TIME_H
#if defined(HAVE_TIME_H) && defined(HAVE_TIMEGM)
if (time) {
pos = headers.find("\r\nLast-Modified: ");
if (pos != string::npos && headers.substr(pos+42, 4) == " GMT") {
Expand Down

0 comments on commit 28bebfa

Please sign in to comment.