Commit 3da753a3f7023389c492e8ad1ce61ced613db3a3

Authored by Perry Werneck
1 parent c29be795
Exists in master and in 2 other branches develop, macos

Fixing windows build.

configure.ac
... ... @@ -539,6 +539,7 @@ AC_CHECK_HEADER(syslog.h, AC_DEFINE(HAVE_SYSLOG,,[do we have syslog.h?]))
539 539 AC_CHECK_FUNCS(getaddrinfo, AC_DEFINE(HAVE_GETADDRINFO) )
540 540 AC_CHECK_FUNC(vasprintf, AC_DEFINE(HAVE_VASPRINTF) )
541 541 AC_CHECK_FUNC(strtok_r, AC_DEFINE(HAVE_STRTOK_R) )
  542 +AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R) )
542 543  
543 544 AC_ARG_WITH([inet-ntop], [AS_HELP_STRING([--with-inet-ntop], [Assume that inet_nto() is available])], [ app_cv_inet_ntop="$withval" ],[ app_cv_inet_ntop="auto" ])
544 545  
... ...
src/core/rpq.c
... ... @@ -273,9 +273,7 @@ void do_qr_rpqnames(H3270 *hSession)
273 273 rpq_dump_warnings(hSession);
274 274 }
275 275  
276   -/**
277   - * @brief Utility function used by the RPQNAMES query reply.
278   - */
  276 +/// @brief Utility function used by the RPQNAMES query reply.
279 277 static Boolean select_rpq_terms(H3270 *hSession)
280 278 {
281 279 int i,j,k,len;
... ... @@ -438,6 +436,8 @@ static int get_rpq_timezone(H3270 *hSession)
438 436 }
439 437  
440 438  
  439 +#ifdef HAVE_LOCALTIME_R
  440 +
441 441 localtime_r(&here,&here_tm);
442 442  
443 443 if(gmtime_r(&here,&utc_tm) == NULL)
... ... @@ -446,23 +446,27 @@ static int get_rpq_timezone(H3270 *hSession)
446 446 return 2;
447 447 }
448 448  
449   - /*
  449 +#else
  450 +
450 451 memcpy(&here_tm, localtime(&here), sizeof(struct tm));
  452 + struct tm * _tm = gmtime(&here);
451 453  
452   - if ((utc_tm = gmtime(&here)) == NULL)
  454 + if(_tm == NULL)
453 455 {
454 456 rpq_warning(hSession, _("RPQ: Unable to determine workstation UTC time"));
455 457 return 2;
456 458 }
457   - */
458 459  
459   - /*
460   - * Do not take Daylight Saving Time into account.
461   - * We just want the "raw" time difference.
462   - */
  460 + memcpy(&utc_tm,_tm,sizeof(struct tm));
  461 +
  462 +#endif // HAVE_LOCALTIME_R
  463 +
  464 + // Do not take Daylight Saving Time into account.
  465 + // We just want the "raw" time difference.
463 466 here_tm.tm_isdst = 0;
464 467 utc_tm.tm_isdst = 0;
465 468 delta = difftime(mktime(&here_tm), mktime(&utc_tm)) / 60L;
  469 +
466 470 }
467 471  
468 472 // sanity check: difference cannot exceed +/- 12 hours
... ... @@ -480,20 +484,20 @@ static int get_rpq_timezone(H3270 *hSession)
480 484 */
481 485 static int get_rpq_user(H3270 *hSession, unsigned char buf[], const int buflen)
482 486 {
483   - /*
484   - * Text may be specified in one of two ways, but not both.
485   - * An environment variable provides the user interface:
486   - * - X3270RPQ: Keyword USER=
487   - *
488   - * NOTE: If the string begins with 0x then no ASCII/EBCDIC
489   - * translation is done. The hex characters will be sent as true hex
490   - * data. E.g., X3270RPQ="user=0x ab 12 EF" will result in 3 bytes
491   - * sent as 0xAB12EF. White space is optional in hex data format.
492   - * When hex format is required, the 0x prefix must be the first two
493   - * characters of the string. E.g., X3270RPQ="user= 0X AB" will
494   - * result in 6 bytes sent as 0x40F0E740C1C2 because the text is
495   - * accepted "as is" then translated from ASCII to EBCDIC.
496   - */
  487 + //
  488 + // Text may be specified in one of two ways, but not both.
  489 + // An environment variable provides the user interface:
  490 + // - X3270RPQ: Keyword USER=
  491 + //
  492 + // NOTE: If the string begins with 0x then no ASCII/EBCDIC
  493 + // translation is done. The hex characters will be sent as true hex
  494 + // data. E.g., X3270RPQ="user=0x ab 12 EF" will result in 3 bytes
  495 + // sent as 0xAB12EF. White space is optional in hex data format.
  496 + // When hex format is required, the 0x prefix must be the first two
  497 + // characters of the string. E.g., X3270RPQ="user= 0X AB" will
  498 + // result in 6 bytes sent as 0x40F0E740C1C2 because the text is
  499 + // accepted "as is" then translated from ASCII to EBCDIC.
  500 + //
497 501 const char *rpqtext = CN;
498 502 int x;
499 503 struct rpq_keyword *kw;
... ...
src/core/telnet.c
... ... @@ -2154,9 +2154,14 @@ void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, in
2154 2154  
2155 2155 {
2156 2156 time_t ltime;
2157   - struct tm tm;
2158 2157 time(&ltime);
  2158 +
  2159 +#ifdef HAVE_LOCALTIME_R
  2160 + struct tm tm;
2159 2161 strftime(l1, 81, "%x %X", localtime_r(&ltime,&tm));
  2162 +#else
  2163 + strftime(l1, 81, "%x %X", localtime(&ltime));
  2164 +#endif // HAVE_LOCALTIME_R
2160 2165 }
2161 2166  
2162 2167 lib3270_write_nettrace(hSession,"%c %s %s data len=%d\n\n",direction,l1,direction == '>' ? "SEND" : "RECV", len);
... ...
src/include/config.h.in
... ... @@ -94,6 +94,7 @@
94 94 #undef HAVE_PRINTER
95 95 #undef HAVE_MALLOC_H
96 96 #undef HAVE_STRTOK_R
  97 + #undef HAVE_LOCALTIME_R
97 98  
98 99 #endif /* LIB3270_CONFIG_INCLUDED */
99 100  
... ...