From 11b0b2a2fa412a28d66efec246b426b7e4a23ab2 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 4 Jul 2024 16:08:36 +0200 Subject: [PATCH] controlapi.cpp: try to fix build errors if member 'time' is not found Ensure backward compatibility for rc_sync and channelEPGformated - Added conditional compilation in rc_sync to check for input_event_sec macro. - Used input_event_sec and input_event_usec macros if defined. - Provided fallback to direct timeval members for older versions. - Minor formatting adjustment in channelEPGformated for consistency. This should ensure compatibility with both newer and older kernel versions, different C library implementations, and possible standard settings of build systems. Addressing different definitions of the input_event structure maintains robustness across kernel, library, and build system configurations. --- src/nhttpd/tuxboxapi/controlapi.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index 3827a852f..9ba8ff5e6 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -993,7 +993,18 @@ void CControlAPI::rc_sync(int fd) { struct input_event ev; - gettimeofday(&ev.time, NULL); +// Check if input_event_sec macro is defined +#ifdef input_event_sec + // Use input_event_sec and input_event_usec macros if they are defined + struct timeval tv; + gettimeofday(&tv, NULL); + ev.input_event_sec = tv.tv_sec; + ev.input_event_usec = tv.tv_usec; +#else + // Fallback for older versions that use timeval directly + gettimeofday(&ev.time, NULL); +#endif + ev.type = EV_SYN; ev.code = SYN_REPORT; ev.value = 0; @@ -1795,6 +1806,7 @@ std::string CControlAPI::channelEPGformated(CyhookHandler *hh, int bouquetnr, t_ return result; } + //----------------------------------------------------------------------------- // Detailed EPG list in XML or JSON //-----------------------------------------------------------------------------